2
schangxiang@126.com
2024-08-16 b47c50a2a514def7374b32d7194b2c599cba5625
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
using FineUIPro;
using iWareCommon.Common.Entity;
using iWareDataCore.BASE.Service;
using iWareDataCore.ORM;
using iWareLog.LOG.Service;
using System;
using System.Collections.Generic;
using System.Text;
 
namespace iWareWms.View.InOut
{
    public partial class WebOrder : PageBase
    {
        protected override Grid GetGrid()
        {
            return WebOrderGrid;
        }
 
        protected override DropDownList GetPageSizeDropDownList()
        {
            return ddlPageSize;
        }
 
        protected override List<object> GetDataSource(int pageIndex, int pageSize, out string msg, out int totalNum, out int currentPage)
        {
            var places = WebOrderService.GetInstance().QueryByParam(new QueryParam
            {
                Search = new Dictionary<string, object> { { "RequestOrder", tbRequestOrder.Text.Trim() },{ "ListNo", tbListNo.Text.Trim() }},
                Geq = new Dictionary<string, object> { { "CreateTime", (DateTime)SCreateTime.SelectedDate } },
                Ltd = new Dictionary<string, object> { { "CreateTime", ((DateTime)CreateTime.SelectedDate).AddDays(1) } },
                Filter = new Dictionary<string, object> { { "BusType", ddlBusType.SelectedValue } },
                PageIndex = pageIndex,
                PageSize = pageSize
            }, out msg, out totalNum, out currentPage);
 
            var res = new List<object>();
            places.ForEach(x => {
              res.Add(x);
            });
            return res;
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var today = DateTime.Today;
                SCreateTime.SelectedDate = today.AddDays(-6);
                CreateTime.SelectedDate = today;
                Query(1);
            }
        }
 
        /// <summary>
        /// 类型前台显示
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        protected string GetType(object type)
        {
            string st = "未知";
            try
            {
                int ty = int.Parse(type.ToString());
                switch (ty)
                {
                    case 0:
                        st = "入库";
                        break;
                    case 1:
                        st = "出库";
                        break;
                    default:
                        break;
                }
                return st;
            }
            catch (Exception)
            {
                return st;
            }
        }
 
 
        protected override Window GetWindow()
        {
            return Window1;
        }
 
        protected override void GetPath(object userName)
        {
            string msg;
 
            var places = InOutStorageDetailService.GetInstance().QueryByParam(new QueryParam
            {
 
                Search = new Dictionary<string, object> { { "RequestOrder", tbRequestOrder.Text.Trim() }, { "ListNo", tbListNo.Text.Trim() } },
                Geq = new Dictionary<string, object> { { "CreateTime", (DateTime)SCreateTime.SelectedDate } },
                Ltd = new Dictionary<string, object> { { "CreateTime", ((DateTime)CreateTime.SelectedDate).AddDays(1) } },
            }, out msg);
 
        }
 
        protected override FineUIPro.Timer GetTimer()
        {
            return timer1;
        }
 
        /// <summary>
        /// 删除物料单按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDeleteRequest_Click(object sender, EventArgs e)
        {
            List<object> selectedRowIDs = new List<object>(WebOrderGrid.SelectedRowIDArray);
            int[] selections = WebOrderGrid.SelectedRowIndexArray;
            var detail = WebOrderGrid.Rows;
 
            int selectRowId = -1;
 
            for (int i = 0; i < selections.Length; i++)
            {
                string RowId = detail[selections[i]].RowID.ToString();
                int id = Convert.ToInt32(detail[selections[i]].Values[1].ToString());
 
                if (selectedRowIDs.Contains(RowId))
                {
                    selectRowId = id;
                    break;
                }
            }
            if (selectRowId > -1)
            {
                string msg;
                int count = WebOrderService.GetInstance().DeleteRequest(selectRowId, out msg);
                if (count >= 0)
                {
                    Alert.ShowInTop("删除成功!");
                    Query(1);
                }
                else
                    Alert.ShowInTop(msg);
            }
            else
                Alert.ShowInTop("请选择单据!");
        }
 
