yangle
2022-06-30 1cf37e52dcefd6bbf567818b50e16f36c7fae84c
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace BLL
{
    public partial class Gy_Material_Add : Form
    {
 
        public Int64 HItemID;
        DAL.ClsGy_Material_Ctl oGroup = new DAL.ClsGy_Material_Ctl();
        DAL.ClsGy_Material_View oGroupHlp = new DAL.ClsGy_Material_View();
 
        public string ModName = "ÎïÁÏ";
        public const string BillName = "Gy_Material";
        public const string ModRightNameEdit = BillName + "_Edit";
        public const string ModRightNameDelete = BillName + "_Delete";
 
        public Gy_Material_Add()
        {
            InitializeComponent();
        }
 
        private void xz_Click(object sender, EventArgs e)
        {
            if (!WriteClass())
                return;
            if (Save())
            {
                MessageBox.Show("±£´æÍê±Ï£¡", "Ìáʾ");
            }
            else
            {
                MessageBox.Show("±£´æÊ§°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
            }
        }
 
        private bool AllowSave()
        {
            if (txtHNumber.Text.Trim() == "")
            {
                MessageBox.Show("ÎïÁÏ´úÂë²»ÄÜΪ¿Õ!", "Ìáʾ");
                return false;
            }
            if (txtHName.Text.Trim() == "")
            {
                MessageBox.Show("ÎïÁÏÃû³Æ²»ÄÜΪ¿Õ!", "Ìáʾ");
                return false;
            }
            //if (txtHModel.Text.Trim() == "")
            //{
            //    MessageBox.Show("¹æ¸ñÐͺŲ»ÄÜΪ¿Õ!", "Ìáʾ");
            //    return false;
            //}
            //ÉóºË´úÂëÊÇ·ñºÏÀí
            if (!DBUtility.ClsPub.AllowNumber(txtHNumber.Text.Trim()))
            {
                MessageBox.Show("´úÂëÖв»ÄܳöÏÖÁ¬Ðø¡®.¡¯²¢ÇÒÊ×λĩλ²»ÄÜΪ¡®.¡¯£¡", "Ìáʾ");
                return false;
            }
 
            //ÊÇ·ñÖØ¸´´úÂë
            if (oGroup.HavSameNumber(HItemID, txtHNumber.Text.Trim()))
            {
                MessageBox.Show("´úÂëÖØ¸´£¡", "Ìáʾ");
                return false;
            }
            return true;
        }
 
 
        //дÈëÀ࠴ӿؼþ
        private bool WriteClass()
        {
            //ÅжÏÊÇ·ñÔÊÐí ±£´æ
            if (!AllowSave())
            {
                return false;
            }
            //¼ì²é¸¸¼¶ÊÇ·ñ´æÔÚ
            string sParent;
            sParent = DBUtility.ClsPub.GetParentCode(txtHNumber.Text.Trim());
            if (sParent.Trim() == "")
            {
                oGroup.oModel.HParentID = 0;
            }
            else
            {
                if (oGroup.HavParentCode(sParent.Trim(), HItemID))
                {
                    oGroup.oModel.HParentID = oGroup.oModel.HItemID;
                }
                else
                {
                    MessageBox.Show("Éϼ¶´úÂë²»´æÔÚ»ò±»½ûÓã¡", "Ìáʾ");
                    return false;
                }
            }
            //µÃµ½¶Ì´úÂë
            string sShortNumber;
            sShortNumber = DBUtility.ClsPub.GetShortNumber(txtHNumber.Text.Trim());
            if (sShortNumber.Trim() == "")
            {
                return false;
            }
            //±£´æÔ­´úÂë
            if (oGroupHlp.GetInfoByID(HItemID))
            {
                oGroup.HOldNumber = oGroupHlp.omodel.HNumber;
                //ÊÇ·ñдúÂëÊÇ×Ô¼º×ÓÏîÄ¿µÄ¡¡×ÓÏîÄ¿
                if (sParent.Length >= oGroup.HOldNumber.Length)
                {
                    if (sParent.Substring(0, oGroup.HOldNumber.ToString().Length) == oGroup.HOldNumber.Trim())
                    {
                        MessageBox.Show("дúÂë²»ÄÜÊÇ×Ô¼ºµÄϼ¶µÄ×ÓÏîÄ¿£¡", "Ìáʾ");
                        return false;
                    }
                }
            }
            else
            {
                oGroup.HOldNumber = "";
            }
            //дÈëÐÅÏ¢
            oGroup.oModel.HShortNumber = sShortNumber;
            oGroup.oModel.HEndFlag = true;
            oGroup.oModel.HLevel = DBUtility.ClsPub.GetLevel(txtHNumber.Text.Trim());
            oGroup.oModel.HNumber = txtHNumber.Text.Trim();
            oGroup.oModel.HHelpCode = txtHHelpCode.Text.Trim();
            oGroup.oModel.HName = txtHName.Text.Trim();
            oGroup.oModel.HStopflag = false;
            oGroup.oModel.HRemark = txtHRemark.Text.Trim();
            //--------------------
            oGroup.oModel.HModel = txtHModel.Text.Trim();
            oGroup.oModel.HUnitID = DBUtility.ClsPub.isLong(txtHUnitID.Tag);
            oGroup.oModel.HMaterClsID = DBUtility.ClsPub.isLong(txtHMaterClsID.Tag);
            oGroup.oModel.HMaterTypeID = DBUtility.ClsPub.isLong(txtHMaterTypeID.Tag);
            oGroup.oModel.HUnitGroupID = DBUtility.ClsPub.isLong(txtHUnitGroupID.Tag);
            oGroup.oModel.HWhID = DBUtility.ClsPub.isLong(txtHWhID.Tag);
            oGroup.oModel.HRoutingID = DBUtility.ClsPub.isLong(txtHRoutingID.Tag);
            oGroup.oModel.HBomID = DBUtility.ClsPub.isLong(txtHBomID.Tag);
            oGroup.oModel.HSecUnitID = DBUtility.ClsPub.isLong(txtHSecUnitID.Tag);
            oGroup.oModel.HSecUnitRate = DBUtility.ClsPub.isDoule(txtHSecUnitRate.Text);
            oGroup.oModel.HHighStock = DBUtility.ClsPub.isDoule(txtHHighStock.Text);
            oGroup.oModel.HLowStock = DBUtility.ClsPub.isDoule(txtHLowStock.Text);
            oGroup.oModel.HSafeStock = DBUtility.ClsPub.isDoule(txtHSafeStock.Text);
            oGroup.oModel.HOrderPrice = DBUtility.ClsPub.isDoule(txtHOrderPrice.Text);
            oGroup.oModel.HSalePrice = DBUtility.ClsPub.isDoule(txtHSalePrice.Text);
            oGroup.oModel.HKeepDays = DBUtility.ClsPub.isDoule(txtHKeepDays.Text);
            oGroup.oModel.HPlanPrice = DBUtility.ClsPub.isDoule(txtHPlanPrice.Text);
            oGroup.oModel.HstdPrice = DBUtility.ClsPub.isDoule(txtHstdPrice.Text);
            oGroup.oModel.HQtyMin = DBUtility.ClsPub.isDoule(txtHQtyMin.Text);
            oGroup.oModel.HQtyMax = DBUtility.ClsPub.isDoule(txtHQtyMax.Text);
            oGroup.oModel.HVersion = txtHVersion.Text.Trim();
            oGroup.oModel.HEngName = txtHEngName.Text.Trim();
            oGroup.oModel.HEngModel = txtHEngModel.Text.Trim();
            oGroup.oModel.HSubjoin = txtHSubjoin.Text.Trim();
            oGroup.oModel.HSubjoin2 = txtHSubjoin2.Text.Trim();
            oGroup.oModel.HColor = txtHColor.Text.Trim();
            oGroup.oModel.HPropertyTypeID = DBUtility.ClsPub.isLong(txtHPropertyTypeID.Tag);
            oGroup.oModel.HSPGroupID = DBUtility.ClsPub.isLong(txtHSPGroupID.Tag);
            oGroup.oModel.HSPID = DBUtility.ClsPub.isLong(txtHSPID.Tag);
            return true;
        }
 
 
 
        //±£´æ
        private bool Save()
        {
            //ÅжÏȨÏÞ
            if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return false;
            }
            // 
            if (oGroup.AddNew())
            {
                Init();
            }
            else
            {
                return false;
            }  
            return true;
        }
 
        //³õʼ»¯½çÃæ
        private bool Init()
        { 
            Sub_Clear(); 
            return true; 
        }
 
        //ÐÂÔöʱÇå¿ÕÐÅÏ¢
        private void Sub_Clear()  //Lock
        {
            DBUtility.Gy_BaseFun.Sub_Clear(tabPage1, ref HItemID, txtHNumber);
        }
 
        private void cmdHUnitID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByUnit(txtHUnitID);
        }
 
        private void cmdHUnitGroupID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByUnitGroup(txtHUnitGroupID);
        }
 
        private void cmdHMaterClsID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByMaterType(txtHMaterClsID);
        }
 
        private void cmdHWhID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByWarehouse(txtHWhID);
        }
 
        private void cmdHSPGroupID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByStockPlaceGroup(txtHSPGroupID);
        }
 
        private void cmdHSPID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByStockPlace(txtHSPID);
        }
 
        private void cmdHRoutingID_Click(object sender, EventArgs e)
        {
 
        }
 
        private void cmdHSecUnitID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByUnit(txtHSecUnitID);
        }
 
        private void cmdHPropertyTypeID_Click(object sender, EventArgs e)
        {
            BLL.ClsBaseSelect.SetTextByPropertyType(txtHPropertyTypeID);
        }
 
        private void txtHUnitID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHUnitID);
        }
 
        private void txtHUnitGroupID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHUnitGroupID);
        }
 
        private void txtHMaterClsID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHMaterClsID); 
        }
 
        private void txtHMaterTypeID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHMaterTypeID); 
        }
 
        private void txtHWhID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHWhID); 
        }
 
        private void txtHSPGroupID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSPGroupID); 
        }
 
        private void txtHSPID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSPID); 
        }
 
        private void txtHRoutingID_TextChanged(object sender, EventArgs e)
        {
 
        }
 
        private void txtHSecUnitID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHSecUnitID); 
        }
 
        private void txtHPropertyTypeID_TextChanged(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.Sub_ClearText(txtHPropertyTypeID); 
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}