From c16d33963f594c4231cdddbf35025cf7fa3dd693 Mon Sep 17 00:00:00 2001
From: yxj <1qaz@123>
Date: 星期四, 28 七月 2022 15:36:01 +0800
Subject: [PATCH] 单据校验扫码模块,新增扫描物料条码功能:源单中存在多行相同物料时自动拆分换行匹配源单数据

---
 CLOUDWEB/WebService1.asmx.cs |  405 +++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 291 insertions(+), 114 deletions(-)

diff --git a/CLOUDWEB/WebService1.asmx.cs b/CLOUDWEB/WebService1.asmx.cs
index 9d7fa1e..e071ee7 100644
--- a/CLOUDWEB/WebService1.asmx.cs
+++ b/CLOUDWEB/WebService1.asmx.cs
@@ -32773,10 +32773,11 @@
             }
             //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
             string[] NewBarCode;
-            if (sBarCode.CompareTo("#") > 0)
+            if (sBarCode.Contains("#"))
             {
                 NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                 sBarCode = NewBarCode[0];
+                HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
             }
             //鏍规嵁鐗╂枡鏉$爜寰楀埌瀵瑰簲婧愬崟淇℃伅锛岄潪澶氭簮鍗曟ā寮忥紝鍒ゆ柇鏄惁宸叉湁婧愬崟璁板綍(鍗曟嵁绫诲瀷=1203锛屽叾浠栧叆搴撳崟闄ゅ)
             if (SourceFlag || HBillType == "1203")
@@ -33330,10 +33331,11 @@
             }
             //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
             string[] NewBarCode;
-            if (sBarCode.CompareTo("#") > 0)
+            if (sBarCode.Contains("#"))
             {
                 NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                 sBarCode = NewBarCode[0];
+                HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
             }
             //鏍规嵁鏉$爜鑾峰彇鏉$爜淇℃伅锛屽瓨鍦ㄧ浉鍚岀墿鏂欐椂鑷姩鑾峰彇涓�琛屾簮鍗曚俊鎭�
             DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
@@ -33838,10 +33840,11 @@
 
             //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
             string[] NewBarCode;
-            if (sBarCode.CompareTo("#") > 0)
+            if (sBarCode.Contains("#"))
             {
                 NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                 sBarCode = NewBarCode[0];
+                HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
             }
             //鏍规嵁鏉$爜鑾峰彇鏉$爜淇℃伅
             DAL.ClsGy_BarCodeBill_View dal = new DAL.ClsGy_BarCodeBill_View();
@@ -34574,10 +34577,11 @@
             }
             //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
             string[] NewBarCode;
-            if (sBarCode.CompareTo("#") > 0)
+            if (sBarCode.Contains("#"))
             {
                 NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                 sBarCode = NewBarCode[0];
+                HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
             }
 
             //鏍规嵁鏉$爜鑾峰彇鏉$爜淇℃伅
@@ -34985,11 +34989,13 @@
             }
             //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
             string[] NewBarCode;
-            if (sBarCode.CompareTo("#") > 0)
+            if (sBarCode.Contains("#"))
             {
                 NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                 sBarCode = NewBarCode[0];
+                HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
             }
+
             //鑾峰彇绯荤粺鍙傛暟
             Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
             if (oSystemParameter.ShowBill(ref sErrMsg) == false)
@@ -38645,10 +38651,11 @@
                 {
                     //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
                     string[] NewBarCode;
-                    if (sBarCode.CompareTo("#") > 0)
+                    if (sBarCode.Contains("#"))
                     {
                         NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                         sBarCode = NewBarCode[0];
+                        HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
                     }
                 }
 
@@ -39124,7 +39131,7 @@
 
 
 
-            #endregion
+        #endregion
 
 
             //        #region 鎵弿鐗╂枡鏉$爜璋冪敤鏂规硶
@@ -39480,9 +39487,9 @@
             //        #endregion
 
 
-            #region 妯″叿鏉$爜澶勭悊鏂规硶
+        #region 妯″叿鏉$爜澶勭悊鏂规硶
 
