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 |  679 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 465 insertions(+), 214 deletions(-)

diff --git a/CLOUDWEB/WebService1.asmx.cs b/CLOUDWEB/WebService1.asmx.cs
index 103dcdd..e071ee7 100644
--- a/CLOUDWEB/WebService1.asmx.cs
+++ b/CLOUDWEB/WebService1.asmx.cs
@@ -24917,7 +24917,6 @@
                 if (SaveProductInBill_ICMO_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
                 {
                     //"淇濆瓨鎴愬姛锛�";
-                    sErrMsg = "淇濆瓨鎴愬姛锛�" + oMain.HBillNo;
                     return true;
                 }
                 else
@@ -24932,7 +24931,6 @@
                 if (SaveProductInBill_ICMOReport_CLD(oMain, sHSourceType, oSystemParameterMain, ref sErrMsg))
                 {
                     //"淇濆瓨鎴愬姛锛�";
-                    sErrMsg = "淇濆瓨鎴愬姛锛�" + oMain.HBillNo;
                     return true;
                 }
                 else
@@ -24957,7 +24955,32 @@
         /// <returns></returns>
         public bool SaveProductInBill_ICMO_CLD(Model.ClsKf_ProductInBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
         {
-            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //寤虹珛涓�涓� 浜嬪姟锛�
+            //浠庨厤缃枃浠惰幏鍙� CLOUD缃戝潃銆佽处濂椾俊鎭�佺櫥褰曠敤鎴枫�佺櫥褰曞瘑鐮�
+            if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
+            {
+                sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
+                return false;
+            }
+
+            //鑾峰彇CLOUD璐﹀彿瀵嗙爜
+            string sCLOUDUseName = Pub_Class.ClsPub.sCLOUDUseName;
+            string sCLOUDPsd = Pub_Class.ClsPub.sCLOUDPsd;
+            DataSet ds11 = get_SaveCLOUDUseNameandPsd(oMain.HInterID);
+            if (ds11 == null || ds11.Tables[0].Rows.Count == 0)
+            {
+            }
+            else
+            {
+                sCLOUDUseName = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserName"]);
+                sCLOUDPsd = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserPsd"]);
+            }
+
+            string HReturn;
+            ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
+            string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
+            bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
+            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+
             try
             {
                 //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
@@ -24993,12 +25016,6 @@
                 //鏇存柊鍏宠仈鏁伴噺
                 oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOToProductIn_Add " + oMain.HInterID.ToString());
 
-                if (oSystemParameterMain.Kf_ProductInBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
-                {
-                    //瀹℃牳鍗曟嵁
-                    oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
-                }
-
                 //鏍规嵁TMP琛� 杩斿洖 瀛愯〃淇℃伅
                 DataSet Ds;
                 Ds = oCn.RunProcReturn("exec h_p_Kf_GetProductInBill_ICMO_CLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetProductInBill_ICMO_CLD_New");
@@ -25010,6 +25027,17 @@
                 }
                 else
                 {
+                    string sCheckFlag = "";         //鏄惁瀹℃牳鏍囧織
+                    string sJson_MainCustom = "";   //涓昏〃鑷畾涔夊瓧娈�
+                    //鏍规嵁缁勭粐鑾峰彇鏄惁瀹℃牳鏍囧織锛岃繑鍥� 涓嶄负绌猴紝鑾峰彇瀵瑰簲缁勭粐 鏄惁瀹℃牳鏍囧織
+                    sCheckFlag = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCheckFlag"]);
+                    if (sCheckFlag != "")
+                    {
+                        oSystemParameterMain.Kf_ProductInBill_AutoCheck = sCheckFlag;
+                    }
+
+                    sJson_MainCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["MainCustom"]);
+
                     string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\"," +
                         "\"IsEntryBatchFill\":\"false\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\"," +
                         "\"Model\": { \"FBILLNO\":\"" + oMain.HBillNo + "\"," +
@@ -25028,6 +25056,7 @@
                         //\"FCurrId\":{\"FNumber\":\"\"},
                         //\"FEntrustInStockId\":\"0\",
                         //\"FScanBox\":\"\",
+                        sJson_MainCustom +
                         "\"FEntity\": [   ";
                     string sJson_Entry = "";
                     for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
@@ -25145,31 +25174,7 @@
                     string sJson_End = "  ]  }}";
                     string sJson = sJson_Main + sJson_Entry + sJson_End;
 
-                    //浠庨厤缃枃浠惰幏鍙� CLOUD缃戝潃銆佽处濂椾俊鎭�佺櫥褰曠敤鎴枫�佺櫥褰曞瘑鐮�
-                    if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
-                    {
-                        sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
-                        return false;
-                    }
-
-                    //鑾峰彇CLOUD璐﹀彿瀵嗙爜
-                    string sCLOUDUseName = Pub_Class.ClsPub.sCLOUDUseName;
-                    string sCLOUDPsd = Pub_Class.ClsPub.sCLOUDPsd;
-                    DataSet ds11 = get_SaveCLOUDUseNameandPsd(oMain.HInterID);
-                    if (ds11 == null || ds11.Tables[0].Rows.Count == 0)
-                    {
-                    }
-                    else
-                    {
-                        sCLOUDUseName = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserName"]);
-                        sCLOUDPsd = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserPsd"]);
-                    }
-
-                    //鐢熸垚 鍏ュ簱鍗� 
-                    string HReturn;
-                    ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
-                    string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
-                    bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
+                    //鐢熸垚閲戣澏浜戝崟鎹�
                     if (bLogin)
                     {
                         var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
@@ -25178,22 +25183,8 @@
                         //鐢熸垚鍗曟嵁鍚庢洿鏂拌嚜瀹氫箟瀛楁
                         oCn.RunProc("exec h_p_Sc_UpDateSelfFildProductIn '" + oMain.HBillNo + "','" + sHSourceType + "'");
 
-                        if (oSystemParameterMain.Kf_ProductInBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
-                        {
-                            string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
-                            var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
-                            new object[] { "PRD_INSTOCK", sJson2 }); //鎻愪氦鍗曟嵁
+                        HReturn = result.ToString();
 
-                            string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
-                            var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
-                            new object[] { "PRD_INSTOCK", sJson3 }); //瀹℃牳鍗曟嵁
-
-                            HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
-                        }
-                        else
-                        {
-                            HReturn = result.ToString();
-                        }
                         if (HReturn.Contains("\"IsSuccess\":false") == true)
                         {
                             sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + HReturn + sJson;
@@ -25203,12 +25194,11 @@
                         else
                         {
                             oCn.Commit();
-                            return true;
                         }
                     }
                     else
                     {
-                        sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒鐧诲綍澶辫触锛�";
+                        sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒閲戣澏浜戠櫥褰曞け璐ワ紒";
                         oCn.RollBack();
                         return false;
                     }
@@ -25220,6 +25210,52 @@
                 oCn.RollBack();
                 return false;
             }
+
+            if (oSystemParameterMain.Kf_ProductInBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+            {
+                try
+                {
+                    oCn.BeginTran();
+                    //瀹℃牳WMS鍗曟嵁
+                    oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
+
+                    //鎻愪氦銆佸鏍搁噾铦朵簯鍗曟嵁
+                    HReturn = "";
+                    string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
+                    var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
+                    new object[] { "PRD_INSTOCK", sJson2 }); //鎻愪氦鍗曟嵁
+
+                    string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
+                    var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
+                    new object[] { "PRD_INSTOCK", sJson3 }); //瀹℃牳鍗曟嵁
+
+                    HReturn = result2.ToString() + "," + result3.ToString();
+
+                    if (HReturn.Contains("\"IsSuccess\":false") == true)
+                    {
+                        sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曟垚鍔燂紝瀹℃牳鍗曟嵁澶辫触锛�" + HReturn;
+                        oCn.RollBack();
+                        return true;
+                    }
+                    else
+                    {
+                        sErrMsg = "鐢熸垚骞跺鏍哥敓浜у叆搴撳崟鎴愬姛锛佸崟鎹彿涓猴細" + oMain.HBillNo;
+                        oCn.Commit();
+                        return true;
+                    }
+                }
+                catch (Exception e)
+                {
+                    sErrMsg = "瀹℃牳鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.Message;
+                    oCn.RollBack();
+                    return false;
+                }
+            }
+            else
+            {
+                sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曟垚鍔燂紒鍗曟嵁鍙蜂负锛�" + oMain.HBillNo;
+                return true;
+            }
         }
 
         /// <summary>
@@ -25230,7 +25266,32 @@
         /// <returns></returns>
         public bool SaveProductInBill_ICMOReport_CLD(Model.ClsKf_ProductInBillMain oMain, string sHSourceType, Pub_Class.ClsXt_SystemParameterMain oSystemParameterMain, ref string sErrMsg)
         {
-            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //寤虹珛涓�涓� 浜嬪姟锛�
+            //浠庨厤缃枃浠惰幏鍙� CLOUD缃戝潃銆佽处濂椾俊鎭�佺櫥褰曠敤鎴枫�佺櫥褰曞瘑鐮�
+            if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
+            {
+                sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
+                return false;
+            }
+
+            //鑾峰彇CLOUD璐﹀彿瀵嗙爜
+            string sCLOUDUseName = Pub_Class.ClsPub.sCLOUDUseName;
+            string sCLOUDPsd = Pub_Class.ClsPub.sCLOUDPsd;
+            DataSet ds11 = get_SaveCLOUDUseNameandPsd(oMain.HInterID);
+            if (ds11 == null || ds11.Tables[0].Rows.Count == 0)
+            {
+            }
+            else
+            {
+                sCLOUDUseName = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserName"]);
+                sCLOUDPsd = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserPsd"]);
+            }
+
+            string HReturn;
+            ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
+            string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
+            bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
+            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
+
             try
             {
                 //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
@@ -25266,12 +25327,6 @@
                 //鏇存柊鍏宠仈鏁伴噺
                 oCn.RunProc("exec h_p_Sc_UpDateRelation_ICMOReportToProductIn_Add " + oMain.HInterID.ToString());
 
-                if (oSystemParameterMain.Kf_ProductInBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
-                {
-                    //瀹℃牳鍗曟嵁
-                    oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
-                }
-
                 //鏍规嵁TMP琛� 杩斿洖 瀛愯〃淇℃伅
                 DataSet Ds;
                 Ds = oCn.RunProcReturn("exec h_p_Kf_GetProductInBill_ICMOReport_CLD_New " + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "'", "h_p_Kf_GetProductInBill_ICMOReport_CLD_New");
@@ -25283,6 +25338,17 @@
                 }
                 else
                 {
+                    string sCheckFlag = "";         //鏄惁瀹℃牳鏍囧織
+                    string sJson_MainCustom = "";   //涓昏〃鑷畾涔夊瓧娈�
+                    //鏍规嵁缁勭粐鑾峰彇鏄惁瀹℃牳鏍囧織锛岃繑鍥� 涓嶄负绌猴紝鑾峰彇瀵瑰簲缁勭粐 鏄惁瀹℃牳鏍囧織
+                    sCheckFlag = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HCheckFlag"]);
+                    if(sCheckFlag!="")
+                    {
+                        oSystemParameterMain.Kf_ProductInBill_AutoCheck = sCheckFlag;
+                    }
+
+                    sJson_MainCustom = Pub_Class.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["MainCustom"]);
+
                     string sJson_Main = "{\"Creator\":\"\",\"NeedUpDateFields\":[],\"NeedReturnFields\":[],\"IsDeleteEntry\":\"True\",\"SubSystemId\":\"\",\"IsVerifyBaseDataField\":\"false\"," +
                         "\"IsEntryBatchFill\":\"false\",\"ValidateFlag\":\"True\",\"NumberSearch\":\"True\",\"InterationFlags\":\"\"," +
                         "\"Model\": { \"FBILLNO\":\"" + oMain.HBillNo + "\"," +
@@ -25301,6 +25367,7 @@
                         //\"FCurrId\":{\"FNumber\":\"\"},
                         //\"FEntrustInStockId\":\"0\",
                         //\"FScanBox\":\"\",
+                        sJson_MainCustom +
                         "\"FEntity\": [   ";
                     string sJson_Entry = "";
                     for (int i = 0; i < Ds.Tables[1].Rows.Count; i++)
@@ -25444,31 +25511,7 @@
                     string sJson_End = "  ]  }}";
                     string sJson = sJson_Main + sJson_Entry + sJson_End;
 
-                    //浠庨厤缃枃浠惰幏鍙� CLOUD缃戝潃銆佽处濂椾俊鎭�佺櫥褰曠敤鎴枫�佺櫥褰曞瘑鐮�
-                    if (!Pub_Class.ClsPub.GetCLOUDLoginInfo(ref Pub_Class.ClsPub.sExeReturnInfo))
-                    {
-                        sErrMsg = Pub_Class.ClsPub.sExeReturnInfo;
-                        return false;
-                    }
-
-                    //鑾峰彇CLOUD璐﹀彿瀵嗙爜
-                    string sCLOUDUseName = Pub_Class.ClsPub.sCLOUDUseName;
-                    string sCLOUDPsd = Pub_Class.ClsPub.sCLOUDPsd;
-                    DataSet ds11 = get_SaveCLOUDUseNameandPsd(oMain.HInterID);
-                    if (ds11 == null || ds11.Tables[0].Rows.Count == 0)
-                    {
-                    }
-                    else
-                    {
-                        sCLOUDUseName = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserName"]);
-                        sCLOUDPsd = DBUtility.ClsPub.isStrNull(ds11.Tables[0].Rows[0]["HCloudUserPsd"]);
-                    }
-
-                    //鐢熸垚 鍏ュ簱鍗� 
-                    string HReturn;
-                    ApiClient client = new ApiClient(Pub_Class.ClsPub.sCLOUDUrl);
-                    string dbId = Pub_Class.ClsPub.sCLOUDAcc; //AotuTest117
-                    bool bLogin = client.Login(dbId, sCLOUDUseName, sCLOUDPsd, 2052);
+                    //鐢熸垚閲戣澏浜戝崟鎹�
                     if (bLogin)
                     {
                         var result = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Save",
@@ -25477,22 +25520,8 @@
                         //鐢熸垚鍗曟嵁鍚庢洿鏂拌嚜瀹氫箟瀛楁
                         oCn.RunProc("exec h_p_Sc_UpDateSelfFildProductIn '" + oMain.HBillNo + "','" + sHSourceType + "'");
 
-                        if (oSystemParameterMain.Kf_ProductInBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
-                        {
-                            string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
-                            var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
-                            new object[] { "PRD_INSTOCK", sJson2 }); //鎻愪氦鍗曟嵁
+                        HReturn = result.ToString();
 
-                            string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
-                            var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
-                            new object[] { "PRD_INSTOCK", sJson3 }); //瀹℃牳鍗曟嵁
-
-                            HReturn = result.ToString() + "," + result2.ToString() + "," + result3.ToString();
-                        }
-                        else
-                        {
-                            HReturn = result.ToString();
-                        }
                         if (HReturn.Contains("\"IsSuccess\":false") == true)
                         {
                             sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + HReturn + sJson;
@@ -25502,12 +25531,11 @@
                         else
                         {
                             oCn.Commit();
-                            return true;
                         }
                     }
                     else
                     {
-                        sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒鐧诲綍澶辫触锛�";
+                        sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒閲戣澏浜戠櫥褰曞け璐ワ紒";
                         oCn.RollBack();
                         return false;
                     }
@@ -25518,6 +25546,52 @@
                 sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.Message;
                 oCn.RollBack();
                 return false;
+            }
+
+            if (oSystemParameterMain.Kf_ProductInBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+            {
+                try
+                {
+                    oCn.BeginTran();
+                    //瀹℃牳WMS鍗曟嵁
+                    oCn.RunProc("Update Kf_ICStockBillMain Set HChecker='" + oMain.HMaker + "',HCheckDate=convert(varchar(10),getdate(),120) where HInterID= " + oMain.HInterID.ToString());
+
+                    //鎻愪氦銆佸鏍搁噾铦朵簯鍗曟嵁
+                    HReturn = "";
+                    string sJson2 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
+                    var result2 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Submit",
+                    new object[] { "PRD_INSTOCK", sJson2 }); //鎻愪氦鍗曟嵁
+
+                    string sJson3 = "{\"CreateOrgId\":0,\"Numbers\":[\"" + oMain.HBillNo + "\"]}";
+                    var result3 = client.Execute<string>("Kingdee.BOS.WebApi.ServicesStub.DynamicFormService.Audit",
+                    new object[] { "PRD_INSTOCK", sJson3 }); //瀹℃牳鍗曟嵁
+
+                    HReturn = result2.ToString() + "," + result3.ToString();
+
+                    if (HReturn.Contains("\"IsSuccess\":false") == true)
+                    {
+                        sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曟垚鍔燂紝瀹℃牳鍗曟嵁澶辫触锛�" + HReturn;
+                        oCn.RollBack();
+                        return true;
+                    }
+                    else
+                    {
+                        sErrMsg = "鐢熸垚骞跺鏍哥敓浜у叆搴撳崟鎴愬姛锛佸崟鎹彿涓猴細" + oMain.HBillNo;
+                        oCn.Commit();
+                        return true;
+                    }
+                }
+                catch (Exception e)
+                {
+                    sErrMsg = "瀹℃牳鐢熶骇鍏ュ簱鍗曞け璐ワ紒" + e.Message;
+                    oCn.RollBack();
+                    return false;
+                }
+            }
+            else
+            {
+                sErrMsg = "鐢熸垚鐢熶骇鍏ュ簱鍗曟垚鍔燂紒鍗曟嵁鍙蜂负锛�" + oMain.HBillNo;
+                return true;
             }
         }
 
@@ -32699,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")
@@ -33256,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();
@@ -33764,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();
@@ -34500,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]);
             }
 
             //鏍规嵁鏉$爜鑾峰彇鏉$爜淇℃伅
@@ -34911,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)
@@ -38571,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]);
                     }
                 }
 
@@ -39050,7 +39131,7 @@
 
 
 
-            #endregion
+        #endregion
 
 
             //        #region 鎵弿鐗╂枡鏉$爜璋冪敤鏂规硶
@@ -39406,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)
@@ -40134,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]);
                     }
                 }
 
@@ -40231,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 = "鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓彂鐢熼敊璇紒";
@@ -40250,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"]);
@@ -40388,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;
         }
 
@@ -40451,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 = "鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓彂鐢熼敊璇紒";
@@ -40480,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
                 {
@@ -40638,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)
@@ -40692,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;
         }
 
@@ -40759,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]);
                     }
                 }
 
@@ -41051,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;
+                }
             }
         }
 
@@ -41514,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