From 2d1dd7ea14fdf01d08ea52889037681dfb1a19cc Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期日, 03 三月 2024 16:50:03 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs | 399 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 297 insertions(+), 102 deletions(-) diff --git a/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs b/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs index e64393c..a8ec430 100644 --- a/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs +++ b/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs @@ -1,4 +1,5 @@ 锘縰sing Newtonsoft.Json.Linq; +using NPOI.SS.Formula.Functions; using Pub_Class; using System; using System.Collections; @@ -14,7 +15,8 @@ public class Kf_POStockInBillController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus; - public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill(); + //public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill(); + public DAL.ClsKf_POStockInBill BillOld = new DAL.ClsKf_POStockInBill(); private json objJsonResult = new json(); public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); public DataSet ds = new DataSet(); @@ -176,8 +178,28 @@ if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板 { + //淇濆瓨鍓嶆帶鍒�========================================= + ds = oCN.RunProcReturn("exec h_p_Kf_POStockInBill_BeforeSaveCtrl " + HInterID, "h_p_Kf_POStockInBill_BeforeSaveCtrl"); + + if (ds == null || 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; + } + //========================================================= //涓昏〃 - String sql=$@"Insert Into Kf_ICStockBillMain + String sql =$@"Insert Into Kf_ICStockBillMain (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus ,HAddress,HSupID,HCurID,HWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID,HExplanation,HRemark ,HInnerBillNo,HSTOCKORGID,HOWNERID ,HChecker,HCheckDate,HMaker,HMakeDate) @@ -202,7 +224,7 @@ oCN.RunProc("delete from Kf_ICStockBillSub where HInterID='" + HInterID + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddBillSub(msg3, HInterID, OperationType); + objJsonResult = AddBillSub(msg3, HInterID, OperationType, user); if (objJsonResult.code == "0") { @@ -229,7 +251,7 @@ } } - public json AddBillSub(string msg3, long HInterID, int OperationType) + public json AddBillSub(string msg3, long HInterID, int OperationType,string user) { List<ClsKf_ICStockBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ICStockBillSub>>(msg3); @@ -312,9 +334,41 @@ ,{(oSub.HPropertyID == null ? 0 : oSub.HPropertyID)},{(oSub.HSecUnitID == null ? 0 : oSub.HSecUnitID)},{(oSub.HSecUnitRate == null ? 0 : oSub.HSecUnitRate)} ,{(oSub.HPlanMode == null ? 0 : oSub.HPlanMode)},'{oSub.HRemark}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}')"; + string sReturn = ""; + ds = oCN.RunProcReturn("exec h_p_Cg_POInStockBillMain " + oSub.HQty + ", '" +oSub.HSourceInterID + "', '" + oSub.HSourceEntryID + "','" + user+" '", "h_p_Cg_POInStockBillMain"); + if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[0]["HBack"]) != 0) + { + sReturn = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]).ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = sReturn; + objJsonResult.data = null; + return objJsonResult; + } + oCN.RunProc(sql); } + //淇濆瓨鍚庢帶鍒�========================================= + ds = oCN.RunProcReturn("exec h_p_Kf_POStockInBill_AfterSaveCtrl " + HInterID, "h_p_Kf_POStockInBill_AfterSaveCtrl"); + + if (ds == null || 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; + } + //========================================================= objJsonResult.code = "1"; objJsonResult.count = 1; @@ -330,30 +384,140 @@ /// <returns></returns> [Route("Kf_POStockInBill/DeltetKf_POStockInBill")] [HttpGet] - public object DeltetKf_POStockInBill(string HInterID) + public object DeleteKf_POStockInBackBill(string Hmainid, string HsupId, string HQty, string HSourceInterID, string HSourceEntryID, string user) { + DataSet ds; + DataSet dss; + //string ModRightNameCheck = "Sc_ProcessReport_check"; try { - oCN.BeginTran(); - oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID); - oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID); - oCN.Commit(); - objJsonResult.code = "1"; + //鍒犻櫎鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Kf_POStockInBackBill_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + if (string.IsNullOrWhiteSpace(Hmainid)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Hmainid涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + string HBillNo = ""; + ds = oCN.RunProcReturn("select * from Kf_ICStockBillMain where HInterID=" + Hmainid, "Kf_ICStockBillMain "); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; + objJsonResult.data = null; + return objJsonResult; ; + } + else + { + HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); + } + + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Kf_POStockInBill_BeforeDelCtrl " + Hmainid + ",'" + HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Kf_POStockInBill_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; + } + //================================================================================== + + oCN.BeginTran();//寮�濮嬩簨鍔� + ds = oCN.RunProcReturn("select * from Kf_ICStockBillMain a inner join Kf_ICStockBillSub b on a.HInterID=b.HInterID where a.HInterID= '"+ Hmainid+"'", "Kf_ICStockBillMain"); + dss = oCN.RunProcReturn("exec h_p_Cg_POInStockBillMain " + HQty + ", '" + HSourceInterID + "', '" + HSourceEntryID + "','" + user + " '", "h_p_Cg_POInStockBillMain"); + var sReturn = ""; + if (DBUtility.ClsPub.isLong(dss.Tables[0].Rows[0]["HBack"]) != 0) + { + sReturn = DBUtility.ClsPub.isStrNull(dss.Tables[0].Rows[0]["HBackRemark"]).ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = sReturn; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows.Count == 1) + { + oCN.RunProc("delete Kf_ICStockBillSub where HInterID=" + Hmainid); + oCN.RunProc("delete Kf_ICStockBillMain where HInterID=" + Hmainid); + } + else + { + oCN.RunProc($"delete Kf_ICStockBillSub where HInterID={ Hmainid}and HEntryID={HsupId}"); + } + + + + oCN.Commit();//鎻愪氦浜嬪姟 + + //鍒犻櫎鍚庢帶鍒�================================================================================== + string sql2 = "exec h_p_Kf_POStockInBill_AfterDelCtrl " + Hmainid + ",'" + HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Kf_POStockInBill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + sReturn = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + sReturn; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + sReturn = ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + sReturn; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //============================================================================================== + + objJsonResult.code = "0"; objJsonResult.count = 1; - objJsonResult.Message = "鍒犻櫎鎴愬姛锛�"; + objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�"; objJsonResult.data = null; - return objJsonResult; + return objJsonResult; ; + } catch (Exception e) { - oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } + /// <summary> /// 鏍规嵁鍩虹璧勬枡ID 鏌ユ壘璁板綍 @@ -429,6 +593,7 @@ [HttpGet] public object AuditKf_POStockInBill(string HInterID, int Type, string user) { + string sql = ""; try { //鍒ゆ柇鏄惁鏈夊鏍告潈闄� @@ -451,104 +616,97 @@ } ClsPub.CurUserName = user; - BillOld.MvarItemKey = "Kf_ICStockBillMain"; + ds = oCN.RunProcReturn("select * from Kf_ICStockBillMain where HInterID = " + int.Parse(HInterID), "Kf_ICStockBillMain"); + string HBillNo = ""; + DAL.ClsKf_POStockInBill oBill = new DAL.ClsKf_POStockInBill(); oCN.BeginTran();//寮�濮嬩簨鍔� + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); + } //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) + + //瀹℃牳鍓嶆帶鍒� + sql = "h_p_Kf_POStockInBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Kf_POStockInBill_BeforeCheckCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦紒"; + 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; } - if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) + + if (!BillOld.CheckBill(int.Parse(HInterID), HBillNo, "h_p_Kf_POStockInBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { - 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; - } - 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]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�"; - objJsonResult.data = null; - return objJsonResult; - } - //瀹℃牳鍗曟嵁 - if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; - } + 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) + //鍙嶅鏍稿墠鎺у埗 + sql = "exec h_p_Kf_POStockInBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql, "h_p_Kf_POStockInBill_BeforeUnCheckCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { - 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; - } - 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]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!"; - objJsonResult.data = null; - return objJsonResult; - } - //鍙嶅鏍稿崟鎹� - if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) - { - objJsonResult.code = "0"; - objJsonResult.count = 1; - objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; - objJsonResult.data = null; - return objJsonResult; - } + 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; + } + + if (BillOld.AbandonCheck(int.Parse(HInterID), HBillNo, "h_p_Kf_POStockInBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) + { + SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); + //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl"); + + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; } } + + oCN.Commit();//鎻愪氦浜嬪姟 @@ -625,14 +783,14 @@ objJsonResult.data = null; return objJsonResult; } - //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]["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]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") { @@ -849,6 +1007,43 @@ #endregion + #region 閲囪喘鍏ュ簱鍗� 鏍规嵁涓诲唴鐮佷笌瀛愬唴鐮佽幏鍙栭噰璐叆搴撳崟鏁版嵁 + [Route("Kf_POStockInBill/loadKf_POStockInBill_Push")] + [HttpGet] + public object loadKf_POStockInBill_Push(long HInterID, long HSubID) + { + try + { + + ds = oCN.RunProcReturn("select * from h_v_IF_POStockInBillList where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_POStockInBillList"); + 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; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + } } #endregion \ No newline at end of file -- Gitblit v1.9.1