-            #region 鎵弿妯″叿婧愬崟鏉$爜
+        #region 鎵弿妯″叿婧愬崟鏉$爜
 
             [WebMethod]
         public Model.ClsKf_ICStockBill_Mould get_CheckTypeByMouldSource(Int64 HInterID, string HBillNo, string HBillType, string HSourceBillNo, string HSourceBillType, string HHMaker, Int64 HOWNERID, ref string sErrMsg)
@@ -40208,10 +40215,11 @@
                 {
                     //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
                     string[] NewBarCode;
-                    if (sBarCode.CompareTo("#") > 0)
+                    if (sBarCode.Contains("#"))
                     {
                         NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                         sBarCode = NewBarCode[0];
+                        HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
                     }
                 }
 
@@ -40305,15 +40313,22 @@
             Model.ClsKF_PonderationBillMain_Temp oMain = new Model.ClsKF_PonderationBillMain_Temp();
 
             double sRelQty = 0;
-            string sBillTypeOneScan = "";   //鏄惁鍚敤涓�娆℃壂鐮佹帶鍒讹紙'Y'涓哄惎鐢級
-            if (HBillType == "1207" && oSystemParameterMain.Kf_MoveStockBill_BillTypeOneScan == "Y")
+            string sWHSPCtl = "Y";   //鏍¢獙-鏄惁鏍″浠撳簱浠撲綅锛�'Y'涓烘牎瀵癸級
+            if (HBillType == "1207" && oSystemParameterMain.Kf_MoveStockBillCheck_WHSPCtl == "N")
             {
                 //鐩存帴璋冩嫧鍗�
-                sBillTypeOneScan = "Y";
+                sWHSPCtl = "N";
+            }
+
+            string sMultilineCtl = "N";   //鏍¢獙-澶氳鐩稿悓鐗╂枡鑷姩鎷嗗垎鎹㈣鍖归厤锛�'Y'涓鸿嚜鍔ㄦ媶鍒嗭級
+            if (HBillType == "1207" && oSystemParameterMain.Kf_MoveStockBillCheck_MultilineCtl == "Y")
+            {
+                //鐩存帴璋冩嫧鍗�
+                sMultilineCtl = "Y";
             }
 
             //鍒ゆ柇鏄惁瀛樺湪鐩稿悓鏉$爜锛屽垽鏂墍鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓�
-            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_MoveStockBillCheck '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + "," + HSCWHID + "," + HSCSPID + ",'" + sBillTypeOneScan + "'", "h_p_WMS_AddBarCode_MoveStockBillCheck");
+            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_MoveStockBillCheck_New '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + "," + HSCWHID + "," + HSCSPID + ",'" + sWHSPCtl + "','" + sMultilineCtl + "'", "h_p_WMS_AddBarCode_MoveStockBillCheck_New");
             if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
             {
                 sErrMsg = "鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓彂鐢熼敊璇紒";
@@ -40324,10 +40339,7 @@
                 if (DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0][0]) == 0)
                 {
                     omodel_View.HMaterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HMaterID"]);
-                    omodel_View.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSourceBillNo"]);
-                    omodel_View.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceEntryID"]);
-                    omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceInterID"]);
-                    omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HQtyMust"]);     //婧愬崟鍙壂鏁伴噺
+                    omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HSumQtyMust"]);     //HSumQtyMust涓烘簮鍗曠浉鍚岀墿鏂欏墿浣欏彲鎵暟閲�
                     HWhID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HWhID"]);
                     HSPID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSPID"]);
                     HSCWHID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSCWHID"]);
@@ -40462,53 +40474,91 @@
                 }
                 else
                 {
-                if (DBUtility.ClsPub.isLong(dsOneScan.Tables[0].Rows[0][0]) == 1)
-                {
-                    sErrMsg = DBUtility.ClsPub.isStrNull(dsOneScan.Tables[0].Rows[0]["HRemark"]);
-                    return false;
-                }
+                    if (DBUtility.ClsPub.isLong(dsOneScan.Tables[0].Rows[0][0]) == 1)
+                    {
+                        sErrMsg = DBUtility.ClsPub.isStrNull(dsOneScan.Tables[0].Rows[0]["HRemark"]);
+                        return false;
+                    }
                 }
             }
 
