From b57da8b5cc90a4f9a66f830fad03d76c8512d2fc Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期五, 29 十一月 2024 14:37:59 +0800 Subject: [PATCH] 采购销售部分单据添加 编辑视图 --- WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs | 228 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 202 insertions(+), 26 deletions(-) diff --git a/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs b/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs index e03d109..67f8f3b 100644 --- a/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs +++ b/WebAPI/Controllers/XSGL/Xs_SeOrderChangeBillController.cs @@ -37,23 +37,23 @@ { List<object> columnNameList = new List<object>(); //鏌ョ湅鏉冮檺 - //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user)) - //{ - // objJsonResult.code = "0"; - // objJsonResult.count = 0; - // objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; - // objJsonResult.data = null; - // return objJsonResult; - //} + if (!DBUtility.ClsPub.Security_Log("Xs_SeOrderChangeBill_Query", 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_Xs_SeOrderChangeBillList_Query order by 鍗曟嵁鍙� ", "h_v_Xs_SeOrderChangeBillList_Query"); + ds = oCN.RunProcReturn("select * from h_v_Xs_SeOrderChangeBillList_Query order by 鍗曟嵁鍙� desc", "h_v_Xs_SeOrderChangeBillList_Query"); } else { string sql1 = "select * from h_v_Xs_SeOrderChangeBillList_Query where 1 = 1 "; - string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; ds = oCN.RunProcReturn(sql, "h_v_Xs_SeOrderChangeBillList_Query"); } @@ -217,7 +217,15 @@ } - + //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗 + int sYear = 0; + int sPeriod = 0; + DateTime HDate = DateTime.Now; + if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) + { + objJsonResult.Message = s; + return objJsonResult; + } //淇濆瓨 //淇濆瓨瀹屾瘯鍚庡鐞� @@ -350,16 +358,73 @@ return objJsonResult; } + //鍒犻櫎鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Xs_SeOrderChangeBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Xs_SeOrderChangeBill_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; + } + //================================================================================== + + //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗 + int sYear = 0; + int sPeriod = 0; + DateTime HDate = DateTime.Now; + if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) + { + objJsonResult.Message = s; + return objJsonResult; + } + oCN.BeginTran(); oCN.RunProc("delete from Xs_SeOrderChangeBillMain where HInterID = " + HInterID); oCN.RunProc("delete from Xs_SeOrderChangeBillSub where HInterID= " + HInterID); + //鍒犻櫎鍚庢帶鍒�================================================================================== + string sql2 = "exec h_p_Xs_SeOrderChangeBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; + ds = oCN.RunProcReturn(sql2, "h_p_Xs_SeOrderChangeBill_AfterDelCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + s = "鍒犻櫎鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + s = ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + s; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //============================================================================================== + oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "Sucess锛�"; + objJsonResult.Message = "鎮ㄥ凡鍒犻櫎鍗曟嵁鍙蜂负" + BillOld.omodel.HBillNo + "鐨勯攢鍞鍗曞彉鏇村崟锛�"; objJsonResult.data = null; return objJsonResult; } @@ -468,20 +533,51 @@ //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣� if (IsAudit == 0) //瀹℃牳鎻愪氦 { + //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗 + string s = ""; + int sYear = 0; + int sPeriod = 0; + DateTime HDate = DateTime.Now; + if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) + { + objJsonResult.Message = s; + return objJsonResult; + } + //妫�楠屽瓙琛ㄦ暟鎹� string errorMessage = ""; DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //褰撴棩鏃ユ湡 foreach (Model.ClsXs_SeOrderChangeBillSub oSub in oBill.DetailColl) { - //鍒ゆ柇鏂版暟閲忔槸鍚﹀皬浜庡崟鎹叧鑱旀暟閲� - if(oSub.HQty_New < oSub.HRelationQty) + string sqlCheck = "select * from Xs_SeOrderBillSub where HInterID = " + oSub.HSourceInterID + " and HEntryID = " + oSub.HSourceEntryID; + ds = oCN.RunProcReturn(sqlCheck, "Xs_SeOrderBillSub"); + if (ds.Tables[0].Rows.Count == 0) { - errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬鍗曟嵁琚叧鑱旀暟閲�!"; - } - //鍒ゆ柇鏂颁氦璐ф棩鏈熸槸鍚︽棭浜庡綋鏃� - if ( oSub.HDate_New.CompareTo(today) < 0 ) + errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欏湪婧愬崟-閿�鍞鍗曚腑涓嶅瓨鍦�!"; + } + else { - errorMessage += "绗�" + oSub.HEntryID + "琛屾柊浜よ揣鏃ユ湡鏃╀簬褰撴棩!"; + double HRelationQty = 0; + double HRelationQty_ICMO = 0; + //鑾峰彇閿�鍞鍗曞彉鏇村崟涓搴旂墿鏂欏湪婧愬崟-閿�鍞鍗曚腑鐨勫叧鑱旀暟閲� + HRelationQty = double.Parse(ds.Tables[0].Rows[0]["HRelationQty"].ToString()); + HRelationQty_ICMO = double.Parse(ds.Tables[0].Rows[0]["HRelationQty_ICMO"].ToString()); + + //鍒ゆ柇鐗╂枡鏂版暟閲忔槸鍚﹀皬浜庢簮鍗曞崟鎹腑瀵瑰簲鐗╂枡鐨勫嚭搴撳叧鑱旀暟閲� + if (oSub.HQty_New < HRelationQty) + { + errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬婧愬崟-閿�鍞鍗曞嚭搴撳叧鑱旀暟閲�!"; + } + //鍒ゆ柇鐗╂枡鏂版暟閲忔槸鍚﹀皬浜庢簮鍗曞崟鎹腑瀵瑰簲鐗╂枡鐨勫嚭搴撳叧鑱旀暟閲� + if (oSub.HQty_New < HRelationQty_ICMO) + { + errorMessage += "绗�" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬婧愬崟-閿�鍞鍗曠敓浜у叧鑱旀暟閲�!"; + } + //鍒ゆ柇鏂颁氦璐ф棩鏈熸槸鍚︽棭浜庡綋鏃� + if (oSub.HDate_New.CompareTo(today) < 0) + { + errorMessage += "绗�" + oSub.HEntryID + "琛屾柊浜よ揣鏃ユ湡鏃╀簬褰撴棩!"; + } } } if(errorMessage != "") @@ -505,17 +601,60 @@ objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟涓嶅瓨鍦�!"; objJsonResult.data = null; return objJsonResult; + }else if(ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "2") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟鏈浜庡鏍哥姸鎬�!"; + objJsonResult.data = null; + return objJsonResult; + } + + + //瀹℃牳鍓嶆帶鍒�========================================= + string sql1 = "exec h_p_Xs_SeOrderChangeBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Xs_SeOrderChangeBill_BeforeCheckCtrl"); + 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(); + //鍙嶅啓閿�鍞鍗曟暟鎹� + sql = "exec h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill " + oBill.omodel.HInterID; + oCN.RunProcReturn(sql, "h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill"); + //淇$敤鎺у埗 + sql = "exec h_p_Kf_CheckSeOrderChangeBill_CrediControl " + oBill.omodel.HMainSourceInterID; + ds = oCN.RunProcReturn(sql, "h_p_Kf_CheckSeOrderBill_CrediControl"); + if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1") + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); + objJsonResult.data = null; + return objJsonResult; } //瀹℃牳鎻愪氦 - if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) + if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderChangeBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { - oCN.BeginTran(); - //鍙嶅啓閿�鍞鍗曟暟鎹� - sql = "exec h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill " + oBill.omodel.HInterID; - oCN.RunProcReturn(sql, "h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill"); oCN.Commit(); - objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "瀹℃牳鎴愬姛"; @@ -524,6 +663,8 @@ } else { + oCN.RollBack(); + objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; @@ -533,8 +674,41 @@ } if (IsAudit == 1) //鍙嶅鏍告彁浜� { + //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗 + string s = ""; + int sYear = 0; + int sPeriod = 0; + DateTime HDate = DateTime.Now; + if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) + { + objJsonResult.Message = s; + return objJsonResult; + } + + //鍙嶅鏍稿墠鎺у埗========================================= + string sql1 = "exec h_p_Xs_SeOrderChangeBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; + ds = oCN.RunProcReturn(sql1, "h_p_Xs_SeOrderChangeBill_BeforeUnCheckCtrl"); + 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; + } + //=========================================================== + //鍙嶅鏍告彁浜bandonCheck - if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) + if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderChangeBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; @@ -555,6 +729,8 @@ } catch (Exception e) { + oCN.RollBack(); + objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); -- Gitblit v1.9.1