From 2566524594675a8d742f9ba0eff35dd5d8d33fa2 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 31 三月 2025 12:43:22 +0800
Subject: [PATCH] 排产:Excel导入功能,上传文件时,如果时宝工,则返回excel文件中维护的数量,不然则取生产订单的数量

---
 WebAPI/Controllers/WebAPIController.cs | 1900 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 1,665 insertions(+), 235 deletions(-)

diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs
index 0674f47..06816a8 100644
--- a/WebAPI/Controllers/WebAPIController.cs
+++ b/WebAPI/Controllers/WebAPIController.cs
@@ -37,7 +37,7 @@
         string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"];
 
         /// <summary>
-        /// 閫佽揣鍗曡〃澶翠俊鎭�
+        /// 鑾峰彇鍗曟嵁鍙蜂笌鍗曟嵁鍐呯爜
         /// </summary>
         /// <param name="sMsg"></param>
         /// <returns></returns>
@@ -352,6 +352,16 @@
                     objjson.code = "0";
                     objjson.count = 0;
                     objjson.Message = "瀵嗙爜閿欒锛�";
+                    objjson.data = null;
+                    return objjson;
+                }
+                //鍒ゆ柇鐢ㄦ埛鏁版槸鍚﹀ぇ浜庡鎴疯处鍙锋暟
+                DataSet ds1 = oCN.RunProcReturn("Exec h_p_Xt_BaseInfo ", "h_p_Xt_BaseInfo");               
+                if (DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = ds1.Tables[0].Rows[0]["HBackRemark"].ToString();
                     objjson.data = null;
                     return objjson;
                 }
@@ -2604,7 +2614,6 @@
             DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_BadReason ", "Gy_BadReason");
             if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
             {
-                //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
                 var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]);
                 maxid += 1;
                 HItemID = maxid;
@@ -2731,7 +2740,7 @@
                     oItem.HShortNumber = sShortNumber;//鐭唬鐮�
                     oItem.HEndFlag = true;//鏈骇鏍囧織
                     oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇
-
+                    oItem.HMakeEmp = msg2;
                     oBill.oModel = oItem;
                 }
 
@@ -2740,19 +2749,17 @@
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
-                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";;
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -2771,6 +2778,142 @@
                 objJsonResult.count = 0;
                 objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
                 objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 涓嶈壇鍘熷洜鑾峰彇淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("GetGy_BadReasonDetail")]
