王 垚
2022-04-21 3bd5db2a574a1280355de503813ba4d5cdca20b5
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Pub_Class;
using SQLHelper;
 
namespace PlanM
{
    public partial class Gy_StdWorkTimes_RoutingBill : BLL.Gy_DataInTmp
    {
        public Gy_StdWorkTimes_RoutingBill()
        {
            InitializeComponent();
        }
        public int HItemID =0;
        public int HMaker = 0;      //ÖÆµ¥ÈË
        public int HMakeDate = 0; //ÖÆµ¥ÈÕÆÚ
        public int HChecker = 0; //ÉóºËÈË
        public int HCheckDate = 0; //ÉóºËÈÕÆÚ
        public int HStopflag = 0;
        public int HRemark = 0;
        public int HUSEORGName = 0;       //×éÖ¯ID
        public int HProcName = 0; //
        public int HMaterName = 0;    //ÎïÁÏID
        public int HProcNum = 0; //
        public int HMaterNum = 0;    //ÎïÁÏID
        public int HStdWorkTimes = 0;    //±ê×¼¹¤Ê±
        public int HUpperlimit = 0;  //ÉÏÏÞ±ÈÀý
        public int HLowerlimit = 0;    //ÏÂÏÞ±ÈÀý
 
        //public int HMaterNumberCol = 0;             //²úÆ·´úÂë
        //public int HWorkTypeNameCol = 0;           //¹¤ÖÖ
        //public int HProcNameCol = 0;           //¹¤Ðò
        //public int HWorkCenterNameCol = 0;        //¹¤×÷ÖÐÐÄ
        //public int HProcMulNameCol = 0;           //¹¤¶Î
        //public int HWorkCenterName_SCol = 0;           //²úÏß
        //public int HWorkQtyCol = 0;          //²úÄÜ
        //public int HSubStdEmpQtyCol = 0;          //ÈËÊý
        //public int HWorkQty_SCol = 0;          //²úÏß²úÄÜ
        //public int HSubStdEmpQty_SCol = 0;          //²úÏßÈËÊý
 
        //public int HMouldNoCol = 0;          //Ä£¾ß±àºÅ
        //public int HChangeMouldCol = 0;          //»»Ä£Ê±¼ä
        //public int HPackStdCol = 0;          //ÖÜתÏä±ê×¼
        //public int HPackCol = 0;          //ÖÜתÏä
        //public int HPutAreaCol = 0;          //ÔÝ·ÅÇø
        ////
        //public int HMyWorkDaysCol = 0;          //Éú²úÖÜÆÚ
        //public int HMyFixWorkDaysCol = 0;          //¹Ì¶¨Éú²úÌìÊý
 
        //public int HBeginDayQtyCol = 6;     //¿ª¹¤¹ÌÌì
        //public int HBeginFixQtyCol = 7;     //¿ª¹¤ÓàÁ¿ 
        //public int HFixPriceCol = 8;        //¶¨¶î Ð¡Ê±¹¤×Ê
        //public int HProcPriceCol = 9;       //¹¤¼Û
        //public int HProcTypeCol = 0;          //¹¤ÐòÀàÐÍ
        //
        public const int HBeginRow = 2;         //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
        // 
        //DAL.ClsGy_RoutingBill;
        public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View();
        public DAL.ClsGy_StdWorkTimes_Ctl BillNew = new DAL.ClsGy_StdWorkTimes_Ctl();
        DAL.ClsIF_Material_View oMaterHlp = new DAL.ClsIF_Material_View();
        //DAL.ClsGy_WorkType_View oWorkType = new DAL.ClsGy_WorkType_View();
        long j = -1;
        int c = 0;
 
        public override bool OpenExcelData()
        {
            base.sSheetName = txtHSheetName.Text;
            return base.OpenExcelData();
        } 
 
