yusijie
2024-11-29 89873b7d156f21e7aa71b3f004a11ced2e7a7d4e
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace WorkM
{
    public partial class Sc_MpsResultBill_WW : Form
    {
        public Sc_MpsResultBill_WW()
        {
            InitializeComponent();
        }
 
        //³õʼ»¯Íø¸ñ
        private void initGrid()
        {
            DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name);
        }
        int HCheckCol = 10;  //Ñ¡ÖÐÁÐ
        int HQtyCol = 9;    //ÊýÁ¿ÁÐ
 
        public long HSeHInterID;
        public long HSeHEntryID;
        public long HDeptID;
        public long HEmpID;
 
        public long HMaterID;
        public double HQty;
 
        private void grdSub_Show()
        {
            grdSub.DataSource = null;
            grdSub.Columns.Clear();
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds1; 
 
            Ds1 = oCn.RunProcReturn("exec h_p_Xs_SeOrderBillMulLevBOMQuery " + HMaterID + "," + HQty + "," + HSeHInterID + "," + HSeHEntryID, "h_p_Xs_SeOrderBillMulLevBOMQuery");
            grdSub.DataSource = Ds1.Tables[0].DefaultView;
 
            DataGridViewCheckBoxColumn columncb = new DataGridViewCheckBoxColumn();
            columncb.HeaderText = "Ñ¡Ôñ";
            columncb.Name = "cb_check";
            columncb.TrueValue = true;
            columncb.FalseValue = false;
            //column9.DataPropertyName = "IsScienceNature";
            columncb.DataPropertyName = "IsChecked";
            grdSub.Columns.Add(columncb);
 
            HQtyCol = Fun_GetColSub("ÉêÇëÊýÁ¿");
            HCheckCol = grdSub.ColumnCount - 1;
            //¶³½á
            int FrCol = 0;
            string s = "";
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name, s, FrCol);
            grdSub.ReadOnly = false;
        }
 
        private void grdSub_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            if (e.ColumnIndex != HQtyCol)
            {
                e.Cancel = true;
            }
        }
 
        private void grdSub_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (grdSub.CurrentRow == null)
                return;
            if (e.ColumnIndex == HCheckCol && DBUtility.ClsPub.isInt(grdSub.Rows[grdSub.CurrentRow.Index].Cells[Fun_GetColSub("herpclsid")].Value) == 3)
            {
                if (DBUtility.ClsPub.isBool(grdSub.Rows[grdSub.CurrentRow.Index].Cells[e.ColumnIndex].Value) == false)
                {
                    grdSub.Rows[grdSub.CurrentRow.Index].Cells[e.ColumnIndex].Value = true;
                }
                else
                {
                    grdSub.Rows[grdSub.CurrentRow.Index].Cells[e.ColumnIndex].Value = false;
                }
            }
        }
 
        private void bclk_Click(object sender, EventArgs e)
        {
 
            DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
 
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name);
        }
 
        private void cg_Click(object sender, EventArgs e)
        {
            string HBillNo;
            //ÅжÏÓÐûÓÐÑ¡ÖÐÐÐ
            bool isCheck = false;
            for (int i = 0; i < grdSub.Rows.Count; i++)
            {
                if (DBUtility.ClsPub.isBool(grdSub.Rows[i].Cells[HCheckCol].Value) == true)
                {
                    if (DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetColSub("ÉêÇëÊýÁ¿")].Value) > DBUtility.ClsPub.isDoule(grdSub.Rows[i].Cells[Fun_GetColSub("δÉêÇëÊýÁ¿")].Value))
                    {
                        MessageBox.Show("ÎïÁÏ´úÂ룺" + DBUtility.ClsPub.isStrNull(grdSub.Rows[i].Cells[Fun_GetColSub("ÎïÁÏ´úÂë")].Value) + "ÉêÇëÊýÁ¿²»ÄÜ´óÓÚδÉêÇëÊýÁ¿£¡", "Ìáʾ");
                        return;
                    }
                    isCheck = true;
                }
            }
            if (isCheck == false)
            {
                MessageBox.Show("ûÓÐÑ¡ÔñÐèÒª²É¹ºµÄÎïÁÏ£¡", "Ìáʾ");
                return;
            }
 
 
            long HSourceInterID = HSeHInterID;
            long HSourceEntryID = HSeHEntryID;
            string HSourceBillNo = DBUtility.ClsPub.isStrNull(txtHSeBillNo.Text);
            string HSourceTranType = "81";
            SQLHelper.ClsCNK3 oCnK3 = new SQLHelper.ClsCNK3();
            try
            {
                HBillNo = DBUtility.Xt_BaseBillFun.get_MaxBillNo_K3("70", oCnK3);
 
                //µÃµ½Óû§ID
                long HBillerID;
                DataSet DsBiller;
                string HSourceBillType = "";
                DsBiller = oCnK3.RunProcReturn("select top 1 fuserid from t_User where fname='" + DBUtility.ClsPub.CurUserName + "'", "t_User");
                if (DsBiller.Tables[0].Rows.Count != 0)
                {
                    HBillerID = DBUtility.ClsPub.isLong(DsBiller.Tables[0].Rows[0][0]);
                }
                else
                {
                    HBillerID = 16394;
                }
                //
                DataSet Ds1;
                //µÃµ½mainid
                long HInterID = 0;
                Ds1 = oCnK3.RunProcReturn("declare @InterID int set @InterID=0 exec GetICMaxNum 'POrequest', @InterID output, 1, " + HBillerID.ToString() + " select ltrim(@InterID)", "GetICMaxNum");
                if (Ds1.Tables[0].Rows.Count != 0)
                {
                    HInterID = DBUtility.ClsPub.isLong(Ds1.Tables[0].Rows[0][0]);
                }
                if (HInterID == 0)
                {
                    MessageBox.Show("Éú³ÉHInterIDʧ°Ü£¡");
                    return;
                }
 
                oCnK3.BeginTran();
                int j = 0;
                long HMaterID;
                long HUnitID;
                double HQty;
                for (int i = 0; i < grdSub.Rows.Count; i++)
                {
                    if (DBUtility.ClsPub.isBool(grdSub.Rows[i].Cells[HCheckCol].Value) == true)
                    {
                        j = j + 1;
                        HMaterID = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[Fun_GetColSub("hmaterid")].Value);
                        HUnitID = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[Fun_GetColSub("HUnitID")].Value);
                        HQty = DBUtility.ClsPub.isLong(grdSub.Rows[i].Cells[Fun_GetColSub("ÉêÇëÊýÁ¿")].Value);
 
                        ////»ªÔ£
                        //oCnK3.RunProc("INSERT INTO POrequestEntry " +
                        //                "(FInterID,FEntryID,FBrNo,FItemID,FAuxPropID,FQty,FUnitID,Fauxqty" +
                        //                ",FSecCoefficient,FSecQty,FAPurchTime,FBOMCategory,FBomInterID,Fuse" +
                        //                ",FSupplyID,FFetchTime,FPlanOrderInterID,FSourceBillNo,FSourceTranType" +
                        //                ",FSourceInterId,FSourceEntryID,FMrpLockFlag,FPlanMode,FIsInquiry,FMTONo)  " +
                        //                "Values (" + HInterID + "," + j + ",'0'," + HMaterID + ",0," + HQty + "," + HUnitID + "," + HQty +
                        //                ",0,0,CONVERT(CHAR(10),GETDATE(),120),0,0,''" +
                        //                ",0,CONVERT(CHAR(10),GETDATE(),120),0,'" + HSourceBillNo + "'," + HSourceTranType +
                        //                "," + HSourceInterID + "," + HSourceEntryID + ",0,14036,0,'' )");
 
                        //±¾µØ
                        oCnK3.RunProc("INSERT INTO POrequestEntry " +
                                      "(FInterID,FEntryID,FBrNo,FItemID,FAuxPropID,FQty,FUnitID,Fauxqty" +
                                      ",FSecCoefficient,FSecQty,FAPurchTime,FBomInterID,Fuse" +
                                      ",FSupplyID,FFetchTime,FPlanOrderInterID,FSourceBillNo,FSourceTranType" +
                                      ",FSourceInterId,FSourceEntryID,FMrpLockFlag,FPlanMode,FMTONo)  " +
                                      "Values (" + HInterID + "," + j + ",'0'," + HMaterID + ",0," + HQty + "," + HUnitID + "," + HQty +
                                      ",0,0,CONVERT(CHAR(10),GETDATE(),120),0,''" +
                                      ",0,CONVERT(CHAR(10),GETDATE(),120),0,'" + HSourceBillNo + "'," + HSourceTranType +
                                      "," + HSourceInterID + "," + HSourceEntryID + ",0,14036,'' )");
                    }
                }
                //////»ªÔ£
                //oCnK3.RunProc("INSERT INTO POrequest" +
                //                "(FInterID,FBillNo,FBrNo,FTranType,FCancellation,FStatus,Fdate" +
                //                ",FDeptID,FBizType,Fnote,FRequesterID,FCheckTime,FBillerID,FMRP" +
                //                ",FMultiCheckDate1,FMultiCheckDate2,FMultiCheckDate3" +
                //                ",FMultiCheckDate4,FMultiCheckDate5,FMultiCheckDate6" +
                //                ",FSelTranType,FPrintCount,FPlanConfirmed,FPlanCategory" +
                //                ",FGeneratePurBudQty,FHeadSelfP0131,FHeadSelfP0133,FHeadSelfP0132) " +
                //                "Values (" + HInterID + ",'" + HBillNo + "','0',70,0,0,CONVERT(CHAR(10),GETDATE(),120) " +
                //                "," + HDeptID + ",12510,''," + HEmpID + ",Null," + HBillerID + ",0" +
                //                ",Null,Null,Null,Null,Null,Null" +
                //                ",81,0,0,'1'" +
                //                ",0,40274,'','')");
 
                //±¾µØ  
                oCnK3.RunProc("INSERT INTO POrequest" +
                                    "(FInterID,FBillNo,FBrNo,FTranType,FCancellation,FStatus,Fdate" +
                                    ",FDeptID,FBizType,Fnote,FRequesterID,FCheckTime,FBillerID,FMRP" +
                                    ",FMultiCheckDate1,FMultiCheckDate2,FMultiCheckDate3" +
                                    ",FMultiCheckDate4,FMultiCheckDate5,FMultiCheckDate6" +
                                    ",FSelTranType,FPlanConfirmed" +
                                    ",FGeneratePurBudQty) " +
                                    "Values (" + HInterID + ",'" + HBillNo + "','0',70,0,0,CONVERT(CHAR(10),GETDATE(),120) " +
                                    "," + HDeptID + ",12510,''," + HBillerID + ",Null," + HBillerID + ",0" +
                                    ",Null,Null,Null,Null,Null,Null" +
                                    ",81,0" +
                                    ",0)");
 
                oCnK3.Commit();
            }
            catch (Exception ex)
            {
                oCnK3.RollBack();
                throw (ex);
            }
 
            MessageBox.Show("µ¥¾ÝºÅ£º" + HBillNo + "£¬±£´æÍê±Ï£¡");
            this.Close();
 
        }
 
        private void sx_Click(object sender, EventArgs e)
        {
            grdSub_Show();
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private Int32 Fun_GetColSub(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            initGrid();
            grdSub_Show();
        }
    }
}