-            oMain.HInterID = HBillID;
-            oMain.HBillNo = HBillNo;
-            oMain.HBillType = HBillType;
-            oMain.HMaker = HMaker;
-            oMain.HMaterID = omodel_View.HMaterID;
-            oMain.HAuxPropID = omodel_View.HAuxPropID;
-            oMain.HQty = sRelQty;
-            oMain.HQtyMust = 0;
-            oMain.HBarCode = omodel_View.HBarCode;
-            oMain.HBatchNo = omodel_View.HBatchNo;
-            oMain.HMTONo = omodel_View.HMTONo;
-            oMain.HWhID = HWhID;
-            oMain.HStockPlaceID = HSPID;
-            oMain.HSCWHID = HSCWHID;
-            oMain.HOutStockPlaceID = HSCSPID;
-            oMain.HSourceInterID = omodel_View.HSourceInterID;
-            oMain.HSourceEntryID = omodel_View.HSourceEntryID;
-            oMain.HSourceBillNo = omodel_View.HSourceBillNo;
-            oMain.HSourceBillType = HBillType;
-            oMain.HRedBlueFlag = false;
-            oMain.HPieceQty = 1;
-            oMain.HSTOCKORGID = HOWNERID;
-            oMain.HOWNERID = HOWNERID;
+            double sSumQty = 0;
+            double sRemQty = 0;
+            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
+            {
+                omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[i]["HQtyMust"]);   //瀛樺湪鐩稿悓鐗╂枡鏃讹紝鍏朵腑涓�琛屾簮鍗曞墿浣欏彲鎵暟閲�
+                sSumQty = sSumQty + omodel_View.HSourceQty;
+                sRemQty = sRelQty - sSumQty;
 
-            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(" + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + "," + oMain.HAuxPropID.ToString() + "," + oMain.HProcID.ToString() +
-                "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
-                "," + oMain.HQtyMust.ToString() + "," + oMain.HQty.ToString() + "," + oMain.HPieceQty.ToString() + ",'" + oMain.HBatchNo + "','" + oMain.HBarCode + "',''" +
-                ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
-                "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
-                "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + ",'','鏍¢獙妯″紡',1" +
-                ",0,0,'" + oMain.HCusBarCode + "',0)");
+                //鏁伴噺
+                //鍙瓨鍦ㄤ竴琛屾暟鎹椂锛屾暟閲�=鏉$爜鍙壂鏁伴噺
+                if (ds1.Tables[0].Rows.Count==1)
+                {
+                    oMain.HQty = sRelQty;
+                }
+                //瀛樺湪澶氳鐩稿悓鐗╂枡锛屾潯鐮佸墿浣欐暟閲�<鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺 鎴� 鎵�閫夎婧愬崟涓烘渶鍚庝竴鏉℃暟鎹椂 锛屾暟閲�=鏉$爜鍓╀綑鏁伴噺
+                else if (sRemQty <= 0 || (i == ds1.Tables[0].Rows.Count-1 && sRemQty > 0))
+                {
+                    oMain.HQty = sRemQty + omodel_View.HSourceQty;
+                }
+                //瀛樺湪澶氳鐩稿悓鐗╂枡锛屾潯鐮佸墿浣欐暟閲�>鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺 锛屾暟閲�=鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺
+                else
+                {
+                    oMain.HQty = omodel_View.HSourceQty;
+                }
+                //鏉$爜鏉℃暟
+                if (i == 0)
+                {
+                    oMain.HPieceQty = 1;
+                }
+                else
+                {
+                    oMain.HPieceQty = 0;
+                }
+
+                oMain.HInterID = HBillID;
+                oMain.HBillNo = HBillNo;
+                oMain.HBillType = HBillType;
+                oMain.HMaker = HMaker;
+                oMain.HMaterID = omodel_View.HMaterID;
+                oMain.HAuxPropID = omodel_View.HAuxPropID;
+                oMain.HQtyMust = 0;
+                oMain.HBarCode = omodel_View.HBarCode;
+                oMain.HBatchNo = omodel_View.HBatchNo;
+                oMain.HMTONo = omodel_View.HMTONo;
+                oMain.HWhID = HWhID;
+                oMain.HStockPlaceID = HSPID;
+                oMain.HSCWHID = HSCWHID;
+                oMain.HOutStockPlaceID = HSCSPID;
+                oMain.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[i]["HSourceInterID"]);
+                oMain.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[i]["HSourceEntryID"]);
+                oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[i]["HSourceBillNo"]);
+                oMain.HSourceBillType = HBillType;
+                oMain.HRedBlueFlag = false;
+                oMain.HSTOCKORGID = HOWNERID;
+                oMain.HOWNERID = HOWNERID;
+
+                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(" + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + "," + oMain.HAuxPropID.ToString() + "," + oMain.HProcID.ToString() +
+                    "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
+                    "," + oMain.HQtyMust.ToString() + "," + oMain.HQty.ToString() + "," + oMain.HPieceQty.ToString() + ",'" + oMain.HBatchNo + "','" + oMain.HBarCode + "',''" +
+                    ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
+                    "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
+                    "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + ",'','鏍¢獙妯″紡',1" +
+                    ",0,0,'" + oMain.HCusBarCode + "',0)");
+
+                if (sRemQty <= 0)
+                {
+                    break;
+                }
+            }
             return true;
         }
 
