From 291fdb29daf239a13fcfb3f5e08a2f5bf9167534 Mon Sep 17 00:00:00 2001
From: chenhaozhe <gaozhechen26@gmail.com>
Date: 星期六, 07 三月 2026 17:37:07 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API

---
 WebAPI/Controllers/Cg_ContractTransportBillListController.cs |  148 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 129 insertions(+), 19 deletions(-)

diff --git a/WebAPI/Controllers/Cg_ContractTransportBillListController.cs b/WebAPI/Controllers/Cg_ContractTransportBillListController.cs
index 90f972d..32e870e 100644
--- a/WebAPI/Controllers/Cg_ContractTransportBillListController.cs
+++ b/WebAPI/Controllers/Cg_ContractTransportBillListController.cs
@@ -90,6 +90,7 @@
         {
             try
             {
+                string s = "";
                 //鏌ョ湅鏉冮檺
                 if (!DBUtility.ClsPub.Security_Log("Cg_ContractTransportBill_Delete", 1, false, user))
                 {
@@ -115,7 +116,7 @@
                 if (BillOld.ShowBill(Int64.Parse(HInterID), ref DBUtility.ClsPub.sExeReturnInfo))
                 {
                     //鍒犻櫎鍓嶆帶鍒�=========================================      
-                    string sql1 = "exec h_p_Cg_ContractTransportBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    string sql1 = "exec h_p_Cg_ContractTransportBill_BeforeDelCtrl  " + BillOld.omodel.HInterID + ",'" + user + "'";
                     ds = oCN.RunProcReturn(sql1, "h_p_Cg_ContractTransportBill_BeforeDelCtrl");
                     if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
@@ -135,38 +136,51 @@
                         return objJsonResult;
                     }
                     //==================================================================================  
-
+                    oCN.RunProc("delete from Cg_ContractTransportBillMain where HInterID = " + HInterID);
+                    oCN.RunProc("delete from Cg_ContractTransportBillSub where HInterID= " + HInterID);
                     //鍒犻櫎鍗曟嵁锛堝寘鍚垹闄ゅ悗鎺у埗銆佸啓鍏ユ棩蹇楋級
-                    if (!BillOld.DeleteBill(BillOld.omodel.HInterID, BillOld.omodel.HBillNo, "h_p_Cg_ContractTransportBill_AfterDelCtrl", user, ref ClsPub.sExeReturnInfo))
+                    //鍒犻櫎鍚庢帶鍒�==================================================================================      
+                    string sql2 = "exec h_p_Cg_ContractTransportBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Cg_ContractTransportBill_AfterDelCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                     {
-                        objJsonResult.code = "0";
-                        objJsonResult.count = 0;
-                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo;
-                        objJsonResult.data = null;
-                        return objJsonResult;
-                    }
-                    else
-                    {
+                        s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
                         objJsonResult.code = "0";
                         objJsonResult.count = 1;
-                        objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
                         objJsonResult.data = null;
+                        oCN.RollBack();
                         return objJsonResult;
                     }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        s = ds.Tables[0].Rows[0]["HRemark"].ToString();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==============================================================================================
 
+                    oCN.Commit();
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎鎴愬姛";
+                    objJsonResult.data = null;
+                    return objJsonResult;
                 }
-
-                oCN.Commit();
-
-
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.Message = "鍒犻櫎鎴愬姛";
                 objJsonResult.data = null;
                 return objJsonResult;
             }
             catch (Exception e)
             {
+                oCN.RollBack();
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "Exception锛�" + e.ToString();
@@ -342,12 +356,12 @@
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
-                if (refSav == "Add")
+                if (refSav == "Add"|| refSav=="1")
                 {
 
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
-                else if (refSav == "Update")
+                else if (refSav == "Update" || refSav == "3")
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
@@ -382,5 +396,101 @@
             }
         }
         #endregion
+
+
+        #region 瀹℃牳銆佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Cg_ContractTransportBillEdit/AuditCg_ContractTransportBillEdit")]
+        [HttpGet]
+        public object AuditCg_ContractTransportBillEdit(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Supplier_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Cg_ContractTransportBillMain where HInterID=" + HInterID, "Cg_ContractTransportBillMain");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HChecker"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                {
+                    oCN.RunProc("update Cg_ContractTransportBillMain set HChecker='" + CurUserName + "',HCheckDate=getdate() ,HBillStatus=2 where HInterID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    oCN.RunProc("update Cg_ContractTransportBillMain set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID=" + HInterID);
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1