wtt
2 天以前 770c739aeadfd1025bd6b64aa6790201b0b1047d
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
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using gregn6Lib;
using Pub_Class;
 
namespace SCM
{
    public partial class Gy_UserGongDuanRelation : Form
    {
        public Gy_UserGongDuanRelation()
        {
            InitializeComponent();
        }
        //定义
        public const Int16 HTagCol = 0;
        public const Int16 HSnoCol = 1;
        public const Int16 HGongDuanIDCol = 2;
        public const Int16 HGongDuanNumberCol = 3;
        public const Int16 HGongDuanNameCol = 4;  
        public const Int16 HRemarkCol = 5;
        public const Int16 HUserIDCol = 6;
        public const Int16 HUserNumberCol = 7;
        public const Int16 HUserNameCol = 8;    
        public bool BillChange;   //
        public DBUtility.ClsPub.Enum_OKTag OkTag;
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        public Int64 KeyID;
        public const string ModName = "用户工段权限表";
        //权限
        public const string ModRightName = "Gy_UserGongDuanRelation";
        public const string ModRightNameEdit = ModRightName + "_Edit";
        public const string ModRightNameCheck = ModRightName + "_Check";
        //
        public bool grdStatus;
        public SCM.ClsGy_UserGongDuanRelation_Ctl BillNew = new SCM.ClsGy_UserGongDuanRelation_Ctl();
        public SCM.ClsGy_UserGongDuanRelation_Model BillOld = new SCM.ClsGy_UserGongDuanRelation_Model();
        ClsGridViewSum oSumGrid = new ClsGridViewSum();
        //-------------------------------------------------------------------------
        #region 固定代码
 
        private void Total()
        {
            oSumGrid.Total();
        }
 
        private void bclk_Click(object sender, EventArgs e)
        {
            //保存列宽
            DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
        }
        //清空界面
        public void Sub_ClearBill()
        {
            //清空界面控件 for 控件   
            foreach (Control ct in gbUp.Controls)
            {
                switch (ct.GetType().Name)
                {
                    case "ListBox":
                        ((ListBox)ct).Items.Clear();
                        break;
                    case "CheckBox":
                        ((CheckBox)ct).Checked = false;
                        break;
                    case "RadioButton":
 
                        break;
                    case "ComboBox":
                        ((ComboBox)ct).SelectedIndex = 0;
                        break;
                    //case "TextBox":
                    //    ((TextBox)ct).Text = "";
                    //    break;
                    case "DateTimePicker":
                        ((DateTimePicker)ct).Value = DateTime.Today;
                        break;
                    default:
                        break;
                }
            }
            //
            initGrid();
        }
        //编辑单据
        private void Sub_EditBill()
        {
            ////删除权限
            //if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            //{
            //    return;
            //}
            //if (BillOld.HChecker != "" && BillOld.HChecker != null)
            //{
            //    MessageBox.Show("此单据已经被审核,不允许修改", "提示");
            //    return;
            //}
            ////if (this.BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly)
            ////{
            ////    MessageBox.Show("此单据已经被审核,不允许修改", "提示");
            ////    return;
            ////}
            //this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            //this.Sub_OperStatus();
            
        }
        //删除单据
        private void Sub_DeleteBill()
        {
            ////删除权限
            //if (!DBUtility.ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            //{
            //    return;
            //}
            ////
            //if (BillOld.HChecker != "" && BillOld.HChecker != null)
            //{
            //    MessageBox.Show("此单据已经被审核,不允许删除", "提示");
            //    return;
            //}
            ////if (this.BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly)
            ////{
            ////    MessageBox.Show("此单据已经被审核,不允许删除", "提示");
            ////    return;
            ////}
            //if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            //{
            //    if (BillNew.DeleteByID(BillOld.HItemID) != true)
            //    {
            //        BillChange = true;
            //        MessageBox.Show("删除失败,原因:" + ClsPub.sExeReturnInfo, "提示");
            //        return;
            //    }
            //    MessageBox.Show("删除成功", "提示");
            //    BillOld = new Model.ClsGy_UserGongDuanRelation_Model();
            //    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
            //    this.Sub_OperStatus();
            //}
 
        }
        //离开单元格
 
