From 5b6d9876d89219f34a2fda2820b1de752d28d77e Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期二, 08 四月 2025 11:05:24 +0800
Subject: [PATCH] 物料:增加 制单人

---
 WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs |  481 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 477 insertions(+), 4 deletions(-)

diff --git a/WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs b/WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs
index 90d4350..0406334 100644
--- a/WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs
+++ b/WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs
@@ -8,6 +8,8 @@
 using WebAPI.Models;
 using WebAPI.DLL;
 using DBUtility;
+using SyntacticSugar.constant;
+using Newtonsoft.Json;
 
 namespace WebAPI.Controllers
 {
@@ -76,6 +78,98 @@
         }
         #endregion
 
+        #region 鍣ㄥ叿缁翠慨娲惧伐鍗� 缂栬緫鏌ヨ
+        [Route("Sc_MouldRepairSendWorkBill/Sc_MouldRepairSendWorkBill_Edit")]
+        [HttpGet]
+        public object Sc_MouldRepairSendWorkBill_Edit(string linterid, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+               
+                ds = oCN.RunProcReturn("select * from  h_v_Sc_MouldRepairSendWorkBill_Edit where 1=1 and hmainid=" + linterid + "order by hmainid desc ", "h_v_Sc_MouldRepairSendWorkBill_Edit");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鍣ㄥ叿缁翠慨娲惧伐鍗曟煡璇�
+        [Route("Sc_MouldRepairSendWorkBill/GetMouldRepairSendWorkBillListPage")]
+        [HttpGet]
+        public object GetMouldRepairSendWorkBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBillList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairSendWorkBill " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairSendWorkBill");
+                }
+                else
+                {
+                    sWhere = sWhere.Replace("'", "''");
+                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairSendWorkBill " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairSendWorkBill");
+                }
+
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+
+                objJsonResult.code = CodeConstant.SUCCEED;
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception ex)
+            {
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = CountConstant.FAIL;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + ex.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region 鍣ㄥ叿缁翠慨娲惧伐鍗�  娣诲姞/淇敼
         [Route("Sc_MouldRepairSendWorkBill/AddBill")]
         [HttpPost]
@@ -128,6 +222,16 @@
 
                 if (OperationType == 1)//鏂板
                 {
+                    //淇濆瓨鍓嶆帶鍒�
+                    objJsonResult = BeforeSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 1);
+                    if (objJsonResult.count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     //涓昏〃
                     oCN.RunProc("Insert Into Sc_MouldRepairSendWorkBill   " +
                  "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
@@ -148,6 +252,16 @@
                 }
                 else if (OperationType == 3)
                 {
+                    //淇濆瓨鍓嶆帶鍒�
+                    objJsonResult = BeforeSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 2);
+                    if (objJsonResult.count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = objJsonResult.Message;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     //淇敼
                     oCN.RunProc("UpDate Sc_MouldRepairSendWorkBill set  " +
                 " HBillNo='" + omodel.HBillNo + "'" +  //鍥哄畾璧嬪��===============
@@ -155,7 +269,7 @@
                 ",HYear='" + omodel.HYear.ToString() + "'" +
                 ",HPeriod='" + omodel.HPeriod.ToString() + "'" +
                 ",HRemark='" + omodel.HRemark + "'" +
-                ",HUpDater='" + omodel.HUpDater + "'" +
+                ",HUpDater='" + omodel.HMaker + "'" +
                 ",HUpDateDate=getdate()" +
                     //========================================
                 ",HMouldID=" + omodel.HMouldID.ToString() +
@@ -185,7 +299,7 @@
                     oCN.RunProc("delete from Sc_MouldRepairSendWorkBillSub where HInterID='" + omodel.HInterID.ToString() + "'");
                 }
                 //淇濆瓨瀛愯〃
-                objJsonResult = AddBillSub(msg3);
+                objJsonResult = AddBillSub(msg3, OperationType);
                 if (objJsonResult.code == "0")
                 {
                     objJsonResult.code = "0";
@@ -211,7 +325,7 @@
             }
         }
 
-        public json AddBillSub(string msg3)
+        public json AddBillSub(string msg3,Int64 OperationType)
         {
             DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSb_MouldRepairWorkBillSub>>(msg3);
             int i = 1;
@@ -229,6 +343,32 @@
                    ") ");
                 i++;
             }
+            if (OperationType == 1)//鏂板
+            {
+                //淇濆瓨鍚庢帶鍒�
+                objJsonResult = AfterSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 1);
+                if (objJsonResult.count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            else
+            {
+                //淇濆瓨鍚庢帶鍒�
+                objJsonResult = AfterSave_MouldRepairSendWorkBill(omodel.HInterID, omodel.HBillNo, 2);
+                if (objJsonResult.count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = objJsonResult.Message;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
 
             objJsonResult.code = "1";
             objJsonResult.count = 1;
@@ -236,6 +376,70 @@
             objJsonResult.data = null;
             return objJsonResult;
         }
+
+        #region 鍣ㄥ叿缁翠慨娲惧伐鍗� 淇濆瓨鍓嶃�佷繚瀛樺悗鎺у埗
+
+        //淇濆瓨鍓嶆帶鍒�
+        public json BeforeSave_MouldRepairSendWorkBill(Int64 HInterID, string HBillNo, Int64 OperationType)
+        {
+            DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldRepairSendWorkBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "',''," + OperationType.ToString(), "h_p_Sc_MouldRepairSendWorkBill_BeforeSaveCtrl");
+            if (BeforeSave == null || BeforeSave.Tables[0].Rows.Count == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else if (DBUtility.ClsPub.isLong(BeforeSave.Tables[0].Rows[0]["HBack"]) == 1)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;  //澶辫触锛�
+                objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]);
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;  //鎴愬姛锛�
+                objJsonResult.Message = DBUtility.ClsPub.isStrNull(BeforeSave.Tables[0].Rows[0]["HRemark"]);
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        //淇濆瓨鍚庢帶鍒�
+        public json AfterSave_MouldRepairSendWorkBill(Int64 HInterID, string HBillNo, Int64 OperationType)
+        {
+            DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldRepairSendWorkBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldRepairSendWorkBill_AfterSaveCtrl");
+            if (AfterSave == null || AfterSave.Tables[0].Rows.Count == 0)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else if (DBUtility.ClsPub.isLong(AfterSave.Tables[0].Rows[0]["HBack"]) == 1)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;  //澶辫触锛�
+                objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]);
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            else
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;  //鎴愬姛锛�
+                objJsonResult.Message = DBUtility.ClsPub.isStrNull(AfterSave.Tables[0].Rows[0]["HRemark"]);
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        #endregion
 
         #endregion
 
@@ -266,7 +470,31 @@
                     return objJsonResult;
                 }
 
