yangle
2024-12-30 7f80be364af2ba22f8cf69b5e7f2ed771297ba2e
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace MES
{
    public partial class Sc_DynamicDataQuery : Form
    {
        private int HItemIDCol = 0;
        private int HNumberCol = 0;  
        const string ModName = "资源";
        const string BillName = "Gy_Source";
        public long  HItemID;//项目ID
        public string sCondition; //过滤条件
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        TreeNode CurNode = new TreeNode();
        public long HInterID = 0;
        public long HEntryID = 0;
        public string HBillNo = "";
        public string HSourceNumber = "";
        public string HSourceName = "";
        public string HMaterNumber = "";
        public string HMaterName = "";
        public string HMaterModel = "";
        public string HUnitName = "";
        public double HPlanQty = 0;
        public double HQty = 0;
 
 
        public Sc_DynamicDataQuery()
        {
            InitializeComponent();
        }
        //以下代码基本不需要修改
        #region 固定代码
        //保存GRID列宽
        private void Sc_DynamicDataQuery_FormClosing(object sender, FormClosingEventArgs e)
        {
            DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);  
        }
        //窗体加载
        private void Sc_DynamicDataQuery_Load(object sender, EventArgs e)
        { 
            LoadTree();
            initGrid(); 
        } 
        private void LoadAllNodes(TreeNode sNode)  //Lock
        {
            DBUtility.Gy_BaseFun.LoadAllNodes(sNode, BillName);
        } 
        private void LoadTree()//Lock
        {
            DBUtility.Gy_BaseFun.LoadTree(tv, imageList1, txtHDeptID.Text, BillName,DBUtility.ClsPub.isLong(txtHDeptID.Tag));
        }
         
        //退出模块
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        } 
        //查询
        private void cx_Click(object sender, EventArgs e)
        {
            string sCode="0";
            if (CurNode.Name.Length >= 2)
            {
                sCode = CurNode.Name.Substring(1, CurNode.Name.Length - 1);
            }
            Display(sCode); 
        } 
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Gy_BaseFun.Fun_GetCol(sCol, grdMain);
        } 
  
        //树型 单击
        private void tv_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            CurNode = e.Node;
            if (CurNode != null)
            {
                if (CurNode.Nodes.Count == 0)
                    LoadAllNodes(CurNode);
                //找到选中结点
                FindRow(CurNode.Name);
            }
        }
        //过滤资料  
        private void FindRow(string sCode)//Lock
        {
            if (sCode.Length >= 2)
            {
                sCode=sCode.Substring(1, sCode.Length - 1);
            }
            Display(sCode); 
        }
       
          
        
        //保存列宽
        private void bclk_Click(object sender, EventArgs e)
        {
            DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);  
        }
        //默认列宽
        private void mrlk_Click(object sender, EventArgs e)//Lock
        {
            DBUtility.ClsPub.DefaultGridView(grdMain);
            //参数解释  开始列 ,结束列,是否以最大列宽为准,最小列宽
            DBUtility.ClsPub.SaveGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);  
        }
        //时间控件
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            Display("0");
        }
         
        //初始化GRID
        private void initGrid()
        {
            DBUtility.Gy_BaseFun.initGrid(grdMain);
            grdMain.ColumnHeadersHeight =45;          //标题行高
        }
        //显示列表
        private void Display(string sSource) // 幻心
        {
            SQLHelper.ClsCN SubCn = new SQLHelper.ClsCN();
            DataSet DSet; 
            string sSql = ""; 
            //过滤条件
            sSql = "exec h_p_Sc_DynamicDataQueryList '%" + txtHICMOBillNo.Text + "%'," + DBUtility.ClsPub.isLong(sSource).ToString();
            //执行SQL
            DSet = SubCn.RunProcReturn(sSql, "xt_xtgnb", ref DBUtility.ClsPub.sExeReturnInfo);
            //
            if (DSet == null)
            {
                MessageBox.Show("显示失败!原因:" + DBUtility.ClsPub.sExeReturnInfo);
                return;
            }
            grdMain.DataSource = DSet.Tables[0].DefaultView;
            //加载列宽
            DBUtility.Gy_BaseFun.DisplayGrid(grdMain, this.Name);
            //
            HItemIDCol = Fun_GetCol("HItemID");
            HNumberCol = Fun_GetCol(ModName + "代码");
            sCondition = "";
        }
 
      
 
        private void cmdLoadTree_Click(object sender, EventArgs e)
        {
            LoadTree();
        }
 
        #endregion
 
        #region 类的读写
 
         
         
        #endregion
 
         
 
        #region 界面控件处理
 
        private void cmdHDeptID_Click(object sender, EventArgs e)
        {
            DAL.ClsK3_Department_View oDept = new DAL.ClsK3_Department_View();
            if (oDept.RefreshView())
            {
                this.txtHDeptID.Text = oDept.oModel.HName;
                this.txtHDeptID.Tag = oDept.oModel.HItemID.ToString();
                this.txtHDeptNumber.Text = oDept.oModel.HNumber;
            }
            else
            {
                this.txtHDeptID.Text = "";
                this.txtHDeptNumber.Text = "";
            }
            LoadTree();
        }
 
        #endregion
        //开工按钮
        private void kg_Click(object sender, EventArgs e)
        {
            Sub_Start();
        }
 
        //开工
        private void Sub_Start()
        {
            DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
            long HInterID = 0;
            long HEntryID = 0;
            long HSourceID = 0;
            string HBillNo = "";
            if (grdMain.CurrentRow == null)
                return;
            HSourceID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsourceid")].Value);
            HInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
            HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsubid")].Value);
            HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
            if (HInterID == 0)
                return;
            //判断是否已经完工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsEnded(),结束时间大于1950-01-01)
            if (!oTmp.IsEnded(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                //判断是否已经开工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsStarted(),开工日期大于1950-01-01)
                if (!oTmp.IsStarted(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    //未开工,则UPDATE生产状态表(在类中增加方法Fun_SetStart(),设置开始时间、当前生产标记、任务单状态1)
                    if (oTmp.Fun_SetStart(HInterID, HEntryID,HSourceID, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        MessageBox.Show("生产订单号:" + HBillNo + ",开工!", "提示");
                    }
                }
                else
                {
                    MessageBox.Show("生产订单号:" + HBillNo + ",正在工作中!", "提示");
                    return;
                }
            }
            else
            {
                MessageBox.Show("生产订单号:" + HBillNo + ",已经完工,无需开工!", "提示");
                return;
            }
            //刷新界面
            Display("0");
        }
        
 
        private void txtHDeptID_TextChanged(object sender, EventArgs e)
        {
            if (txtHDeptID.Text.Trim()=="")
            {
                txtHDeptID.Tag = "0";
            }
        }
 
 
        //完工按钮
        private void wg_Click(object sender, EventArgs e)
        {
            Sub_End();
        }
        //完工
        private void Sub_End()
        {
            DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
            long HInterID = 0;
            long HEntryID = 0;
            string HBillNo = "";
            if (grdMain.CurrentRow == null)
                return;
            HInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
            HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsubid")].Value);
            HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
            if (HInterID == 0)
                return;
            //判断是否已经开工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsStarted(),开工日期大于1950-01-01)
            if (oTmp.IsStarted(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
            {
 
                //判断是否已经完工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsEnded(),结束时间大于1950-01-01)
                if (!oTmp.IsEnded(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    //未完工,则UPDATE生产状态表(在类中增加方法Fun_SetEnd(),设置结束时间、当前生产标记、任务单状态3)
                    if (oTmp.Fun_SetEnd(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        MessageBox.Show("生产订单号:" + HBillNo + ",完工!", "提示");
                    }
                }
                else
                {
                    MessageBox.Show("生产订单号:" + HBillNo + ",已完工!", "提示");
                    return;
                }
            }
            else
            {
                MessageBox.Show("生产订单号:" + HBillNo + ",未开工!", "提示");
                return;
            }
            //刷新界面
            Display("0");
        }
 
        //挂起按钮
        private void gq_Click(object sender, EventArgs e)
        {
            Sub_Pause();
        }
 
        //挂起
        private void Sub_Pause()
        {
            
        }
        //引出按钮
        private void yc_Click(object sender, EventArgs e)
        {
            Sub_DataIn();
        }
 
        //引出
        private void Sub_DataIn()
        {
            
        }
 
        //产量汇报按钮
        private void clhb_Click(object sender, EventArgs e)
        {
            Sub_WorkQtyReport();
        }
         
 
          //产量汇报
        private void Sub_WorkQtyReport()
        {
 
            //弹出 产量汇报窗体,对应DAL,MODEL类ClsSc_ICMOBillWorkQtyStatus_Tmp已经建立.窗体需要重新制作。
            MES.Sc_ICMOBillWorkQtyStatus_Tmp oSc_ICMOReportBill_WMS = new Sc_ICMOBillWorkQtyStatus_Tmp();
            DAL.ClsSc_ICMOBillWorkQtyStatus_Tmp oWms = new DAL.ClsSc_ICMOBillWorkQtyStatus_Tmp();
            DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
            DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
            DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
            DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View();
            long HInterID_Tmp = 0;
            if (grdMain.CurrentRow == null)
                return;
            HInterID_Tmp = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HInterID_Tmp")].Value);
            HInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hmainid")].Value);
            HEntryID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("hsubid")].Value);
            HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
            //判断是否已经开工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsStarted(),开工日期大于1950-01-01)
            if (oTmp.IsStarted(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
            {
 
                //判断是否已经完工(在ClsSc_ICMOBillStatus_Tmp类中增加方法IsEnded(),结束时间大于1950-01-01)
                if (!oTmp.IsEnded(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo))
                {
                    if (oTmp.ShowBill(HInterID_Tmp, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        oSc_ICMOReportBill_WMS.txtHICMOBillNo.Text = oTmp.omodel.HICMOBillNo;
                        oSc_ICMOReportBill_WMS.txtHSplitNO.Text = oTmp.omodel.HSplitNO;
                        oSc_ICMOReportBill_WMS.txtHSourceNumber.Tag = oTmp.omodel.HSourceID;
                        if (oSource.GetInfoByID(oTmp.omodel.HSourceID))
                        {
                            oSc_ICMOReportBill_WMS.txtHSourceNumber.Text = oSource.omodel.HNumber;
                            oSc_ICMOReportBill_WMS.txtHSourceName.Text = oSource.omodel.HName;
                        }
                        if (oMater.GetInfoByID(oTmp.omodel.HMaterID))
                        {
                            oSc_ICMOReportBill_WMS.txtHMaterNumber.Text = oMater.omodel.HNumber;
                            oSc_ICMOReportBill_WMS.txtHMaterName.Text = oMater.omodel.HName;
                            oSc_ICMOReportBill_WMS.txtHMaterModel.Text = oMater.omodel.HModel;
                        }
                        if (oUnit.GetInfoByID(oTmp.omodel.HUnitID))
                        {
                            oSc_ICMOReportBill_WMS.txtHUnitName.Text = oUnit.omodel.HName;
                        }
                        oSc_ICMOReportBill_WMS.txtHPlanQty.Text = oTmp.omodel.HPlanQty.ToString();
                        oSc_ICMOReportBill_WMS.txtHDayQty.Text = oTmp.omodel.HDatePlanQty.ToString();
                        oSc_ICMOReportBill_WMS.txtHBarCode.Text = "";
                        oSc_ICMOReportBill_WMS.txtHPieceQty.Text = "";
                        oSc_ICMOReportBill_WMS.txtHQty.Text = oTmp.omodel.HDatePlanQty.ToString();
                        oSc_ICMOReportBill_WMS.HSourceInterID = HInterID_Tmp;
                        oSc_ICMOReportBill_WMS.ShowDialog();
                    }
                    //汇报完毕,需要判断,新增汇报数量后,是否完工,更改生产状态表状态。
                    if (oWms.IsEnded(HInterID_Tmp, ref DBUtility.ClsPub.sExeReturnInfo))
                    {
                        //如果已经完工,调用方法Fun_SetEnd(),设置结束时间、当前生产标记、任务单状态3
                        oTmp.Fun_SetEnd(HInterID, HEntryID, ref DBUtility.ClsPub.sExeReturnInfo);
                    }
                }
                else
                {
                    MessageBox.Show("生产订单号:" + HBillNo + ",已经完工!", "提示");
                    return;
                }
            }
            else
            {
                MessageBox.Show("生产订单号:" + HBillNo + ",未开工!", "提示");
                return;
            }
            //刷新界面
            Display("0");
        } 
 
 
 
 
 
 
 
        //质量汇报
        private void Sub_QualityReport()
        {
            ///弹出 质量汇报窗体,对应DAL,MODEL类ClsSc_ICMOBillQualityStatus_Tmp已经建立.窗体需要重新制作。
            MES.Sc_ICMOBillQualityStatus_Tmp oSc_QualityReportBill_WMS = new Sc_ICMOBillQualityStatus_Tmp();
            DAL.ClsSc_ICMOBillStatus_Tmp oTmp = new DAL.ClsSc_ICMOBillStatus_Tmp();
            DAL.ClsGy_Source_View oSource = new DAL.ClsGy_Source_View();
            DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
            DAL.ClsK3_Unit_View oUnit = new DAL.ClsK3_Unit_View();
            long HInterID_Tmp = 0;
            if (grdMain.CurrentRow == null)
                return;
            HInterID_Tmp = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("HInterID_Tmp")].Value);
            HBillNo = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentRow.Index].Cells[Fun_GetCol("生产订单")].Value);
            //
            if (oTmp.ShowBill(HInterID_Tmp, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                oSc_QualityReportBill_WMS.txtHICMOBillNo.Text = oTmp.omodel.HICMOBillNo;
                oSc_QualityReportBill_WMS.txtHSplitNO.Text = oTmp.omodel.HSplitNO;
                oSc_QualityReportBill_WMS.txtHSourceNumber.Tag = oTmp.omodel.HSourceID;
                if (oSource.GetInfoByID(oTmp.omodel.HSourceID))
                {
                    oSc_QualityReportBill_WMS.txtHSourceNumber.Text = oSource.omodel.HNumber;
                    oSc_QualityReportBill_WMS.txtHSourceName.Text = oSource.omodel.HName;
                }
                if (oMater.GetInfoByID(oTmp.omodel.HMaterID))
                {
                    oSc_QualityReportBill_WMS.txtHMaterNumber.Text = oMater.omodel.HNumber;
                    oSc_QualityReportBill_WMS.txtHMaterName.Text = oMater.omodel.HName;
                    oSc_QualityReportBill_WMS.txtHMaterModel.Text = oMater.omodel.HModel;
                }
                if (oUnit.GetInfoByID(oTmp.omodel.HUnitID))
                {
                    oSc_QualityReportBill_WMS.txtHUnitName.Text = oUnit.omodel.HName;
                }
                oSc_QualityReportBill_WMS.txtHPlanQty.Text = oTmp.omodel.HPlanQty.ToString();
                oSc_QualityReportBill_WMS.txtHDayQty.Text = oTmp.omodel.HDatePlanQty.ToString();
                oSc_QualityReportBill_WMS.txtHBarCode.Text = "";
                oSc_QualityReportBill_WMS.HSourceInterID = HInterID_Tmp;
                oSc_QualityReportBill_WMS.ShowDialog();
            }
            //刷新界面
            Display("0");
        }
 
 
        //质量汇报按钮
        private void zlhb_Click(object sender, EventArgs e)
        {
            Sub_QualityReport();
        }
 
 
 
        
 
        
    }
}