+        [HttpGet]
+        public ApiResult<DataSet> GetGy_BadReasonDetail(string HID)
+        {
+            var model = LuBaoSevice.GetGy_BadReasonBillDetail(HID);
+            return model;
+        }
+
+        /// <summary>
+        /// 涓嶈壇鍘熷洜鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("DeltetGy_BadReason")]
+        [HttpGet]
+        public object DeltetGy_BadReason(string HItemID, string user)
+        {
+            DataSet ds;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_BadReason_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (string.IsNullOrWhiteSpace(HItemID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+                ds = oCN.RunProcReturn("select * from Gy_BadReason where HItemID=" + HItemID, "Gy_BadReason");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
+                //if (HStopflag)
+                //{
+                //    oCN.RollBack();//鍥炴粴浜嬪姟
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏁版嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_BadReason_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadReason_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+
+                oCN.RunProc("delete Gy_BadReason where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_BadReason_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadReason_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+               
+                oCN.Commit();//鎻愪氦浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
                 return objJsonResult;
             }
         }
@@ -3110,7 +3253,9 @@
         #endregion
         #endregion
 
+        #endregion
 
+        #region 涓嶈壇绫诲瀷  璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
 
         /// <summary>
         /// 淇濆瓨涓嶈壇绫诲瀷
@@ -3271,7 +3416,7 @@
                     oItem.HShortNumber = sShortNumber;//鐭唬鐮�
                     oItem.HEndFlag = true;//鏈骇鏍囧織
                     oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇
-
+                    oItem.HMakeEmp = msg2;
                     oBill.oModel = oItem;
                 }
 
@@ -3280,19 +3425,17 @@
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -3311,6 +3454,143 @@
                 objJsonResult.count = 0;
                 objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
                 objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 涓嶈壇绫诲瀷鑾峰彇淇℃伅
+        /// </summary>
+        /// <returns></returns>
+        [Route("GetGy_BadTypeDetail")]
+        [HttpGet]
+        public ApiResult<DataSet> GetGy_BadTypeDetail(string HID)
+        {
+            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_gy_BadTypeList  where HItemID= " + HID + " ", "h_v_gy_BadTypeList");
+            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
+                return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄤ笉鑹被鍨嬫暟鎹�" };
+            return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
+        }
+
+        /// <summary>
+        /// 涓嶈壇绫诲瀷鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("DeltetGy_BadType")]
+        [HttpGet]
+        public object DeltetGy_BadType(string HItemID, string user)
+        {
+            DataSet ds;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_BadType_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (string.IsNullOrWhiteSpace(HItemID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+                ds = oCN.RunProcReturn("select * from Gy_BadType where HItemID=" + HItemID, "Gy_BadType");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
+                //if (HStopflag)
+                //{
+                //    oCN.RollBack();//鍥炴粴浜嬪姟
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏁版嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_BadType_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadType_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+
+                oCN.RunProc("delete Gy_BadType where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_BadType_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadType_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+              
+                oCN.Commit();//鎻愪氦浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
                 return objJsonResult;
             }
         }
@@ -3621,6 +3901,9 @@
         #endregion
         #endregion
 
+        #endregion
+
+        #region  寮傚父绫诲瀷   璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
 
         /// <summary>
         /// 淇濆瓨寮傚父绫诲瀷
@@ -4261,175 +4544,6 @@
         }
         #endregion
         #endregion
-
-        /// <summary>
-        /// 涓嶈壇绫诲瀷鑾峰彇淇℃伅
-        /// </summary>
-        /// <returns></returns>
-        [Route("GetGy_BadTypeDetail")]
-        [HttpGet]
-        public ApiResult<DataSet> GetGy_BadTypeDetail(string HID)
-        {
-            var dataSet = oCN.RunProcReturn("select top 1 * from h_v_gy_BadTypeList  where HItemID= " + HID + " ", "h_v_gy_BadTypeList");
-            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
-                return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄤ笉鑹被鍨嬫暟鎹�" };
-            return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
-        }
-
-        /// <summary>
-        /// 涓嶈壇绫诲瀷鍒犻櫎鍔熻兘
-        /// </summary>
-        /// <returns></returns>
-        [Route("DeltetGy_BadType")]
-        [HttpGet]
-        public object DeltetGy_BadType(string HItemID, string user)
-        {
-            DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
-            try
-            {
-                //鍒犻櫎鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Gy_BadType_Drop", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                if (string.IsNullOrWhiteSpace(HItemID))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "HItemID涓虹┖锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                oCN.BeginTran();//寮�濮嬩簨鍔�
-                ds = oCN.RunProcReturn("select * from Gy_BadType where HItemID=" + HItemID, "Gy_BadType");
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
-                    objJsonResult.data = null;
-                    return objJsonResult; ;
-                }
-                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
-                //if (HStopflag)
-                //{
-                //    oCN.RollBack();//鍥炴粴浜嬪姟
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "鏁版嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
-
-                oCN.RunProc("delete Gy_BadType where HItemID=" + HItemID);
-                oCN.Commit();//鎻愪氦浜嬪姟
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult; ;
-
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-
-        /// <summary>
-        /// 涓嶈壇鍘熷洜鑾峰彇淇℃伅
-        /// </summary>
-        /// <returns></returns>
-        [Route("GetGy_BadReasonDetail")]
-        [HttpGet]
-        public ApiResult<DataSet> GetGy_BadReasonDetail(string HID)
-        {
-            var model = LuBaoSevice.GetGy_BadReasonBillDetail(HID);
-            return model;
-        }
-
-        /// <summary>
-        /// 涓嶈壇鍘熷洜鍒犻櫎鍔熻兘
-        /// </summary>
-        /// <returns></returns>
-        [Route("DeltetGy_BadReason")]
-        [HttpGet]
-        public object DeltetGy_BadReason(string HItemID, string user)
-        {
-            DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
-            try
-            {
-                //鍒犻櫎鏉冮檺
-                if (!DBUtility.ClsPub.Security_Log("Gy_BadReason_Delete", 1, false, user))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-
-                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                if (string.IsNullOrWhiteSpace(HItemID))
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "HItemID涓虹┖锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
-                }
-                oCN.BeginTran();//寮�濮嬩簨鍔�
-                ds = oCN.RunProcReturn("select * from Gy_BadReason where HItemID=" + HItemID, "Gy_BadReason");
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
-                {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
-                    objJsonResult.data = null;
-                    return objJsonResult; ;
-                }
-                //var HStopflag = Convert.ToBoolean(ds.Tables[0].Rows[0]["HStopflag"]);
-                //if (HStopflag)
-                //{
-                //    oCN.RollBack();//鍥炴粴浜嬪姟
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "鏁版嵁宸插垹闄ゆ棤娉曞啀娆″垹闄わ紒";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
-
-                oCN.RunProc("delete Gy_BadReason where HItemID=" + HItemID);
-                oCN.Commit();//鎻愪氦浜嬪姟
-                objJsonResult.code = "0";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�";
-                objJsonResult.data = null;
-                return objJsonResult; ;
-
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
-                objJsonResult.data = null;
-                return objJsonResult;
-            }
-        }
-
         #endregion
 
 
@@ -4604,11 +4718,11 @@
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -4702,7 +4816,58 @@
                 //    return objJsonResult;
                 //}
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_BadResult_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadResult_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+
                 oCN.RunProc("delete Gy_BadResult where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_BadResult_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadResult_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+               
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -5162,14 +5327,15 @@
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
+                string sExeReturnInfo = "";
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -5184,7 +5350,7 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + sExeReturnInfo;
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -5263,7 +5429,54 @@
                 //    return objJsonResult;
                 //}
 
+
+                //鍒犻櫎鍓嶆帶鍒�=========================================
+                ds = oCN.RunProcReturn("Exec h_p_Gy_InspectValue_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_InspectValue_BeforeDelCtrl");
+
+                if (ds == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
                 oCN.RunProc("delete Gy_InspectValue where HItemID=" + HItemID);
+
+                //鍒犻櫎鍚庢帶鍒�=========================================
+                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_InspectValue_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_InspectValue_AfterDelCtrl");
+                if (ds2 == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -6231,14 +6444,15 @@
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
+                string sExeReturnInfo = "";
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -6253,7 +6467,7 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + sExeReturnInfo;
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -6332,7 +6546,55 @@
                 //    return objJsonResult;
                 //}
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================
+                ds = oCN.RunProcReturn("Exec h_p_Gy_InspectInstruMent_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_InspectInstruMent_BeforeDelCtrl");
+
+                if (ds == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
+
                 oCN.RunProc("delete Gy_InspectInstruMent where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================
+                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_InspectInstruMent_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_InspectInstruMent_AfterDelCtrl");
+                if (ds2 == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -6994,19 +7256,17 @@
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -7049,8 +7309,7 @@
         [HttpGet]
         public object DeltetGy_PostSkill(string HItemID, string user)
         {
-            DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            DataSet ds;           
             try
             {
                 //鍒犻櫎鏉冮檺
@@ -7083,8 +7342,58 @@
                     return objJsonResult; ;
                 }
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_PostSkill_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_PostSkill_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_PostSkill where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_PostSkill_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_PostSkill_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+                
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -7578,19 +7887,17 @@
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -7634,7 +7941,6 @@
         public object DeltetGy_Post(string HItemID, string user)
         {
             DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
             try
             {
                 //鍒犻櫎鏉冮檺
@@ -7667,8 +7973,59 @@
                     return objJsonResult; ;
                 }
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_Post_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_Post_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_Post where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_Post_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_Post_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+               
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -10363,19 +10720,17 @@
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -10407,7 +10762,6 @@
         public object DeltetGy_TechnologyType(string HItemID, string user)
         {
             DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
             try
             {
                 //鍒犻櫎鏉冮檺
@@ -10440,8 +10794,59 @@
                     return objJsonResult; ;
                 }
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_TechnologyParameterClass_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_TechnologyParameterClass_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_TechnologyParameterClass where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_TechnologyParameterClass_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_TechnologyParameterClass_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+              
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -11777,14 +12182,15 @@
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
+                string sExeReturnInfo = "";
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -11799,7 +12205,7 @@
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + sExeReturnInfo;
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -11888,8 +12294,54 @@
                     return objJsonResult;
                 }
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================
+                ds = oCN.RunProcReturn("Exec h_p_Gy_ErrMsgBackType_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_ErrMsgBackType_BeforeDelCtrl");
+
+                if (ds == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
 
                 oCN.RunProc("delete Gy_ErrMsgBackType where HItemID=" + HItemID);
+
+                //鍒犻櫎鍚庢帶鍒�=========================================
+                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_ErrMsgBackType_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_ErrMsgBackType_AfterDelCtrl");
+                if (ds2 == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -12337,11 +12789,11 @@
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID,ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -12445,8 +12897,59 @@
                     return objJsonResult;
                 }
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_BadPhenomena_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_BadPhenomena_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_BadPhenomena where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_BadPhenomena_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_BadPhenomena_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+              
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -13781,11 +14284,11 @@
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -13860,8 +14363,56 @@
                 }
                 oCN.BeginTran();//寮�濮嬩簨鍔�
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_PreventErrMould_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_PreventErrMould_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
 
                 oCN.RunProc("delete Gy_PreventErrMould where HItemID=" + HItemID);
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_PreventErrMould_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_PreventErrMould_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+               
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -13914,7 +14465,6 @@
             DataSet Maxds = oCN.RunProcReturn("select isNull(MAX(HItemID),0) HItemID from Gy_MaintainLev ", "Gy_MaintainLev");
             if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
             {
-                //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
                 var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]);
                 maxid += 1;
                 HItemID = maxid;
@@ -14053,18 +14603,17 @@
                 if (oBill.oModel.HItemID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                     objJsonResult.data = 1;
                     return objJsonResult;
                 }
@@ -14106,9 +14655,7 @@
         [Route("DeltetGy_MaintainLev")]
         [HttpGet]
         public object DeltetGy_MaintainLev(string HItemID, string user)
-        {
-            DataSet ds;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
+        {            
             try
             {
                 //鍒犻櫎鏉冮檺
@@ -14132,8 +14679,59 @@
                 }
                 oCN.BeginTran();//寮�濮嬩簨鍔�
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_MaintainLev_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_MaintainLev_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_MaintainLev where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_MaintainLev_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_MaintainLev_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -14323,11 +14921,11 @@
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
                 {
-                    bResult = oBill.AddNew();
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -14400,8 +14998,58 @@
                 }
                 oCN.BeginTran();//寮�濮嬩簨鍔�
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_CheckNoteItem_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_CheckNoteItem_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_CheckNoteItem where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_CheckNoteItem_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_CheckNoteItem_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+               
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -15056,10 +15704,736 @@
         }
         #endregion
 
-
-        #region  鐜妫�娴嬪崟  璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
+        #region  宸ヨ壓璺嚎澶х被  璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
         /// <summary>
-        /// 淇濆瓨鐜妫�娴嬪崟
+        ///  宸ヨ壓璺嚎澶х被 淇濆瓨
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("SaveGy_RoutingGroup")]
+        [HttpPost]
+        public object SaveGy_RoutingGroup([FromBody] JObject msg)
+        {
+            DataSet ds;
+            var _value = msg["msg"].ToString();
+            string msg3 = _value.ToString();
+            string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg1 = sArray[0].ToString();
+            string msg2 = sArray[1].ToString();
+
+            //鏌ョ湅鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log("Gy_RoutingGroup_Edit", 1, false, msg2))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            Int64 HItemID = 0;
+            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+            //鑾峰彇鏈�澶D鍊艰祴鍊�
+            DataSet Maxds = oCN.RunProcReturn("select isNull(MAX(HItemID),0) HItemID from Gy_RoutingGroup ", "Gy_RoutingGroup");
+            if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
+            {
+                //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
+                var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]);
+                maxid += 1;
+                HItemID = maxid;
+            }
+            ListModels oListModels = new ListModels();
+            try
+            {
+
+                WebAPI.DLL.ClsGy_RoutingGroup_Ctl oBill = new WebAPI.DLL.ClsGy_RoutingGroup_Ctl();
+                List<Model.ClsGy_RoutingGroup_Model> lsmain = new List<Model.ClsGy_RoutingGroup_Model>();
+                msg1 = msg1.Replace("\\", "");
+                msg1 = msg1.Replace("\n", "");
+                lsmain = oListModels.getObjectByJson_Gy_RoutingGroup(msg1);
+                foreach (Model.ClsGy_RoutingGroup_Model oItem in lsmain)
+                {
+                    if (oItem.HNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷笉鑳戒负绌猴紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if (oItem.HName.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佸悕绉颁笉鑳戒负绌猴紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim()))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮�
+
+                    ds = oCN.RunProcReturn("select * from  Gy_RoutingGroup where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_RoutingGroup");
+                    if (oItem.HNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷负绌猴紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    //鏂板鏃跺垽鏂�
+                    if (oItem.HItemID == 0)
+                    {
+                        if (ds == null || ds.Tables[0].Rows.Count == 0)
+                        {
+
+                        }
+                        else
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦�
+                        string sParent;
+                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
+                        if (sParent.Trim() == "")
+                        {
+                            oBill.oModel.HParentID = 0;
+                        }
+                        else
+                        {
+                            if (oBill.HavParentCode(sParent.Trim(), HItemID))
+                            {
+                                oBill.oModel.HParentID = oBill.oModel.HItemID;
+                            }
+                            else
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�";
+                                objJsonResult.data = 1;
+                                return objJsonResult;
+                            }
+                        }
+                    }
+                    else//缂栬緫鏃跺垽鏂�
+                    {
+                        //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦�
+                        string sParent;
+                        sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim());
+                        if (sParent.Trim() == "")
+                        {
+                            oBill.oModel.HParentID = 0;
+                        }
+                        else
+                        {
+                            if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID))
+                            {
+                                oBill.oModel.HParentID = oBill.oModel.HItemID;
+                            }
+                            else
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�";
+                                objJsonResult.data = 1;
+                                return objJsonResult;
+                            }
+                        }
+                    }
+                    //寰楀埌鐭唬鐮�
+                    string sShortNumber;
+                    sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim());
+                    if (sShortNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oItem.HShortNumber = sShortNumber;//鐭唬鐮�
+                    oItem.HEndFlag = true;//鏈骇鏍囧織
+                    oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇
+                    oItem.HMakeEmp = msg2; //鍒涘缓浜�
+
+                    oBill.oModel = oItem;
+                }
+
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                string sExeReturnInfo = "";
+                if (oBill.oModel.HItemID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddNew(ref sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+
+        #region 淇敼 宸ヨ壓璺嚎澶х被 鑾峰彇缁戝畾鏁版嵁
+        [Route("Gy_RoutingGroup/EditGy_RoutingGroup")]
+        [HttpGet]
+        public object EditGy_RoutingGroup(long HInterID)
+        {
+            try
+            {
+                ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingGroup where HItemID=" + HInterID, "h_v_Gy_RoutingGroup");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        /// <summary>
+        /// 宸ヨ壓璺嚎澶х被 瀹℃牳銆佸弽瀹℃牳
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_RoutingGroup/AuditGy_RoutingGroup")]
+        [HttpGet]
+        public object AuditGy_RoutingGroup(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_RoutingGroup_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_RoutingGroup where HItemID=" + HInterID, "Gy_RoutingGroup");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].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)  //瀹℃牳鍒ゆ柇
+                {
+                    //瀹℃牳鍓嶆帶鍒�=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_BeforeCheckCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_RoutingGroup set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
+
+                    //瀹℃牳鍚庢帶鍒�=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_AfterCheckCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    //鍙嶅鏍稿墠鎺у埗=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_BeforeUnCheckCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_RoutingGroup set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
+
+                    //鍙嶅鏍稿悗鎺у埗=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_AfterUnCheckCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    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;
+            }
+        }
+
+
+
+        /// <summary>
+        /// 宸ヨ壓璺嚎澶х被 绂佺敤銆佸弽绂佺敤
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_RoutingGroup/StopGy_RoutingGroup")]
+        [HttpGet]
+        public object StopGy_RoutingGroup(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_RoutingGroup_Close", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_RoutingGroup where HItemID=" + HInterID, "Gy_RoutingGroup");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].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 (IsStop == 0)  //绂佺敤鍒ゆ柇
+                {
+                    //绂佺敤鍓嶆帶鍒�=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_BeforeStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_BeforeStopCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_RoutingGroup set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
+
+                    //绂佺敤鍚庢帶鍒�=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_AfterStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_AfterStopCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "绂佺敤鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                {
+                    //鍙嶇鐢ㄥ墠鎺у埗=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_BeforeUnStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_BeforeUnStopCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+
+                    oCN.RunProc("update Gy_RoutingGroup set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
+
+                    //鍙嶇鐢ㄥ悗鎺у埗=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_AfterUnStopCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Gy_RoutingGroup_AfterUnStopCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    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
+
+        /// <summary>
+        /// 宸ヨ壓璺嚎澶х被 鍒犻櫎鍔熻兘
+        /// </summary>
+        /// <returns></returns>
+        [Route("DeltetGy_RoutingGroup")]
+        [HttpGet]
+        public object DeltetGy_RoutingGroup(string HItemID, string user)
+        {
+            DataSet ds;
+            //string ModRightNameCheck = "Sc_ProcessReport_check";
+            try
+            {
+                //鍒犻櫎鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_RoutingGroup_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                if (string.IsNullOrWhiteSpace(HItemID))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                oCN.BeginTran();//寮�濮嬩簨鍔�
+
+                ds = oCN.RunProcReturn("select * from Gy_RoutingGroup where HItemID=" + HItemID, "Gy_RoutingGroup");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (ds.Tables[0].Rows[0]["HStopEmp"].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;
+                }
+
+                //鍒犻櫎鍓嶆帶鍒�=========================================
+                ds = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_BeforeDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_RoutingGroup_BeforeDelCtrl");
+
+                if (ds == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
+
+                oCN.RunProc("delete Gy_RoutingGroup where HItemID=" + HItemID);
+
+                //鍒犻櫎鍚庢帶鍒�=========================================
+                DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_RoutingGroup_AfterDelCtrl " + HItemID + ",'" + User + "'", "h_p_Gy_RoutingGroup_AfterDelCtrl");
+                if (ds2 == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
+                oCN.Commit();//鎻愪氦浜嬪姟
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult; ;
+
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  鐜妫�娴嬮」鐩�  璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶
+        /// <summary>
+        /// 淇濆瓨鐜妫�娴嬮」鐩�
         /// </summary>
         /// <param name="msg"></param>
         /// <returns></returns>
@@ -15090,7 +16464,6 @@
             DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_EnvironmentTestItem ", "Gy_EnvironmentTestItem");
             if (Maxds != null || Maxds.Tables[0].Rows.Count > 0)
             {
-                //HItemID= Maxds.Tables[0].Rows[0]["HItemID"]
                 var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]);
                 maxid += 1;
                 HItemID = maxid;
@@ -15226,12 +16599,12 @@
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
                 if (oBill.oModel.HItemID == 0)
-                {                    
-                    bResult = oBill.AddNew();
+                {
+                    bResult = oBill.AddNew(ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 else
                 {
-                    bResult = oBill.ModifyByID(oBill.oModel.HItemID);
+                    bResult = oBill.ModifyByID(oBill.oModel.HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                 }
                 if (bResult)
                 {
@@ -15311,9 +16684,59 @@
                     objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
                     objJsonResult.data = null;
                     return objJsonResult; ;
-                }               
+                }
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_EnvironmentTestItem_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_EnvironmentTestItem_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
 
                 oCN.RunProc("delete Gy_EnvironmentTestItem where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_EnvironmentTestItem_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_EnvironmentTestItem_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+               
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -16856,12 +18279,16 @@
         /// <returns></returns>
         [Route("Web/GetCheckItemID")]
         [HttpGet]
-        public object GetCheckItemID(string HName,string HProName)
+        public object GetCheckItemID(string HName,string HProName,string HSourceID)
         {         
             try
             {
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
-                ds = oCN.RunProcReturn("select  top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='"+HName+ "' and 宸ュ簭鍚嶇О='" + HProName + "'   order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main");
+                ds = oCN.RunProcReturn("select  top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='"+HName+ "' and 宸ュ簭鍚嶇О='" + HProName + "' and HSourceID='" + HSourceID + "'   order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main");
+                if (ds == null || ds.Tables[0].Rows.Count <= 0)
+                {
+                    ds = oCN.RunProcReturn("select  top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='" + HName + "' and  ='" + HProName + "'  order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main");
+                }
                 if (ds == null || ds.Tables[0].Rows.Count <= 0)
                 {
                     objjson.code = "0";
@@ -17996,6 +19423,7 @@
             public int HLevel { get; set; }
             public string Hurl { get; set; }
             public string HPicNum { get; set; }
+            public string HShowMode { get; set; }
             public List<MenuLoad> childMenus { get; set; }
         }
 
@@ -18007,18 +19435,18 @@
             {
                 List<MenuLoad> mu = new List<MenuLoad>();                       //浠ョ埗瀛愮骇缁撴瀯瀛樻斁鑿滃崟娓呭崟淇℃伅
                 SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();            //鏁版嵁搴撴搷浣滃伐鍏�
-                string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition";
+                string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition";
                 ds = oCn.RunProcReturn(sql, "Gy_MenuDefineSet");        //鏌ヨ褰撳墠鐢ㄦ埛鐨勮嚜瀹氫箟鑿滃崟鏁版嵁
                 if (ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) //鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁鏈夎缃繃鑷畾涔変俊鎭紝鑻ヨ褰曟暟涓�0锛屽垯娌℃湁璁剧疆杩囷紝鍔犺浇鎵�鏈夌殑鑿滃崟淇℃伅
                 {
-                    string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName=" +
+                    string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName=" +
                         "(select   top 1 c.GroupName  from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId  " +
                         "left join System_UserGroup c on b.GroupId = c.GroupID  where a.Czymc ='"+HMakeName+"' order by len(c.GroupName ))";
                     ds = oCn.RunProcReturn(sql1, "Gy_MenuDefineSet");        //鏌ヨ鐢ㄦ埛缁戝畾鐨勮鑹� 鏄惁璁剧疆鑿滃崟淇℃伅 鍙栬鑹插悕绉版渶鐭殑涓�涓�
                     if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0))
                     {
                         sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID  ";
-                        ds = oCn.RunProcReturn(sql, "Gy_Menu");
+                        ds = oCn.RunProcReturn(sql, "Gy_Menu_1");
                     }                 
                 }
 
@@ -18033,6 +19461,7 @@
                         tbj.HPartentID = ds.Tables[0].Rows[i]["HPartentID"].ToString();
                         tbj.HLevel = int.Parse(ds.Tables[0].Rows[i]["HLevel"].ToString());
                         tbj.Hurl = ds.Tables[0].Rows[i]["Hurl"].ToString();
+                        tbj.HShowMode = ds.Tables[0].Rows[i]["HShowMode"].ToString();
                         if (ds.Tables[0].Rows[i]["HPicNum"] != null)
                         {
                             tbj.HPicNum = ds.Tables[0].Rows[i]["HPicNum"].ToString();
@@ -18075,6 +19504,7 @@
                         tbjson.HName = dt.Rows[i]["HName"].ToString();
                         tbjson.HLevel = tree[m].HLevel;
                         tbjson.Hurl = dt.Rows[i]["Hurl"].ToString();
+                        tbjson.HShowMode = dt.Rows[i]["HShowMode"].ToString();
                         if (dt.Rows[i]["HPicNum"] != null)
                         {
                             tbjson.HPicNum = dt.Rows[i]["HPicNum"].ToString();

--
Gitblit v1.9.1