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 | 786 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 758 insertions(+), 28 deletions(-) diff --git a/WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs b/WebAPI/Controllers/Sc_MouldRepairSendWorkBillController.cs index f24d16c..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 { @@ -20,47 +22,148 @@ private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; + DLL.ClsSb_MouldRepairWorkBill oBill = new DLL.ClsSb_MouldRepairWorkBill(); #region 鍣ㄥ叿缁翠慨娲惧伐鍗曟煡璇� [Route("Sc_MouldRepairSendWorkBill/GetMouldRepairSendWorkBillList")] [HttpGet] - public object GetMouldRepairSendWorkBillList(string sWhere) + public object GetMouldRepairSendWorkBillList(string sWhere,string user) { try { + 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("select * from h_v_Sc_MouldRepairSendWorkBill ", "h_v_Sc_MouldRepairSendWorkBill"); + ds = oCN.RunProcReturn("select * from h_v_Sc_MouldRepairSendWorkBill order by hmainid desc ", "h_v_Sc_MouldRepairSendWorkBill"); } else { string sql1 = "select * from h_v_Sc_MouldRepairSendWorkBill where 1 = 1 "; - string sql = sql1 + sWhere; + string sql = sql1 + sWhere+ " order by hmainid desc "; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairSendWorkBill"); } - if (ds == null || ds.Tables[0].Rows.Count == 0) - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"; - objJsonResult.data = null; - return objJsonResult; - } - else - { - objJsonResult.code = "1"; - objJsonResult.count = 1; - objJsonResult.Message = "Sucess锛�"; - objJsonResult.data = ds.Tables[0]; - return objJsonResult; - } + //if (ds.Tables[0].Rows.Count != 0 || ds != null) + //{ + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + //} + //else + //{ + //objJsonResult.code = "0"; + //objJsonResult.count = 0; + //objJsonResult.Message = "鏃犳暟鎹�"; + //objJsonResult.data = null; + //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/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; } @@ -100,16 +203,35 @@ string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); - int hentryid = int.Parse(sArray[2].ToString());//瀛愯〃鐨勯『搴廼d - int OperationType = int.Parse(sArray[3].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 + int OperationType = int.Parse(sArray[2].ToString());//鏁版嵁绫诲瀷 1娣诲姞 3淇敼 + string msg4 = sArray[3].ToString(); try { + if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBill_Edit", 1, false, msg4)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + omodel = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSb_MouldRepairWorkBillMain>(msg2); string BillType = "3843"; 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" + @@ -117,7 +239,7 @@ ",HEquipID,HRepairID,HRepairBeginDate,HRepairEndDate,HRepairContent" + ",HCycleUnit,HPlanTimes,HTimes,HEmpID,HManagerID" + ",HDeptID,HExplanation,HInnerBillNo,HMouldID" + - ",HSupID,HRepairType,HNewModel,HNewDesignLife,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID" + + ",HSupID,HRepairType,HNewModel,HNewDesignLife,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID,HBillStatus" + ") " + " values('" + BillType + "','" + BillType + "'," + omodel.HInterID.ToString() + ",'" + omodel.HBillNo + "','" + omodel.HDate + "'" + "," + omodel.HYear.ToString() + "," + omodel.HPeriod.ToString() + ",'" + omodel.HRemark + "','" + omodel.HMaker + "',getdate()" + @@ -125,10 +247,21 @@ ",'" + omodel.HCycleUnit + "'," + omodel.HPlanTimes.ToString() + "," + omodel.HTimes.ToString() + "," + omodel.HEmpID.ToString() + "," + omodel.HManagerID.ToString() + "," + omodel.HDeptID.ToString() + ",'" + omodel.HExplanation + "','" + omodel.HInnerBillNo + "'," + omodel.HMouldID.ToString() + ", " + omodel.HSupID.ToString() + ",'" + omodel.HRepairType + "','" + omodel.HNewModel + "'," + omodel.HNewDesignLife.ToString() + ",'" + omodel.HMainSourceBillType + "'," + omodel.HMainSourceInterID.ToString() + "," + omodel.HMainSourceEntryID.ToString() + - ") "); + + ",1) "); } 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 + "'" + //鍥哄畾璧嬪��=============== @@ -136,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() + @@ -163,10 +296,10 @@ " where HInterID=" + omodel.HInterID.ToString()); //鍒犻櫎瀛愯〃 - oCN.RunProc("delete from Sc_MouldRepairSendWorkBillSub where HInterID='" + omodel.HInterID.ToString() + "' and HEntryID='" + hentryid + "'"); + oCN.RunProc("delete from Sc_MouldRepairSendWorkBillSub where HInterID='" + omodel.HInterID.ToString() + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddBillSub(msg3, hentryid); + objJsonResult = AddBillSub(msg3, OperationType); if (objJsonResult.code == "0") { objJsonResult.code = "0"; @@ -192,7 +325,7 @@ } } - public json AddBillSub(string msg3, int hentryid) + public json AddBillSub(string msg3,Int64 OperationType) { DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSb_MouldRepairWorkBillSub>>(msg3); int i = 1; @@ -204,11 +337,37 @@ ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" + ",HRepairID,HRepairExplanation,HManagerID,HMoney" + ") values(" - + omodel.HInterID.ToString() + "," + (hentryid == -1 ? i : hentryid) + ",'" + oSub.HCloseMan + "','" + DateTime.Now + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" + + + omodel.HInterID.ToString() + "," + (i) + ",'" + oSub.HCloseMan + "','" + DateTime.Now + "'," + Convert.ToString(oSub.HCloseType ? 1 : 0) + ",'" + oSub.HRemark + "'" + "," + oSub.HSourceInterID.ToString() + "," + oSub.HSourceEntryID.ToString() + ",'" + oSub.HSourceBillNo + "','" + oSub.HSourceBillType + "'," + oSub.HRelationQty.ToString() + "," + oSub.HRelationMoney.ToString() + "," + oSub.HRepairID.ToString() + ",'" + oSub.HRepairExplanation + "'," + oSub.HManagerID.ToString() + "," + oSub.HMoney.ToString() + ") "); 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"; @@ -218,6 +377,577 @@ 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 + + #region 鍣ㄥ叿缁翠慨娲惧伐鍗� 鍒犻櫎 + [Route("Sc_MouldRepairSendWorkBill/MouldDeleteBill")] + [HttpGet] + public object MouldDeleteBill(long HInterID, string user) + { + try + { + //鍒ゆ柇鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBill_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鍒犻櫎鏉冮檺"; + objJsonResult.data = null; + return objJsonResult; + } + oBill.ShowBill(HInterID, ref DBUtility.ClsPub.sExeReturnInfo); + + if (oBill.omodel.HChecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁宸茬粡瀹℃牳,涓嶈兘鍒犻櫎锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍒犻櫎鍓嶆帶鍒�========================================= + 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; + objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触"; + objJsonResult.data = null; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬垹闄�"; + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鍣ㄥ叿缁翠慨娲惧伐鍗� 瀹℃牳/鍙嶅鏍� + [Route("Sc_MouldRepairSendWorkBill/CheckDeOAuditBill")] + [HttpGet] + public object CheckDeOAuditBill(int HInterID, int IsAudit, string CurUserName) + { + + DBUtility.ClsPub.CurUserName = CurUserName; //瀛樺偍鐢ㄦ埛鍚� + try + { + //鍒ゆ柇鏄惁鏈夊鏍告潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_MouldRepairSendWorkBill_Check", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍒ゆ柇id 鏄惁澶т簬0 + if (HInterID <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "ID灏忎簬0"; + objJsonResult.data = null; + return objJsonResult; + } + + + //杞崲id + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); + + //鏌ヨ瀹℃牳鐨勮繖鏉℃暟鎹� + ds = oCN.RunProcReturn("select * from Sc_MouldRepairSendWorkBill where HInterID='" + lngBillKey.ToString() + "'", "Sc_MouldRepairSendWorkBill"); + + if (ds.Tables[0].Rows.Count != 0) + { + string HCloseMan = ds.Tables[0].Rows[0]["HCloseMan"].ToString().Trim();//鍏抽棴浜� + string HDeleteMan = ds.Tables[0].Rows[0]["HDeleteMan"].ToString().Trim();//鍋氬簾浜� + string HChecker = ds.Tables[0].Rows[0]["HChecker"].ToString().Trim();//瀹℃牳浜� + + if (HCloseMan != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�,涓嶈兘瀹℃牳"; + objJsonResult.data = null; + return objJsonResult; + } + if (HDeleteMan != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�,涓嶈兘瀹℃牳"; + objJsonResult.data = null; + return objJsonResult; + } + //IsAudit 0 瀹℃牳 + if (IsAudit == 0) + { + if (HChecker != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳"; + objJsonResult.data = null; + return objJsonResult; + } + } + //IsAudit 1 鍙嶅鏍� + if (IsAudit == 1) + { + if (HChecker == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�;鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + 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"; + 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 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"; + 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; + } + } + //瀹℃牳 + public bool CheckBill(Int64 lngBillKey, ref string sReturn) + { + try + { + 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; + } + catch (Exception e) + { + sReturn = e.Message; + throw (e); + } + } + //鍙嶅鏍� + public bool AbandonCheck(Int64 lngBillKey, ref string sReturn) + { + try + { + 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; + } + catch (Exception e) + { + sReturn = e.Message; + throw (e); + } + } + #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