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
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DBUtility;
 
namespace BLL
{
    public partial class Xt_CheckExtend : Form
    {
        public Xt_CheckExtend()
        {
            InitializeComponent();
        }
        //定义
        //public const Int16 HTagCol = 0;
        //public const Int16 HSnoCol = 1;
        //public const Int16 HSendStatusCol = 2;
        //public const Int16 HSendManCol = 3;
        //public const Int16 HDateCol = 4;
        //public const Int16 HDescriptionCol = 5;
        //表1
        //
        public  string ModName = "4510";
        public  string ModCaption = "合同评审会签表";
        public const string ModRightName = "Xt_CheckExtend";
        public const string ModRightNameEdit = ModRightName + "_Edit";
        public const string ModRightNameCheck = ModRightName + "_Check";
        public const string ModRightNameClose = ModRightName + "_Close";
        public const string ModRightNameDelete = ModRightName + "_Delete";
        public bool BillChange;   //
        public string SeBillNo = "";
        public string HCusNumber = "";
        public string HCommDate = "";
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        public Int64 KeyID;
        public bool grdStatus;
        public BLL.ClsXt_CheckExtend_Ctl BillNew = new BLL.ClsXt_CheckExtend_Ctl();
        public BLL.ClsXt_CheckExtend_Ctl BillOld = new BLL.ClsXt_CheckExtend_Ctl();
        //-------------------------------------------------------------------------
        #region 固定代码
 