-                if (oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo))
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeDelCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_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;
+                    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;
+                    return objJsonResult;
+                }
+                //==================================================================================  
+
+                bool IsDete = oBill.DeleteBill(HInterID, oBill.omodel.HBillNo, "h_p_Sc_MouldRepairSendWorkBill_AfterDelCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo);
+
+                if (IsDete)
                 {
                     objJsonResult.code = "1";
                     objJsonResult.count = 1;
@@ -276,6 +504,7 @@
                 }
                 else
                 {
+
                     objJsonResult.code = "0";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "鍒犻櫎澶辫触";
@@ -386,9 +615,35 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                DataSet ds2;
                 //瀹℃牳鎻愪氦
                 if (IsAudit == 0)
                 {
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + CurUserName + "'";
+                    ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeCheckCtrl");
+                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================  
+
                     if (CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "1";
@@ -410,6 +665,28 @@
                 //鍙嶅鏍告彁浜�
                 if (IsAudit == 1)
                 {
+                    //鍙嶅鏍稿墠鎺у埗=========================================        
+                    string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + CurUserName + "'";
+                    ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_BeforeUnCheckCtrl");
+                    if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //===========================================================         
+
                     if (AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
                     {
                         objJsonResult.code = "1";
@@ -447,6 +724,34 @@
                 string HChecker = DBUtility.ClsPub.CurUserName;//鐢ㄦ埛鍚�
                 oCN.BeginTran();//鎵撳紑浜嬪姟
                 oCN.RunProc("update Sc_MouldRepairSendWorkBill set HChecker='" + HChecker + "',HCheckDate='" + DateTime.Now + "',HBillStatus=2 where HInterID='" + lngBillKey + "'");
+
+                //瀹℃牳鍚庢帶鍒�=========================================      
+                DataSet ds2;
+                string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_AfterCheckCtrl " + lngBillKey + ",'','" + HChecker + "'";
+                ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_AfterCheckCtrl");
+                if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    sReturn = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    return false;
+                }
+
+                if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); 
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    sReturn = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); 
+                    return false;
+                }
+                //==================================================================================  
+
                 oCN.Commit();//鍏抽棴浜嬪姟
                 sReturn = "瀹℃牳鍗曟嵁鎴愬姛!";
                 return true;
@@ -465,6 +770,33 @@
                 string HChecker = DBUtility.ClsPub.CurUserName;//鐢ㄦ埛鍚�
                 oCN.BeginTran();//鎵撳紑浜嬪姟
                 oCN.RunProc("update Sc_MouldRepairSendWorkBill set HChecker='',HCheckDate=null,HBillStatus=1 where HInterID='" + lngBillKey + "'");
+
+                //鍙嶅鏍稿悗鎺у埗=========================================      
+                DataSet ds2;
+                string sql1 = "exec h_p_Sc_MouldRepairSendWorkBill_AfterUnCheckCtrl " + lngBillKey + ",'','" + HChecker + "'";
+                ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldRepairSendWorkBill_AfterUnCheckCtrl");
+                if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:鍙嶅鏍稿悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    sReturn = "瀹℃牳澶辫触!鍘熷洜:鍙嶅鏍稿悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    return false;
+                }
+
+                if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString();
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    sReturn = "瀹℃牳澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString();
+                    return false;
+                }
+                //==================================================================================  
                 oCN.Commit();//鍏抽棴浜嬪姟
                 sReturn = "鍙嶅鏍稿崟鎹垚鍔�!";
                 return true;
@@ -476,5 +808,146 @@
             }
         }
         #endregion