        /// <summary>
        ///  ³õʼ»¯½çÃæ
        /// </summary>
        public override void initData()
        {
            base.initData();
            base.sSheetName = txtHSheetName.Text ; 
            base.ModRightName = "Gy_StdWorkTimes_RoutingBill";
            base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck;
            base.ModRightNameClose = base.ModRightName + base.ModRightNameClose;
            base.ModRightNameDelete = base.ModRightName + base.ModRightNameDelete;
            base.ModRightNameEdit = base.ModRightName + base.ModRightNameEdit;
            base.ModRightNameMoney = base.ModRightName + base.ModRightNameMoney;
            base.ModRightNameQty = base.ModRightName + base.ModRightNameQty;
            base.ModCaption = "±ê×¼¹¤Ê±µ¼Èë";
            this.Text = base.ModCaption;
            lblCaption.Text = base.ModCaption;
            //
            DBUtility.Gy_BaseFun.SetComboxYear(cmbHYear);
            DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod);
            //
        }
        //µ¼Èë
        public override void Sub_DataIn()
        {
            string hnumber = "";
                                    //
            HStdWorkTimes = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¹¤Ê±", grdMain);
            HProcNum = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
            HProcName = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò", grdMain);
            HMaterNum = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ´úÂë", grdMain);
            HMaterName = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ", grdMain);
            HUpperlimit = DBUtility.Gy_BaseFun.Fun_GetCol("ÉÏÏß±ÈÀý", grdMain);
            HLowerlimit = DBUtility.Gy_BaseFun.Fun_GetCol("ÏÂÏß±ÈÀý", grdMain);
            HUSEORGName = DBUtility.Gy_BaseFun.Fun_GetCol("×éÖ¯", grdMain);
            HMaker = DBUtility.Gy_BaseFun.Fun_GetCol("ÖÆµ¥ÈË", grdMain);
            HMakeDate = DBUtility.Gy_BaseFun.Fun_GetCol("ÖÆµ¥ÈÕÆÚ", grdMain);
 
            //ûÓÐÕÒµ½ÁÐ
            if (HStdWorkTimes == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾±ê×¼¹¤Ê±¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HProcName == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾¹¤Ðò¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HMaterName == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾ÎïÁÏ¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HUpperlimit == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾ÉÏÏß±ÈÀý¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HLowerlimit == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾ÏÂÏß±ÈÀý¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HUSEORGName == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾×éÖ¯¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HMaker == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾ÖƵ¥ÈË¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            if (HMakeDate == -1)
            {
                MessageBox.Show("ûÓÐÕÒµ½¡¾ÖƵ¥ÈÕÆÚ¡¿µÄ±êÌâ", "Ìáʾ");
                return;
            }
            //
            if (!Checkdata())
            {
                return;
            }
            if (grdMain.Rows.Count > 0)
            { 
                hnumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[0].Cells[HMaterNum].Value);
                BillNew.omodel.HMakeDate =  (DateTime.Today.Date).ToString();
                BillNew.omodel.HUSEORGID =  DBUtility.ClsPub.HOrgID;
                BillNew.omodel.HStopflag = false;
                BillNew.DetailColl.Clear();
            } 
            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNum].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNum].Value) != "")
                {
                    //дÈëÀà
                    if (WriteClass(i))
                    {
                        //±£´æ¼Ç¼
                        if (!BillNew.AddNew())
                        {
                            MessageBox.Show("µ¼Èëʧ°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("¹¤Ðò´úÂë»òÎïÁÏ´úÂëΪ¿Õ!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                    return;
                }
            }
            MessageBox.Show("µ¼ÈëÍê±Ï");
            grdMain.DataSource = null;
        }
 
        //дÈëÀ࠴ӿؼþ
        private bool WriteClass(int row)
        {
            string sHNumber = "";
            string sHNamePoc = "";
            string HStopflag = "";
            string HUSEORGID = "";
            //string sHNumberWorkType = "";
            string HStdWorkTimes = "";
            string HUpperlimit="";  //ÉÏÏÞ±ÈÀý
            string HLowerlimit="";  //ÏÂÏÞ±ÈÀý
 
            int HMaterNum = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·´úÂë", grdMain);
            int sMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·Ãû³Æ", grdMain);
            int sModelCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹æ¸ñÐͺÅ", grdMain);
            int HProcNum = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
            int sProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò", grdMain);
            int sSourceNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("×ÊÔ´´úÂë", grdMain);
            int sSourceNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("Éú²ú×ÊÔ´", grdMain);
            int sPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("µ¥¼Û", grdMain);
            //long HItemID = 0; 
            //
            sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HMaterNum].Value);
            sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HProcNum].Value);
            //
            //
            HStopflag = DBUtility.ClsPub.isBool(grdMain.Rows[row].Cells[HStopflag].Value).ToString();
            HUSEORGID = DBUtility.ClsPub.HOrgID.ToString();
            HStdWorkTimes = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HStdWorkTimes].Value).ToString();
            HUpperlimit = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HUpperlimit].Value).ToString();
            HLowerlimit = DBUtility.ClsPub.isSingle(grdMain.Rows[row].Cells[HLowerlimit].Value).ToString();
 
            //ÅжÏÊÇ·ñÔÊÐí ±£´æ
            if (!DBUtility.ClsPub.AllowNumber(sHNumber))
            {
                MessageBox.Show("²úÆ·´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
            if (!DBUtility.ClsPub.AllowNumber(sHNamePoc))
            {
                MessageBox.Show("¹¤Ðò´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
 
            Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
 
            //µÃµ½¹¤ÐòÄÚÂë
            if (oProcHlp.GetInfoByName(sHNamePoc))
            {
                oSub.HProcID = oProcHlp.omodel.HItemID;
            }
            //µÃµ½ÎïÁÏÄÚÂë
            if (oMaterHlp.GetInfoByName(sHNumber))
            {
                oSub.HMaterID = oMaterHlp.omodel.HItemID;
            }
 
 
            //дÈëÐÅÏ¢
            oSub.HEntryID = j;
 
            oSub.HMaker = DBUtility.ClsPub.CurUserName;
            oSub.HMakeDate = (DateTime.Today.Date).ToString();
            oSub.HStdWorkTimes = double.Parse(HStdWorkTimes);
            oSub.HRemark = "";
            oSub.HUpperlimit = double.Parse(HUpperlimit);
            oSub.HLowerlimit = double.Parse(HLowerlimit);
            oSub.HStopflag = bool.Parse(HStopflag);
 
 
            BillNew.DetailColl.Add(oSub);
            return true;
        }
 
        //¼ì²éÎïÁÏ
        private bool Checkdata()
        {
            bool b = false;
            string sErrMsg = "";
            string sMsg = "";
            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
            {
                string sHNumber = "";
                string sHNamePoc = "";
 
                //
                sHNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HMaterNum].Value);
                sHNamePoc = DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HProcNum].Value);
                if (sHNumber != "")
                {
                    // 
                    //ÉóºË´úÂëÊÇ·ñºÏÀí
                    if (!DBUtility.ClsPub.AllowNumber(sHNumber))
                    {
                        MessageBox.Show("ÎïÁÏ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                        return false;
                    }
                    //µÃµ½ÎïÁÏÄÚÂë
                    int j = i + HBeginRow;
                    if (!oMaterHlp.GetInfoByNumber(sHNumber))
                    {
                        sMsg = "[" + sHNumber + "]ÎïÁϲ»´æÔÚ";
                        if (sErrMsg.Contains(sMsg) == false)
                        {
                            sErrMsg = sErrMsg + "[" + sHNumber + "]ÎïÁϲ»´æÔÚ\r\n";
                        }
                        b = true;
                    }
                    //µÃµ½¹¤ÐòÄÚÂë
                    if (!oProcHlp.GetInfoByName(sHNamePoc))
                    {
                        sMsg = "[" + sHNamePoc + "]¹¤Ðò²»´æÔÚ";
                        if (sErrMsg.Contains(sMsg) == false)
                        {
                            sErrMsg = sErrMsg + "[" + sHNamePoc + "]¹¤Ðò²»´æÔÚ\r\n";
                        }
                        b = true;
                    }
                }
            }
            if (b == true)
            {
                Pub_Control.ErrMsgBox oMsgbox = new Pub_Control.ErrMsgBox();
                oMsgbox.txtHErrMsg.Text = sErrMsg;
                oMsgbox.ShowDialog();
                return false;
            }
            else
            {
                return true;
            }
        }
 
        private void Gy_StdWorkTimes_RoutingBill_Load(object sender, EventArgs e)
        {
 
        }
    }
}