@@ -40525,25 +40575,42 @@
             Model.ClsKF_PonderationBillMain_Temp oMain = new Model.ClsKF_PonderationBillMain_Temp();
 
             double sRelQty = 0;
-            string sBillTypeOneScan = "";   //鏄惁鍚敤涓�娆℃壂鐮佹帶鍒讹紙'Y'涓哄惎鐢級
-            if (HBillType == "1203" && oSystemParameterMain.Kf_OtherInBill_BillTypeOneScan == "Y")
+            string sWHSPCtl = "Y";   //鏍¢獙-鏄惁鏍″浠撳簱浠撲綅锛�'Y'涓烘牎瀵癸級
+            if (HBillType == "1203")
             {
                 //鍏朵粬鍏ュ簱鍗�
-                sBillTypeOneScan = "Y";
+                sWHSPCtl = "Y";
             }
-            else if (HBillType == "1204" && oSystemParameterMain.Kf_MateOutBill_BillTypeOneScan == "Y")
+            else if (HBillType == "1204" && oSystemParameterMain.Kf_MateOutBillCheck_WHSPCtl == "N")
             {
                 //棰嗘枡鍑哄簱鍗�
-                sBillTypeOneScan = "Y";
+                sWHSPCtl = "N";
             }
-            else if (HBillType == "1206" && oSystemParameterMain.Kf_OtherOutBill_BillTypeOneScan == "Y")
+            else if (HBillType == "1206")
             {
                 //鍏朵粬鍑哄簱鍗�
-                sBillTypeOneScan = "Y";
+                sWHSPCtl = "Y";
             }
 
