From 94d0ab3adaaa7c74ea9aeb6475fd198511a29323 Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期二, 15 七月 2025 16:26:17 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs | 1394 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 1,319 insertions(+), 75 deletions(-) diff --git a/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs b/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs index 9ba9e13..7395023 100644 --- a/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs +++ b/WebAPI/Controllers/MJGL/Sc_MouldUpperBillController.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json; using Model; using DBUtility; +using SyntacticSugar.constant; namespace WebAPI.Controllers.MJGL { @@ -39,7 +40,7 @@ return objJsonResult; } - ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldUpperBillList"); + ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBill_Edit where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldUpperBill_Edit"); //娣诲姞鍒楀悕 foreach (DataColumn col in ds.Tables[0].Columns) @@ -65,6 +66,119 @@ return objJsonResult; } } + #endregion + + #region 涓婃ā鍗� 鍒楄〃鍒嗛〉鏌ヨ + [Route("Sc_MouldUpperBill/Sc_MouldUpperBillListPage")] + [HttpGet] + public object Sc_MouldUpperBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + sWhere = sWhere.Replace("'", "''"); + ds = oCN.RunProcReturn("exec h_p_Sc_MouldUpperBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldUpperBillList"); + + //娣诲姞鍒楀悕 + 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 涓婃ā鍗� 淇濆瓨鍓嶃�佷繚瀛樺悗鎺у埗 + + //淇濆瓨鍓嶆帶鍒� + public json BeforeSave_MouldUpperBill(Int64 HInterID, string HBillNo, Int64 OperationType) + { + DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldUpperBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldUpperBill_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_MouldUpperBill(Int64 HInterID, string HBillNo, Int64 OperationType) + { + DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldUpperBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldUpperBill_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 #region 涓婃ā鍗� 鏂板 @@ -136,6 +250,16 @@ if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板 { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldUpperBill(HInterID, 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_MouldUpperBillMain (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate @@ -147,7 +271,18 @@ } else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) - { //淇敼 + { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldUpperBill(HInterID, 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_MouldUpperBillMain set " + "HDate='" + HDate + "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + @@ -157,7 +292,7 @@ oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddBillSub(msg3, HInterID, HBillNo); + objJsonResult = AddBillSub(msg3, HInterID, HBillNo, OperationType); if (objJsonResult.code == "0") { objJsonResult.code = "0"; @@ -183,7 +318,7 @@ } } - public json AddBillSub(string msg3, long HInterID,string HBillNo) + public json AddBillSub(string msg3, long HInterID,string HBillNo, Int64 OperationType) { List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg3); int i = 0; @@ -200,6 +335,32 @@ "') "); } + if (OperationType == 1)//鏂板 + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 1); + if (objJsonResult.count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldUpperBill(HInterID, 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; objJsonResult.Message = null; @@ -278,11 +439,59 @@ return objJsonResult; } + BillOld.MvarItemKey = "Sc_MouldUpperBillMain"; + //鍒犻櫎鍓嶆帶鍒�========================================= + DataSet ds2; + string sql1 = "exec h_p_Sc_MouldUpperBill_BeforeDelCtrl " + Convert.ToInt32(HInterID) + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldUpperBill_BeforeDelCtrl"); + 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 (ds.Tables[0].Rows.Count == 1) { oCN.RunProc("delete from Sc_MouldUpperBillMain where HInterID=" + hmainid); } oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID=" + hmainid + " and HEntryID=" + hsubid); + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Sc_MouldUpperBill_AfterDelCtrl " + Convert.ToInt32(HInterID) + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql2, "h_p_Sc_MouldUpperBill_AfterDelCtrl"); + if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //================================================================================== oCN.Commit(); } @@ -340,6 +549,7 @@ { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳 DataSet ds; + DataSet ds2; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) @@ -353,15 +563,38 @@ return objJsonResult; } - //瀹℃牳鍗曟嵁 - if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Sc_MouldUpperBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldUpperBill_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 (!BillOld.CheckBill(int.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldUpperBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; - } + } } else { @@ -371,13 +604,12 @@ objJsonResult.data = null; return objJsonResult; } - - } else { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍� DataSet ds; + DataSet ds2; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) @@ -391,19 +623,36 @@ return objJsonResult; } - //鍙嶅鏍稿崟鎹� - if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_Sc_MouldUpperBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldUpperBill_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; } - else + 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 (!BillOld.AbandonCheck(int.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldUpperBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; - } + } } else @@ -436,6 +685,331 @@ } #endregion + #region 涓婃ā鍗� 鍏抽棴 鍙嶅叧闂� + [Route("Sc_MouldUpperBill/CloseSc_MouldUpperBill")] + [HttpGet] + public object CloseSc_MouldUpperBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Close", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "Sc_MouldUpperBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 鍏抽棴 2 鍙嶅叧闂� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴 + DataSet ds; + DataSet ds2; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍏抽棴鍓嶆帶鍒�===============================================Begin=================================================================== + sql = "exec h_p_Sc_MouldUpperBill_BeforeCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql, "h_p_Sc_MouldUpperBill_BeforeCloseCtrl"); + if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍏抽棴鍓嶆帶鍒�===============================================End=================================================================== + + //鍏抽棴鎻愪氦 + if (BillOld.CloseBill(Convert.ToInt32(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldUpperBill_AfterCloseCtrl", user, 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; + } + } + } + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂� + DataSet ds; + DataSet ds2; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍙嶅叧闂墠鎺у埗===============================================Begin=================================================================== + sql = "exec h_p_Sc_MouldUpperBill_BeforeUnCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql, "h_p_Sc_MouldUpperBill_BeforeUnCloseCtrl"); + if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅叧闂墠鎺у埗===============================================End=================================================================== + + //鍙嶅叧闂彁浜� + if (BillOld.CancelClose(Convert.ToInt32(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldUpperBill_AfterUnCloseCtrl", user, 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; + } + } + } + + 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 涓婃ā鍗� 浣滃簾 鍙嶄綔搴� + [Route("Sc_MouldUpperBill/DropSc_MouldUpperBill")] + [HttpGet] + public object DropSc_MouldUpperBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈変綔搴熸潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_MouldUpperBill_Drop", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愪綔搴�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "Sc_MouldUpperBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 浣滃簾 2 鍙嶄綔搴� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡浣滃簾 + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶉渶瑕佸啀浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } + //浣滃簾鍗曟嵁 + if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶄綔搴� + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸啀鍙嶄綔搴�!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶄綔搴熷崟鎹� + if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + 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 涓嬫ā鍗� 鍒楄〃鏌ヨ [Route("Sc_MouldUpperBill/Sc_MouldLowerBillList")] @@ -456,7 +1030,7 @@ return objJsonResult; } - ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBillList where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldLowerBillList"); + ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldLowerBill_Edit where 1=1" + sWhere + "order by hmainid desc ", "h_v_Qj_Sc_MouldLowerBill_Edit"); //娣诲姞鍒楀悕 foreach (DataColumn col in ds.Tables[0].Columns) @@ -482,6 +1056,119 @@ return objJsonResult; } } + #endregion + + #region 涓嬫ā鍗� 鍒楄〃鍒嗛〉鏌ヨ + [Route("Sc_MouldUpperBill/Sc_MouldLowerBillListPage")] + [HttpGet] + public object Sc_MouldLowerBillListPage(string sWhere, string user, int page, int size) + { + try + { + List<object> columnNameList = new List<object>(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + sWhere = sWhere.Replace("'", "''"); + ds = oCN.RunProcReturn("exec h_p_Sc_MouldLowerBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldLowerBillList"); + + //娣诲姞鍒楀悕 + 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 涓嬫ā鍗� 淇濆瓨鍓嶃�佷繚瀛樺悗鎺у埗 + + //淇濆瓨鍓嶆帶鍒� + public json BeforeSave_MouldLowerBill(Int64 HInterID, string HBillNo, Int64 OperationType) + { + DataSet BeforeSave = oCN.RunProcReturn("Exec h_p_Sc_MouldLowerBill_BeforeSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldLowerBill_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_MouldLowerBill(Int64 HInterID, string HBillNo, Int64 OperationType) + { + DataSet AfterSave = oCN.RunProcReturn("Exec h_p_Sc_MouldLowerBill_AfterSaveCtrl " + HInterID.ToString() + ",'" + HBillNo + "'," + OperationType.ToString(), "h_p_Sc_MouldLowerBill_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 #region 涓嬫ā鍗� 鏂板 @@ -553,6 +1240,16 @@ if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板 { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldLowerBill(HInterID, 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_MouldLowerBillMain (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate @@ -564,7 +1261,18 @@ } else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) - { //淇敼 + { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldLowerBill(HInterID, 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_MouldLowerBillMain set " + "HDate='" + HDate + "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + @@ -574,7 +1282,7 @@ oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddMouldLowerBill(msg3, HInterID, HBillNo); + objJsonResult = AddMouldLowerBill(msg3, HInterID, HBillNo, OperationType); if (objJsonResult.code == "0") { objJsonResult.code = "0"; @@ -600,7 +1308,7 @@ } } - public json AddMouldLowerBill(string msg3, long HInterID, string HBillNo) + public json AddMouldLowerBill(string msg3, long HInterID, string HBillNo, Int64 OperationType) { List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(msg3); int i = 0; @@ -617,6 +1325,32 @@ "') "); } + if (OperationType == 1)//鏂板 + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 1); + if (objJsonResult.count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldLowerBill(HInterID, 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; objJsonResult.Message = null; @@ -695,12 +1429,60 @@ return objJsonResult; } + BillOld.MvarItemKey = "Sc_MouldLowerBillMain"; + //鍒犻櫎鍓嶆帶鍒�========================================= + DataSet ds2; + string sql1 = "exec h_p_Sc_MouldLowerBill_BeforeDelCtrl " + Convert.ToInt32(HInterID) + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldLowerBill_BeforeDelCtrl"); + 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 (ds.Tables[0].Rows.Count == 1) { oCN.RunProc("delete from Sc_MouldLowerBillMain where HInterID=" + hmainid); } oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID=" + hmainid + " and HEntryID=" + hsubid); + + //鍒犻櫎鍚庢帶鍒�========================================= + string sql2 = "exec h_p_Sc_MouldLowerBill_AfterDelCtrl " + Convert.ToInt32(HInterID) + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql2, "h_p_Sc_MouldLowerBill_AfterDelCtrl"); + if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //================================================================================== oCN.Commit(); } @@ -758,6 +1540,7 @@ { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡瀹℃牳 DataSet ds; + DataSet ds2; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) @@ -771,8 +1554,31 @@ return objJsonResult; } - //瀹℃牳鍗曟嵁 - if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Sc_MouldLowerBill_BeforeCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldLowerBill_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 (!BillOld.CheckBill(int.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldLowerBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; @@ -793,6 +1599,7 @@ { //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅鏍� DataSet ds; + DataSet ds2; string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) @@ -806,12 +1613,29 @@ return objJsonResult; } - //鍙嶅鏍稿崟鎹� - if (BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_Sc_MouldLowerBill_BeforeUnCheckCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql1, "h_p_Sc_MouldLowerBill_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; } - else + 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 (!BillOld.AbandonCheck(int.Parse(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldLowerBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; @@ -850,11 +1674,373 @@ } #endregion + #region 涓嬫ā鍗� 鍏抽棴 鍙嶅叧闂� + [Route("Sc_MouldUpperBill/CloseSc_MouldLowerBill")] + [HttpGet] + public object CloseSc_MouldLowerBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Close", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "Sc_MouldLowerBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 鍏抽棴 2 鍙嶅叧闂� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍏抽棴 + DataSet ds; + DataSet ds2; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + + + if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插叧闂�!涓嶈兘鍐嶆鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍏抽棴鍓嶆帶鍒�===============================================Begin=================================================================== + sql = "exec h_p_Sc_MouldLowerBill_BeforeCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql, "h_p_Sc_MouldLowerBill_BeforeCloseCtrl"); + if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:鍏抽棴鍓嶅墠鍒ゆ柇澶辫触锛屾棤杩斿洖淇℃伅锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍏抽棴鍓嶆帶鍒�===============================================End=================================================================== + + //鍏抽棴鎻愪氦 + if (BillOld.CloseBill(Convert.ToInt32(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldLowerBill_AfterCloseCtrl", user, 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; + } + } + } + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶅叧闂� + DataSet ds; + DataSet ds2; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶈兘杩涜鍏抽棴!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈叧闂�!涓嶉渶瑕佸啀鍙嶅叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍙嶅叧闂墠鎺у埗===============================================Begin=================================================================== + sql = "exec h_p_Sc_MouldLowerBill_BeforeUnCloseCtrl " + HInterID + ",'" + ds.Tables[0].Rows[0]["HBillNo"] + "','" + user + "'"; + ds2 = oCN.RunProcReturn(sql, "h_p_Sc_MouldLowerBill_BeforeUnCloseCtrl"); + if (ds2 == null || ds2.Tables.Count == 0 || ds2.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:鍙嶅叧闂墠鍓嶅垽鏂け璐ワ紝鏃犺繑鍥炰俊鎭紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + + } + if (ds2.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ds2.Tables[0].Rows[0]["HRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶅叧闂墠鎺у埗===============================================End=================================================================== + + //鍙嶅叧闂彁浜� + if (BillOld.CancelClose(Convert.ToInt32(HInterID), ds.Tables[0].Rows[0]["HBillNo"].ToString(), "h_p_Sc_MouldLowerBill_AfterUnCloseCtrl", user, 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; + } + } + } + + 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 涓嬫ā鍗� 浣滃簾 鍙嶄綔搴� + [Route("Sc_MouldUpperBill/DropSc_MouldLowerBill")] + [HttpGet] + public object DropSc_MouldLowerBill(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈変綔搴熸潈闄� + if (!DBUtility.ClsPub.Security_Log("Sc_MouldLowerBill_Drop", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愪綔搴�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + BillOld.MvarItemKey = "Sc_MouldLowerBillMain"; + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 浣滃簾 2 鍙嶄綔搴� + if (Type == 1) + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡浣滃簾 + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸蹭綔搴�!涓嶉渶瑕佸啀浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } + //浣滃簾鍗曟嵁 + if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + //鍒ゆ柇鍗曟嵁鏄惁宸茬粡鍙嶄綔搴� + DataSet ds; + string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; + ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); + if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + { + if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘杩涜浣滃簾!"; + objJsonResult.data = null; + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁鏈綔搴�!涓嶉渶瑕佸啀鍙嶄綔搴�!"; + objJsonResult.data = null; + return objJsonResult; + } + //鍙嶄綔搴熷崟鎹� + if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + 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 涓嬫ā鍗曟煡璇笂妯″崟淇℃伅 鍒楄〃鏌ヨ + [Route("Sc_MouldLowerBill/Sc_MouldUpperBillList")] + [HttpGet] + public object Sc_MouldUpperBillList(string sWhere) + { + try + { + + ds = oCN.RunProcReturn("select * from h_v_Qj_Sc_MouldUpperBillList where 1=1" + sWhere, "h_v_Qj_Sc_MouldUpperBillList"); + + 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; + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + 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; + } + } + #endregion #region 涓�/涓嬫ā鍗曡幏鍙栨潯鐮佷俊鎭� [Route("Sc_MouldUpperBill/txtHBarCode_KeyDown")] [HttpGet] - public object txtHBarCode_KeyDown(string HBarCode, string UserID, string HBillType) + public object txtHBarCode_KeyDown(string HBarCode,int HSourceID, string UserID, string HBillType) { try { @@ -867,58 +2053,22 @@ return objJsonResult; } - //鎷嗗垎鏉″舰鐮� - string sBillBarCode = HBarCode.Trim(); - - - //鎴彇鏉$爜绫诲瀷2 鍓嶄袱浣� - string BillNoType2 = sBillBarCode.Substring(0, Math.Min(2, sBillBarCode.Length)); - //鎴彇鏉$爜绫诲瀷 鍓嶄笁浣� - string BillNoType3 = sBillBarCode.Substring(0, Math.Min(3, sBillBarCode.Length)); - //鎴彇鏉$爜绫诲瀷3 鍓嶅洓浣� - string BillNoType4 = sBillBarCode.Substring(0, Math.Min(4, sBillBarCode.Length)); - - - switch (BillNoType2) - { - //鐢熶骇璧勬簮 - case "BM": - case "SS": - ds = oCN.RunProcReturn("select HItemID,HName,HNumber from Gy_Source where HNumber = '" + HBarCode + "'", "Gy_Source"); - break; - case "MO": - ds = oCN.RunProcReturn("select 鍗曟嵁鍙�,hmainid,HEntryID from h_v_IF_ICMOBillList where 鍗曟嵁鍙� = '" + HBarCode + "'", "h_v_IF_ICMOBillList"); - break; - default: - break; - } - - switch (BillNoType3) - { - //鍣ㄥ叿妗f - case "MJD": - case "PAK": - ds = oCN.RunProcReturn("select * from h_v_Gy_MouldFileList where 鍗曟嵁鍙� = '" + HBarCode + "'", "h_v_Gy_MouldFileList"); - break; - default: - break; - } - - switch (BillNoType4) - { - //娴佽浆鍗� - case "GXLX": - ds = oCN.RunProcReturn("select 浠诲姟鍗曞彿,hicmointerid,HICMOEntryID,鍗曟嵁鍙�,hmainid,HEntryID from h_v_Sc_ProcessExchangeBillQuerySub where 鍗曟嵁鍙� = '" + HBarCode + "'", "h_v_Sc_ProcessExchangeBillQuerySub"); - break; - default: - break; - } + ds = oCN.RunProcReturn("exec h_p_Sc_AllowLoadData '" + HBarCode + "','"+ HSourceID + "','"+ HBillType + "'", "h_p_Sc_AllowLoadData"); 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 (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); objJsonResult.data = null; return objJsonResult; } @@ -1008,6 +2158,16 @@ if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板 { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldUpperBill(HInterID, 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_MouldUpperBillMain (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate @@ -1019,7 +2179,18 @@ } else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) - { //淇敼 + { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldUpperBill(HInterID, 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_MouldUpperBillMain set " + "HDate='" + HDate + "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + @@ -1029,7 +2200,7 @@ oCN.RunProc("delete from Sc_MouldUpperBillSub where HInterID='" + HInterID + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddBillSub_PDA(msg2, HInterID, HBillNo); + objJsonResult = AddBillSub_PDA(msg2, HInterID, HBillNo, OperationType); if (objJsonResult.code == "0") { objJsonResult.code = "0"; @@ -1055,7 +2226,7 @@ } } - public json AddBillSub_PDA(string msg2, long HInterID, string HBillNo) + public json AddBillSub_PDA(string msg2, long HInterID, string HBillNo, Int64 OperationType) { List<ClsSc_MouldUpperBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldUpperBillSub>>(msg2); int i = 0; @@ -1075,6 +2246,32 @@ + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') "); } + if (OperationType == 1)//鏂板 + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldUpperBill(HInterID, HBillNo, 1); + if (objJsonResult.count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldUpperBill(HInterID, 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; objJsonResult.Message = null; @@ -1152,6 +2349,16 @@ if ((OperationType == 1) && ds.Tables[0].Rows.Count == 0)//鏂板 { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldLowerBill(HInterID, 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_MouldLowerBillMain (HBillType,HBillStatus, HBillSubType, HInterID, HBillNo, HDate @@ -1163,7 +2370,18 @@ } else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) - { //淇敼 + { + //淇濆瓨鍓嶆帶鍒� + objJsonResult = BeforeSave_MouldLowerBill(HInterID, 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_MouldLowerBillMain set " + "HDate='" + HDate + "',HYear='" + HYear + "',HPeriod='" + HPeriod + "',HRemark='" + HRemark + "',hupdater='" + HMaker + @@ -1173,7 +2391,7 @@ oCN.RunProc("delete from Sc_MouldLowerBillSub where HInterID='" + HInterID + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddSc_MouldLowerBillSub_PDA(msg2, HInterID, HBillNo); + objJsonResult = AddSc_MouldLowerBillSub_PDA(msg2, HInterID, HBillNo, OperationType); if (objJsonResult.code == "0") { objJsonResult.code = "0"; @@ -1199,7 +2417,7 @@ } } - public json AddSc_MouldLowerBillSub_PDA(string msg2, long HInterID, string HBillNo) + public json AddSc_MouldLowerBillSub_PDA(string msg2, long HInterID, string HBillNo, Int64 OperationType) { List<ClsSc_MouldLowerBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsSc_MouldLowerBillSub>>(msg2); int i = 0; @@ -1219,6 +2437,32 @@ + ",'" + oSub.HScanDate.ToString() + "','" + oSub.HMouldNumber.ToString() + "') "); } + if (OperationType == 1)//鏂板 + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldLowerBill(HInterID, HBillNo, 1); + if (objJsonResult.count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //淇濆瓨鍚庢帶鍒� + objJsonResult = AfterSave_MouldLowerBill(HInterID, 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; objJsonResult.Message = null; -- Gitblit v1.9.1