        private void grdMain_LeaveCell(object sender, EventArgs e)
        {
            oSumGrid.LeaveCell();
        }
      
        
        //网格单元格变化事件
        private void grdMain_RowColChange(object sender, EventArgs e)
        {
            //
            if (!grdStatus)
            {
                return;
            }
            oSumGrid.SetGridsum();
            oSumGrid.Total();
            //
            //if (oSumGrid.Changelock)
            //    return;
            //if(oSumGrid.EditStatus)
            //{
                if (!CheckGridRow(oSumGrid.OldCell.Row))
                    return;
            //}
            
        }
       
        private void Gy_UserGongDuanRelation_Paint(object sender, PaintEventArgs e)//画线
        {
           //控件位置设置
 
        }
        //控件位置
        private void Sub_ControlLocation()
        {
            gbUp.Width = P1.Width - 20;
            gbUp.Left = 10;
            gbUp.Height = P1.Height - 35;
            gbUp.Top = 30;
        }
        //窗体加载
        private void Gy_UserGongDuanRelation_Load(object sender, EventArgs e)
        {
            //打印初始化    
            oSumGrid.NoCol = HSnoCol;
            oSumGrid.ogrdMain = grdMain;
            oSumGrid.oGridsum = grdSum;
            lblCaption.Text = ModName;
            this.Text = ModName;
        }
       
        //审核单据
        private void Sub_CheckBill()
        {
            //if (BillNew.CheckBill(BillOld.HItemID, ref ClsPub.sExeReturnInfo) == true)
            //{
            //    BillChange = true;
            //    txtHChecker.Text = ClsPub.CurUserName;
            //    txtHCheckDate.Text = BillOld.HCheckDate;
            //    BillOld.HChecker = ClsPub.CurUserName;
            //    BillOld.HCheckDate = ClsPub.GetServerDate(-1);
            //    this.Sub_OperStatus();//刷新TOOL按钮
            //}
            //else
            //{
            //    MessageBox.Show("审核失败!原因:" + ClsPub.sExeReturnInfo, "提示");
            //}
        }
        //反审单据
        private void Sub_AbandonCheck()
        {
            //if (BillNew.AbandonCheck(BillOld.HItemID, ref ClsPub.sExeReturnInfo) == true)
            //{
            //    BillChange = true;
            //    txtHChecker.Text = "";
            //    txtHCheckDate.Text = "";
            //    BillOld.HChecker ="";
            //    BillOld.HCheckDate ="";
            //    this.Sub_OperStatus();//刷新TOOL按钮
            //}
            //else
            //{
            //    MessageBox.Show("反审核失败!原因:" + ClsPub.sExeReturnInfo, "提示");
            //}
        }
        
        
        //新增按纽
        private void xz_Click(object sender, EventArgs e)
        {
            this.Sub_AddBill();
        }
        //修改按纽
        private void xg_Click(object sender, EventArgs e)
        {
            this.Sub_EditBill();
        }
        //删除按钮
        private void sc_Click(object sender, EventArgs e)
        {
            this.Sub_DeleteBill();
        }
        //保存按钮
        private void bc_Click(object sender, EventArgs e)
        {
            this.Sub_SaveBill();
        }
       
        //审核按钮
        private void sh_Click(object sender, EventArgs e)
        {
            this.Sub_CheckBill();
        }
        //放弃审核按钮
        private void qsh_Click(object sender, EventArgs e)
        {
            this.Sub_AbandonCheck();
        }
       