+
+        #region 鍣ㄥ叿缁翠慨娲惧伐鍗� 鍏抽棴/鍙嶅叧闂�
+        /// <summary>
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">鍏抽棴(0),鍙嶅叧闂�(1)</param>
+        /// <param name="CurUserName">鍏抽棴浜�</param>
+        /// <returns></returns>
+        [Route("Sc_MouldRepairSendWorkBill/CloseSc_MouldRepairSendWorkBill")]
+        [HttpGet]
+        public object CloseSc_MouldRepairSendWorkBill(int HInterID, int IsAudit, string CurUserName)
+        {
+            string ModRightNameCheck = "Sc_MouldRepairSendWorkBill_Close";
+            DBUtility.ClsPub.CurUserName = CurUserName;
+            try
+            {
+                //妫�鏌ユ潈闄�
+                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍏抽棴澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //HInterID鏁版嵁鍒ゆ柇
+                if (HInterID <= 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID灏忎簬0锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsSc_ICMOBill oBill = new DAL.ClsSc_ICMOBill();           //瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+                oBill.MvarItemKey = "Sc_MouldRepairSendWorkBill";
+               
+
+                //杩涜闇�瑕佽繘琛岀殑鍏抽棴/鍙嶅叧闂搷浣�
+                if (IsAudit == 0) //鍏抽棴鎻愪氦
+                {
+                    string sql = "";
+                    //鍏抽棴鍓嶆帶鍒�===============================================Begin===================================================================
+                    sql = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeCloseCtrl " + HInterID + ",' ','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldRepairSendWorkBill_BeforeCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍏抽棴鍓嶆帶鍒�===============================================End===================================================================
+
+                    //鍏抽棴鎻愪氦
+                    if (oBill.CloseBill(lngBillKey, "", "h_p_Sc_MouldRepairSendWorkBill_AfterCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍏抽棴鎴愬姛";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                if (IsAudit == 1) //鍙嶅叧闂彁浜�
+                {
+                    string sql = "";
+                    //鍙嶅叧闂墠鎺у埗===============================================Begin===================================================================
+                    sql = "exec h_p_Sc_MouldRepairSendWorkBill_BeforeUnCloseCtrl " + HInterID + ",'','" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldRepairSendWorkBill_BeforeUnCloseCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+
+                    }
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //鍙嶅叧闂墠鎺у埗===============================================End===================================================================
+
+                    //鍙嶅叧闂彁浜�
+                    if (oBill.CancelClose(lngBillKey,"", "h_p_Sc_MouldRepairSendWorkBill_AfterUnCloseCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅叧闂垚鍔�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鍏抽棴澶辫触鎴栬�呭弽鍏抽棴澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1