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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
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 Xs_SendGoodsPlan : Form
    {
        public Xs_SendGoodsPlan()
        {
            InitializeComponent();
        }
 
 
        //¶¨ÒåÁÐ
        public const Int16 FixCols = 12;
        //
        public const Int16 HTypeCol = 0;
        public const Int16 HSourceIDCol = 1;
        public const Int16 HSourceEntryIDCol = 2;
        public const Int16 HSourceNameCol = 3;
 
        public const Int16 HMaterIDCol = 4;
        public const Int16 HMaterNumberCol = 5;
        public const Int16 HMaterNameCol = 6;
        public const Int16 HMaterModelCol = 7;
        public const Int16 HUnitIDCol = 8;
        public const Int16 HUnitNumberCol = 9;
        public const Int16 HUnitNameCol = 10;
        public const Int16 HQtyCol = 11;
 
 
        //
        public string ModName = "1423";
        public string ModCaption = "ÏúÊÛ·¢»õ¼Æ»®";
        //
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        public string sAllowCol="";
        //
 
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
 
 
        //³õʼ»¯Íø¸ñ
        private void initGrid()
        {
            grdmain.ColumnCount = FixCols;
            DBUtility.Xt_BaseBillFun.initGridFst(grdmain, this.Name);
            DBUtility.Xt_BaseBillFun.initGridList(grdsub1, this.Name);
            DBUtility.Xt_BaseBillFun.initGridList(grdsub2, this.Name); 
            grdmain.BackgroundColor = Color.Lavender;              //Íø¸ñ±³¾°É«
            grdmain.ColumnHeadersDefaultCellStyle.BackColor = Color.Beige;
            grdmain.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText;
            grdmain.ReadOnly = false;
            grdmain.RowCount = 0;
            grdmain.Columns[HMaterNumberCol].HeaderText = "²úÆ·´úÂë";
            grdmain.Columns[HMaterNameCol].HeaderText = "²úÆ·Ãû³Æ";
            grdmain.Columns[HMaterModelCol].HeaderText = "¹æ¸ñÐͺÅ";
            grdmain.Columns[HUnitNumberCol].HeaderText = "µ¥Î»´úÂë";
            grdmain.Columns[HUnitNameCol].HeaderText = "µ¥Î»Ãû³Æ";
            grdmain.Columns[HSourceNameCol].HeaderText = "Ô´µ¥ºÅ";
            grdmain.Columns[HQtyCol].HeaderText = "¶©µ¥ÊýÁ¿";
            grdmain.Columns[HTypeCol].HeaderText = "²ð·Ö±ê¼Ç";
            //
            //grdmain.Columns[0].Visible = false;
            grdmain.Columns[HSourceIDCol].Visible = false;
            grdmain.Columns[HSourceEntryIDCol].Visible = false;
            grdmain.Columns[HMaterIDCol].Visible = false;
            grdmain.Columns[HUnitIDCol].Visible = false; 
            //grdmain.ReadOnly = true;
            for (int i = 0; i < grdmain.ColumnCount; i++)
            {
                grdmain.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; //ÁРÅÅÐòģʽ
 
            }
            //
            // 
            DBUtility.ClsPub.GetGridView(grdsub2, this.Name + "grdsub2", DBUtility.ClsPub.AppPath);
            DBUtility.ClsPub.GetGridView(grdsub1, this.Name + "grdsub1", DBUtility.ClsPub.AppPath);
            DBUtility.ClsPub.GetGridView(grdmain, this.Name + "grdmain", DBUtility.ClsPub.AppPath);
            LoadDateCol(grdmain, FixCols, 60);
            grdmain.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;//±êÌâÐÐ×Ô¶¯»»ÐÐ
 
 
            //ÉèÖÿɱ༭ÁÐ
            sAllowCol = ","+HMaterNumberCol.ToString() +
                            "," + HMaterNameCol.ToString() +
                            "," + HMaterModelCol.ToString() +
                            "," + HUnitNumberCol.ToString() +
                            "," + HUnitNameCol.ToString() +
                            "," + HSourceNameCol.ToString() +
                            "," + HQtyCol.ToString()+",";
            grdmain.Columns[11].Frozen = true;
        }
 
        //¼ÓÔØ µ±ÔÂÈÕÆÚ
        public static void LoadDateCol(DataGridView grdMain, int FixCols, int iDates)
        {
            DateTime bDate, eDate, dDate;
            //grdMain.Cols = FixCols;
            bDate = Convert.ToDateTime(DBUtility.ClsPub.GetServerDate(0));
            eDate = (DBUtility.ClsPub.isDate(bDate).AddDays(iDates));
            dDate = bDate;
            //
            grdMain.ColumnCount = grdMain.ColumnCount + 1;
            dDate = (DBUtility.ClsPub.isDate(bDate).AddDays(0));
            grdMain.Columns[grdMain.ColumnCount - 1].Width = 40;
            //
            grdMain.Columns[grdMain.ColumnCount - 1].HeaderText = Convert.ToDateTime(dDate).ToString("MM-dd");
            grdMain.Columns[grdMain.ColumnCount - 1].Tag = Convert.ToDateTime(dDate).ToString("yyyy-MM-dd");
            //grdMain.set_ColData(grdMain.Cols - 1, Convert.ToDateTime(dDate).ToString("yyyy-MM-dd"));
            //
            for (int i = 1; i < iDates; i++)
            {
                if (dDate.CompareTo(eDate) > 0)
                    return;
                grdMain.ColumnCount = grdMain.ColumnCount + 1;
                grdMain.Columns[grdMain.ColumnCount - 1].Width = 40;
                dDate = (DBUtility.ClsPub.isDate(bDate).AddDays(i));
                grdMain.Columns[grdMain.ColumnCount - 1].HeaderText = Convert.ToDateTime(dDate).ToString("MM-dd");
                grdMain.Columns[grdMain.ColumnCount - 1].Tag = Convert.ToDateTime(dDate).ToString("yyyy-MM-dd");
                //grdMain.set_TextMatrix(1, grdMain.Cols - 1, Convert.ToDateTime(dDate).ToString("yyyy-MM-dd"));
            }
 
        }
 
        //¼ÓÔØ Ñ¡Ô´µ¥
        private void yd_Click(object sender, EventArgs e)
        {
            DAL.Cls_S_K3_SeOrder_PD oK3_SeOrder_PD = new DAL.Cls_S_K3_SeOrder_PD();
            //string sWhere = " And HDeptID=" + DBUtility.ClsPub.isLong(txtHDeptID.Tag) + " ";
            string sWhere = "";
            if (oK3_SeOrder_PD.Refresh(sWhere))  //Ñ¡ÔñÔ­µ¥
            {
                FillSelectData(oK3_SeOrder_PD.oBillSelectColl);
            }
        }
 
        //¼ÓÔØ Ô­µ¥µ½±¾µØ
        private void FillSelectData(List<DBUtility.BillSelect> oList)
        {
            // 
            bool sBool = false;
            DataSet Ds;
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            foreach (DBUtility.BillSelect oSelectRow in oList)
            {
                if (oSelectRow.BillType == "81")
                {
                    sBool = false;
                    //µÃµ½ÐÅÏ¢
                    Ds = oCn.RunProcReturn("select * from h_v_K3_SEOrder_PD where hmainid=" + oSelectRow.BillMainID + " and hsubid=" + oSelectRow.BillSubID, "h_v_K3_SEOrder_PD");
                    //дÈëÐÅÏ¢
                    for (int j = 0; j <= grdmain.RowCount - 1; j++)
                    {
                        if (DBUtility.ClsPub.isLong(grdmain.Rows[j].Cells[HSourceIDCol].Value) == DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMainID"]) && DBUtility.ClsPub.isLong(grdmain.Rows[j].Cells[HSourceEntryIDCol].Value) == DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["hsubid"]))
                        {
                            sBool = true;
                            MessageBox.Show("ÏúÊÛ¶©µ¥£º" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["µ¥¾ÝºÅ"]) + ",²úÆ·£º"+ DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["²úÆ·Ãû³Æ"]) +"ÒÑ´æÔÚ´ýÅżƻ®ÖУ¬²»ÔÊÐíÌí¼Ó£¡", "Ìáʾ");
                            break;
                        }
                    }
                    if (sBool != true)
                    {
                        grdmain.RowCount = grdmain.RowCount + 1;
                        Sub_WriteInForm(Ds.Tables[0], grdmain.RowCount - 1);
                    }
                }
            }
        }
        //¸ù¾ÝTABLEдÈë½çÃæ
        private void Sub_WriteInForm(DataTable oTable, int i)
        {
            try
            {
                ////¼ÓÔØ±íÌå 
                grdmain.Rows[i].Cells[HSourceIDCol].Value = oTable.Rows[0]["hmainid"].ToString();
                grdmain.Rows[i].Cells[HSourceEntryIDCol].Value = oTable.Rows[0]["hsubid"].ToString();
                grdmain.Rows[i].Cells[HSourceNameCol].Value = oTable.Rows[0]["µ¥¾ÝºÅ"].ToString();
                grdmain.Rows[i].Cells[HMaterIDCol].Value = oTable.Rows[0]["HMaterID"].ToString();
                grdmain.Rows[i].Cells[HMaterNumberCol].Value = oTable.Rows[0]["²úÆ·´úÂë"].ToString();
                grdmain.Rows[i].Cells[HMaterNameCol].Value = oTable.Rows[0]["²úÆ·Ãû³Æ"].ToString();
                grdmain.Rows[i].Cells[HMaterModelCol].Value = oTable.Rows[0]["¹æ¸ñÐͺÅ"].ToString();
                grdmain.Rows[i].Cells[HUnitIDCol].Value = oTable.Rows[0]["HUnitID"].ToString();
                grdmain.Rows[i].Cells[HUnitNameCol].Value = oTable.Rows[0]["µ¥Î»Ãû³Æ"].ToString();
                grdmain.Rows[i].Cells[HUnitNumberCol].Value = oTable.Rows[0]["µ¥Î»´úÂë"].ToString(); 
                //============
                grdmain.Rows[i].Cells[HQtyCol].Value = oTable.Rows[0]["ÊýÁ¿"].ToString(); 
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            //³õʼ»¯
            initGrid();
            ShowBill();
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            bool sClose=true;
            for (int i = 0; i < grdmain.Rows.Count; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdmain.Rows[i].Cells[HTypeCol].Value) == "ÒѲð·Ö")
                {
                    if (MessageBox.Show("´æÔÚÒѲð·Öδ±£´æÊý¾Ý£¬ÊÇ·ñ·ÅÆú±£´æ£¿", "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                    {
                        this.Close();
                    }
                    else
                    {
                        sClose = false;
                        break;
                    }
                }
            }
            if (sClose == true)
            {
                this.Close();
            }
        }
 
        private void grdmain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            //int i = grdmain.CurrentCell.ColumnIndex;
            //string srow = "," + i.ToString() + ",";
            //if (sAllowCol.IndexOf(srow) != -1)
            //{
            //    e.Cancel = true;
            //}
            e.Cancel = true;
        }
 
        private void bc_Click(object sender, EventArgs e)
        {
            string HBillType = "1423";
            long HInterID;
            long HEntryID;
            long HMaterID;
            long HUnitID;
            double HQty = 0;
            DateTime HSendDate;
            //ɾ³ý×÷·Ïµ¥¾Ý
            oCn.RunProc("exec h_p_Xs_SendGoodsPlanBill_DropDel");
            for (int i = 0; i < grdmain.Rows.Count; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdmain.Rows[i].Cells[HTypeCol].Value) == "ÒѲð·Ö")
                {
                    HInterID = DBUtility.ClsPub.isLong(grdmain.Rows[i].Cells[HSourceIDCol].Value);
                    HEntryID = DBUtility.ClsPub.isLong(grdmain.Rows[i].Cells[HSourceEntryIDCol].Value);
                    HMaterID = DBUtility.ClsPub.isLong(grdmain.Rows[i].Cells[HMaterIDCol].Value);
                    HUnitID = DBUtility.ClsPub.isLong(grdmain.Rows[i].Cells[HUnitIDCol].Value);
                    //×÷·Ï
                    oCn.RunProc("exec h_p_Xs_SendGoodsPlanBill_Del " + HInterID + "," + HEntryID + ",'" + DBUtility.ClsPub.CurUserName + "'");
                    for (int j = FixCols; j < grdmain.ColumnCount; j++)
                    {
                        HQty = DBUtility.ClsPub.isDoule(grdmain.Rows[i].Cells[j].Value);
                        HSendDate = DBUtility.ClsPub.isDate(grdmain.Columns[j].Tag);
                        if (HQty != 0)
                        {
                            //ÐÂÔö
                            oCn.RunProc("exec h_p_Xs_SendGoodsPlanBill_AddNew " + HInterID + "," + HEntryID + "," + HMaterID + "," + HUnitID + "," + HQty + ",'" + HSendDate + "','" + DBUtility.ClsPub.CurUserName + "'");
                        }
                    }
                    grdmain.Rows[i].Cells[HTypeCol].Value = "Òѱ£´æ";
                }
            }
            MessageBox.Show("±£´æÍê±Ï£¡","Ìáʾ");
        }
 
        private void cf_Click(object sender, EventArgs e)
        {
            if (grdmain.CurrentRow == null)
                return;
            if (DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HTypeCol].Value) == "ÒÑÏÂÍÆ")
            {
                MessageBox.Show("¸Ã¶©µ¥´æÔÚÒÑÏÂÍÆ¼Æ»®£¬²»ÔÊÐí²ð·Ö£¡");
                return;
            }
 
            Xs_SendGoodsPlan_CF oCF = new Xs_SendGoodsPlan_CF();
            oCF.txtHBillNo.Text = DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HSourceNameCol].Value);
            oCF.txtHMaterID.Text = DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HMaterNameCol].Value);
            oCF.txtHMaterID.Tag = DBUtility.ClsPub.isLong(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HMaterIDCol].Value);
            oCF.txtHMaterNumber.Text = DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HMaterNumberCol].Value);
            oCF.txtHModel.Text = DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HMaterModelCol].Value);
            oCF.txtHUnitID.Text = DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HUnitNameCol].Value);
            oCF.txtHUnitID.Tag = DBUtility.ClsPub.isLong(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HUnitIDCol].Value);
            oCF.txtHQty.Text = DBUtility.ClsPub.isStrNull(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HQtyCol].Value);
            double HQty = 0;
            DateTime HSendDate;
            int r = 0;
 
            for (int j = FixCols; j < grdmain.ColumnCount; j++)
            {
                HQty = DBUtility.ClsPub.isDoule(grdmain.Rows[grdmain.CurrentRow.Index].Cells[j].Value);
                HSendDate = DBUtility.ClsPub.isDate(grdmain.Columns[j].Tag);
                if (HQty != 0)
                {
                    oCF.row[r, 0] = HSendDate.ToShortDateString();
                    oCF.row[r, 1] = HQty.ToString();
                    r = r + 1;
                }
            }
 
            oCF.ShowDialog();
            if (oCF.isOk == true)
            {
                for (int j = FixCols; j < grdmain.ColumnCount; j++)
                {
                    grdmain.Rows[grdmain.CurrentRow.Index].Cells[j].Value = "";
                }
                for (int i = 0; i < oCF.grdMain.Rows.Count; i++)
                {
                    HQty = DBUtility.ClsPub.isDoule(oCF.grdMain.Rows[i].Cells[oCF.sHQtyCol].Value);
                    HSendDate = DBUtility.ClsPub.isDate(oCF.grdMain.Rows[i].Cells[oCF.sHDateCol].Value);
                    for (int j = FixCols; j < grdmain.ColumnCount; j++)
                    {
                        if (grdmain.Columns[j].Tag.ToString() == Convert.ToDateTime(HSendDate).ToString("yyyy-MM-dd"))
                        {
                            grdmain.Rows[grdmain.CurrentRow.Index].Cells[j].Value = HQty;
                            break ;
                        }
                    }
                }
                grdmain.Rows[grdmain.CurrentRow.Index].Cells[HTypeCol].Value = "ÒѲð·Ö";
            }
        }
        private void ShowBill()
        {
            DataSet Ds;
            Ds = oCn.RunProcReturn("select * from h_v_Xs_SendGoodsPlanView order by ÏúÊÛ¶©µ¥Ö÷ÄÚÂë,ÏúÊÛ¶©µ¥×ÓÄÚÂë", "h_v_Xs_SendGoodsPlanView", ref DBUtility.ClsPub.sErrInfo);
            if (Ds == null)
            {
                MessageBox.Show("´íÎóÔ­Òò£º" + DBUtility.ClsPub.sErrInfo);
                return;
            }
            if (Ds.Tables[0].Rows.Count == 0)
            {
                return;
            }
            else
            {
                long sHInterID = 0;
                long sHEntryID = 0;
                int row = 0;
                for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        sHInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥Ö÷ÄÚÂë"]);
                        sHEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥×ÓÄÚÂë"]);
                        grdmain.RowCount = grdmain.RowCount + 1;
 
                        grdmain.Rows[row].Cells[HTypeCol].Value = Ds.Tables[0].Rows[i]["״̬"].ToString();
                        grdmain.Rows[row].Cells[HSourceIDCol].Value = Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥Ö÷ÄÚÂë"].ToString();
                        grdmain.Rows[row].Cells[HSourceEntryIDCol].Value = Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥×ÓÄÚÂë"].ToString();
                        grdmain.Rows[row].Cells[HSourceNameCol].Value = Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥ºÅ"].ToString();
                        grdmain.Rows[row].Cells[HMaterIDCol].Value = Ds.Tables[0].Rows[i]["HMaterID"].ToString();
                        grdmain.Rows[row].Cells[HMaterNumberCol].Value = Ds.Tables[0].Rows[i]["²úÆ·´úÂë"].ToString();
                        grdmain.Rows[row].Cells[HMaterNameCol].Value = Ds.Tables[0].Rows[i]["²úÆ·Ãû³Æ"].ToString();
                        grdmain.Rows[row].Cells[HMaterModelCol].Value = Ds.Tables[0].Rows[i]["¹æ¸ñÐͺÅ"].ToString();
                        grdmain.Rows[row].Cells[HUnitIDCol].Value = Ds.Tables[0].Rows[i]["HUnitID"].ToString();
                        grdmain.Rows[row].Cells[HUnitNameCol].Value = Ds.Tables[0].Rows[i]["µ¥Î»Ãû³Æ"].ToString();
                        grdmain.Rows[row].Cells[HUnitNumberCol].Value = Ds.Tables[0].Rows[i]["µ¥Î»´úÂë"].ToString();
                        grdmain.Rows[row].Cells[HQtyCol].Value = Ds.Tables[0].Rows[i]["¶©µ¥ÊýÁ¿"].ToString(); 
 
                        for (int j = FixCols; j < grdmain.Columns.Count; j++)
                        {
                            if (DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["·¢»õÈÕÆÚ"]) == DBUtility.ClsPub.isDate(grdmain.Columns[j].Tag))
                            {
                                grdmain.Rows[row].Cells[j].Value = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["ÊýÁ¿"]);
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (sHInterID == DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥Ö÷ÄÚÂë"]) && sHEntryID == DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥×ÓÄÚÂë"]))
                        {
                            if (DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["״̬"]) == "ÒÑÏÂÍÆ")
                            {
                                grdmain.Rows[row].Cells[HTypeCol].Value = Ds.Tables[0].Rows[i]["״̬"].ToString();
                            }
                            for (int j = FixCols; j < grdmain.Columns.Count; j++)
                            {
                                if (DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["·¢»õÈÕÆÚ"]) == DBUtility.ClsPub.isDate(grdmain.Columns[j].Tag))
                                {
                                    grdmain.Rows[row].Cells[j].Value = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["ÊýÁ¿"]);
                                    break;
                                } 
                            }
                        }
                        else
                        {
                            sHInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥Ö÷ÄÚÂë"]);
                            sHEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥×ÓÄÚÂë"]);
                            grdmain.RowCount = grdmain.RowCount + 1;
                            row = row + 1;
 
                            grdmain.Rows[row].Cells[HTypeCol].Value = Ds.Tables[0].Rows[i]["״̬"].ToString();
                            grdmain.Rows[row].Cells[HSourceIDCol].Value = Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥Ö÷ÄÚÂë"].ToString();
                            grdmain.Rows[row].Cells[HSourceEntryIDCol].Value = Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥×ÓÄÚÂë"].ToString();
                            grdmain.Rows[row].Cells[HSourceNameCol].Value = Ds.Tables[0].Rows[i]["ÏúÊÛ¶©µ¥ºÅ"].ToString();
                            grdmain.Rows[row].Cells[HMaterIDCol].Value = Ds.Tables[0].Rows[i]["HMaterID"].ToString();
                            grdmain.Rows[row].Cells[HMaterNumberCol].Value = Ds.Tables[0].Rows[i]["²úÆ·´úÂë"].ToString();
                            grdmain.Rows[row].Cells[HMaterNameCol].Value = Ds.Tables[0].Rows[i]["²úÆ·Ãû³Æ"].ToString();
                            grdmain.Rows[row].Cells[HMaterModelCol].Value = Ds.Tables[0].Rows[i]["¹æ¸ñÐͺÅ"].ToString();
                            grdmain.Rows[row].Cells[HUnitIDCol].Value = Ds.Tables[0].Rows[i]["HUnitID"].ToString();
                            grdmain.Rows[row].Cells[HUnitNameCol].Value = Ds.Tables[0].Rows[i]["µ¥Î»Ãû³Æ"].ToString();
                            grdmain.Rows[row].Cells[HUnitNumberCol].Value = Ds.Tables[0].Rows[i]["µ¥Î»´úÂë"].ToString();
                            grdmain.Rows[row].Cells[HQtyCol].Value = Ds.Tables[0].Rows[i]["¶©µ¥ÊýÁ¿"].ToString(); 
 
                            for (int j = FixCols; j < grdmain.Columns.Count; j++)
                            {
                                if (DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[i]["·¢»õÈÕÆÚ"]) == DBUtility.ClsPub.isDate(grdmain.Columns[j].Tag))
                                {
                                    grdmain.Rows[row].Cells[j].Value = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["ÊýÁ¿"]);
                                    break;
                                } 
                            }
                        }
                    }
 
 
                }
            }
        }
 
        private void grdmain_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (grdmain.CurrentRow == null)
                return;
            DataSet Ds1;
            DataSet Ds2;
            long sHInterID;
            long sHEntryID;
            long sHItemID;
            sHInterID = DBUtility.ClsPub.isLong(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HSourceIDCol].Value);
            sHEntryID = DBUtility.ClsPub.isLong(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HSourceEntryIDCol].Value);
            sHItemID = DBUtility.ClsPub.isLong(grdmain.Rows[grdmain.CurrentRow.Index].Cells[HMaterIDCol].Value);
            Ds1 = oCn.RunProcReturn("select * from h_v_Xs_SendGoodsPlanView2 where hmainid=" + sHInterID + " and hsubid=" + sHEntryID, "h_v_Xs_SendGoodsPlanView2");
            Ds2 = oCn.RunProcReturn("select * from h_v_Xs_SendGoodsPlanView3 where hitemid=" + sHItemID , "h_v_Xs_SendGoodsPlanView3");
            grdsub1.DataSource = Ds1.Tables[0].DefaultView;
            grdsub2.DataSource = Ds2.Tables[0].DefaultView;
            //¶³½á
            int FrCol = 0;
            string s = "";
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdsub1, this.Name, s, FrCol);
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdsub2, this.Name, s, FrCol);
        }
 
        private void bclk_Click(object sender, EventArgs e)
        {
            //±£´æÁпí
            DBUtility.Xt_BaseBillFun.SaveGrid(grdmain, this.Name);
            DBUtility.Xt_BaseBillFun.SaveGrid(grdsub1, this.Name);
            DBUtility.Xt_BaseBillFun.SaveGrid(grdsub2, this.Name);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdmain, this.Name);
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdsub1, this.Name);
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdsub2, this.Name);
        }
    }
}