        //清空界面
        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;
                }
            }
            //
            txtHMaker.Text = ClsPub.CurUserName;
            txtHMakeDate.Text = "";
            txtHChecker.Text = "";
            txtHCheckDate.Text = "";
            txtHCloseMan.Text = "";
            txtHCloseDate.Text = "";
            txtHDeleteMan.Text = "";
            txtHDeleteDate.Text = "";
            txtHUpDater.Text = "";
            txtHUpDateDate.Text = "";
            initGrid();
        }
        //编辑单据
        private void Sub_EditBill()
        {
            //if (BillOld.omodel.HChecker != "")
            //{
            //    MessageBox.Show("此单据已经被审核,不允许修改", "提示");
            //    return;
            //}
            this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            this.Sub_OperStatus();
            txtHUpDater.Text = ClsPub.CurUserName;
            //txtHBillNo.Enabled = false;
        }
        //删除单据
        private void Sub_DeleteBill()
        {
            //if (BillOld.omodel.HChecker != "")
            //{
            //    MessageBox.Show("此单据已经被审核,不允许审核", "提示");
            //    return;
            //}
            if (MessageBox.Show("确定要删除当前单据?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                if (BillOld.DeleteBill(BillOld.omodel.HItemID, ref ClsPub.sExeReturnInfo) != true)
                {
                    BillChange = true;
                    MessageBox.Show("删除失败,原因:" + ClsPub.sExeReturnInfo, "提示");
                    return;
                }
                MessageBox.Show("删除成功", "提示");
                BillOld = new  BLL.ClsXt_CheckExtend_Ctl();
                this.Sub_Next();  //显示下一张单据
                if (BillOld.omodel.HItemID == 0)//若找不到下一张,则显示上一张
                {
                    this.Sub_Prev();
                }
                if (BillOld.omodel.HItemID == 0)//若找不到上一张,清空
                {
                    this.Sub_ClearBill();
                }
                BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
                this.Sub_OperStatus();
            }
 
        }
        private void bclk_Click(object sender, EventArgs e)
        {
            //保存列宽
            //ClsPub.SaveGridView(grdMain, this.Name);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            //ClsPub.DefaultGridView(grdMain);
            //参数解释  开始列 ,结束列,是否以最大列宽为准,最小列宽
            //ClsPub.SaveGridView(grdMain, this.Name);
        }
 
        //放弃 编辑
        private void Sub_AbandonBill()
        {
            if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew || BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
            {
                if (MessageBox.Show("单据尚未保存,是否放弃?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    //显示第一张单据
                    this.Sub_First();
                }
            }
        }
        private void Xt_CheckExtend_Paint(object sender, PaintEventArgs e)//画线
        {
            Graphics g = this.panel2.CreateGraphics();
            Pen p = new Pen(Color.Gray);
            p.Width = 1;
            //g.DrawLine(p, new Point(txtHMaker.Left, txtHMaker.Top + txtHMaker.Height), new Point(txtHMaker.Left + txtHMaker.Width, txtHMaker.Top + txtHMaker.Height));
            //g.DrawLine(p, new Point(txtHMakeDate.Left, txtHMakeDate.Top + txtHMakeDate.Height), new Point(txtHMakeDate.Left + txtHMakeDate.Width, txtHMakeDate.Top + txtHMakeDate.Height));
            ////
            //g.DrawLine(p, new Point(txtHChecker.Left, txtHChecker.Top + txtHChecker.Height), new Point(txtHChecker.Left + txtHChecker.Width, txtHChecker.Top + txtHChecker.Height));
            //g.DrawLine(p, new Point(txtHCheckDate.Left, txtHCheckDate.Top + txtHCheckDate.Height), new Point(txtHCheckDate.Left + txtHCheckDate.Width, txtHCheckDate.Top + txtHCheckDate.Height));
            ////
            g.DrawLine(p, new Point(txtHCloseMan.Left, txtHCloseMan.Top + txtHCloseMan.Height), new Point(txtHCloseMan.Left + txtHCloseMan.Width, txtHCloseMan.Top + txtHCloseMan.Height));
            g.DrawLine(p, new Point(txtHCloseDate.Left, txtHCloseDate.Top + txtHCloseDate.Height), new Point(txtHCloseDate.Left + txtHCloseDate.Width, txtHCloseDate.Top + txtHCloseDate.Height));
            ////
            //g.DrawLine(p, new Point(this.txtHDeleteMan.Left, txtHDeleteMan.Top + txtHDeleteMan.Height), new Point(txtHDeleteMan.Left + txtHDeleteMan.Width, txtHDeleteMan.Top + txtHDeleteMan.Height));
            //g.DrawLine(p, new Point(txtHDeleteDate.Left, txtHDeleteDate.Top + txtHDeleteDate.Height), new Point(txtHDeleteDate.Left + txtHDeleteDate.Width, txtHDeleteDate.Top + txtHDeleteDate.Height));
            ////
            //g.DrawLine(p, new Point(this.txtHUpDater.Left, txtHUpDater.Top + txtHUpDater.Height), new Point(txtHUpDater.Left + txtHUpDater.Width, txtHUpDater.Top + txtHUpDater.Height));
            //g.DrawLine(p, new Point(txtHUpDateDate.Left, txtHUpDateDate.Top + txtHUpDateDate.Height), new Point(txtHUpDateDate.Left + txtHUpDateDate.Width, txtHUpDateDate.Top + txtHUpDateDate.Height));
            ////控件位置设置
 
        }
        //控件位置
        private void Sub_ControlLocation()
        {
            //gbUp.Width = P1.Width - 20;
            //gbUp.Left = 10;
            //gbUp.Height = P1.Height - 35;
            //gbUp.Top = 30;
        }
        //窗体加载
        private void Xt_CheckExtend_Load(object sender, EventArgs e)
        {
            //打印初始化
            this.Text = ModCaption;
            this.lblCaption.Text = ModCaption;
        }
        //首张
        private void Sub_First()
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            BillOld = new BLL.ClsXt_CheckExtend_Ctl();
            //if (BillOld.GetFirstBill(ref  ClsPub.sExeReturnInfo))
            //{
            //    this.Sub_ShowBill();
            //}
            //else  //没有找到则 变为新增状态
            //{
            this.Sub_AddBill();
            //}
        }
 
        //上张
        private void Sub_Prev()
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            if (BillOld.GetPrevousBill(ref  ClsPub.sExeReturnInfo, txtHBillNo.Text))
            {
                this.Sub_ShowBill();
            }
        }
 
        //下张
        private void Sub_Next()
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            if (BillOld.GetNextBill(ref  ClsPub.sExeReturnInfo, txtHBillNo.Text))
            {
                this.Sub_ShowBill();
            }
        }
 
        //末张
        private void Sub_Last()
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
            BillOld = new BLL.ClsXt_CheckExtend_Ctl();
            if (BillOld.GetLastBill(ref  ClsPub.sExeReturnInfo))
            {
                this.Sub_ShowBill();
            }
        }
        //审核单据
        private void Sub_CheckBill()
        {
            //判断权限
            DateTime sDate;
            string sNote;
            string sHCheckItem;
            string sEx = "";
            //
            if (BillOld.omodel.HStatus == 2)
            {
                if (cmbHCheckItem.Text == "")
                {
                    MessageBox.Show("限价条件没有选择!", "提示");
                    return;
                }
                sDate = DateTime.Today;
                sNote = txtHManagerNote.Text.Trim();
                sHCheckItem = cmbHCheckItem.Text;
            }
            else if (BillOld.omodel.HStatus == 3)
            {
                sDate = DateTime.Today;
                sNote = txtHFstManagerNote.Text.Trim();
                sHCheckItem = "";
            }
            else if (BillOld.omodel.HStatus == 4)
            {
                sDate = dtpHProdCheckDate.Value;
                sNote = txtHProdManNote.Text.Trim();
                sHCheckItem = "";
            }
            else if (BillOld.omodel.HStatus == 5)
            {
                sDate = dtpHLstRequesterCheckDate.Value;
                sNote = txtHLstRequesterNote.Text.Trim();
                sHCheckItem = "";
            }
            else if (BillOld.omodel.HStatus == 6)
            {
                sDate = dtpHLstCommDate.Value;
                sNote = "";
                sHCheckItem = "";
            }
            else if (BillOld.omodel.HStatus == 7)
            {
                sDate = DateTime.Today;
                sNote = "";
                sHCheckItem = "";
            }
            else if (BillOld.omodel.HStatus == 8)
            {
                sDate = DateTime.Today;
                sNote = txtHLstManagerNote.Text.Trim();
                sHCheckItem = "";
            }
            else if (BillOld.omodel.HStatus == 99)
            {
                MessageBox.Show("单据已经终审!", "提示");
                return;
            }
            else
            {
                sDate = DateTime.Today;
                sNote = "";
                sHCheckItem = "";
            }
 
            //
            if (BillOld.CheckBill(SeBillNo, sDate, sHCheckItem, sNote, ref sEx) == true)
            {
                BillChange = true;
                txtHChecker.Text = ClsPub.CurUserName;
                //txtHCheckDate.Text = BillOld.omodel.HCheckDate;
                this.Sub_OperStatus();//刷新TOOL按钮
                Sub_ShowBill();
                MessageBox.Show(sEx, "提示");
                return;
            }
            else
            {
                MessageBox.Show("审核失败!原因:" + sEx, "提示");
            }
        }
        //反审单据
        private void Sub_AbandonCheck()
        {
            //判断权限
            if (!ClsPub.Security_Log(ModRightNameCheck, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
            //
            if (BillOld.AbandonCheck(BillOld.omodel.HItemID, ref ClsPub.sExeReturnInfo) == true)
            {
                BillChange = true;
                txtHChecker.Text = "";
                txtHCheckDate.Text = "";
                this.Sub_OperStatus();//刷新TOOL按钮
            }
            else
            {
                MessageBox.Show("反审核失败!原因:" + ClsPub.sExeReturnInfo, "提示");
            }
        }
        //关闭单据
        private void Sub_CloseBill()
        {
            //判断权限
            //if (!ClsPub.Security_Log(ModRightNameClose, 1, true, DBUtility.ClsPub.CurUserName))
            //{
            //    return;
            //}
            //
            if (BillOld.CloseBill(SeBillNo, ref ClsPub.sExeReturnInfo) == true)
            {
                BillChange = true;
                txtHCloseMan.Text = ClsPub.CurUserName;
                //txtHCloseDate.Text = BillOld.omodel.HCloseDate;
                this.Sub_OperStatus();//刷新TOOL按钮
            }
            else
            {
                MessageBox.Show("关闭失败!原因:" + ClsPub.sExeReturnInfo, "提示");
            }
        }
        //反关闭单据
        private void Sub_Cancel()
        {
            //判断权限
            if (!ClsPub.Security_Log(ModRightNameClose, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
            //
            if (BillOld.CancelClose(BillOld.omodel.HItemID, ref ClsPub.sExeReturnInfo) == true)
            {
                BillChange = true;
                txtHCloseMan.Text = "";
                txtHCloseDate.Text = "";
                this.Sub_OperStatus();//刷新TOOL按钮
            }
            else
            {
                MessageBox.Show("恢复失败!原因:" + ClsPub.sExeReturnInfo, "提示");
            }
        }
        //作废单据
        private void Sub_Cancelltion()
        {
            //判断权限
            if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
            //
            if (BillOld.Cancelltion(BillOld.omodel.HItemID, ref ClsPub.sExeReturnInfo) == true)
            {
                BillChange = true;
                this.txtHDeleteMan.Text = ClsPub.CurUserName;
                //this.txtHDeleteDate.Text = BillOld.omodel.HDeleteDate;
                this.Sub_OperStatus();//刷新TOOL按钮
            }
            else
            {
                MessageBox.Show("作废失败!原因:" + ClsPub.sExeReturnInfo, "提示");
            }
        }
        //反作废
        private void Sub_AbandonCancelltion()
        {
            //判断权限
            if (!ClsPub.Security_Log(ModRightNameDelete, 1, true, DBUtility.ClsPub.CurUserName))
            {
                return;
            }
            //
            if (BillOld.AbandonCancelltion(BillOld.omodel.HItemID, ref ClsPub.sExeReturnInfo) == true)
            {
                BillChange = true;
                this.txtHDeleteMan.Text = "";
                this.txtHDeleteDate.Text = "";
                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 fq_Click(object sender, EventArgs e)
        {
            this.Sub_AbandonBill();
        }
        //审核按钮
        private void sh_Click(object sender, EventArgs e)
        {
            this.Sub_CheckBill();
        }
        //放弃审核按钮
        private void qsh_Click(object sender, EventArgs e)
        {
            this.Sub_AbandonCheck();
        }
        //关闭按钮
        private void gb_Click(object sender, EventArgs e)
        {
            this.Sub_CloseBill();
        }
        //恢复按钮
        private void hf_Click(object sender, EventArgs e)
        {
            this.Sub_Cancel();
        }
        //作废按钮
        private void zf_Click(object sender, EventArgs e)
        {
            this.Sub_Cancelltion();
        }
        //反作废按钮
        private void zc_Click(object sender, EventArgs e)
        {
            this.Sub_AbandonCancelltion();
        }
        //首张单据按钮
        private void sz_Click(object sender, EventArgs e)
        {
            this.Sub_First();
        }
        //上一张按钮
        private void syz_Click(object sender, EventArgs e)
        {
            this.Sub_Prev();
        }
        //下一张按钮
        private void xyz_Click(object sender, EventArgs e)
        {
            this.Sub_Next();
        }
        //末张按钮
        private void mz_Click(object sender, EventArgs e)
        {
            this.Sub_Last();
        }
        //退出按钮
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //窗体尺寸变化时
        private void Xt_CheckExtend_Resize(object sender, EventArgs e)
        {
            Sub_ControlLocation();
        }
 
        //根据编辑状态 设置 控件是否允许录入    
        private void Sub_LrtextStatus(bool TextEnabled)
        {
            if (TextEnabled == true)
            {
                //控件全部有效
                gbUp.Enabled = true;
                //grdMain.BackColor = ClsPub.EditColor;
 
            }
            else
            {   //控件全部无效
                gbUp.Enabled = false;
                //grdMain.BackColor = ClsPub.ViewColor;
            }
        }
        //复制单据
        private void Sub_CopyBill()
        {
            this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
            this.Sub_OperStatus();//设置TOOLBAR
            this.txtHBillNo.Text = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//得到新单号 
            this.txtHBillNo.Enabled = true;
            this.txtHBillNo.Focus();
            this.txtHMaker.Text = ClsPub.CurUserName;
            this.txtHMakeDate.Text = ClsPub.GetServerDate(-1);
            this.txtHChecker.Text = "";
            this.txtHCloseDate.Text = "";
            this.txtHCloseMan.Text = "";
            this.txtHCloseDate.Text = "";
            this.txtHDeleteMan.Text = "";
            this.txtHDeleteDate.Text = "";
            this.txtHUpDater.Text = "";
            this.txtHUpDateDate.Text = "";
        }
        //复制按钮
        private void fz_Click(object sender, EventArgs e)
        {
            Sub_CopyBill();
        }
 
        //timer
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            Sub_ControlLocation();
            if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
            {
                this.Sub_ShowBill();
            }
            else
            {
                this.Sub_AddBill();
 
                this.Sub_ShowBillByID();
            }
 
        }
        //窗体卸载
        private void Xt_CheckExtend_FormClosing(object sender, FormClosingEventArgs e)
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
        }
        //新增单据
        private void Sub_AddBill()
        {
            this.BillNew = new BLL.ClsXt_CheckExtend_Ctl();
            this.BillOld = new BLL.ClsXt_CheckExtend_Ctl();
            this.BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
            this.Sub_OperStatus();//设置TOOLBAR
            this.Sub_ClearBill();//清空界面
            this.txtHBillNo.Text = ClsPub.CreateBillCode(BillNew.BillType, ref ClsPub.sExeReturnInfo, true);//得到新单号(缺少函数)  未完成
            this.txtHBillNo.Enabled = true;
            this.txtHBillNo.Focus();
        }
 
        //TOOLBAR状态  按钮是否灰度
        public void Sub_OperStatus()
        {
            switch (BillStatus)
            {
                //case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
                //    //浏览状态
                //    yl.Enabled = true;
                //    xz.Enabled = true;
                //    xg.Enabled = true;
                //    sc.Enabled = true;
                //    //AddRow.Enabled = false;
                //    //DelRow.Enabled = false;
                //    bc.Enabled = false;
                //    fq.Enabled = false;
                //    sz.Enabled = true;
                //    syz.Enabled = true;
                //    xyz.Enabled = true;
                //    mz.Enabled = true;
                //    tc.Enabled = true;
                //    fz.Enabled = true;
                //    //未审核
                //    if (txtHChecker.Text.Trim() == "")
                //    {
                //        sh.Enabled = true;
                //        qsh.Enabled = false;
                //        gb.Enabled = false;
                //        hf.Enabled = false;
                //        xg.Enabled = true;
                //        sc.Enabled = true;
                //        //未审核
                //        pic1.Visible = false;
                //        pic1.Image = null;
                //        //
                //    }
                //    else if (txtHCloseMan.Text.Trim() == "" && txtHChecker.Text.Trim() != "")//审核未关闭
                //    {
                //        sh.Enabled = false;
                //        qsh.Enabled = true;
                //        gb.Enabled = true;
                //        hf.Enabled = false;
                //        xg.Enabled = false;
                //        sc.Enabled = false;
                //        //
                //        pic1.Visible = true;
                //        pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Checked.jpg");
                //        //
                //    }
                //    else//已关闭
                //    {
                //        sh.Enabled = false;
                //        qsh.Enabled = false;
                //        gb.Enabled = false;
                //        hf.Enabled = true;
                //        xg.Enabled = false;
                //        sc.Enabled = false;
                //        //
                //        pic1.Visible = true;
                //        pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Closed.jpg");
                //        //
                //    }
                //    if (txtHDeleteMan.Text.Trim() == "")
                //    {
                //        zf.Enabled = true;
                //        zc.Enabled = false;
                //    }
                //    else //已作废
                //    {
                //        zf.Enabled = false;
                //        zc.Enabled = true;
                //        xg.Enabled = false;
                //        sc.Enabled = false;
                //        //AddRow.Enabled = false;
                //        //DelRow.Enabled = false;
                //        bc.Enabled = false;
                //        fq.Enabled = false;
                //        sh.Enabled = false;
                //        qsh.Enabled = false;
                //        gb.Enabled = false;
                //        hf.Enabled = false;
                //        //
                //        pic1.Visible = true;
                //        pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Deleted.jpg");
                //        //
                //    }
                //    Sub_LrtextStatus(false);
                //    grdStatus = false;
                //    break;
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew:
                    //新增状态
                    yl.Enabled = false;
                    
                    //AddRow.Enabled = true;
                    //DelRow.Enabled = true;
                    bc.Enabled = true;
                   
                    sh.Enabled = false;
                    qsh.Enabled = false;
                    gb.Enabled = false;
                 
                   
                    tc.Enabled = true;
                    Sub_LrtextStatus(true);
                    grdStatus = true; 
                    //未审核
                    pic1.Visible = false;
                    pic1.Image = null;
                    //
                    break;
                case DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify:
                    //修改状态
                    yl.Enabled = false;
                   
                    //AddRow.Enabled = true;
                    //DelRow.Enabled = true;
                    bc.Enabled = false;
                   
                    sh.Enabled = true;
                    qsh.Enabled = true;
                    gb.Enabled = true;
                 
                    
                    tc.Enabled = true;
                    Sub_LrtextStatus(true);
                    grdStatus = true; 
                    //未审核
                    pic1.Visible = false;
                    pic1.Image = null;
                    //
                    if (txtHCloseMan.Text.Trim() != "")
                    {
                        sh.Enabled = false;
                        bc.Enabled = false;
                        qsh.Enabled = false;
                        gb.Enabled = false;
                      
                        //
                        pic1.Visible = true;
                        pic1.Image = System.Drawing.Image.FromFile(ClsPub.AppPath + @"/Pic/Closed.jpg");
                    }
                    break;
            }
 
        }
        #endregion
 
        #region  读写类
        //显示单据
        public void Sub_ShowBill()
        {
            DAL.ClsA3_Customer_View oCus = new DAL.ClsA3_Customer_View();
            //判断是否存在单据
            if (BillOld.ShowBill(SeBillNo, ref  ClsPub.sExeReturnInfo) == false)
            {
                MessageBox.Show(ClsPub.sExeReturnInfo, "提示");
                return;
            }
            //清空
            Sub_ClearBill();
            //grid禁止刷新
            //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone;
            //加载表头
 
            //
            if (oCus.GetInfoByNumber(BillOld.omodel.HCusNumber))
            {
                this.txtHCusNumber.Text = oCus.omodel.HNumber;
                this.txtHCusName.Text = oCus.omodel.HName;
            }
            else
            {
                this.txtHCusNumber.Text = "";
                this.txtHCusName.Text = "";
            }
 
            this.txtHBillNo.Text = BillOld.omodel.HBillNo;
            this.txtHType.Text = BillOld.omodel.HType;
            this.txtHTypeNote.Text = BillOld.omodel.HTypeNote;
            this.txtHRequester.Text = BillOld.omodel.HRequester;
            if (ClsPub.isDate(BillOld.omodel.HRequestDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHRequestDate.Text = "";
            }
            else
            {
                this.txtHRequestDate.Text = BillOld.omodel.HRequestDate;
            }
            this.txtHRequestNote.Text = BillOld.omodel.HRequestNote;
            this.txtHManager.Text = BillOld.omodel.HManager;
            if (ClsPub.isDate(BillOld.omodel.HManagerDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHManagerDate.Text = "";
            }
            else
            {
                this.txtHManagerDate.Text = BillOld.omodel.HManagerDate;
            }
            this.txtHManagerNote.Text = BillOld.omodel.HManagerNote;
            this.txtHFstManager.Text = BillOld.omodel.HFstManager;
            if (ClsPub.isDate(BillOld.omodel.HFstManagerDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHFstManagerDate.Text = "";
            }
            else
            {
                this.txtHFstManagerDate.Text = BillOld.omodel.HFstManagerDate;
            }
            this.txtHFstManagerNote.Text = BillOld.omodel.HFstManagerNote;
            this.txtHProdMan.Text = BillOld.omodel.HProdMan;
            if (ClsPub.isDate(BillOld.omodel.HProdManDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHProdManDate.Text = "";
            }
            else
            {
                this.txtHProdManDate.Text = BillOld.omodel.HProdManDate;
            }
            this.txtHProdManNote.Text = BillOld.omodel.HProdManNote;
            this.txtHLstRequester.Text = BillOld.omodel.HLstRequester;
            if (ClsPub.isDate(BillOld.omodel.HLstRequesterDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHLstRequesterDate.Text = "";
            }
            else
            {
                this.txtHLstRequesterDate.Text = BillOld.omodel.HLstRequesterDate;
            }
            this.txtHLstRequesterNote.Text = BillOld.omodel.HLstRequesterNote;
            this.txtHRequesterSign.Text = BillOld.omodel.HRequesterSign;
            if (ClsPub.isDate(BillOld.omodel.HRequesterSignDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHRequesterSignDate.Text = "";
            }
            else
            {
                this.txtHRequesterSignDate.Text = BillOld.omodel.HRequesterSignDate;
            }
            this.txtHProdManSign.Text = BillOld.omodel.HProdManSign;
            if (ClsPub.isDate(BillOld.omodel.HProdManSignDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHProdManSignDate.Text = "";
            }
            else
            {
                this.txtHProdManSignDate.Text = BillOld.omodel.HProdManSignDate;
            }
            this.txtHLstManager.Text = BillOld.omodel.HLstManager;
            if (ClsPub.isDate(BillOld.omodel.HLstManagerDate) < ClsPub.isDate("1950-01-01"))
            {
                this.txtHLstManagerDate.Text = "";
            }
            else
            {
                this.txtHLstManagerDate.Text = BillOld.omodel.HLstManagerDate;
            }
            this.txtHLstManagerNote.Text = BillOld.omodel.HLstManagerNote;
 
            if (BillOld.omodel.HCommDate > ClsPub.isDate("1950-01-01"))
            {
                this.dtpHCommDate.Value = BillOld.omodel.HCommDate;
            }
            //
            if (BillOld.omodel.HProdCheckDate > ClsPub.isDate("1950-01-01"))
            {
                this.dtpHProdCheckDate.Value = BillOld.omodel.HProdCheckDate;
            }
            //
            if (BillOld.omodel.HLstRequesterCheckDate > ClsPub.isDate("1950-01-01"))
            {
                this.dtpHLstRequesterCheckDate.Value = BillOld.omodel.HLstRequesterCheckDate;
            }
            //
            if (BillOld.omodel.HLstCommDate > ClsPub.isDate("1950-01-01"))
            {
                this.dtpHLstCommDate.Value = BillOld.omodel.HLstCommDate;
            }
            //
 
            this.cmbHSelType.Text = BillOld.omodel.HSelType;
            this.cmbHCheckItem.Text = BillOld.omodel.HCheckItem;
 
            //
            //this.txtHMaker.Text = BillOld.omodel.HMaker;
            //this.txtHMakeDate.Text = BillOld.omodel.HMakeDate;
            //this.txtHChecker.Text = BillOld.omodel.HChecker;
            //this.txtHCheckDate.Text = BillOld.omodel.HCheckDate;
            this.txtHCloseMan.Text = BillOld.omodel.HBacker;
            if (BillOld.omodel.HBackDate > ClsPub.isDate("1950-01-01"))
            {
                this.txtHCloseDate.Text = BillOld.omodel.HBackDate.ToShortDateString();
            }
            //this.txtHDeleteMan.Text = BillOld.omodel.HDeleteMan;
            //this.txtHDeleteDate.Text = BillOld.omodel.HDeleteDate;
            //this.txtHUpDater.Text = BillOld.omodel.HUpDater;
            //this.txtHUpDateDate.Text = BillOld.omodel.HUpDateDate;
            //加载表体
            //int i = 0;
            //foreach (ClsXt_CheckExtendSub oSub in BillOld.DetailColl)
            //{
            //    if (i >= grdMain.RowCount - 1)
            //        grdMain.Rows.Add();
            //    //
            //    grdMain.Rows[i].Cells[HSnoCol].Value = Convert.ToString(i+1); 
            //    grdMain.Rows[i].Cells[HSendStatusCol].Value = oSub.HSendStatus.ToString().Trim();
            //    grdMain.Rows[i].Cells[HSendManCol].Value = oSub.HSendMan.ToString().Trim();
            //    grdMain.Rows[i].Cells[HDateCol].Value = oSub.HDate.ToString().Trim();
            //    grdMain.Rows[i].Cells[HDescriptionCol].Value = oSub.HDescription.ToString().Trim();
 
            //    i = i + 1;
            //}
            //GRID允许刷新
            //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDBuffered;
            //
            Sub_OperStatus();
        }
 
        public void Sub_ShowBillByID()
        {
            //判断是否存在单据
            if (SeBillNo == "")
            {
                return;
            }
            DAL.ClsA3_Customer_View oCus = new DAL.ClsA3_Customer_View();
            //清空
            //Sub_ClearBill();
            //grid禁止刷新
            //grdMain.Redraw = VSFlex7.RedrawSettings.flexRDNone;
            //加载表头
            //
            //
            if (oCus.GetInfoByNumber(HCusNumber))
            {
                this.txtHCusNumber.Text = oCus.omodel.HNumber;
                this.txtHCusName.Text = oCus.omodel.HName;
            }
            else
            {
                this.txtHCusNumber.Text = "";
                this.txtHCusName.Text = "";
            }
            this.txtHBillNo.Text = SeBillNo;
            this.dtpHCommDate.Value = DBUtility.ClsPub.isDate(HCommDate);
            this.txtHRequester.Text = DBUtility.ClsPub.CurUserName;
            this.txtHRequestDate.Text = DBUtility.ClsPub.GetServerDate(-1);
            //
            Sub_OperStatus();
        }
 
        //单据完整性判断          未完成
        private bool Sub_AllowSave()
        {
            //必输项目是否为空
 
            //if (txtHDeptID.Tag.ToString().Trim() == "0")
            //{
            //    MessageBox.Show("部门没有选择!", "提示");
            //    return false;
            //}
            //单据号是否重复
            //if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, txtHBillNo.Text.Trim(), BillStatus, BillOld.omodel.HItemID))
            //{
            //    MessageBox.Show("单据号重复!", "提示");
            //    return false;
            //}
            //明细表是否为零行
 
            return true;
        }
        //保存单据
        private bool Sub_SaveBill()
        {
            //判断权限
            //
            Int32 i;
            bool bResult;
            //网格失去焦点
            txtHBillNo.Focus();
            //
            BillNew = new BLL.ClsXt_CheckExtend_Ctl();
            if (!Sub_AllowSave())//单据完整性判断
                return false;
            ////是否是合理的会计期间
            int sYear = 0;
            int sPeriod = 0;
            //if (ClsPub.Sub_GetPeriodByDate(ClsPub.isDate(dtpHDate.Value, 0), ref sYear, ref sPeriod))
            //{
            //    if (!(sYear * 100 + sPeriod >= ClsPub.CurYear * 100 + ClsPub.CurPeriod))
            //    {
            //        MessageBox.Show("您选择的日期的会计期间已结账!请与管理员联系", "提示");
            //        return false;
            //    }
            //}
            //else
            //{
            //    MessageBox.Show("您选择的日期不属于合理的会计期间!请与管理员联系", "提示");
            //    return false;
            //}
            //赋值ID
            if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
            {
                BillNew.omodel.HItemID = BillOld.omodel.HItemID;
                SeBillNo = BillOld.omodel.HBillNo;
            }
            //主类赋值
            BillNew.omodel.HBillNo = this.txtHBillNo.Text.Trim();  //在赋值类前就处理好字符串和数字
            BillNew.omodel.HCommDate = this.dtpHCommDate.Value;
            BillNew.omodel.HCusNumber = this.txtHCusNumber.Text;
            BillNew.omodel.HSelType = this.cmbHSelType.Text;
            BillNew.omodel.HType = this.txtHType.Text;
            BillNew.omodel.HTypeNote = this.txtHTypeNote.Text;
            BillNew.omodel.HRequester = this.txtHRequester.Text;
            BillNew.omodel.HRequestDate = this.txtHRequestDate.Text;
            BillNew.omodel.HRequestNote = this.txtHRequestNote.Text;
            BillNew.omodel.HStatus = 2;
            //
            //明细类赋值
            //保存完毕后处理
            if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
            {
                bResult = BillNew.AddBill(ref ClsPub.sExeReturnInfo);
            }
            else
            {
                //bResult = BillNew.ModifyBill(BillNew.HItemID, ref ClsPub.sExeReturnInfo);
                bResult = false;
            }
            //提示
            if (bResult == true)
            {
                BillChange = true;
                MessageBox.Show("单据存盘完毕!单据号:" + this.txtHBillNo.Text.Trim(), "提示");
                if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew)
                {
                    SeBillNo = BillNew.omodel.HBillNo;
                    Sub_ShowBill();
                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
                }
                else if (BillStatus == DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify)
                {
                    BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify;
                }
                this.Sub_OperStatus();
                return true;
            }
            else
            {
                MessageBox.Show("保存失败!原因:" + ClsPub.sExeReturnInfo, "提示");
                return false;
            }
        }
        #endregion
 
 
        #region 窗体处理方法
        //初始化GRID
        private void initGrid()
        {
            //表1
            //grdMain.RowTemplate.Height = 18;                //行高设置
            //grdMain.RowTemplate.MinimumHeight = 18;         //最小行高
            //grdMain.ColumnHeadersHeight = 35;               //标题行高
            //grdMain.RowHeadersVisible = false;              //固定列是否显示
            //grdMain.ColumnHeadersVisible = true;            //固定行是否显示
            //grdMain.ColumnCount = 6;                       //总列数
            //grdMain.RowCount = 0;                           //总行数
            //grdMain.RowCount = 1;                          //总行数
            ////设置 标题
            //grdMain.Columns[HTagCol].HeaderText = "";
            //grdMain.Columns[HSnoCol].HeaderText = "序号";
            //grdMain.Columns[HSendManCol].HeaderText = "回复人";
            //grdMain.Columns[HSendStatusCol].HeaderText = "类型";
            //grdMain.Columns[HDateCol].HeaderText = "回复日期";
            //grdMain.Columns[HDescriptionCol].HeaderText = "回复内容";
            ////格式化
            ////隐藏列
            //grdMain.Columns[HTagCol].Visible = false;
            ////表格设置
            //for (int i = 0; i < grdMain.ColumnCount; i++)
            //{
            //    grdMain.Columns[i].Width = 100;                                 //设置 列宽
            //    grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; //列 排序模式
            //}
            ////
            //grdMain.RowsDefaultCellStyle.SelectionForeColor = Color.Black;          //行选中字体颜色
            //grdMain.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;  //内容布局(居中,靠右)
            //grdMain.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//标题行布局(居中,靠右)
            //grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect;                     //选行模式
            //grdMain.ReadOnly = true;                                               //是否只读
            //grdMain.EditMode = DataGridViewEditMode.EditOnEnter;                    //编辑模式
            //grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;  //标题行高 调整模式
            //grdMain.EnableHeadersVisualStyles = true;                              //标题 显示样式
            //grdMain.AllowUserToAddRows = false;             //是否允许自增--否
            //grdMain.AllowUserToDeleteRows = false;          //是否允许删除--否 
            //grdMain.AllowUserToResizeColumns = true;         //允许调整列宽--是
            //grdMain.AllowUserToResizeRows = false;           //允许调整行高--否
            //grdMain.AllowUserToOrderColumns = false;            //是否允许拖拽列
            //grdMain.BackgroundColor = Color.White;              //网格背景色
            //grdMain.GridColor = Color.LightGray;                //网格线颜色
            //grdMain.DefaultCellStyle.SelectionBackColor = Color.AntiqueWhite;   //选中时背景颜色
            //grdMain.ShowCellToolTips = false;                                   //鼠标停留 显示提示
            ////
            ////
            //ClsPub.GetGridView(grdMain, this.Name);//设置列宽
            //设置可编辑列和合计列
        }
 
        #endregion
 
 
 
 
    }
}