        //退出按钮
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        //窗体尺寸变化时
        private void Gy_UserGongDuanRelation_Resize(object sender, EventArgs e)
        {
            Sub_ControlLocation();
        }
 
        //根据编辑状态 设置 控件是否允许录入    
        private void Sub_LrtextStatus(bool TextEnabled)
        {
            if (TextEnabled == true)
            {
                //控件全部有效
                gbUp.Enabled = true;
 
            }
            else
            {   //控件全部无效
                gbUp.Enabled = false;
 
            }
        }
       
        //timer
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            Sub_ControlLocation(); 
            this.Sub_ShowBill(); 
            oSumGrid.SetGridsum();
 
        }
        //窗体卸载
        private void Gy_UserGongDuanRelation_FormClosing(object sender, FormClosingEventArgs e)
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
        }
        //新增单据
        private void Sub_AddBill()
        {
            this.BillNew = new SCM.ClsGy_UserGongDuanRelation_Ctl();
            this.BillOld = new SCM.ClsGy_UserGongDuanRelation_Model();
            this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
            this.Sub_OperStatus();//设置TOOLBAR
            this.Sub_ClearBill();//清空界面
           
        }
        //TOOLBAR状态  按钮是否灰度
        public void Sub_OperStatus()
        {
            switch (BillStatus)
            {
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_View:
                //case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Viewonly:
                    //浏览状态
                    yl.Enabled = true;
                    xz.Enabled = true;
                    //xg.Enabled = true;
                    //sc.Enabled = true;
                    AddRow.Enabled = false;
                    DelRow.Enabled = false;
                    bc.Enabled = false;
                    tc.Enabled = true;
                    //未审核
                    if (txtHChecker.Text.Trim() == "")
                    {
                        //xg.Enabled = true;
                        //sc.Enabled = true;
                    }
                    else
                    {
                        //xg.Enabled = false;
                        //sc.Enabled = false;
                    }
                    Sub_LrtextStatus(false);
                    grdStatus = false;
                    break;
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew:
                    //新增状态
                    yl.Enabled = false;
                    xz.Enabled = false;
                    //xg.Enabled = false;
                    //sc.Enabled = false;
                    AddRow.Enabled = true;
                    DelRow.Enabled = true;
                    bc.Enabled = true;
                    tc.Enabled = true;
                    Sub_LrtextStatus(true);
                    grdStatus = true;
                    break;
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
                    //修改状态
                    yl.Enabled = false;
                    xz.Enabled = false;
                    //xg.Enabled = false;
                    //sc.Enabled = false;
                    AddRow.Enabled = true;
                    DelRow.Enabled = true;
                    bc.Enabled = true;
                    tc.Enabled = true;
                    Sub_LrtextStatus(true);
                    grdStatus = true;
                    break;
            }
 
        }
        #endregion 
 
        #region  读写类
        //显示单据
        public void Sub_ShowBill()
        {
            SCM.ClsCLD_BaseGD_View oGongDuan = new SCM.ClsCLD_BaseGD_View(); 
            //判断是否存在单据
            if(BillNew.ShowBill(txtHUserID.Text,ref  ClsPub.sExeReturnInfo)==false )
            {
                Sub_AddBill();
                return;
            }
            //清空
            Sub_ClearBill();
            //grid禁止刷新
            //加载表头
            
            //
            BillStatus  = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            //this.txtHUserID.Text = BillOld.HUserID.ToString();
 
            //加载表体
            initGrid();
            int i = 0;
            foreach (SCM.ClsGy_UserGongDuanRelation_Model oSub in BillNew.DetailColl)
            {
               
                //
                if (i >= grdMain.RowCount - 1)
                    grdMain.Rows.Add();
                grdMain.Rows[i].Cells[HTagCol].Value = "*";
                grdMain.Rows[i].Cells[HGongDuanIDCol].Value = oSub.HGongDuanID.ToString();
                if (oGongDuan.GetInfoByID( DBUtility.ClsPub.isStrNull(oSub.HGongDuanID)))
                {
                    grdMain.Rows[i].Cells[HGongDuanNumberCol].Value = oGongDuan.omodel.HNumber;
                    grdMain.Rows[i].Cells[HGongDuanNameCol].Value = oGongDuan.omodel.HName;                    
                }
                else
                {
                    grdMain.Rows[i].Cells[HGongDuanNumberCol].Value = "";
                    grdMain.Rows[i].Cells[HGongDuanNameCol].Value = "";                    
                }
                //            
                //
                //grdMain.Rows[i].Cells[HUserIDCol].Value = oSub.HUserID.ToString();
                //if (oUser.GetInfoByID(oSub.HUserID))
                //{
                //    grdMain.Rows[i].Cells[HUserNumberCol].Value = oUser.omodel.HNumber;
                //    grdMain.Rows[i].Cells[HUserNameCol].Value = oUser.omodel.HName;
                //}
                //else
                //{
                //    grdMain.Rows[i].Cells[HUserNumberCol].Value = "";
                //    grdMain.Rows[i].Cells[HUserNameCol].Value = "";
                //}
                //
           
                grdMain.Rows[i].Cells[HRemarkCol].Value = oSub.HRemark;
                
               
 
                
                i = i + 1;
            }
            //GRID允许刷新
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            //合计
            Total();
            //
            Sub_OperStatus();
            //oBillSub = null;
        }
       
        //单据完整性判断          未完成
        private bool Sub_AllowSave()
        {
            if (DBUtility.ClsPub.isStrNull(txtHUserID.Text) == "")
            {
                MessageBox.Show("用户没有选择!", "提示");
                return false;
            } 
           return true;
        }
        //保存单据
        private bool Sub_SaveBill()
        {
            SCM.ClsGy_UserGongDuanRelation_Model oBillSub = new SCM.ClsGy_UserGongDuanRelation_Model();
            Int32 i;
            bool bResult;
            BillNew = new SCM.ClsGy_UserGongDuanRelation_Ctl();
            //编辑权限
            //if (!ClsPub.Security_Log(ModRightNameEdit, 1, true, DBUtility.ClsPub.CurUserName))
            //{
            //    return false;
            //}
            //失去焦点
            lblCaption.Focus();
            //
            if (!Sub_AllowSave())//单据完整性判断
                return false;
            //
            //明细类赋值
            BillNew.DetailColl = new List<SCM.ClsGy_UserGongDuanRelation_Model>();
            for (i = 0; i <= grdMain.RowCount - 1; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HGongDuanIDCol].Value) != "")//  
                {
                    SCM.ClsGy_UserGongDuanRelation_Model oSub = new SCM.ClsGy_UserGongDuanRelation_Model();
                    oSub.HGongDuanID = ClsPub.isStrNull(grdMain.Rows[i].Cells[HGongDuanIDCol].Value);
                    oSub.HUserID = ClsPub.isStrNull(txtHUserID.Text);
                    BillNew.DetailColl.Add(oSub);
                }
            }
            //保存完毕后处理
            if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
            {
                bResult = BillNew.AddNew();
            }
            else
            {
                bResult = BillNew.ModifyByID(txtHUserID.Text);
            }
            //提示
            if (bResult == true)
            {
                BillChange = true;
                MessageBox.Show("单据存盘完毕!", "提示");
                if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
                {
                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
                }
                else if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
                {
                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_View;
                }
                this.Sub_OperStatus();
                return true;
            }
            else
            {
                MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示");
                return false;
            }
        }
 
        
        #endregion 
 
 
        #region 窗体处理方法
 
        
        //初始化GRID
        private void initGrid()
        {
            grdMain.ColumnCount = 9;                       //总列数
            SCM.公用类.Xt_BaseBillFun.initGridFst(grdMain, this.Name);
            //
 
            grdMain.Columns[HGongDuanIDCol].HeaderText = "工段ID";
            grdMain.Columns[HGongDuanNumberCol].HeaderText = "工段代码";
            grdMain.Columns[HGongDuanNameCol].HeaderText = "工段名称";
 
            grdMain.Columns[HUserIDCol].HeaderText = "用户ID";
            grdMain.Columns[HUserNumberCol].HeaderText = "用户代码";
            grdMain.Columns[HUserNameCol].HeaderText = "用户名称";
            grdMain.Columns[HRemarkCol].HeaderText = "备注";
            //
            //设置特殊列
            //HOldMaterBackFlagCol
           
            grdMain.Columns[HTagCol].Visible = false;
            grdMain.Columns[HUserIDCol].Visible = false;
            grdMain.Columns[HGongDuanIDCol].Visible = false;
            grdMain.Columns[HUserNumberCol].Visible = false;
            grdMain.Columns[HUserNameCol].Visible = false;
            //
            string sAllowCol = HGongDuanNumberCol.ToString() +                           
                            "," + HUserNumberCol.ToString() +                           
                            "," + HRemarkCol.ToString();
            string sTotalCol = HTagCol.ToString();
            //格式化网格
            DBUtility.Xt_BaseBillFun.initGridLast(sAllowCol, sTotalCol, oSumGrid);
        }
        
        //公式重算
        private void RowCount(int sRow,int   sTag)
        {
            if (sTag == 0)
            {
                //金额列=数量*单价
                
            }
            else
            {
                //单价列=金额/数量
                 
            }
        }
        
        //增行按钮 未完成
        private void AddRow_Click(object sender, EventArgs e)
        {
            oSumGrid.Sub_AddRow();
        }
        //删行按纽 未完成
        private void DelRow_Click(object sender, EventArgs e)
        {
            oSumGrid.Sub_DelRow();
        }
        
        
 
        //核对选择的内容
        public bool CheckGridCell(Cell oCell)
        {
            int Row;
            int Col;
            Row = oCell.Row;
            Col = oCell.Col;
            //输入代码得到信息
            //if (Col == HMaterNumberCol)  //物料代码列
            //{
 
            //    return false;
            //}
            //else //其他列
            //{
            //}
            //  
            oSumGrid.EditStatus = false;
            return true;
        }
        //是否是空行
        private bool IsNullRow(int Row)
        {
            //if (ClsPub.isInt(grdMain.Rows[Row].Cells[HMaterIDCol].Value) == 0)
            //{
            //    return true;
            //}
            return true;
        }
        //'判断网格行的录入是否正确
        private bool CheckGridRow(int Row)
        {
            //Cell oCell = new Cell();
            //int c = 0;
            //for (c = 0; c < grdMain.Cols; c++)
            //{
            //    oCell.Row = Row;
            //    oCell.Col = c;
            //    if (!CheckGridCell(oCell))
            //        return false;
 
            //}
            return true;
        }
        //帮助函数
        private void Sub_GridKey(int sKeyCode, int sRow, int sCol, DataGridViewTextBoxEditingControl oEdit)
        {
            SCM.ClsCLD_BaseGD_View oGongDuan = new SCM.ClsCLD_BaseGD_View(); 
            if (!grdStatus)
            {
                return;
            }
            //if (oSumGrid.FindAllowEditCol(sCol))
            //{
            oSumGrid.EditStatus = true;
            //}
            //else
            //{
            //    return;
            //}
            switch (sKeyCode)
            {
                case 118:
                    {
                    switch (sCol)
                    {
                       
                        //
                        case HGongDuanNumberCol:
                            oGongDuan.WherePart = "";
                            string DeWhere = "";
                            DeWhere = " and HUSEORGID = " + ClsPub1.HOrgID;
                            if (oGongDuan.RefreshView())
                            {
                                //if (oGongDuan.GetInfoByID(oGongDuan.oModel.HItemID))
                                //{
                                grdMain.Rows[sRow].Cells[HGongDuanIDCol].Value = oGongDuan.omodel.HGDID.ToString();
                                grdMain.Rows[sRow].Cells[HGongDuanNumberCol].Value = oGongDuan.oModel.HNumber;
                                grdMain.Rows[sRow].Cells[HGongDuanNameCol].Value = oGongDuan.oModel.HName;
                                oEdit.Text = oGongDuan.omodel.HNumber;
                                //}
                                //else
                                //{
                                //    grdMain.Rows[sRow].Cells[HGongDuanIDCol].Value = 0;
                                //    grdMain.Rows[sRow].Cells[HGongDuanNumberCol].Value = "";
                                //    grdMain.Rows[sRow].Cells[HGongDuanNameCol].Value = "";
                                //}
                            }
                            else
                            {
                                grdMain.Rows[sRow].Cells[HGongDuanIDCol].Value = 0;
                                grdMain.Rows[sRow].Cells[HGongDuanNumberCol].Value = "";
                                grdMain.Rows[sRow].Cells[HGongDuanNameCol].Value = "";
                            }
                            break;
                        default:
                            break;
                    }
                    break;
                    }
                case 117:
                    MessageBox.Show("此功能尚未开放!", "提示");
                    break;
                default:
                    break;
            }
        }
 
        #endregion
 
        DataGridViewTextBoxEditingControl EditingControl;
        private void grdMain_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
        {
            int i = grdMain.CurrentCell.ColumnIndex;
            if (DBUtility.Xt_BaseBillFun.AllowEdit(grdStatus, oSumGrid, i))
            {
                e.Cancel = true;
            }
        }
 
        private void grdMain_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            RowCount(e.RowIndex, 0);  //计算 金额 单价
            //
            if (this.EditingControl != null)      //释放事件
            {
                EditingControl.KeyDown -= new KeyEventHandler(this.EditingControl_KeyDown);
                this.EditingControl = null;
            }
        }
 
        private void grdMain_CellLeave(object sender, DataGridViewCellEventArgs e)
        {
            if (!grdStatus)
            {
                return;
            }
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            // 
            if (!CheckGridRow(oSumGrid.OldCell.Row))
                return;
        }
 
        private void grdMain_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
        }
 
        private void grdMain_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            if (grdMain.CurrentCell != null)
            {
                if (e.Control is DataGridViewTextBoxEditingControl)
                {
                    this.EditingControl = (DataGridViewTextBoxEditingControl)e.Control;
                    //增加委托处理 
                    this.EditingControl.KeyDown += new KeyEventHandler(this.EditingControl_KeyDown);
                }
            }
        }
 
        private void EditingControl_KeyDown(object sender, KeyEventArgs e)
        {
            //业务处理 
            Sub_GridKey(e.KeyValue, grdMain.CurrentRow.Index, grdMain.CurrentCell.ColumnIndex, EditingControl);
        }
 
        private void grdMain_RowHeadersWidthChanged(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
        }
 
        private void grdMain_Scroll(object sender, ScrollEventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SetSumGrid(oSumGrid);
            oSumGrid.DisplayCurRow();
        }
 
        private void cmdHUserID_Click(object sender, EventArgs e)
        {
            //DBUtility.Gy_UserSelect oUser = new DBUtility.Gy_UserSelect();
            //oUser.bSingle = false;
            //oUser.ShowDialog();
            //if (oUser.IsOk == 1)
            //{
            //    txtHUserID.Text = oUser.sReturn;
            //}
            //else
            //{
            //    txtHUserID.Text = "";
            //}
        }
 
        private void txtHUserID_TextChanged(object sender, EventArgs e)
        {
            //if (txtHUserID.Text.Trim() == "")
            //{
            //    txtHUserID.Tag = "0";
            //}
        }
 
        
 
        
    }
}