1
wtt
4 天以前 b371b604a464e7249634bbdb45cda85dd5bd1f3a
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace PayM
{
    public partial class Pay_PayMent_QCAdd : Form
    {
        public Pay_PayMent_QCAdd()
        {
            InitializeComponent();
        }
 
        public int HYear;
        public int HPeriod;
        long HMaterID;
        long HDeptID;
        long HGroupID;
        long HEmpID;
        long HProcID;
        long HUnitID;
        double HMoney;
        long HICMOInterID;
        string HICMOBillNo;
        string HRemark;
        private void cmdHMaterID_Click(object sender, EventArgs e)
        {
 
            DAL.ClsGy_Material_View oMater = new DAL.ClsGy_Material_View();
            if (oMater.RefreshView())
            {
                txtHMaterID.Tag = oMater.omodel.HItemID;
                txtHMaterID.Text = oMater.omodel.HNumber;
                txtHMaterName.Text = oMater.omodel.HName;
                txtHUnitID.Tag = oMater.omodel.HUnitID;
                txtHUnitID.Text = oMater.omodel.HUnitName;
            }
            else
            {
                txtHMaterID.Tag = 0;
                txtHMaterID.Text = "";
                txtHMaterName.Text = "";
                txtHUnitID.Tag = 0;
                txtHUnitID.Text = "";
            }
        }
 
        private void txtHMaterID_TextChanged(object sender, EventArgs e)
        {
            if (txtHMaterID.Text.Trim() == "")
            {
                txtHMaterID.Tag = "0";
                txtHMaterName.Text = "";
            }
        }
 
        private void cmdHCostItemID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View();
            if (oDept.RefreshView())
            {
                txtHDeptID.Text = oDept.oModel.HName;
                txtHDeptID.Tag = oDept.oModel.HItemID;
            }
            else
            {
                txtHDeptID.Text = "";
                txtHDeptID.Tag = 0;
            }
        }
 
        private void txtHCostItemID_TextChanged(object sender, EventArgs e)
        {
            if (txtHDeptID.Text.Trim() == "")
                txtHDeptID.Tag = "0";
        }
 
        private void Pay_PayMent_QCAdd_Load(object sender, EventArgs e)
        {
 
            //获取本期成本会计期间
            if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
            {
                MessageBox.Show("获取成本会计期间失败!");
                return;
            }
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear);
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 1);
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 2);
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 3);
            //cmbHYear.SelectedIndex = 0;
            //cmdHPeriod.Text = DBUtility.ClsPub.CBCurPeriod.ToString();
            cmbHYear.Text = DBUtility.ClsPub.isStrNull(HYear);
            cmbHPeriod.Text = DBUtility.ClsPub.isStrNull(HPeriod);
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds;
            HYear = DBUtility.ClsPub.isInt( cmbHYear.Text);
            HPeriod = DBUtility.ClsPub.isInt(cmbHPeriod.Text);
            HDeptID = DBUtility.ClsPub.isLong(txtHDeptID.Tag);
            HGroupID = DBUtility.ClsPub.isLong(txtHGroupID.Tag);
            HEmpID = DBUtility.ClsPub.isLong(txtHEmpID.Tag);
            HMaterID = DBUtility.ClsPub.isLong(txtHMaterID.Tag);
            HProcID = DBUtility.ClsPub.isLong(txtHProcID.Tag);
            HUnitID = DBUtility.ClsPub.isLong(txtHUnitID.Tag);
            HMoney = DBUtility.ClsPub.isDoule(txtHMoney.Text);
            HICMOInterID = DBUtility.ClsPub.isLong(txtHICMOBillNo.Tag);
            HICMOBillNo = DBUtility.ClsPub.isStrNull(txtHICMOBillNo.Text);
            HRemark=DBUtility.ClsPub.isStrNull(txtHRemark.Text);
 
 
            Ds = oCn.RunProcReturn("select * from Pay_InitReportBalBill where HYear=" + HYear +
                                                    " and HPeriod=" + HPeriod +
                                                    " and HDeptID=" + HDeptID +
                                                    " and HGroupID=" + HGroupID +
                                                    " and HEmpID=" + HEmpID +
                                                    " and HMaterID=" + HMaterID +
                                                    " and HProcID=" + HProcID +
                                                    " and HICMOBillNo='" + HICMOBillNo +"'"+
                                                    " and HICMOInterID=" + HICMOInterID +
                                                    " and HUnitID=" + HUnitID, "Pay_InitReportBalBill");
            if (Ds.Tables[0].Rows.Count > 0)
            {
                if (MessageBox.Show("该员工对应工序已存在期初,是否覆盖?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    oCn.RunProc("delete Pay_InitReportBalBill  where HYear=" + HYear +
                                                    " and HPeriod=" + HPeriod +
                                                    " and HDeptID=" + HDeptID +
                                                    " and HGroupID=" + HGroupID +
                                                    " and HEmpID=" + HEmpID +
                                                    " and HMaterID=" + HMaterID +
                                                    " and HProcID=" + HProcID +
                                                    " and HICMOBillNo='" + HICMOBillNo + "'" +
                                                    " and HICMOInterID=" + HICMOInterID +
                                                    " and HUnitID=" + HUnitID);
                }
                else
                {
                    return; 
                }
            }
            oCn.RunProc("insert into  Pay_InitReportBalBill (HYear,HPeriod,HBillType,HDate " +
                               " ,HDeptID,HGroupID,HEmpID,HMaterID,HProcID,HUnitID,HBeginQty" +
                               " ,HReceiveQty,HSendQty,HEndQty,HBeginBal,HReceiveBal,HSendBal,HEndBal" +
                               " ,HICMOInterID,HICMOBillNo,HRemark,HMaker,HMakeDate" +
                               ") values (" +
                                HYear + "," + HPeriod + ",2213,getdate()"+
                                "," + HDeptID + "," + HGroupID + "," + HEmpID + "," + HMaterID + "," + HProcID + "," + HUnitID + "," + HMoney + 
                                ",0,0,0,0,0,0,0"+
                                ","+HICMOInterID+",'"+HICMOBillNo+"','"+HRemark+"','"+DBUtility.ClsPub.CurUserName+"',getdate()"+
                                ")");
            MessageBox.Show("保存完毕!"); 
        }
 
        private void cmdHGroupID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_Group_View oGroup = new DAL.ClsGy_Group_View();
            if (oGroup.RefreshView())
            {
                txtHGroupID.Text = oGroup.oModel.HName;
                txtHGroupID.Tag = oGroup.oModel.HItemID;
            }
            else
            {
                txtHGroupID.Text = "";
                txtHGroupID.Tag = 0;
            }
        }
 
        private void cmdHProcID_Click(object sender, EventArgs e)
        {
            //DAL.ClsK3_Process_View oProc = new DAL.ClsK3_Process_View();
            //if (oProc.RefreshView())
            //{
            //    txtHProcID.Text = oProc.oModel.HName;
            //    txtHProcID.Tag = oProc.oModel.HItemID;
            //}
            //else
            //{
            //    txtHProcID.Text = "";
            //    txtHProcID.Tag = 0;
            //}
            if (DBUtility.ClsPub.isLong(txtHICMOBillNo.Tag) == 0)
            {
                BLL.ClsBaseSelect_InterFace.SetTextByProc(txtHProcID);
            }
            else
            {
                BLL.ClsBaseSelect_InterFace.SetTextByProc_ICMO(txtHProcID, DBUtility.ClsPub.isLong(txtHICMOBillNo.Tag));
            }
        }
 
        private void cmdHEmpID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_Employee_View oEmp = new DAL.ClsGy_Employee_View();
            if (oEmp.RefreshView())
            {
                txtHEmpID.Text = oEmp.oModel.HName;
                txtHEmpID.Tag = oEmp.oModel.HItemID;
            }
            else
            {
                txtHEmpID.Text = "";
                txtHEmpID.Tag = 0;
            }
        }
 
        private void txtHGroupID_TextChanged(object sender, EventArgs e)
        {
            if (txtHGroupID.Text.Trim() == "")
                txtHGroupID.Tag = "0";
        }
 
        private void txtHProcID_TextChanged(object sender, EventArgs e)
        {
            if (txtHProcID.Text.Trim() == "")
                txtHProcID.Tag = "0";
        }
 
        private void txtHEmpID_TextChanged(object sender, EventArgs e)
        {
            if (txtHEmpID.Text.Trim() == "")
                txtHEmpID.Tag = "0";
        }
 
        private void cmdHUnitID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_Unit_View oUnit = new DAL.ClsGy_Unit_View();
            if (oUnit.RefreshView())
            {
                txtHUnitID.Text = oUnit.oModel.HName;
                txtHUnitID.Tag = oUnit.oModel.HItemID;
            }
            else
            {
                txtHUnitID.Text = "";
                txtHUnitID.Tag = 0;
            }
        }
 
        private void txtHUnitID_TextChanged(object sender, EventArgs e)
        {
            if (txtHUnitID.Text.Trim() == "")
                txtHUnitID.Tag = "0";
        }
 
        private void cmdHICMOBillNo_Click(object sender, EventArgs e)
        {
            DAL.Cls_S_K3_ICMOForProdInList oK3_ICMOForProdInList = new DAL.Cls_S_K3_ICMOForProdInList();
            if (oK3_ICMOForProdInList.Refresh(""))  //选择原单
            {
                FillSelectData(oK3_ICMOForProdInList.oBillSelectColl);
            }
        }
        private void FillSelectData(List<DBUtility.BillSelect> oList)
        {
            DataSet Ds;
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            int i = -1;
            foreach (DBUtility.BillSelect oSelectRow in oList)
            {
                i = i + 1;
                //生产任务单
                if (oSelectRow.BillType == "85")
                {
                    //grdMain.Rows.Add();
                    Application.DoEvents();
                    //得到信息
                    Ds = oCn.RunProcReturn("select * from h_v_K3_ICMOBillList where hmainid=" + oSelectRow.BillMainID + " and hsubid=0", "h_v_K3_ICMOBillList");
                    //写入信息
                    //Sub_WriteInForm(Ds.Tables[0], i);
                    txtHDeptID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HDeptID"]);
                    txtHDeptID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["部门"]);
                    txtHMaterID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                    txtHMaterID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["物料代码"]);
                    txtHMaterName.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["物料名称"]);
                    txtHUnitID.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HUnitID"]);
                    txtHUnitID.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["计量单位"]);
                    txtHICMOBillNo.Tag = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainID"]);
                    txtHICMOBillNo.Text = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["单据号"]);
                    Application.DoEvents();
                }
 
                //
            }
        }
    }
}