ch
2021-12-24 fa2d8a898b44bbd2c54ab83961b696e9bfeeb368
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
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
 
namespace DAL
{
    public class ClsKF_PonderationBillMain_Temp_View : DBUtility.ClsGy_Base_View
    {
        
        //
        public Model.ClsKF_PonderationBillMain_Temp omodel = new Model.ClsKF_PonderationBillMain_Temp();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); 
        public ClsKF_PonderationBillMain_Temp_View()
        {
            base.MvarReportTitle = "出入库条码临时表";
            base.MvarItemKey = "KF_PonderationBillMain_Temp";
            base.SQLName = "Select HItemID from KF_PonderationBillMain_Temp Order by HItemID ";
        }
        //
        public void Dispose()
        {
            GC.SuppressFinalize(this);
        }
        //
 
 
        #region 单据列表数据处理
 
        //显示物料明细列表、模治具列表、先进先出列表信息
        public DataSet GetBillEntry_TmpList(long HInterID, string HBillNo, string HBillType, ref string sMouldManagerCtl, ref string sFIFOCtl, ref string sErrMsg)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            string sSimpleMode = "N";  //是否启用扫码简易模式,只显示已扫码源单记录(Y,N)
 
            //获取系统参数
            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
            {
                sErrMsg = "单据号:" + HBillNo + ",单据ID:" + HInterID + ";返回物料明细列表时获取系统参数失败! " + sErrMsg;
                return null;
            }
 
            //判断是否启用器具管理(Y,N)
            if (oSystemParameter.omodel.WMS_MouldManagerCtl == "Y")   //启用模治具管理
            {
                sMouldManagerCtl = "Y";
            }
            //判断是否启用先进先出管理(Y,N),是否启用扫码简易模式,只显示已扫码源单记录(Y,N)
            if (HBillType == "1204")   //生产领料单
            {
                if (oSystemParameter.omodel.Kf_MateOutBill_FIFOCtl == "Y")   //生产领料单-先进先出控制
                {
                    sFIFOCtl = "Y";
                }
                if (oSystemParameter.omodel.Kf_MateOutBill_SimpleMode == "Y")   //生产领料单-扫码简易模式
                {
                    sSimpleMode = "Y";
                }
            }
            if (HBillType == "1205" && oSystemParameter.omodel.Kf_SellOutBill_FIFOCtl == "Y")   //销售出库单-先进先出控制
            {
                sFIFOCtl = "Y";
            }
            if (HBillType == "1211" && oSystemParameter.omodel.Kf_EntrustOutBill_FIFOCtl == "Y")   //委外出库单-先进先出控制
            {
                sFIFOCtl = "Y";
            }
 
