zzr99
2022-04-25 e5e8b23083cd7f09ebe3c110e84cfad7747eba49
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
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 HStdPiece = 0;  //ÉÏÏÞ±ÈÀý
        public int HStdPric = 0;    //ÏÂÏÞ±ÈÀý
        //
        public const int HBeginRow = 2;         //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
 
 
        // 
        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();
 
       
 
        public override bool OpenExcelData()
        {
            base.sSheetName = txtHSheetName.Text;
            return base.OpenExcelData();
        }
 
 
        /// <summary>
        ///  ³õʼ»¯½çÃæ
        /// </summary>
        public override void initData()
        {
            base.initData();
            base.sSheetName = "±ê×¼¹¤Ê±";
            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()
        {
            int sHStdWorkTimesCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¹¤Ê±", grdMain);
            int sHProcNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
            int sHProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò", grdMain);
            int sHMaterNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ´úÂë", grdMain);
            int sHMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ", grdMain);
            int sHUpperlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÉÏÏß±ÈÀý", grdMain);
            int sHLowerlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÏÂÏß±ÈÀý", grdMain);
            int sHStdPieceCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¼Æ¼þ", grdMain);
            int sHStdPricCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¼Æ¼Û", grdMain);
            int sHUSEORGNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("×éÖ¯", grdMain);
            int sHMakerCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÖÆµ¥ÈË", grdMain);
            int sHMakeDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÖÆµ¥ÈÕÆÚ", grdMain);
 
            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sHMaterNumCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sHProcNumCol].Value) != ""&& DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sHStdWorkTimesCol].Value) != "")
                {
                    if (DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[sHStdWorkTimesCol].Value)>0&& DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[sHUpperlimitCol].Value) > 0&& DBUtility.ClsPub.isDoule(grdMain.Rows[i].Cells[sHLowerlimitCol].Value) > 0)
                    {
                        //дÈëÀà
                        if (WriteClass(i))
                        {
                            //±£´æ¼Ç¼
                            if (!BillNew.AddNew())
                            {
                                MessageBox.Show("µ¼Èëʧ°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                                return;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("µÚ" + (i + 1) + "ÐÐ,±ê×¼¹¤Ê±¡¢ÉÏÏÞ±ÈÀýºÍÏÂÏÞ±ÈÀý²»ÄÜСÓÚ0", "Ìáʾ");
                        return;
                    }
                }
                else
                {
                    MessageBox.Show("µÚ"+(i+1)+"ÐÐ,¹¤Ðò´úÂë¡¢ÎïÁÏ´úÂëºÍ±ê×¼¹¤Ê±²»ÄÜΪ¿Õ!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                    return;
                }
            }
            MessageBox.Show("µ¼ÈëÍê±Ï");
            grdMain.DataSource = null;
        }
 
        //дÈëÀ࠴ӿؼþ
        private bool WriteClass(int row)
        {
            BillNew.DetailColl.Clear();
            string sMaterNumber = "";
            string sMaterName = "";
            string sProcNumber = "";
            string sProcName = "";
            double sStdWorkTimes = 0;
            double sUpperlimit = 0;
            double sLowerlimit = 0;
            double sStdPiece = 0;
            double sStdPric= 0;
            int sUSEORGName = 0;
            DateTime sHMakeDate = DateTime.Today.Date;
            string sHMaker = DBUtility.ClsPub.CurUserName;
 
            int sHStdWorkTimesCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¹¤Ê±", grdMain);
            int sHProcNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò´úÂë", grdMain);
            int sHProcNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤Ðò", grdMain);
            int sHMaterNumCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ´úÂë", grdMain);
            int sHMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÎïÁÏ", grdMain);
            int sHUpperlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÉÏÏß±ÈÀý", grdMain);
            int sHLowerlimitCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÏÂÏß±ÈÀý", grdMain);
            int sHStdPieceCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¼Æ¼þ", grdMain);
            int sHStdPricCol = DBUtility.Gy_BaseFun.Fun_GetCol("±ê×¼¼Æ¼Û", grdMain);
            int sHUSEORGNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("×éÖ¯", grdMain);
            int sHMakerCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÖÆµ¥ÈË", grdMain);
            int sHMakeDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÖÆµ¥ÈÕÆÚ", grdMain);
            //
            sMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHMaterNumCol].Value);
            //sMaterName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHMaterNameCol].Value);
            sProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHProcNumCol].Value);
            //sProcName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHProcNameCol].Value);
            sStdWorkTimes = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHStdWorkTimesCol].Value);
            sUpperlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHUpperlimitCol].Value);
            sLowerlimit = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHLowerlimitCol].Value);
            sStdPiece = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHStdPieceCol].Value);
            sStdPric = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sHStdPricCol].Value);
            //sUSEORGName = DBUtility.ClsPub.isInt(grdMain.Rows[row].Cells[sHUSEORGNameCol].Value);
            //sHMakeDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[sHMakeDateCol].Value);
            //sHMaker = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sHMakerCol].Value);
 
            //ÅжÏÊÇ·ñÔÊÐí ±£´æ
            
            //ÉóºË´úÂëÊÇ·ñºÏÀí
            if (!DBUtility.ClsPub.AllowNumber(sMaterNumber))
            {
                MessageBox.Show("²úÆ·´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
            if (!DBUtility.ClsPub.AllowNumber(sProcNumber))
            {
                MessageBox.Show("¹¤Ðò´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
 
            Model.ClsGy_StdWorkTimes_Model oSub = new Model.ClsGy_StdWorkTimes_Model();
            //µÃµ½ÎïÁÏÄÚÂë
            if (oMaterHlp.GetInfoByNumber(sMaterNumber))
            {
                oSub.HMaterID = oMaterHlp.omodel.HItemID;
            }
            else
            {
                oSub.HMaterID = 0;
                MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sMaterNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄÎïÁÏ£¡");
                return false;
            }
            //µÃµ½¹¤ÐòÄÚÂë
            if (oProcHlp.GetInfoByNumber(sProcNumber))
            {
                oSub.HProcID = oProcHlp.omodel.HItemID;
            }
            else
            {
                oSub.HProcID = 0;
                MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sProcNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤Ðò£¡");
                return false;
            }
            
            //дÈëÐÅÏ¢
           
            oSub.HRemark = "";
            oSub.HStdWorkTimes = sStdWorkTimes;
            oSub.HUpperlimit = sUpperlimit;
            oSub.HLowerlimit = sLowerlimit;
            oSub.HStdPiece = sStdPiece;
            oSub.HStdPric = sStdPric;
            oSub.HUSEORGID = DBUtility.ClsPub.HOrgID;
            oSub.HMaker = DBUtility.ClsPub.CurUserName;
            oSub.HMakeDate = DateTime.Today.ToShortDateString();
            BillNew.DetailColl.Add(oSub);
            //oProc.oModel.HBillSubType = DBUtility.ClsPub.isStrNull(txtHBillSubType.Text);
 
            return true;
        }
 
 
        private void Gy_StdWorkTimes_RoutingBill_Load(object sender, EventArgs e)
        {
 
        }
    }
}