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
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 SQLHelper;
using DBUtility;
using System.Threading;
using System.IO;
using Pub_Class;
 
namespace WarM
{
    public partial class Kf_WeighToBarCode : Form
    {
        public Kf_WeighToBarCode()
        {
            InitializeComponent();
        }
        public frmBillQueryCondition_New frmCondition;
        public string ModCaption = "称重入库";
        public const string ModName = "85";
        public Int64 HInterID = 0;
        public string HBillNo = "";
        public string HBillType = "1202";
        public Int64 HAuxPropID = 0;
        public Int64 HUnitID = 0;
        public Int64 HWhID = 0;
        public bool HSPFlag = false;
        public Int64 HSPID = 0;
        public Int64 HSourceInterID = 0;
        public Int64 HSourceEntryID = 0;
        public string HSourceBillNo = "";
        public string HSourceBillType = "";
        public Int64 ProcessExchangeInterID = 0;
        public Int64 HSupID = 0;
        public double HSourceQty = 0;
        public double HMaterWeight = 0;         //物料克重
        public string HMaker = DBUtility.ClsPub.CurUserName;
        public Int64 HStockOrgID = DBUtility.ClsPub.HOrgID;
        public DateTime HDate = DateTime.Today;
        public long PrintQty = 0;               //允许条码打印次数
        public string PrintQtyCtl = "";         //条码打印次数控制
        public string UpdatePrintQtyCtl = "";   //条码打印次数更新
        public string sBarCodeItemID = "";      //条码自增列
        public DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
 
        #region  //固定代码
 
        //清空界面
        public void Sub_ClearBill()
        {
            cmbHBarCodeType.Items.Clear();
            cmbHBarCodeType.Items.Add("唯一条码");
            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
            txtHBarCode.Text = "";
            grdMain.DataSource = null;
            grdSub.DataSource = null;
            chkHDYFlag.Checked = true;
        }
 
        //窗体加载
        private void Kf_WeighToBarCode_Load(object sender, EventArgs e)
        {
            frmCondition = new frmBillQueryCondition_New();
            this.Text = ModCaption;
            Sub_GetSystemParameter();
        }
 
        private void initGrid()
        {
            DBUtility.Xt_BaseBillFun.initGridList(grdMain, this.Name);
            DBUtility.Xt_BaseBillFun.initGridList(grdSub, this.Name + "grdSub");
        }
 
        //获取系统参数信息
        private void Sub_GetSystemParameter()
        {
            //获取系统参数
            ClsXt_SystemParameter oSystemParameter = new ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref DBUtility.ClsPub.sExeReturnInfo) == false)
            {
                MessageBox.Show("获取系统参数失败!原因:" + DBUtility.ClsPub.sExeReturnInfo, "提示");
                return;
            }
            else
            {
                PrintQty = oSystemParameter.omodel.BarCode_PrintQty;
                PrintQtyCtl = oSystemParameter.omodel.BarCode_PrintQtyCtl;
                UpdatePrintQtyCtl = oSystemParameter.omodel.BarCode_UpdatePrintQtyCtl;
            }
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            initGrid();
            this.Sub_ClearBill();//清空界面
 