-            //鍒ゆ柇鏄惁瀛樺湪鐩稿悓鏉$爜锛屽垽鏂槸鍚﹀惎鐢ㄤ竴娆℃壂鐮佹帶鍒讹紝鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓�
-            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_BillCheck '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + ",'" + sBillTypeOneScan + "'", "h_p_WMS_AddBarCode_BillCheck");
+            string sMultilineCtl = "N";   //鏍¢獙-澶氳鐩稿悓鐗╂枡鑷姩鎷嗗垎鎹㈣鍖归厤锛�'Y'涓鸿嚜鍔ㄦ媶鍒嗭級
+            if (HBillType == "1203")
+            {
+                //鍏朵粬鍏ュ簱鍗�
+                sMultilineCtl = "N";
+            }
+            else if (HBillType == "1204" && oSystemParameterMain.Kf_MateOutBillCheck_MultilineCtl == "Y")
+            {
+                //棰嗘枡鍑哄簱鍗�
+                sMultilineCtl = "Y";
+            }
+            else if (HBillType == "1206")
+            {
+                //鍏朵粬鍑哄簱鍗�
+                sMultilineCtl = "N";
+            }
+
+            //鍒ゆ柇鏄惁瀛樺湪鐩稿悓鏉$爜锛屽垽鏂墍鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓�
+            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_BillCheck_New '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + ",'" + sWHSPCtl + "','" + sMultilineCtl + "'", "h_p_WMS_AddBarCode_BillCheck_New");
             if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
             {
                 sErrMsg = "鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓彂鐢熼敊璇紒";
@@ -40554,10 +40621,9 @@
                 if (DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0][0]) == 0)
                 {
                     omodel_View.HMaterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HMaterID"]);
-                    omodel_View.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSourceBillNo"]);
-                    omodel_View.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceEntryID"]);
-                    omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceInterID"]);
-                    omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HQtyMust"]);     //婧愬崟鍙壂鏁伴噺
+                    omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HSumQtyMust"]);     //HSumQtyMust涓烘簮鍗曠浉鍚岀墿鏂欏墿浣欏彲鎵暟閲�
+                    HWhID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HWhID"]);
+                    HSPID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSPID"]);
                 }
                 else
                 {
@@ -40712,11 +40778,12 @@
                     DataSet DsWMS = oCn.RunProcReturn("exec h_p_KF_ICInventory_WMS_GetWHAndSP " + HBillID.ToString() + ",'" + HBillType + "','" + omodel_View.HBarCode + "'," + HWhID.ToString() + "," + HSPID.ToString(), "h_p_KF_ICInventory_WMS_GetWHAndSP");
                     if (DsWMS == null || DsWMS.Tables[0].Rows.Count == 0)
                     {
-                        sErrMsg = "鍒ゆ柇WMS鏉$爜搴撳瓨锛屽彂鐢熼敊璇紒";
-                        return false;
+                        sRelQty = 0;
                     }
                     else
                     {
+                        HWhID = DBUtility.ClsPub.isLong(DsWMS.Tables[0].Rows[0]["HWhID"]);
+                        HSPID = DBUtility.ClsPub.isLong(DsWMS.Tables[0].Rows[0]["HSPID"]);
                         sWMSQty = DBUtility.ClsPub.isDoule(DsWMS.Tables[0].Rows[0]["HKFQty"]);
                         //鍒ゆ柇鎵弿鏉$爜鏁伴噺涓庢潯鐮佸簱瀛樻暟閲�
                         if(sRelQty> sWMSQty)
@@ -40766,43 +40833,100 @@
                 }
             }
 
