1
wtt
4 天以前 797e02f68d79c931233f25af1d39bc136ce6185d
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace BaseSet
{
    public partial class Gy_DataIn_ProcessPrice :BLL.Gy_DataInTmp
    {
        public Gy_DataIn_ProcessPrice()
        {
            InitializeComponent();
        }
 
        public int HCollectIDCol = 1;         //²É¼¯Æ÷ÄÚÂë
        public int HRoomIDCol = 5;            //Òµ»§ÄÚÂë
        public int HBeginDateCol = 13;         //¿ªÊ¼ÈÕÆÚ
        public int HEndDateCol = 10;           //½áÊøÈÕÆÚ
        public int HItMoneyIDCol = 5;         //·ÑÓÃÏîÄ¿
        public int HQtyCol = 6;               //ÊýÁ¿
        public int HPriceCol = 7;             //µ¥¼Û
        public int HMoneyCol = 8;             //½ð¶î
        public int HBeginBalanceCol = 12;      //¿ªÊ¼ÊýÖµ
        public int HEndBalanceCol = 9;        //½áÊøÊýÖµ
        //
        public const int HBeginRow = 2;         //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
        //
     
        //
        //public DAL.ClsGy_Process_Ctl oProc = new DAL.ClsGy_Process_Ctl();
        //public DAL.ClsGy_Process_View oProcHlp = new DAL.ClsGy_Process_View();
        //public DAL.ClsGy_Department_View oFactory = new DAL.ClsGy_Department_View();
 
        public DAL.ClsGy_ProcPrice_Ctl BillNew = new DAL.ClsGy_ProcPrice_Ctl();
        //DAL.ClsGy_Material_Ctl oMater = new DAL.ClsGy_Material_Ctl();
        //DAL.ClsGy_Material_View oMaterHlp = new DAL.ClsGy_Material_View();
 
        DAL.ClsIF_Process_View oProc = new DAL.ClsIF_Process_View();
        DAL.ClsIF_Material_View oMater = new DAL.ClsIF_Material_View();
        DAL.ClsIF_Source_View oSource = new DAL.ClsIF_Source_View();
        DAL.ClsIF_Department_View oDept = new DAL.ClsIF_Department_View(); 
 
        /// <summary>
        ///  ³õʼ»¯½çÃæ
        /// </summary>
        public override void initData()
        {
            base.initData();
            base.sSheetName = "¹¤Ðò¹¤¼Û"; 
            base.ModRightName = "Gy_DataIn_ProcessPrice";
            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 sMaterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·´úÂë", grdMain);
            int sMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·Ãû³Æ", grdMain);
            int sModelCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹æ¸ñÐͺÅ", grdMain);
            int sProcNumberCol = 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);
            int sFixPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("¶¨¶î", grdMain);
            int sBadPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("²»Á¼¿Û¿î", grdMain);
            int sWasterPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("±¨·Ï¿Û¿î", grdMain);
            int sDeptNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("²¿ÃÅ´úÂë", grdMain);
            int sDeptNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("²¿ÃÅ", grdMain);
            int sCostFlagCol = DBUtility.Gy_BaseFun.Fun_GetCol("Á÷תĬÈÏ", grdMain);
            int sPayFlagCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤×ÊĬÈÏ", grdMain);
            int sFlowFlagCol = DBUtility.Gy_BaseFun.Fun_GetCol("³É±¾Ä¬ÈÏ", grdMain);
            int sBeginDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÉúЧÈÕÆÚ", grdMain);
            int sEndDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("ʧЧÈÕÆÚ", grdMain);
            
            for (int i = 0; i <= grdMain.Rows.Count - 1; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sMaterNumberCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sProcNumberCol].Value) != "" && DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[sPriceCol].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)
        {
            BillNew.DetailColl.Clear();
            //string sHNumber = "";
            //string sProcNumber = "";
            //double Price = 0 ;
            string sMaterNumber = "";
            string sMaterName = "";
            string sModel = "";
            string sProcNumber = "";
            string sProcName = "";
            string sSourceNumber = "";
            string sSourceName = "";
            double sPrice = 0;
            double sFixPrice = 0;
            double sBadPrice = 0;
            double sWasterPrice = 0;
            string sDeptNumber = "";
            string sDeptName = "";
            bool sCostFlag = false;
            bool sPayFlag = false;
            bool sFlowFlag = false;
            DateTime sBeginDate = DateTime.Today.Date;
            DateTime sEndDate = DateTime.Today.Date;
            int sMaterNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·´úÂë", grdMain);
            int sMaterNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("²úÆ·Ãû³Æ", grdMain);
            int sModelCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹æ¸ñÐͺÅ", grdMain);
            int sProcNumberCol = 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);
            int sFixPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("¶¨¶î", grdMain);
            int sBadPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("²»Á¼¿Û¿î", grdMain);
            int sWasterPriceCol = DBUtility.Gy_BaseFun.Fun_GetCol("±¨·Ï¿Û¿î", grdMain);
            int sDeptNumberCol = DBUtility.Gy_BaseFun.Fun_GetCol("²¿ÃÅ´úÂë", grdMain);
            int sDeptNameCol = DBUtility.Gy_BaseFun.Fun_GetCol("²¿ÃÅ", grdMain);
            int sCostFlagCol = DBUtility.Gy_BaseFun.Fun_GetCol("Á÷תĬÈÏ", grdMain);
            int sPayFlagCol = DBUtility.Gy_BaseFun.Fun_GetCol("¹¤×ÊĬÈÏ", grdMain);
            int sFlowFlagCol = DBUtility.Gy_BaseFun.Fun_GetCol("³É±¾Ä¬ÈÏ", grdMain);
            int sBeginDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("ÉúЧÈÕÆÚ", grdMain);
            int sEndDateCol = DBUtility.Gy_BaseFun.Fun_GetCol("ʧЧÈÕÆÚ", grdMain);
            //
            sMaterNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sMaterNumberCol].Value);
            sMaterName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sMaterNameCol].Value);
            sModel = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sModelCol].Value);
            sProcNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sProcNumberCol].Value);
            sProcName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sProcNameCol].Value);
            sSourceNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sSourceNumberCol].Value);
            sSourceName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sSourceNameCol].Value);
            sPrice = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sPriceCol].Value);
            sFixPrice = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sFixPriceCol].Value);
            sBadPrice = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sBadPriceCol].Value);
            sWasterPrice = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[sWasterPriceCol].Value);
            sDeptNumber = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sDeptNumberCol].Value);
            sDeptName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sDeptNameCol].Value);
            sCostFlag = DBUtility.ClsPub.StringToBool(grdMain.Rows[row].Cells[sCostFlagCol].Value);
            sPayFlag = DBUtility.ClsPub.StringToBool(grdMain.Rows[row].Cells[sPayFlagCol].Value);
            sFlowFlag = DBUtility.ClsPub.StringToBool(grdMain.Rows[row].Cells[sFlowFlagCol].Value);
            sBeginDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[sBeginDateCol].Value);
            sEndDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[sEndDateCol].Value);
 
            //ÅжÏÊÇ·ñÔÊÐí ±£´æ
            //ÉóºË´úÂëÊÇ·ñºÏÀí
            if (!DBUtility.ClsPub.AllowNumber(sMaterNumber))
            {
                MessageBox.Show("²úÆ·´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
            if (!DBUtility.ClsPub.AllowNumber(sProcNumber))
            {
                MessageBox.Show("¹¤Ðò´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
            if (!DBUtility.ClsPub.AllowNumber(sSourceNumber))
            {
                MessageBox.Show("×ÊÔ´´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
            if (!DBUtility.ClsPub.AllowNumber(sDeptNumber))
            {
                MessageBox.Show("²¿ÃÅ´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
            Model.ClsGy_ProcPrice_Model oSub=new Model.ClsGy_ProcPrice_Model();
            //µÃµ½ÎïÁÏÄÚÂë
            if (oMater.GetInfoByNumber(sMaterNumber))
            {
                oSub.HMaterID = oMater.omodel.HItemID;
            }
            else
            {
                oSub.HMaterID = 0;
                MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sMaterNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄÎïÁÏ£¡");
                return false;
            }
            //µÃµ½¹¤ÐòÄÚÂë
            if (oProc.GetInfoByNumber(sProcNumber))
            {
                oSub.HProcID = oProc.omodel.HItemID;
            }
            else
            {
                oSub.HProcID = 0;
                MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sProcNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄ¹¤Ðò£¡");
                return false;
            }
            //µÃµ½×ÊÔ´ÄÚÂë
            if (oSource.GetInfoByNumber(sSourceNumber))
            {
                oSub.HSourceID = oSource.omodel.HItemID;
            }
            else
            {
                oSub.HSourceID = 0;
                //MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sSourceNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄ×ÊÔ´£¡");
                //return false;
            }
            //µÃµ½²¿ÃÅÄÚÂë
            if (oDept.GetInfoByNumber(sDeptNumber))
            {
                oSub.HDeptID = oDept.omodel.HItemID;
            }
            else
            {
                oSub.HDeptID = 0;
                //MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sDeptNumber + "ûÓÐÕÒµ½¶ÔÓ¦µÄ²¿ÃÅ£¡");
                //return false;
            }
            //дÈëÐÅÏ¢
            oSub.HCostFlag = sCostFlag;
            oSub.HFlowFlag =sFlowFlag;
            oSub.HPayFlag = sPayFlag;
            if ( DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sBeginDateCol].Value)!= "" )
                oSub.HBeginDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[sBeginDateCol].Value);
            else
                oSub.HBeginDate =DateTime.Today.Date;
 
            if ( DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[sBeginDateCol].Value)!= "" )
                oSub.HEndDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[sEndDateCol].Value);
            else
                oSub.HEndDate = DateTime.Today.Date.AddYears(100);
 
            oSub.HRemark = "";
            oSub.HPrice = sPrice;
            oSub.HFixPrice = sFixPrice;
            oSub.HBadPrice = sBadPrice;
            oSub.HWasterPrice = sWasterPrice;
            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 button1_Click(object sender, EventArgs e)
        {
 
        }
 
        
 
    }
}