        /// <summary>
        /// 确认作业
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnDoInOutWork_Click(object sender, EventArgs e)
        {
            List<object> selectedRowIDs = new List<object>(WebOrderGrid.SelectedRowIDArray);
            int[] selections = WebOrderGrid.SelectedRowIndexArray;
            var detail = WebOrderGrid.Rows;
 
            int selectRowId = -1;
 
            for (int i = 0; i < selections.Length; i++)
            {
                string RowId = detail[selections[i]].RowID.ToString();
                int id = Convert.ToInt32(detail[selections[i]].Values[1].ToString());
 
                if (selectedRowIDs.Contains(RowId))
                {
                    selectRowId = id;
                    break;
                }
            }
            if (selectRowId > -1)
            {
                string msg;
                bool doResult = WebOrderService.GetInstance().DoInOutWork(selectRowId, out msg);
                if (doResult)
                {
                    Alert.ShowInTop("下发成功!");
                    Query(1);
                }
                else
                    Alert.ShowInTop(msg);
            }
            else
                Alert.ShowInTop("请选择单据!");
        }
 
        /// <summary>
        /// 校验
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCheckWorkOption_Click(object sender, EventArgs e)
        {
            List<object> selectedRowIDs = new List<object>(WebOrderGrid.SelectedRowIDArray);
            int[] selections = WebOrderGrid.SelectedRowIndexArray;
            var detail = WebOrderGrid.Rows;
 
            int selectRowId = -1;
 
            for (int i = 0; i < selections.Length; i++)
            {
                string RowId = detail[selections[i]].RowID.ToString();
                int id = Convert.ToInt32(detail[selections[i]].Values[1].ToString());
 
                if (selectedRowIDs.Contains(RowId))
                {
                    selectRowId = id;
                    break;
                }
            }
            if (selectRowId > -1)
            {
                string msg;
                List<MaterialPlaceView> outMrl;
                WebOrderService.GetInstance().CheckWorkOption(selectRowId,out outMrl,out msg);
                Alert.ShowInTop(msg);
            }
            else
                Alert.ShowInTop("请选择单据!");
        }
 
        /// <summary>
        /// 导出excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ExportToExcel(object sender, EventArgs e)
        {
            List<object> selectedRowIDs = new List<object>(WebOrderGrid.SelectedRowIDArray);
            int[] selections = WebOrderGrid.SelectedRowIndexArray;
            var detail = WebOrderGrid.Rows;
 
            int selectRowId = -1;
 
            for (int i = 0; i < selections.Length; i++)
            {
                string RowId = detail[selections[i]].RowID.ToString();
                int id = Convert.ToInt32(detail[selections[i]].Values[1].ToString());
 
                if (selectedRowIDs.Contains(RowId))
                {
                    selectRowId = id;
                    break;
                }
            }
            if (selectRowId > -1)
            {
                string msg = "";
                List<WebOrderDetailView> cutOrderDetail = WebOrderDetailService.GetInstance().GetWebOrderDetail(selectRowId,out msg);
                if (cutOrderDetail == null || cutOrderDetail.Count == 0)
                {
                    ShowNotify("无单据明细");
                    return;
                }
                Response.ClearContent();
                Response.AddHeader("content-disposition", "attachment; filename=推送单" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls");
                Response.ContentType = "application/excel";
                Response.ContentEncoding = System.Text.Encoding.UTF8;
                Response.Write(GetGridHtml(cutOrderDetail));
                Response.End();
            }
            else
                Alert.ShowInTop("请选择单据!");
        }
 
        private string GetGridHtml(List<WebOrderDetailView> orderDetail)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
            sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
            sb.Append("<tr>");
 
            List<string> titles = new List<string>() { "推送单据号", "出入库单据号", "序号", "规格号", "物料二维码", "物料名称", "数量", 
                                                       "物件编号", "等级", "分类", "类型", "长度" , "density","宽度", "厚度", "突起宽度", 
                                                       "突起厚度","规格","单位重量" };
 
            foreach (string column in titles)
            {
                sb.AppendFormat("<td>{0}</td>", column);
            }
            sb.Append("</tr>");
            foreach (WebOrderDetailView row in orderDetail)
            {
                sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td><td>{7}</td><td>{8}</td>"
                              + "<td>{9}</td><td>{10}</td><td>{11}</td><td>{12}</td><td>{13}</td><td>{14}</td><td>{15}</td><td>{16}</td><td>{17}</td><td>{18}</td></tr>",
                              row.requestorder, row.listno, row.sequenceno, row.materialno, row.nestingno, row.nestingname, row.quantity, row.articlenumber,
                              row.grade,row.classification,row.profiletype,row.length,row.density,row.webheight,row.webthickness,row.flangewidth,row.flangethickness,
                              row.sectiondim,row.unitweight);
            }
            sb.Append("</table>");
            return sb.ToString();
        }
 
    }
}