From b7f9458b0ec768c1bef45f83c1926031e2cc5cae Mon Sep 17 00:00:00 2001 From: zrg <z18737863051@163.com> Date: 星期二, 16 一月 2024 10:04:42 +0800 Subject: [PATCH] 采购入库单收料通知单,保存前反写关联数量的存储过程 --- WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs | 88 +++++++++++++++++++++++++---- WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs | 58 +++++++++++++++--- 2 files changed, 123 insertions(+), 23 deletions(-) diff --git a/WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs b/WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs index 8489302..cdb9774 100644 --- a/WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs +++ b/WebAPI/Controllers/CGGL/Cg_POInStockBillController.cs @@ -130,10 +130,11 @@ /// <returns></returns> [Route("Cg_POInStockBill/DeltetPOInStockBill")] [HttpGet] - public object DeltetPOInStockBill(string HInterID, string user) + public object DeltetPOInStockBill(string HInterID, string HsupId, string HQty, string HSourceInterID, string HSourceEntryID, string user) { try { + DataSet dss; //鍒ゆ柇鏄惁鏈夊垹闄ょ殑鏉冮檺 if (!DBUtility.ClsPub.Security_Log("Cg_POInStockBill_Drop", 1, false, user)) { @@ -149,9 +150,31 @@ if (objJsonResult.code == "0") return objJsonResult; - oCN.BeginTran(); - oCN.RunProc("Delete From Cg_POInStockBillMain where HInterID = " + HInterID); - oCN.RunProc("Delete From Cg_POInStockBillSub where HInterID = " + HInterID); + oCN.BeginTran(); //寮�濮嬩簨鍔� + //鏌ヨ鏁版嵁 + ds = oCN.RunProcReturn("select * from Cg_POInStockBillMain a inner join Cg_POInStockBillSub b on a.HInterID=b.HInterID where a.HInterID= '" + HInterID + "'", "Kf_ICStockBillMain"); + //鎵ц瀛樺偍杩囩▼杩涜鍙嶅啓 + dss = oCN.RunProcReturn("exec h_p_Cg_POOrderBillMain_Delete " + 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 Cg_POInStockBillMain where HInterID=" + HInterID); + oCN.RunProc("delete Cg_POInStockBillSub where HInterID=" + HInterID); + } + else + { + oCN.RunProc($"delete Cg_POInStockBillSub where HInterID={ HInterID}and HEntryID={HsupId}"); + } + oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -236,9 +259,9 @@ } } //鍙嶅鏍� 鍒犻櫎 鍒犻櫎閲戣澏鏁版嵁搴撳搴� 鏀舵枡閫氱煡鍒版暟鎹� - public json DeleteKingDee(string hinterid) + public json DeleteKingDee(string HInterID) { - string sql = string.Format("select HinterID,HERPBillNO,HERPInterID from Cg_POInStockBillMain where HERPInterID>0 and hinterid in (" + hinterid + ")"); + string sql = string.Format("select HinterID,HERPBillNO,HERPInterID from Cg_POInStockBillMain where HERPInterID>0 and hinterid in (" + HInterID + ")"); DataTable dt = oCN.RunProcReturn(sql, "deleteDt").Tables[0]; if (dt.Rows.Count > 0) { @@ -408,13 +431,13 @@ "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + ",HSupID=" + HSupID + ",HCurID=" + HCurID + ",HExRate=" + HExRate + ",HEmpID=" + HEmpID + ",HManagerID=" + HManagerID + ",HDeptID=" + HDeptID - + ",HAddress='" + HAddress + " where HInterID=" + HInterID); + + ",HAddress='" + HAddress + "' where HInterID=" + HInterID); //鍒犻櫎瀛愯〃 oCN.RunProc("delete from Cg_POInStockBillSub where HInterID='" + HInterID + "'"); } //淇濆瓨瀛愯〃 - objJsonResult = AddBillSub(msg3, HInterID, OperationType); + objJsonResult = AddBillSub(msg3, HInterID, OperationType,user); if (objJsonResult.code == "0") { @@ -441,7 +464,7 @@ } } - public json AddBillSub(string msg3, long HInterID, int OperationType) + public json AddBillSub(string msg3, long HInterID, int OperationType,string user) { List<ClsCg_POInStockBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_POInStockBillSub>>(msg3); @@ -475,7 +498,7 @@ string HPROJECTNO = DetailColl2[0].HPROJECTNO == null ? "''" : DetailColl2[0].HPROJECTNO; string HGIVEAWAY = DetailColl2[0].HGIVEAWAY == null ? "''" : DetailColl2[0].HGIVEAWAY; string HCHECKINCOMING = DetailColl2[0].HCHECKINCOMING == null ? "''" : DetailColl2[0].HCHECKINCOMING; - string HDISCOUNTRATE = DetailColl2[0].HDISCOUNTRATE == null ? "''" : DetailColl2[0].HDISCOUNTRATE; + string HDISCOUNTRATE = DetailColl2[0].HDISCOUNTRATE == null ? "'0'" : DetailColl2[0].HDISCOUNTRATE; double HPRICECOEFFICIENT = DetailColl2[0].HPRICECOEFFICIENT == null ? 0 : DetailColl2[0].HPRICECOEFFICIENT; long HPRICEUNITID = DetailColl2[0].HPRICEUNITID == null ? 0 : DetailColl2[0].HPRICEUNITID; long HPRICELISTENTRY = DetailColl2[0].HPRICELISTENTRY == null ? 0 : DetailColl2[0].HPRICELISTENTRY; @@ -547,6 +570,18 @@ NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()); NewHEntryID += 1; } + //鍙嶅啓閲囪喘鍏ュ簱鍗� + string sReturn = ""; + ds = oCN.RunProcReturn("exec h_p_Cg_POOrderBillMain " + oSub.HQty + ", '" + oSub.HSourceInterID + "', '" + oSub.HSourceEntryID + "','" + user + " '", "h_p_Cg_POOrderBillMain"); + 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($@"Insert into Cg_POInStockBillSub (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice @@ -559,8 +594,9 @@ ,HEXCHANGERATE,HLOCALCURRID,HISINCLUDEDTAX,HISPRICEEXCLUDETAX ,HTAXRATEID,HCOSTPERCENT,HCOSTAMOUNT,HVAT,HSELLERWITHHOLDING,HBUYERWITHHOLDING,HSecUnitID) values({HInterID},{NewHEntryID},{oSub.HMaterID},{oSub.HUnitID},{(oSub.HQty == null ? 0 : oSub.HQty)} - ,{oSub.HPrice},{oSub.HMoney},{oSub.HWHID},{oSub.HSPID},'{HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},{HSourceBillNo},{HSourceBillType},{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID},{HPOOrderBillNo},{HAuxPropID},{HBatchNO},{HMTONo},{HPlanMode},{HERPInterID},{HERPEntryID},{HRelationQty},{HGiveAwayFlag},{HReceiveQty},{HSEQ},{HPRODUCEDATE},{HEXPIRYDATE}, + ,{oSub.HPrice},{oSub.HMoney},{oSub.HWHID},{oSub.HSPID},'{HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{HSourceBillNo}',{HSourceBillType},{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID},{HPOOrderBillNo},{HAuxPropID},{HBatchNO},{HMTONo},{HPlanMode},{HERPInterID},{HERPEntryID},{HRelationQty},{HGiveAwayFlag},{HReceiveQty},{HSEQ},{HPRODUCEDATE},{HEXPIRYDATE}, {HSUPPLYLOT},{HREQTRACENO},{HBOMID},{HSTOCKUNITID},{HBASEUNITID},{HSTOCKSTATUSID},'{HKEEPERTYPEID}',{HPROJECTNO},{HCHECKINCOMING},{oSub.HTaxPrice},{HDISCOUNTRATE},{HPRICECOEFFICIENT},{HPRICEUNITID},{HPRICELISTENTRY},{HSAMPLEDAMAGEQTY},{HSAMPLEDAMAGEBASEQTY},{HPAYORGID},{HSETTLEORGID},{HSETTLECURRID},{HSETTLEMODEID},{HEXCHANGETYPEID},{HPAYCONDITONID},{oSub.HEXCHANGERATE},{HLOCALCURRID},{HISINCLUDEDTAX},{HISPRICEEXCLUDETAX},{HTAXRATEID},{HCOSTPERCENT},{HCOSTAMOUNT},{HVAT},{HSELLERWITHHOLDING},{HBUYERWITHHOLDING},{oSub.HSecUnitID})"); + } objJsonResult.code = "1"; diff --git a/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs b/WebAPI/Controllers/CGGL/Kf_POStockInBillController.cs index e64393c..50b3852 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; @@ -202,7 +203,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 +230,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,6 +313,18 @@ ,{(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); } @@ -330,30 +343,81 @@ /// <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; + } + 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 == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; + 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();//鎻愪氦浜嬪姟 + 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 鏌ユ壘璁板綍 -- Gitblit v1.9.1