From a5d691a24ef8fdb7155ecc9f6dd1bef843020f03 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期二, 20 二月 2024 13:28:10 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs |   53 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 41 insertions(+), 12 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs b/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
index 8360cc1..2b6ef3a 100644
--- a/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
+++ b/WebAPI/Controllers/CJGL/Sc_ProcessExchangeBillController.cs
@@ -838,9 +838,9 @@
         }
         #endregion
 
-        #region [妯″叿淇濆吇璁″垝鍗曞垹闄ゅ姛鑳絔
+        #region [宸ュ簭娴佽浆鍗″垹闄ゅ姛鑳絔
         /// <summary>
-        /// 妯″叿缁翠慨鍗曞垹闄ゅ姛鑳�
+        /// 宸ュ簭娴佽浆鍗″垹闄ゅ姛鑳�
         /// </summary>
         /// <returns></returns>
         [Route("Sc_ProcessExchangeBill/DeltetProcessExchangeBillByID")]
@@ -877,14 +877,15 @@
 
             DAL.ClsSc_ProcessExchangeBill oBill = new DAL.ClsSc_ProcessExchangeBill();
 
-            string[] HBillNo = HInterID.Split(',');
+            string[] HInterIDs = HInterID.Split(',');
+            string[] HBillNos = new string[HInterIDs.Length];
 
             string HBillNo_S = "";
 
-            foreach (var item in HBillNo)
+            for (int i = 0; i < HInterIDs.Length; i++)
             {
                 Int64 lngBillKey = 0;
-                lngBillKey = DBUtility.ClsPub.isLong(item);
+                lngBillKey = DBUtility.ClsPub.isLong(HInterIDs[i]);
 
                 DBUtility.ClsPub.HOrgID = HPRDORGID;
                 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
@@ -893,7 +894,7 @@
                     {
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
-                        objJsonResult.Message = "鍗曟嵁鍙�:"+ oBill .omodel.HBillNo+ "鍗曟嵁ID涓虹┖锛�";
+                        objJsonResult.Message = "鍗曟嵁鍙�:" + oBill.omodel.HBillNo + "鍗曟嵁ID涓虹┖锛�";
                         objJsonResult.data = null;
                         return objJsonResult;
                     }
@@ -949,6 +950,7 @@
                         return objJsonResult;
                     }
                     HBillNo_S += oBill.omodel.HBillNo + ",";
+                    HBillNos[i] = oBill.omodel.HBillNo;
                 }
                 else
                 {
@@ -961,17 +963,18 @@
             }
 
             HBillNo_S = HBillNo_S.Substring(0, HBillNo_S.Length - 1);
-            LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鍒犻櫎宸ュ簭娴佽浆鍗″崟鎹�:" + HBillNo_S);
 
             oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鍒犻櫎宸ュ簭娴佽浆鍗″崟鎹細" + HBillNo_S + "','LMES-宸ュ簭娴佽浆鍗℃ā鍧�','" + DBUtility.ClsPub.IPAddress + "','鍒犻櫎鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
 
-            foreach (var item in HBillNo)
+            for (int i = 0; i < HInterIDs.Length; i++)
             {
                 oCN.BeginTran();
-                if (HSouceBillType == "SUB") {
-                    ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HInterID=" + item, "Sc_ProcessExchangeBillMain");
+                if (HSouceBillType == "SUB")
+                {
+                    ds = oCN.RunProcReturn("select  * from Sc_ProcessExchangeBillMain where HInterID=" + HInterIDs[i], "Sc_ProcessExchangeBillMain");
 
-                    if (ds.Tables[0].Rows.Count == 0) {
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
                         oCN.RollBack();
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
@@ -983,7 +986,31 @@
                     oCN.RunProc("update Sc_ProcessExchangeBillSub set HSourceID=0 where HInterID=" + ds.Tables[0].Rows[0]["HMainSourceInterID"].ToString() + " and HEntryID=" + ds.Tables[0].Rows[0]["HMainSourceEntryID"].ToString());
                 }
 
-                bool IsDete = oBill.DeleteBill(long.Parse(item), ref DBUtility.ClsPub.sExeReturnInfo);
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Sc_ProcessExchangeBill_BeforeDelCtrl " + HInterIDs[i] + ",'" + HBillNos[i] + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Sc_ProcessExchangeBill_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //==================================================================================      
+
+                bool IsDete = oBill.DeleteBill(long.Parse(HInterIDs[i]), HBillNos[i], "h_p_Sc_ProcessExchangeBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
 
                 if (!IsDete)
                 {
@@ -994,6 +1021,8 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+
                 oCN.Commit();
             }
 

--
Gitblit v1.9.1