            //获取生产入库单单据ID、单据号
            DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetWeighSource_TempList '" + HMaker + "'," + HStockOrgID.ToString(), "h_p_KF_GetWeighSource_TempList");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //得到新单据ID
                HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);    //得到新单据号
            }
            else if (DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HBack"]) == 1)
            {
                HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);           //得到新单据ID
                HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);    //得到新单据号
            }
            else
            {
                HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
                HBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBillNo"]);
            }
            Source_Display();
            BarCode_Display();
            if (grdSub.Rows.Count > 0)
            {
                grdSub.Rows[0].Selected = true;
                SourceBill();
                txtHQty.Focus();
            }
            else
            {
                txtHBarCode.Focus();
            }
        }
 
        private void grdMain_Paint(object sender, PaintEventArgs e)
        {
            GraphicsGrid();
        }
 
        private void GraphicsGrid()
        {
            DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
        }
 
        private void grdSub_Paint(object sender, PaintEventArgs e)
        {
            GraphicsGridSub();
        }
 
        private void GraphicsGridSub()
        {
            DBUtility.Xt_BaseBillFun.GraphicsGrid(grdSub);
        }
 
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
        }
 
        private Int32 Fun_GetSubCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdSub);
        }
 
        //保存列宽
        private void bclk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
            DBUtility.Xt_BaseBillFun.SaveGrid(grdSub, this.Name + "grdSub");
        }
 
        //默认列宽
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdSub, this.Name + "grdSub");
        }
 
        #endregion
 
        #region  //刷新
 
        private void sx_Click_1(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }
 
        #endregion
 
        #region  //打印
 
        GridppReport Report;
 
        private void dy_Click_1(object sender, EventArgs e)
        {
            //打印前判断条码是否超过允许可打印次数
            if (ReportPrintBegin())
            {
                return;
            }
 
            //选择打印模板
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(false);
                Thread.Sleep(1000);
            }
        }
 
        //打印前判断条码是否超过允许可打印次数
        private bool ReportPrintBegin()
        {
            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
            string sHRemark = "";
            sBarCodeItemID = "";
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
            {
                sBarCodeItemID = sBarCodeItemID + "," + DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
            }
            sBarCodeItemID = sBarCodeItemID.Remove(0, 1);
 
            if (PrintQtyCtl == "Y")
            {
                if (oBar.Set_CheckPrintQty(sBarCodeItemID, PrintQty, ref sHRemark))
                {
                    MessageBox.Show(sHRemark);
                    return true;
                }
                return false;
            }
            else
            {
                return false;
            }
        }
 
        private void Sub_SetReport(string sOpenTmp)
        {
            //判断行数
            for (int i = 0; i < grdMain.Rows.Count; i++)
            {
                grdMain.Rows[i].Cells[0].Value = "";
            }
            for (int i = 0; i < grdMain.SelectedRows.Count; i++)
            {
                grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
            }
            //
            Report = new GridppReport();
            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
        }
 
        //填入单据表头信息
        private void ReportBeforePostRecord()//your report?kao
        {
            try
            {
                //Report.FieldByName("物料代码").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("物料代码")].Value.ToString();
                //Report.FieldByName("物料名称").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("物料名称")].Value.ToString();
                //Report.FieldByName("规格型号").AsString = grdMain.Rows[CurRows].Cells[Fun_GetCol("规格型号")].Value.ToString();
            }
            catch (Exception e)
            {
                MessageBox.Show("打印失败!表头:" + e.Message);
            }
        }
 
        //填入单据表体信息
        private void ReportFetchRecordByDataTable()
        {
            try
            {
                DataTable ds = new DataTable();
                BLL.Utility.FillRecordToReport_Sel(Report, grdMain, ds, Fun_GetCol("选择"));
            }
            catch (Exception e)
            {
                MessageBox.Show("打印失败!表体:" + e.Message);
            }
        }
 
        //打印结束后回填条码打印次数
        private void ReportPrintEnd()
        {
            DAL.ClsGy_BarCodeBill_Ctl oBar = new DAL.ClsGy_BarCodeBill_Ctl();
            if (UpdatePrintQtyCtl == "Y")
            {
                oBar.Set_UpdatePrintQty(sBarCodeItemID);
            }
        }
 
        #endregion
 
        #region  //换班
 
        private void hb_Click(object sender, EventArgs e)
        {
            this.Sub_SaveBill();
            timer1.Enabled = true;
        }
 
        private bool Sub_SaveBill()
        {
            //称重记录列表是否有记录判断
            bool b = false;
            for (int i = 0; i < grdMain.RowCount; i++)
            {
                b = true;
                break;
            }
            if (b == false)
            {
                MessageBox.Show("当前称重记录列表无数据,不允许换班生成单据!", "提示");
                return false;
            }
 
            //判断会计期是否合理
            string s = "";
            int sYear = 0;
            int sPeriod = 0;
            if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
            {
                MessageBox.Show(s, "提示");
                return false;
            }
 
            try
            {
                oCn.BeginTran();
                //生成出入库单据
                //插入子表
                DataSet ds = oCn.RunProcReturn("EXEC h_p_Kf_ProductInBillSub_Insert_New " + HInterID.ToString() + ",'" + HBillNo + "','" + HSourceBillType + "'", "h_p_Kf_ProductInBillSub_Insert_New");
                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                }
                else if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][0]) != "OK")
                {
                    oCn.RollBack();
                    MessageBox.Show("生成入库单失败,当前称重记录列表无数据,不允许换班生成单据!", "提示");
                    return false;
                }
                //插入主表
                oCn.RunProc("Insert Into Kf_ICStockBillMain " +
                    "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMainSourceBillType" +
                    ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
                    ",HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID" +
                    ",HKeeperID,HDeptID,HExplanation,HInnerBillNo,HRedBlueFlag" +
                    ",HSTOCKORGID,HOWNERID" +
                    ") Values ("
                    + "'" + HBillType + "','" + HBillType + "'," + HInterID.ToString() + ",'" + HBillNo + "',convert(varchar(10),getdate(),120),''"
                    + ", " + sYear.ToString() + "," + sPeriod.ToString() + ",'" + txtHRemark.Text + "','" + HMaker + "',getdate()"
                    + ", 0,0,0,0,0,0"
                    + ", 0," + txtHDeptName.Tag.ToString() + ",'','',0"
                    + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ") ");
                //更新关联数量
                oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToProductIn_Add " + HInterID.ToString());
                //回填已生单状态
                oCn.RunProc("Update KF_WeighSource_Temp set HRelationInterID=1 where HInterID= " + HInterID.ToString());
                MessageBox.Show("生成生产入库单:" + HBillNo + " 成功!", "提示");
                oCn.Commit();
                return true;
            }
            catch (Exception e)
            {
                oCn.RollBack();
                MessageBox.Show("生成生产入库单失败!" + e.Message);
                return false;
            }
        }
 
        #endregion
 
        #region  //退出
 
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        #endregion
 
        #region  //扫描条码
 
        private void txtHBarCode_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Return)
            {
                if (!AddSource())
                {
                    txtHBarCode.Focus();
                    txtHBarCode.SelectAll();
                    return;
                }
                Source_Display();
                grdSub.Rows[0].Selected = true;
                DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
                SourceBill();
                txtHBarCode.Text = "";
                txtHQty.Focus();
            }
        }
 
        private void cmdOK_Click(object sender, EventArgs e)
        {
            if (!AddSource())
            {
                txtHBarCode.Focus();
                txtHBarCode.SelectAll();
                return;
            }
            Source_Display();
            grdSub.Rows[0].Selected = true;
            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
            SourceBill();
            txtHBarCode.Text = "";
            txtHQty.Focus();
        }
 
        private bool AddSource()
        {
            //将扫描单据号写入临时表
            DataSet ds = oCn.RunProcReturn("exec h_p_Kf_AddSource_WeighToBarCode " + HInterID.ToString() + ",'" + HBillNo + "','" + txtHBarCode.Text.Trim() + "','" + HMaker + "'," + HStockOrgID.ToString(), "h_p_Kf_AddSource_WeighToBarCode");
            if (ds == null || ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("扫描条码写入临时表发生错误!", "提示");
                return false;
            }
            else if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0][0]) == 1)
            {
                MessageBox.Show(DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HRemark"]), "提示");
                return false;
            }
            else
            {
                return true;
            }
        }
 
        #endregion
 
        #region  //选单
 
        private void cmdSourceBillNo_Click(object sender, EventArgs e)
        {
            //初始化右边表头信息
            cmbHBarCodeType.Items.Clear();
            cmbHBarCodeType.Items.Add("唯一条码");
            DBUtility.Xt_BaseBillFun.Sub_ClearBill(gbUp);
 
            if (grdSub.CurrentRow == null)
            {
                MessageBox.Show("请在左边单据列表中选择一行单据!", "提示");
                return;
            }
            else if (grdSub.SelectedRows.Count != 1)
            {
                MessageBox.Show("不允许同时选择多行单据,请重新选择单据!");
                return;
            }
            else
            {
                SourceBill();
                txtHQty.Focus();
            }
        }
 
        #endregion
 
        #region  //保存
 
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (!Sub_AllowSave())
            {
                return;
            }
            SaveBarCode();
            BarCode_Display();
            grdMain.Rows[0].Selected = true;
 
            sBarCodeItemID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.SelectedRows[0].Index].Cells[Fun_GetCol("HItemID")].Value).ToString();
            //自动打印
            if (chkHDYFlag.Checked == true)
            {
                //打印条码
                Sub_SetReport("物料条码");
                Report.Print(false);
                Thread.Sleep(1000);
            }
            else
            {
                //选择打印模板
                BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
                oFrm.sBillName = ModName;
                oFrm.sBillModel = ModCaption;
                oFrm.ShowDialog();
                if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
                {
                    Sub_SetReport(oFrm.sOpenTmp);
                    Report.Print(false);
                    Thread.Sleep(1000);
                }
            }
 
            txtHQty.Text = "";
            txtHWeightQyt.Text = "";
            txtHKDQty.Text = "";
            txtHBarcodeNo.Text = "";
            txtHRemark.Text = "";
            txtHRemark.Tag = 0;
            txtHQty.Focus();
        }
 
        //条码生成前判断
        private bool Sub_AllowSave()
        {
            if (HInterID==0 || HBillNo=="")
            {
                MessageBox.Show("获取条码对应单据ID或单据号失败,请重新刷新界面!", "提示");
                return false;
            }
            else if (DBUtility.ClsPub.isDoule(txtHQty.Text) == 0)
            {
                MessageBox.Show("请输入正确米数!", "提示");
                return false;
            }
            else if (DBUtility.ClsPub.isDoule( txtHWeightQyt.Text) == 0)
            {
                MessageBox.Show("请输入正确重量!", "提示");
                return false;
            }
            else if (DBUtility.ClsPub.isDoule(txtHQty.Text)- DBUtility.ClsPub.isDoule(txtHKDQty.Text) <= 0)
            {
                MessageBox.Show("输入的扣点数不能大于米数!", "提示");
                return false;
            }
            else if (DBUtility.ClsPub.isInt(txtHBarcodeNo.Text) == 0)
            {
                MessageBox.Show("请输入包号!", "提示");
                return false;
            }
            else if (HWhID==0)
            {
                MessageBox.Show("物料未设置默认仓库,获取仓库信息失败,请先设置物料默认仓库!", "提示");
                return false;
            }
            else if (HSPFlag==true && HSPID==0)
            {
                MessageBox.Show("物料默认仓库启用了仓位,但未设置仓位,获取仓位信息失败,请先设置物料默认仓位!", "提示");
                return false;
            }
 
            //实际克重=重量/米数*1000,实际克重超出物料维护克重的百分之二十或不足物料维护克重的百分之八十,预警提示
            double sQty = 0;    //实际克重
            sQty = DBUtility.ClsPub.isDoule(txtHWeightQyt.Text) / DBUtility.ClsPub.isDoule(txtHQty.Text) * 1000;
 
            if (sQty > HMaterWeight * 1.2 || sQty < HMaterWeight * 0.8)
            {
                if (MessageBox.Show("物料维护克重为:"+HMaterWeight.ToString()+ ",实际克重为:" + sQty.ToString() + ",所输入实际克重超出物料维护克重的百分之二十或不足物料维护克重的百分之八十,请检查输入的数据是否正确!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            return true;
        }
 
        //生成条码
        private void SaveBarCode()
        {
            int LSHlen = 6;             //流水号长度
            Int64 LSH = 0;              //流水号
            string LSH2 = "";           //流水号转换成字符
            string HMaterID = "";       //物料内码
            string HBatchNo = "";       //批次
            string sDate = "";          //日期
            string sYear = "";          //年
            string sPeriod = "";        //月
            string sDay = "";           //日
            string sTMNumber = "";      //条码自定义前缀
            string TM = "";             //条码编号
            DataSet Ds;
 
            HMaterID = DBUtility.ClsPub.isStrNull(txtHMaterNumber.Tag);
            HBatchNo = DBUtility.ClsPub.isStrNull(txtHBatchNo.Text);
            //日期获取方式
            sDate = dtpHDate.Value.ToShortDateString();
            sYear = DBUtility.ClsPub.isDate(sDate).Year.ToString().Substring(2, 2);
            sPeriod = "0" + DBUtility.ClsPub.isDate(sDate).Month.ToString();
            sPeriod = sPeriod.Substring(sPeriod.Length - 2, 2);
            sDay = "0" + DBUtility.ClsPub.isDate(sDate).Day.ToString();
            sDay = sDay.Substring(sDay.Length - 2, 2);
            //==================================
            if (cmbHBarCodeType.Text == "唯一条码")
            {
                //条码前缀 = 组织代码 + 物料内码 + 年 + 月 + 日
                sTMNumber = DBUtility.ClsPub.HOrgNumber + HMaterID + sYear + sPeriod + sDay;
                Ds = oCn.RunProcReturn("exec h_p_WMS_GetMaxNo '" + sTMNumber + "'", "h_p_WMS_GetMaxNo");    //获取最大流水号
                LSH = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
                LSH = LSH + 1;
                LSH2 = LSH.ToString();
                while (LSH2.Length < LSHlen)  //如果流水号小于6位数前面补0
                {
                    LSH2 = "0" + LSH2;
                }
                TM = sTMNumber + LSH2;
            }
            else if (cmbHBarCodeType.Text == "品种条码")
            {
                TM = DBUtility.ClsPub.HOrgNumber + HMaterID;
            }
            else if (cmbHBarCodeType.Text == "批次条码")
            {
                TM = DBUtility.ClsPub.HOrgNumber + HMaterID + HBatchNo;
            }
            else
            {
                MessageBox.Show("错误的条码类型,不能生成条码!");
                return;
            }
 
            string HBarCode = "";
            string HBarCodeType = "";
            double HNowQty = 0;         //米数
            double HMaterialJQty = 0;   //重量
            double HMaterialMQty = 0;   //扣点数
            double HQty = 0;            //数量
            Int64 HDeptID = 0;
            string HRemark = "";
            string HMaterName = "";
            string HMaterModel = "";
            string ProcessExchangeBillNo = "";
            Int64 HBarcodeNo = 0;       //包数
            Int64 HBadReasonID = 0;     //不良原因ID
            string HCusMaterName = "";  //客户物料名称
            string HCusModel = "";      //客户规格型号
 
            HBarCode = TM;
            HBarCodeType = DBUtility.ClsPub.isStrNull(cmbHBarCodeType.Text);
            HNowQty = DBUtility.ClsPub.isDoule(txtHQty.Text);
            HMaterialJQty = DBUtility.ClsPub.isDoule(txtHWeightQyt.Text);
            HMaterialMQty = DBUtility.ClsPub.isDoule(txtHKDQty.Text);
            HQty = HNowQty- HMaterialMQty;
            HDeptID = DBUtility.ClsPub.isLong(txtHDeptName.Tag);
            HRemark = DBUtility.ClsPub.isStrNull(txtHRemark.Text);
            HMaterName = DBUtility.ClsPub.isStrNull(txtHMaterName.Text);
            HMaterModel = DBUtility.ClsPub.isStrNull(txtHMaterModel.Text);
            ProcessExchangeBillNo = DBUtility.ClsPub.isStrNull(txtHBillNo.Text);
            HBarcodeNo = DBUtility.ClsPub.isLong(txtHBarcodeNo.Text);
            HBadReasonID = DBUtility.ClsPub.isLong(txtHRemark.Tag);
            HCusMaterName = DBUtility.ClsPub.isStrNull(txtHCusMaterName.Text);
            HCusModel = DBUtility.ClsPub.isStrNull(txtHCusModel.Text);
 
            try
            {
                oCn.BeginTran();
                //写入条码档案    (客户物料名称HCusMaterName存入HMaterialModel字段,客户规格型号HCusModel存入HCusModel字段,不良原因ID存入HCustomQty1字段)
                oCn.RunProc("Insert into Gy_BarCodeBill " +
                "(HBarCode,HBarCodeType,HMaterID,HUnitID,HQty" +
                ",HBatchNo,HSupID,HGroupID,HMaker,HMakeDate,HPrintQty,HinitQty" +
                ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HEndQty " +
                ",HBarcodeQtys,HBarcodeNo,HDeptID,HWhID,HSPID,HRemark " +
                ",HCusID,HCusType,HEndDate,HWorkLineName,HBarCodeDate,HMaterialJQty,HMaterialMQty,HNowQty " +
                ",HSTOCKORGID,HOWNERID,HSeOrderBillNo,HInterID,HGiveAwayFlag " +
                ",HOrderInterID,HOrderEntryID,HOrderBillNo,HCustomQty1,HMaterialModel,HCusModel " +
                ",HMaterName,HMaterModel,HPinfan,HAuxPropID,HMTONo,HInnerBillNo,HLogo " +
                ") Values ("
                + "'" + HBarCode + "','" + HBarCodeType + "'," + HMaterID.ToString() + "," + HUnitID.ToString() + "," + HQty.ToString()
                + ",'" + HBatchNo + "'," + HSupID.ToString() + ",0,'" + HMaker + "',getdate(),0," + HQty.ToString()
                + ", " + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillNo + "','" + HSourceBillType + "',''"
                + ", 1," + HBarcodeNo.ToString() + "," + HDeptID.ToString() + "," + HWhID.ToString() + "," + HSPID.ToString() + ",'" + HRemark + "'"
                + ", 0,'',getdate(),'','" + sDate + "'," + HMaterialJQty.ToString() + "," + HMaterialMQty.ToString() + "," + HNowQty.ToString()
                + ", " + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",''," + HInterID.ToString() + ",0"
                + ", " + ProcessExchangeInterID.ToString() + ",0,'" + ProcessExchangeBillNo + "'," + HBadReasonID.ToString() + ",'" + HCusMaterName + "','" + HCusModel + "'"
                + ",'" + HMaterName + "','" + HMaterModel + "',''," + HAuxPropID.ToString() + ",'','','1')");
 
                //回填最大流水号
                oCn.RunProc("exec h_p_WMS_SetMaxNo_QTY '" + sTMNumber + "',1 ");
 
                //回填源单临时表HInterID
                oCn.RunProc("update a set a.HInterID=" + HInterID.ToString() + ",a.HBillNo='" + HBillNo +"',a.HRelationInterID= 0 from KF_WeighSource_Temp a where a.HInterID<>" + HInterID.ToString() + " and a.HMaker='" + HMaker + "' and a.HSourceBillNo='" + ProcessExchangeBillNo + "'");
 
                //写入条码出入库临时表
                oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
                    "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
                    ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
                    ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
                    ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                    ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
                    ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
                    ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
                    " Values("
                    + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HMaterID.ToString() + "," + HAuxPropID.ToString() + ",0"
                    + "," + HWhID.ToString() + ",0," + HSPID.ToString() + ",0,0,''"
                    +",0," + HQty.ToString() + ",1,'" + HBatchNo + "','" + HBarCode + "',''"
                    +",'" + HMaker + "',getdate()," + HSourceInterID.ToString() + "," + HSourceEntryID.ToString() + ",'" + HSourceBillType + "','" + HSourceBillNo + "'"
                    +",0,0,'',0,'',0"
                    +"," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + "," + HStockOrgID.ToString() + ",'','称重入库生成','2'"
                    +",0,0,'',0)");
 
                oCn.Commit();
            }
            catch (Exception e)
            {
                oCn.RollBack();
                MessageBox.Show("条码生成失败!" + e.Message);
            }
        }
 
        #endregion
 
        #region  //返回信息
 
        //返回源单列表信息
        private void SourceBill()
        {
            txtHBillNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("单据号")].Value);
            txtHDeptName.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HDeptID")].Value);
            txtHDeptName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("车间")].Value);
            txtHMaterNumber.Tag = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterID")].Value);
            txtHMaterNumber.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("物料代码")].Value);
            txtHMaterName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("物料名称")].Value);
            txtHMaterModel.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("规格型号")].Value);
            txtHBatchNo.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("批号")].Value);
            txtHCusMaterName.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusMaterName")].Value);
            txtHCusModel.Text = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HCusModel")].Value);
            HAuxPropID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HAuxPropID")].Value);
            HUnitID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HUnitID")].Value);
            HWhID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HWhID")].Value);
            HSPFlag = DBUtility.ClsPub.isBool(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSPFlag")].Value);
            HSPID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSPID")].Value);
            HSourceInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceInterID")].Value);
            HSourceEntryID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceEntryID")].Value);
            HSourceBillNo = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("生产订单")].Value);
            HSourceBillType = DBUtility.ClsPub.isStrNull(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSourceBillType")].Value);
            HSourceQty = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("数量")].Value);
            ProcessExchangeInterID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("ProcessExchangeInterID")].Value);
            HSupID = DBUtility.ClsPub.isLong(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HSupID")].Value);
            HMaterWeight = DBUtility.ClsPub.isDoule(grdSub.SelectedRows[0].Cells[Fun_GetSubCol("HMaterWeight")].Value);
        }
 
        //返回源单列表信息
        private void Source_Display()
        {
            DataSet DSet = oCn.RunProcReturn("exec h_p_KF_GetWeighSource_TempList '" + HMaker + "'," + HStockOrgID.ToString(), "h_p_KF_GetWeighSource_TempList");
            grdSub.DataSource = DSet.Tables[0].DefaultView;
            //冻结
            int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
            string s = frmCondition.cmbHComplete.Text;
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdSub, this.Name + "grdSub", s, FrCol);
            //画线
            GraphLine();
        }
 
        //返回称重记录列表信息
        private void BarCode_Display()
        {
            DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID desc", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
            grdMain.DataSource = DSet.Tables[0].DefaultView;
            //冻结
            int FrCol = DBUtility.ClsPub.isInt(frmCondition.txtFrozenCol.Text);
            string s = frmCondition.cmbHComplete.Text;
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
            //画线
            GraphLine();
        }
 
        private void GraphLine()
        {
            int MainIDCol = Fun_GetCol("hmainid");
            int SubIDCol = Fun_GetCol("hsubid");
            string s = frmCondition.cmbHComplete.Text;
            long n = 0;
            DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
 
            int MainIDCol2 = Fun_GetSubCol("hmainid");
            int SubIDCol2 = Fun_GetSubCol("hsubid");
            string s2 = frmCondition.cmbHComplete.Text;
            long n2 = 0;
            DBUtility.Xt_BaseBillFun.GraphLine(grdSub, MainIDCol2, SubIDCol2, s2, ref n2);
        }
 
        #endregion
 
        #region  //作废
        private void cmdZF_Click(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow == null)
            {
                MessageBox.Show("请先选择需要作废的条码!", "提示");
                return;
            }
            else
            {
                if (MessageBox.Show("确定要作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    string HRemark = "";
                    string HItemID = "";
                    string HBarCode = "";
                    string HBarCode2 = "";
                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                    {
                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value) + "'";
                        if (i != 0 && i % 100 == 0)
                        {
                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        else
                        {
                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("作废标记")].Value) != "")
                        {
                            HRemark = HRemark + "、" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                    }
                    if (HRemark != "")
                    {
                        MessageBox.Show("所选条码编号:"+ HRemark.Remove(0, 1)+" 已作废,不允许重复作废!", "提示");
                        return;
                    }
                    HItemID = HItemID.Remove(0, 1);     //去掉字符串第一个字符
                    HBarCode = HBarCode.Remove(0, 1);
                    HBarCode2 = HBarCode2.Remove(0, 1);
 
                    try
                    {
                        oCn.BeginTran();
                        string[] NewBarCode;
                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
 
                        //作废条码
                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=1,HDeleteMan='" + DBUtility.ClsPub.CurUserName + "',HDeleteDate=getdate() where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                        //删除条码出入库临时表记录
                        oCn.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode in (" + HBarCode + ")", ref DBUtility.ClsPub.sExeReturnInfo);
                        //写入系统日志
                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
                        {
                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','作废条码:" + NewBarCode[i] + "','称重入库模块','" + DBUtility.ClsPub.IPAddress + "','作废'", ref DBUtility.ClsPub.sExeReturnInfo);
                        }
                        oCn.Commit();
                    }
                    catch (Exception e2)
                    {
                        oCn.RollBack();
                        MessageBox.Show("作废条码失败!" + e2.Message, "提示");
                        return;
                    }
                    //刷新称重记录列表信息
                    BarCode_Display();
                    MessageBox.Show("所选条码编号:" + HBarCode.Remove(0, 1) + " 作废成功!", "提示");
                }
            }
        }
 
        #endregion
 
        #region  //反作废
        private void cmdFZF_Click(object sender, EventArgs e)
        {
            if (grdMain.CurrentRow == null)
            {
                MessageBox.Show("请先选择需要反作废的条码!", "提示");
                return;
            }
            else
            {
                if (MessageBox.Show("确定要反作废所选条码?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                else
                {
                    string HRemark = "";
                    string HItemID = "";
                    string HBarCode = "";
                    string HBarCode2 = "";
                    for (int i = 0; i <= grdMain.SelectedRows.Count - 1; i++)
                    {
                        HItemID = HItemID + "," + DBUtility.ClsPub.isLong(grdMain.SelectedRows[i].Cells[Fun_GetCol("hmainid")].Value.ToString());
                        HBarCode = HBarCode + ",'" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value) + "'";
                        if (i != 0 && i % 100 == 0)
                        {
                            HBarCode2 = HBarCode2 + "#" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        else
                        {
                            HBarCode2 = HBarCode2 + "," + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                        if (DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("作废标记")].Value) == "")
                        {
                            HRemark = HRemark + "、" + DBUtility.ClsPub.isStrNull(grdMain.SelectedRows[i].Cells[Fun_GetCol("条码编号")].Value);
                        }
                    }
                    if (HRemark != "")
                    {
                        MessageBox.Show("所选条码编号:" + HRemark.Remove(0, 1) + " 未作废,不允许反作废!", "提示");
                        return;
                    }
                    HItemID = HItemID.Remove(0, 1);     //去掉字符串第一个字符
                    HBarCode = HBarCode.Remove(0, 1);
                    HBarCode2 = HBarCode2.Remove(0, 1);
 
                    try
                    {
                        oCn.BeginTran();
                        string[] NewBarCode;
                        NewBarCode = HBarCode2.Split(Convert.ToChar("#"));
 
                        //反作废条码
                        oCn.RunProc("update Gy_BarCodeBill set HStopflag=0,HDeleteMan='',HDeleteDate=null where HItemID in (" + HItemID + ")", ref DBUtility.ClsPub.sExeReturnInfo);
 
                        //删除条码出入库临时表记录
                        oCn.RunProc("delete from KF_PonderationBillMain_Temp where HInterID=" + HInterID.ToString() + " and HBillType='" + HBillType + "' and HBarCode in (" + HBarCode + ")", ref DBUtility.ClsPub.sExeReturnInfo);
 
                        //写入条码出入库临时表
                        oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
                        "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
                        ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
                        ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
                        ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                        ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
                        ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
                        ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
                        " select " + HInterID.ToString() + ",'" + HBillNo + "','" + HBillType + "',HMaterID,HAuxPropID,0" +
                        ",HWhID,0,HSPID,0,0,''" +
                        ",0,HQty,1,HBatchNo,HBarCode,''" +
                        ",'" + HMaker + "',getdate(),HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
                        ",0,0,'',0,'',0" +
                        ",HSTOCKORGID,HSTOCKORGID,HSTOCKORGID,'','称重入库生成-反作废','2'" +
                        ",0,0,'',0" +
                        "from Gy_BarCodeBill with(nolock) where HItemID in (" + HItemID + ")"
                        );
 
                        //写入系统日志
                        for (int i = 0; i <= NewBarCode.Length - 1; i++)
                        {
                            oCn.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.ComputerName + "','反作废条码:" + NewBarCode[i] + "','称重入库模块','" + DBUtility.ClsPub.IPAddress + "','反作废'", ref DBUtility.ClsPub.sExeReturnInfo);
                        }
                        oCn.Commit();
                    }
                    catch (Exception e2)
                    {
                        oCn.RollBack();
                        MessageBox.Show("反作废条码失败!" + e2.Message, "提示");
                        return;
                    }
                    //刷新称重记录列表信息
                    BarCode_Display();
                    MessageBox.Show("所选条码编号:" + HBarCode.Remove(0, 1) + " 反作废成功!", "提示");
                }
            }
        }
 
 
        #endregion
 
        #region  //备注   不良原因选择
        private void cmdHBadReasonID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_BadReason_View oBadReason = new DAL.ClsGy_BadReason_View();
            if (oBadReason.RefreshView())
            {
                this.txtHRemark.Text = oBadReason.oModel.HName;
                this.txtHRemark.Tag = oBadReason.oModel.HItemID.ToString();
            }
        }
 
        #endregion
 
 
 
 
 
 
 
    }
}