-            oMain.HInterID = HBillID;
-            oMain.HBillNo = HBillNo;
-            oMain.HBillType = HBillType;
-            oMain.HMaker = HMaker;
-            oMain.HMaterID = omodel_View.HMaterID;
-            oMain.HAuxPropID = omodel_View.HAuxPropID;
-            oMain.HQty = sRelQty;
-            oMain.HQtyMust = 0;
-            oMain.HBarCode = omodel_View.HBarCode;
-            oMain.HBatchNo = omodel_View.HBatchNo;
-            oMain.HMTONo = omodel_View.HMTONo;
-            oMain.HWhID = HWhID;
-            oMain.HStockPlaceID = HSPID;
-            oMain.HSourceInterID = omodel_View.HSourceInterID;
-            oMain.HSourceEntryID = omodel_View.HSourceEntryID;
-            oMain.HSourceBillNo = omodel_View.HSourceBillNo;
-            oMain.HSourceBillType = HBillType;
-            oMain.HRedBlueFlag = false;
-            oMain.HPieceQty = 1;
-            oMain.HSTOCKORGID = HOWNERID;
-            oMain.HOWNERID = HOWNERID;
+            //涓�娆℃壂鐮佹帶鍒讹紝鍚屼竴鏉$爜銆佸悓涓�鍗曟嵁绫诲瀷锛屽湪WMS琛ㄥ拰TEMP琛ㄩ噷锛屽彧鍏佽杩涜涓�娆℃壂鐮�
+            if ((HBillType == "1203" && oSystemParameterMain.Kf_OtherInBill_BillTypeOneScan == "Y")
+                || (HBillType == "1204" && oSystemParameterMain.Kf_MateOutBill_BillTypeOneScan == "Y")
+                || (HBillType == "1206" && oSystemParameterMain.Kf_OtherOutBill_BillTypeOneScan == "Y"))
+            {
+                DataSet dsOneScan = oCn.RunProcReturn("exec h_p_WMS_CheckBarCodeOneScan_New '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + ",0,0,'" + HMaker + "'", "h_p_WMS_CheckBarCodeOneScan_New");
+                if (dsOneScan == null || dsOneScan.Tables[0].Rows.Count == 0)
+                {
+                }
+                else
+                {
+                    if (DBUtility.ClsPub.isLong(dsOneScan.Tables[0].Rows[0][0]) == 1)
+                    {
+                        sErrMsg = DBUtility.ClsPub.isStrNull(dsOneScan.Tables[0].Rows[0]["HRemark"]);
+                        return false;
+                    }
+                }
+            }
 
-            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(" + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + "," + oMain.HAuxPropID.ToString() + "," + oMain.HProcID.ToString() +
-                "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
-                "," + oMain.HQtyMust.ToString() + "," + oMain.HQty.ToString() + "," + oMain.HPieceQty.ToString() + ",'" + oMain.HBatchNo + "','" + oMain.HBarCode + "',''" +
-                ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
-                "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
-                "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + ",'','鏍¢獙妯″紡',1" +
-                ",0,0,'" + oMain.HCusBarCode + "',0)");
+            double sSumQty = 0;
+            double sRemQty = 0;
+            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
+            {
+                omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[i]["HQtyMust"]);   //瀛樺湪鐩稿悓鐗╂枡鏃讹紝鍏朵腑涓�琛屾簮鍗曞墿浣欏彲鎵暟閲�
+                sSumQty = sSumQty + omodel_View.HSourceQty;
+                sRemQty = sRelQty - sSumQty;
+
+                //鏁伴噺
+                //鍙瓨鍦ㄤ竴琛屾暟鎹椂锛屾暟閲�=鏉$爜鍙壂鏁伴噺
+                if (ds1.Tables[0].Rows.Count == 1)
+                {
+                    oMain.HQty = sRelQty;
+                }
+                //瀛樺湪澶氳鐩稿悓鐗╂枡锛屾潯鐮佸墿浣欐暟閲�<鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺 鎴� 鎵�閫夎婧愬崟涓烘渶鍚庝竴鏉℃暟鎹椂 锛屾暟閲�=鏉$爜鍓╀綑鏁伴噺
+                else if (sRemQty <= 0 || (i == ds1.Tables[0].Rows.Count - 1 && sRemQty > 0))
+                {
+                    oMain.HQty = sRemQty + omodel_View.HSourceQty;
+                }
+                //瀛樺湪澶氳鐩稿悓鐗╂枡锛屾潯鐮佸墿浣欐暟閲�>鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺 锛屾暟閲�=鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺
+                else
+                {
+                    oMain.HQty = omodel_View.HSourceQty;
+                }
+                //鏉$爜鏉℃暟
+                if (i == 0)
+                {
+                    oMain.HPieceQty = 1;
+                }
+                else
+                {
+                    oMain.HPieceQty = 0;
+                }
+
+                oMain.HInterID = HBillID;
+                oMain.HBillNo = HBillNo;
+                oMain.HBillType = HBillType;
+                oMain.HMaker = HMaker;
+                oMain.HMaterID = omodel_View.HMaterID;
+                oMain.HAuxPropID = omodel_View.HAuxPropID;
+                oMain.HQtyMust = 0;
+                oMain.HBarCode = omodel_View.HBarCode;
+                oMain.HBatchNo = omodel_View.HBatchNo;
+                oMain.HMTONo = omodel_View.HMTONo;
+                oMain.HWhID = HWhID;
+                oMain.HStockPlaceID = HSPID;
+                oMain.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[i]["HSourceInterID"]);
+                oMain.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[i]["HSourceEntryID"]);
+                oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[i]["HSourceBillNo"]);
+                oMain.HSourceBillType = HBillType;
+                oMain.HRedBlueFlag = false;
+                oMain.HSTOCKORGID = HOWNERID;
+                oMain.HOWNERID = HOWNERID;
+
+                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(" + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + "," + oMain.HAuxPropID.ToString() + "," + oMain.HProcID.ToString() +
+                    "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
+                    "," + oMain.HQtyMust.ToString() + "," + oMain.HQty.ToString() + "," + oMain.HPieceQty.ToString() + ",'" + oMain.HBatchNo + "','" + oMain.HBarCode + "',''" +
+                    ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
+                    "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
+                    "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + ",'','鏍¢獙妯″紡',1" +
+                    ",0,0,'" + oMain.HCusBarCode + "',0)");
+
+                if (sRemQty <= 0)
+                {
+                    break;
+                }
+            }
             return true;
         }
 