            DataSet DS = oCn.RunProcReturn("exec h_p_WMS_BillEntryTmpList " + HInterID.ToString() + ",'" + HBillType + "','" + sMouldManagerCtl + "','" + sFIFOCtl + "','" + sSimpleMode + "'", "h_p_WMS_BillEntryTmpList");
            return DS;
        }
 
 
        #endregion
 
 
        //缓存列表界面,返回缓存列表信息
        public DataSet GetKf_PonderationBillMain_TempList_New(string sHBillType, string sHMaker, Int64 sHOWNERID)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds = oCn.RunProcReturn("exec h_p_KF_GetPonderationBillMain_TempList_New '" + sHBillType + "','" + sHMaker + "'," + sHOWNERID.ToString(), "h_p_KF_GetPonderationBillMain_TempList_New");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                return null;
            }
            else
            {
                return Ds;
            }
        }
 
        public DataSet GetKf_ICStockBillList(string sHBillType, string sHMaker, Int64 sHOWNERID)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds = oCn.RunProcReturn("exec h_p_Kf_ICStockBillList '" + sHBillType + "','" + sHMaker + "'," + sHOWNERID.ToString(), "h_p_Kf_ICStockBillList");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                return null;
            }
            else
            {
                return Ds;
            }
        }
 
        //扫描条码返回出入库条码临时表信息
        public DataSet GetInfoByID_View(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_KF_PonderationBillMain_Temp Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //扫描条码返回出入库条码临时表信息  一条条码显示一行
        public DataSet GetInfoByIDDetails_View(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select top 20 * from h_v_KF_PonderationBillMainDetails_Temp Where HQty<>0 And HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere + " order by HMakeDate desc ", "h_v_KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据条码 数量 判断条码库存 是否充足 并且带出 仓库仓位
        public bool CheckQtyByBarCode(long InterID, string sBillType, string sBarCode, ref long HWHID, ref long HSPID, double sQty, ref double sRelQty)
        {
            DataSet DS;
            DataSet DSErp;
            try
            {
                //单条码,一张单据一条条码(凯波)
                //DS = oCn.RunProcReturn("exec h_p_KF_ICInventory_WMS_GetWHAndSP_Single " + InterID.ToString() + ",'" + sBillType + "','" + sBarCode + "'," + HWHID.ToString() + "," + HSPID.ToString(), "h_p_KF_ICInventory_WMS_GetWHAndSP_Single", ref DBUtility.ClsPub.sExeReturnInfo);
                //判断条码库存
                DS = oCn.RunProcReturn("exec h_p_KF_ICInventory_WMS_GetWHAndSP " + InterID.ToString() + ",'" + sBillType + "','" + sBarCode + "'," + HWHID.ToString() + "," + HSPID.ToString(), "h_p_KF_ICInventory_WMS_GetWHAndSP", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                {
                    sRelQty = 0;
                    return false;
                }
                else
                {
                    double sKFQty = 0;
                    double sKFQtyErp = 0;
                    sKFQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HKFQty"]);
                    HWHID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HWhID"]);
                    HSPID = DBUtility.ClsPub.isLong(DS.Tables[0].Rows[0]["HSPID"]);
                    //强制返回99999,已没有作用
                    DSErp = oCn.RunProcReturn("exec h_p_IF_ICInventory_WMS_GetWHAndSP " + InterID.ToString() + ",'" + sBillType + "','" + sBarCode + "'," + HWHID.ToString() + "," + HSPID.ToString(), "h_p_IF_ICInventory_WMS_GetWHAndSP", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DSErp.Tables[0].Rows.Count == 0)
                    {
                        sRelQty = 0;
                        return false;
                    }
                    sKFQtyErp = DBUtility.ClsPub.isDoule(DSErp.Tables[0].Rows[0]["HKFQty"]);
                    if (sQty > sKFQty && sQty > sKFQtyErp)
                    {
                        sRelQty = sKFQtyErp;
                        return false;
                    }
                    else if (sQty > sKFQty && sQty < sKFQtyErp)
                    {
                        sRelQty = sKFQty;
                        return false;
                    }
                    else if (sQty < sKFQty && sQty > sKFQtyErp)
                    {
                        sRelQty = sKFQtyErp;
                        return false;
                    }
                    else
                    {
                        sRelQty = sQty;
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                sRelQty = 0;
                throw (e);
            }
        }
 
        //编辑时,返回条码临时表信息
        public DataSet GetBarCodeByID_View(long HInterID, string sBillType, long HMaterID, Int64 HAuxPropID, string HMTONo, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select HMTONo,HBatchNo,HBarCode,HWHID,HStockPlaceID,HSCWHID,HOutStockPlaceID,sum(HQty) HQty from KF_PonderationBillMain_Temp Where HQty<>0 and HInterID=" + HInterID.ToString() +
                            " and HBillType='" + sBillType + "'" +
                            " and HMaterID=" + HMaterID +
                            " and HAuxPropID=" + HAuxPropID +
                            " and HMTONo='" + HMTONo + "'" +
                    //" and HWHID=" + HWhID +
                    //" and HStockPlaceID=" + HSPID +
                    //" and HSCWHID=" + HSCWhID +
                    //" and HOutStockPlaceID=" + HSCSPID +
                            " and (HBatchNo='" + HBatchNo + "' or '" + HBatchNo + "' ='')" +
                            " and HSourceInterID=" + HSourceInterID +
                            " and HSourceEntryID=" + HSourceEntryID +
                             sWhere +
                            " Group by HBatchNo,HMTONo,HBarCode,HWHID,HStockPlaceID,HSCWHID,HOutStockPlaceID", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //编辑条码数量时 判断条码档案数量 
        public bool CheckQtyByBarCodeBill(long InterID, string sBillType, string sBatchNo, string sBarCode, ref double sRelQty)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_Kf_CheckBarCodeQty " + InterID.ToString() + ",'" + sBillType + "','" + sBatchNo + "','" + sBarCode + "'," + sRelQty.ToString(), "h_p_Kf_CheckBarCodeQty", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                {
                    sRelQty = sRelQty;
                    return true;
                }
                else
                {
                    double sQtyMust = 0;
                    sQtyMust = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQtyMust"]);
                    sRelQty = sQtyMust;
                    return false;
                }
            }
            catch (Exception e)
            {
                sRelQty = 0;
                throw (e);
            }
        }
 
        //编辑条码数量时 判断条码库存 是否充足 (仓库仓位)
        public bool CheckQtyByBarCode(string sBarCode, long HWHID, long HSPID, long HAuxPropID, string sBatchNo, string HMTONo, double sQty, ref double sRelQty)
        {
            DataSet DS;
            DataSet DSErp;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_ICInventory_WMS '" + sBarCode + "'," + HWHID.ToString() + "," + HSPID.ToString() + "," + HAuxPropID.ToString() + ",'" + sBatchNo + "','" + HMTONo + "'", "h_p_KF_ICInventory_WMS", ref DBUtility.ClsPub.sExeReturnInfo);
                DSErp = oCn.RunProcReturn("exec h_p_IF_ICInventory '" + sBarCode + "'," + HWHID.ToString() + "," + HSPID.ToString(), "h_p_IF_ICInventory", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0 || DSErp.Tables[0].Rows.Count == 0)
                {
                    sRelQty = 0;
                    return false;
                }
                else
                {
                    double sKCQty = 0;
                    double sKCQtyErp = 0;
                    sKCQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQty"]);
                    sKCQtyErp = DBUtility.ClsPub.isDoule(DSErp.Tables[0].Rows[0]["HQty"]);
                    if (sQty > sKCQty && sQty > sKCQtyErp)
                    {
                        sRelQty = sKCQtyErp;
                        return false;
                    }
                    else if (sQty > sKCQty && sQty < sKCQtyErp)
                    {
                        sRelQty = sKCQty;
                        return false;
                    }
                    else if (sQty < sKCQty && sQty > sKCQtyErp)
                    {
                        sRelQty = sKCQtyErp;
                        return false;
                    }
                    else
                    {
                        sRelQty = sQty;
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                sRelQty = 0;
                throw (e);
            }
        }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
        public bool CheakBarCodeAndCP(long HCusID, string sCPStr, string sBarCode, ref string sReturn)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_CheakBarCodeAndCP " + HCusID.ToString() + ",'" + sCPStr + "','" + sBarCode + "'", "h_p_CheakBarCodeAndCP", ref DBUtility.ClsPub.sExeReturnInfo);
                //if (DS.Tables[0].Rows.Count == 0)
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                {
                    sReturn = "验证失败!";
                    return false;
                }
                else
                {
                    double sBack = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HBack"]);
                    string sBackRemark = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HBackRemark"]);
                    if (sBack == 0)
                    {
                        sReturn = "验证通过!";
                        return true;
                    }
                    else
                    {
                        sReturn = sBackRemark;
                        return false;
                    }
                    
                }
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
        ////判断明细表中条码库存、K3库存 是否充足 (仓库仓位批次)
        //public bool CheckQtyByBarCode_Sub(long HInterID, string sBillType, long HMaterID, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sWhere, ref string sReturn)
        //{
        //    DataSet DSBarCode;
        //    DataSet DS;
        //    DataSet DSk3;
        //    string sBarCode;
        //    string sBatchNo;
        //    Int64 sHWHID;
        //    Int64 sHSPID;
        //    double sQty;
        //    try
        //    {
        //        DSBarCode=GetBarCodeByID_View(HInterID, sBillType, HMaterID, HWhID, HSPID, HSCWhID, HSCSPID, HBatchNo, HSourceInterID, HSourceEntryID, sWhere);
        //        if (DSBarCode == null || DSBarCode.Tables[0].Rows.Count == 0)
        //        {
        //            sReturn = "正常!";
        //            return true;
        //        }
        //        for (int i = 0; i <= DSBarCode.Tables[0].Rows.Count - 1; i++)
        //        {
        //            sBarCode = DBUtility.ClsPub.isStrNull(DSBarCode.Tables[0].Rows[i]["HBarCode"].ToString());
        //            sBatchNo = DBUtility.ClsPub.isStrNull(DSBarCode.Tables[0].Rows[i]["HBatchNo"].ToString());
        //            sHWHID = DBUtility.ClsPub.isInt(DSBarCode.Tables[0].Rows[i]["HWHID"].ToString());
        //            sHSPID = DBUtility.ClsPub.isInt(DSBarCode.Tables[0].Rows[i]["HStockPlaceID"].ToString());
        //            sQty = DBUtility.ClsPub.isDoule(DSBarCode.Tables[0].Rows[i]["HQty"].ToString());
 
        //            DS = oCn.RunProcReturn("exec h_p_KF_ICInventory_WMS '" + sBarCode + "'," + sHWHID.ToString() + "," + sHSPID.ToString() + ",'" + sBatchNo + "'", "h_p_KF_ICInventory_WMS", ref DBUtility.ClsPub.sExeReturnInfo);
        //            DSk3 = oCn.RunProcReturn("exec h_p_k3_icinventory '" + sBarCode + "'," + sHWHID.ToString() + "," + sHSPID.ToString(), "h_p_k3_icinventory", ref DBUtility.ClsPub.sExeReturnInfo);
        //            if (DS.Tables[0].Rows.Count == 0)
        //            {
        //                sReturn = "条码" + sBarCode + "无条码库存!";
        //                return false;
        //            } 
        //            else if (DSk3.Tables[0].Rows.Count == 0)
        //            {
        //                sReturn = "条码" + sBarCode + "无K3库存!";
        //                return false;
        //            }
        //            else
        //            {
        //                double sKCQty = 0;
        //                double sKCQtyk3 = 0;
        //                sKCQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQty"]);
        //                sKCQtyk3 = DBUtility.ClsPub.isDoule(DSk3.Tables[0].Rows[0]["HQty"]);
        //                if (sQty > sKCQty && sQty > sKCQtyk3)
        //                {
        //                    sReturn = "条码" + sBarCode + "的扫描数量" + sQty + "大于条码库存数量" + sKCQty + ",大于K3库存数量" + sKCQtyk3 + "!";
        //                    return false;
        //                }
        //                else if (sQty > sKCQty && sQty < sKCQtyk3)
        //                {
        //                    sReturn = "条码" + sBarCode + "的扫描数量" + sQty + "大于条码库存数量" + sKCQty + "!";
        //                    return false;
        //                }
        //                else if (sQty < sKCQty && sQty > sKCQtyk3)
        //                {
        //                    sReturn = "条码" + sBarCode + "的扫描数量" + sQty + ",大于K3库存数量" + sKCQtyk3 + "!";
        //                    return false;
        //                }
        //                else
        //                {
 
        //                }
        //            }
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        sReturn = e.Message;
        //        throw (e);
        //    }
        //    return false;
        //}
 
        //根据条码 判断条码库存中物料仓库仓位是否与所选源单一致
        public bool CheckQtyByBarCode_WHAndSP(long HInterID, string sBarCode)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_ICInventory_WMS_GetWHAndSPAndBC " + HInterID.ToString() + ",'" + sBarCode + "'" , "h_p_KF_ICInventory_WMS_GetWHAndSPAndBC", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
         
        //返回项目信息
        public override bool GetInfoByID(Int64 sItemID)
        {
            DataSet DS ;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HItemID='" + sItemID + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count  == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        
 
        //根据代码返回项目信息
        public DataSet GetInfoByID_View_Check(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_KF_PonderationBillMain_Temp_Wh_SP Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_KF_PonderationBillMain_Temp_Wh_SP", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据代码返回项目信息(盘点)
        public DataSet GetInfoByID_View_CheckStcok(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_CheckStock " + HInterID.ToString() + ",'" + sBillType + "'", "h_p_KF_PonderationBillMain_Temp_CheckStock", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        
 
        //根据代码返回项目信息
        public DataSet GetInfoByID_View_FIFO(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("select * from  h_v_Kf_ICInventory_FIFO_Tmp Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_Kf_ICInventory_FIFO_Tmp", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据代码返回项目信息
        public DataSet GetInfoByID_View_FIFO(long HInterID, string sBillType, long HMaterID, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("select * from  h_v_Kf_ICInventory_FIFO_Tmp_New Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "'  and HMaterID=" + HMaterID.ToString() + sWhere, "h_v_Kf_ICInventory_FIFO_Tmp_New", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
        ////根据代码返回项目信息
        //public DataSet GetCusAndBarCodeByID_View(long HInterID, string sWhere)
        //{
        //    DataSet DS;
        //    try
        //    {
        //        DS = oCn.RunProcReturn("Select * from h_v_K3_GetCusAndBarCodeList Where HInterID=" + HInterID.ToString() + sWhere, "h_v_K3_GetCusAndBarCodeList", ref DBUtility.ClsPub.sExeReturnInfo);
        //        if (DS.Tables[0].Rows.Count == 0)
        //            return null;
        //        else
        //        {
        //            return DS;
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        throw (e);
        //    }
        //}
 
        //根据代码返回项目信息
        public DataSet GetBarCodeByID_View(long HInterID, string sBillType, long HMaterID, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from KF_PonderationBillMain_Temp Where HQty<>0 and HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' and HMaterID=" + HMaterID + sWhere, "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
        ////根据代码返回项目信息
        //public DataSet GetBarCodeByID_View(long HInterID, string sBillType, long HMaterID, Int64 HWhID, Int64 HSPID, Int64 HSCWhID, Int64 HSCSPID, string HBatchNo, Int64 HSourceInterID, Int64 HSourceEntryID, string sWhere)
        //{
        //    DataSet DS;
        //    try
        //    {
        //        DS = oCn.RunProcReturn("Select HBarCode,sum(HQty) HQty from KF_PonderationBillMain_Temp Where HQty<>0 and HInterID=" + HInterID.ToString() +
        //                    " and HBillType='" + sBillType + "'" +
        //                    " and HMaterID=" + HMaterID +
        //                    " and HWHID=" + HWhID +
        //                    " and HStockPlaceID=" + HSPID +
        //                    " and HSCWHID=" + HSCWhID +
        //                    " and HOutStockPlaceID=" + HSCSPID +
        //                    " and HBatchNo='" + HBatchNo + "'" +
        //                    " and HSourceInterID=" + HSourceInterID +
        //                    " and HSourceEntryID=" + HSourceEntryID +
        //                     sWhere +
        //                    " Group by HBarCode", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
        //        if (DS.Tables[0].Rows.Count == 0)
        //            return null;
        //        else
        //        {
        //            return DS;
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        throw (e);
        //    }
        //}
 
 
 
 
        //根据代码返回项目信息
        public override bool GetInfoByNumber(string sNumber)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from " + MvarItemKey + " Where HBarCode='" + sNumber + "'", MvarItemKey, ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return false;
                else
                {
                    return GetInfo(DS);
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        } 
        //返回项目信息
        public override bool GetInfo(DataSet Ds)
        {
            try
            {
                omodel = new Model.ClsKF_PonderationBillMain_Temp();
                omodel.HItemID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HItemID"]);
                omodel.HInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"]);
                omodel.HBarCode = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HBarCode"]);
                omodel.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HMaterID"]);
                omodel.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HProcID"]);
                omodel.HWhID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HWhID"]);
                omodel.HSCWHID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSCWHID"]);
                omodel.HStockPlaceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HStockPlaceID"]);
                omodel.HOutStockPlaceID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HOutStockPlaceID"]);
                omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HGroupID"]);
                omodel.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HQty"]);
                omodel.HPieceQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[0]["HPieceQty"]);
                omodel.HAddr = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HAddr"]);
                //
                omodel.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HSourceBillType"]);
                omodel.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceInterID"]);
                omodel.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["HSourceEntryID"]);
                return true;
 
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
       
        //根据代码返回项目信息
        public DataSet GetCusAndBarCodeByID_View(long HInterID, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_K3_GetCusAndBarCodeList Where HInterID=" + HInterID.ToString() + sWhere, "h_v_K3_GetCusAndBarCodeList", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        
 
        public DataSet GetInfoByID_View_Sub(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_Sub " + HInterID.ToString() + " ,'" + sBillType + "' ", "h_p_KF_PonderationBillMain_Temp_Sub", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        public DataSet GetInfoByID_View_Sub_FIFO(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_FIFO " + HInterID.ToString() + " ,'" + sBillType + "' ", "h_p_KF_PonderationBillMain_Temp_FIFO", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        public DataSet GetInfoByID_View_Sub_FIFO_Bill(string sBillNo, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_PonderationBillMain_Temp_FIFO_Bill '" + sBillNo + "' ,'" + sBillType + "' ", "h_p_KF_PonderationBillMain_Temp_FIFO_Bill", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据代码返回项目信息
        public DataSet GetInfoByID_View_Sum(long HInterID, string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_KF_PonderationBillMain_Temp_Sum Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_KF_PonderationBillMain_Temp_Sum", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据代码返回项目信息(未上传)
        public DataSet GetInfoByID_View(string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("Select * from h_v_KF_PonderationBillMain_Temp_OffLine Where  HBillType='" + sBillType + "' " + sWhere, "h_v_KF_PonderationBillMain_Temp_OffLine", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //返回缓存列表信息
        public DataSet GetKf_PonderationBillMain_TempList(string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec  h_p_KF_GetPonderationBillMain_TempList '" + sBillType + "','" +sWhere + "'", "h_p_KF_GetPonderationBillMain_TempList", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //返回缓存列表信息(倒箱单)
        public DataSet GetKf_PonderationBillMain_TempList_ChangeBox(string sBillType, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec  h_p_KF_GetPonderationBillMain_TempList_ChangeBox '" + sBillType + "','" + sWhere + "'", "h_p_KF_GetPonderationBillMain_TempList_ChangeBox", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        ////根据代码返回项目信息
        //public DataSet GetInfoByID_View(long HInterID, string sBillType, string sWhere)
        //{
        //    DataSet DS;
        //    try
        //    {
        //        DS = oCn.RunProcReturn("Select * from h_v_KF_PonderationBillMain_Temp Where HInterID=" + HInterID.ToString() + " and HBillType='" + sBillType + "' " + sWhere, "h_v_KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
        //        if (DS.Tables[0].Rows.Count == 0)
        //            return null;
        //        else
        //        {
        //            return DS;
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        throw (e);
        //    }
        //}
 
        public DataSet GetMaterByBarCode_View(string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn(" exec h_p_KF_ICInventory_BarCodeMater_Main '" + sWhere + "'","h_p_KF_ICInventory_BarCodeMater_Main", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
 
        public DataSet GetICInventoryByBarCode_View(string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn(" exec h_p_KF_ICInventory_BarCodeMater_Sub '" + sWhere + "'","h_p_KF_ICInventory_BarCodeMater_Sub", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
 
        public DataSet GetMaterByBarCodeSP_View(string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn(" exec h_p_KF_ICInventory_BarCodeSP_Sub '" + sWhere + "'","h_p_KF_ICInventory_BarCodeSP_Sub", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
 
        public DataSet GetICInventoryByBarCodeSP_View(string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn(" exec h_p_KF_ICInventory_BarCodeSP_Main '" + sWhere + "'","h_p_KF_ICInventory_BarCodeSP_Main", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
 
 
        
        //返回即时库存
        public DataSet Get_ICInventoryByBarCodeList(string sBarCode, long sHWHID, long sHSPID, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_ICInventoryByBarCodeList '" + sBarCode + "'," + sHWHID.ToString() + "," + sHSPID.ToString(), "h_p_KF_ICInventoryByBarCodeList", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //根据物料返回即时库存
        public DataSet Get_ICInventoryByMaterID(long sHMaterID, long sHWhID, string sWhere)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_KF_ICInventoryByMaterID " + sHMaterID.ToString() + "," + sHWhID.ToString(), "h_p_KF_ICInventoryByMaterID", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS == null || DS.Tables[0].Rows.Count == 0)
                    return null;
                else
                {
                    return DS;
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
        //判断扫描记录,是否按照先进先出规则
        public bool CheckICInventory_FIFO_Tmp(long InterID, string sBillType, ref string sReturn)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("exec h_p_Kf_ICInventory_FIFO_Tmp_Check " + InterID.ToString() + "," + sBillType.ToString(), "h_p_Kf_ICInventory_FIFO_Tmp_Check", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0 || DS == null)
                {
                    oCn.CnClose();
                    oCn.CnDispose();
                    sReturn = "null未知错误";
                    return false;       //不存在 入库数量超过条码本身额定数量 条码
                }
                else
                {
                    if (DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0][0]) == 1)
                    {
                        oCn.CnClose();
                        oCn.CnDispose();
                        sReturn = DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0][1]);
                        return false;
                    }
                    else
                    {
                        oCn.CnClose();
                        oCn.CnDispose();
                        sReturn = "正常!";
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                sReturn = e.Message;
                throw (e);
            }
        }
 
        //根据VDA箱号 数量 判断扫描数量 是否匹配 
        public bool CheckQtyByVDAPack(long InterID, string sBillType, string sVDAPack, ref string sReturn)
        {
            DataSet DS;
            try
            {
                DS = oCn.RunProcReturn("select sum(HQty) HQty,HVDAQty from  KF_PonderationBillMain_Temp  where HInterID=" + InterID.ToString() + " and HBillType='" + sBillType + "' and HVDAPack='" + sVDAPack + "' group by HVDAQty", "KF_PonderationBillMain_Temp", ref DBUtility.ClsPub.sExeReturnInfo);
                if (DS.Tables[0].Rows.Count == 0)
                {
                    return false;
                }
                else
                {
                    double sQty = 0;
                    double sVDAQty = 0;
                    sQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HQty"]);
                    sVDAQty = DBUtility.ClsPub.isDoule(DS.Tables[0].Rows[0]["HVDAQty"]);
                    if (sQty != sVDAQty)
                    {
                        sReturn = "本托数量与 VDA数量不一致!";
                        return false;
                    }
                    else
                    {
                        sReturn = "正常";
                        return true;
                    }
                }
            }
            catch (Exception e)
            {
                throw (e);
            }
        }
 
 
 
 
 
    }
}