@@ -40833,10 +40957,11 @@
                 {
                     //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
                     string[] NewBarCode;
-                    if (sBarCode.CompareTo("#") > 0)
+                    if (sBarCode.Contains("#"))
                     {
                         NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                         sBarCode = NewBarCode[0];
+                        HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
                     }
                 }
 
@@ -41125,6 +41250,56 @@
             else
             {
                 return DS;
+            }
+        }
+
+        #endregion
+
+
+        #region 鐣岄潰鍚屾鍗曟嵁鎸夐挳璋冪敤鏂规硶    *鏍¢獙妯″紡
+
+        [WebMethod]
+        public bool set_UpdateTemp_BillCheck(Int64 HBillID, string HBillNo, string HBillType, string HMaker, Int64 HOWNERID, ref string sErrMsg)
+        {
+            //鑾峰彇绯荤粺鍙傛暟
+            Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+            if (oSystemParameter.ShowBill(ref sErrMsg) == false)
+            {
+                sErrMsg = "鑾峰彇绯荤粺鍙傛暟澶辫触锛� " + sErrMsg;
+                return false;
+            }
+
+            string sWHSPCtl = "Y";   //鏍¢獙-鏄惁鏍″浠撳簱浠撲綅锛�'Y'涓烘牎瀵癸級
+            if (HBillType == "1204" && oSystemParameter.omodel.Kf_MateOutBillCheck_WHSPCtl == "N")
+            {
+                //棰嗘枡鍑哄簱鍗�
+                sWHSPCtl = "N";
+            }
+            else if (HBillType == "1207" && oSystemParameter.omodel.Kf_MoveStockBillCheck_WHSPCtl == "N")
+            {
+                //鐩存帴璋冩嫧鍗�
+                sWHSPCtl = "N";
+            }
+
+            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_UpdateTemp_BillCheck " + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "','" + HMaker + "'," + HOWNERID.ToString() + ",'" + sWHSPCtl + "'", "h_p_WMS_UpdateTemp_BillCheck");
+            if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
+            {
+                sErrMsg = "鍗曟嵁鍙凤細" + HBillNo + "锛涘悓姝ュ崟鎹俊鎭彂鐢熼敊璇紒";
+                return false;
+            }
+            else
+            {
+                if (DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0][0]) == 0)
+                {
+                    sErrMsg = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HRemark"]);
+                    return true;
+                }
+                else
+                {
+                    sErrMsg = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HRemark"]);
+                    return false;
+                }
             }
         }
 
@@ -41588,11 +41763,13 @@
             }
             //鍒ゆ柇鏉$爜鏄惁鍚壒娈婄鍙� # 锛屽鏋滃惈鏈夊垯 鎷嗗垎
             string[] NewBarCode;
-            if (sBarCode.CompareTo("#") > 0)
+            if (sBarCode.Contains("#"))
             {
                 NewBarCode = sBarCode.Split(Convert.ToChar("#"));
                 sBarCode = NewBarCode[0];
+                HQty = DBUtility.ClsPub.isDoule(NewBarCode[1]);
             }
+
             //鑾峰彇绯荤粺鍙傛暟
             Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
             if (oSystemParameter.ShowBill(ref sErrMsg) == false)

--
Gitblit v1.9.1