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_ExceptiveCheckRequestBillController.cs | 256 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 243 insertions(+), 13 deletions(-) diff --git a/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs b/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs index dc8bfd5..96cff0d 100644 --- a/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs +++ b/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.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_ExceptiveCheckRequestBill_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_ExceptiveCheckRequestBillList_Query order by 鍗曟嵁鍙� ", "h_v_Xs_ExceptiveCheckRequestBillList_Query"); + ds = oCN.RunProcReturn("select * from h_v_Xs_ExceptiveCheckRequestBillList_Query order by 鍗曟嵁鍙� desc", "h_v_Xs_ExceptiveCheckRequestBillList_Query"); } else { string sql1 = "select * from h_v_Xs_ExceptiveCheckRequestBillList_Query where 1 = 1 "; - string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� "; + string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc"; ds = oCN.RunProcReturn(sql, "h_v_Xs_ExceptiveCheckRequestBillList_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,6 +358,16 @@ 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_ExceptiveCheckRequestBillMain where HInterID = " + HInterID); @@ -359,7 +377,7 @@ objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "Sucess锛�"; + objJsonResult.Message = "鎮ㄥ凡鍒犻櫎鍗曟嵁鍙蜂负" + BillOld.omodel.HBillNo + "鐨勭壒鎵圭敵璇峰崟锛�"; objJsonResult.data = null; return objJsonResult; } @@ -468,9 +486,96 @@ //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣� 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; + } + + oCN.BeginTran(); + + //妫�楠屾簮鍗曟槸鍚﹀瓨鍦� + string sql = ""; + if(oBill.omodel.HMainSourceBillType == "1401") + { + sql = "select * from Xs_SeOrderBillMain as a " + + "inner join Xs_SeOrderBillSub as b on a.HInterID = b.HInterID " + + "where a.HInterID = " + oBill.omodel.HMainSourceInterID; + ds = oCN.RunProcReturn(sql, "Xs_SeOrderBill"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曚笉瀛樺湪!"; + objJsonResult.data = null; + return objJsonResult; + } + else if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曟湭澶勪簬鍒涘缓鐘舵��!"; + objJsonResult.data = null; + return objJsonResult; + } + } + else if(oBill.omodel.HMainSourceBillType == "1205") + { + sql = "select * from Kf_ICStockBillMain as a " + + "inner join Kf_ICStockBillSub as b on a.HInterID = b.HInterID " + + "where a.HInterID = " + oBill.omodel.HMainSourceInterID; + ds = oCN.RunProcReturn(sql, "Kf_ICStockBill"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞嚭搴撳崟涓嶅瓨鍦�!"; + objJsonResult.data = null; + return objJsonResult; + } + else if (int.Parse(ds.Tables[0].Rows[0]["HBillStatus"].ToString()) > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞嚭搴撳崟鏈浜庡垱寤虹姸鎬�!"; + objJsonResult.data = null; + return objJsonResult; + } + } + else if (oBill.omodel.HMainSourceBillType == "1425") + { + objJsonResult = AuditXs_ExceptiveCheckRequestBill_CheckSeOrderChangeBill(oBill.omodel.HMainSourceInterID); + if (objJsonResult.code != "1") + { + return objJsonResult; + } + + //鍙嶅啓閿�鍞鍗曟暟鎹� + sql = "exec h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill " + oBill.omodel.HMainSourceInterID; + oCN.RunProc(sql); + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟涓嶆槑纭紒!"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍙嶅啓婧愬崟鍗曟嵁鐘舵�� + sql = "exec h_p_Xs_ExceptiveCheckRequestBill_ReWriteSourceStatus " + oBill.omodel.HMainSourceInterID + ",'" + oBill.omodel.HMainSourceBillType + "','" + CurUserName + "'"; + oCN.RunProc(sql); + if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { + oCN.Commit(); + objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "瀹℃牳鎴愬姛"; @@ -479,6 +584,8 @@ } else { + oCN.RollBack(); + objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; @@ -488,6 +595,18 @@ } 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; + } + //鍙嶅鏍告彁浜bandonCheck if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { @@ -510,6 +629,8 @@ } catch (Exception e) { + oCN.RollBack(); + objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); @@ -517,6 +638,115 @@ return objJsonResult; } } + + #region 瀹℃牳鐗规壒鐢宠鍗曞弽鍐欓攢鍞鍗曞彉鏇村崟鐘舵�佹暟鎹楠� + public json AuditXs_ExceptiveCheckRequestBill_CheckSeOrderChangeBill(long HInterID) + { + + try + { + Int64 lngBillKey = 0; + lngBillKey = DBUtility.ClsPub.isLong(HInterID); //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹� + DAL.ClsXs_SeOrderChangeBill oBill = new DAL.ClsXs_SeOrderChangeBill(); //閿�鍞鍗曞彉鏇村崟瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣� + DAL.ClsXs_SeOrderBill oBillSource = new DAL.ClsXs_SeOrderBill(); //閿�鍞鍗曞疄渚嬪寲鍗曟嵁鎿嶄綔绫伙紝鐢ㄤ簬杩涜鐩稿叧鎿嶄綔 + + //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔 + if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //鏍规嵁HInterID鑾峰彇閿�鍞鍗曞彉鏇村崟鍗曟嵁鐨勬暟鎹� + { + if (!oBillSource.ShowBill(oBill.DetailColl[0].HSourceInterID, ref DBUtility.ClsPub.sExeReturnInfo)) //鍒ゆ柇閿�鍞鍗曞彉鏇村崟鐨勬簮鍗�-閿�鍞鍗曟槸鍚﹀瓨鍦ㄥ苟鑾峰彇鏁版嵁 + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟鐨勬簮鍗�-閿�鍞鍗曚笉瀛樺湪!"; + objJsonResult.data = null; + return objJsonResult; + } + + + if (oBill.omodel.HBillStatus > 1) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟涓嶄负鈥樺垱寤衡�欑姸鎬侊紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (oBillSource.omodel.HBillStatus != 2) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟鐨勬簮鍗�-閿�鍞鍗曚笉涓衡�樺凡瀹℃牳鈥欑姸鎬侊紒"; + objJsonResult.data = null; + return objJsonResult; + } + + //妫�楠屽瓙琛ㄦ暟鎹� + string errorMessage = ""; + DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); //褰撴棩鏃ユ湡 + double HRelationQty = 0; //婧愬崟-閿�鍞鍗曞叧鑱旀暟閲�(閿�鍞嚭搴撴暟閲�) + foreach (Model.ClsXs_SeOrderChangeBillSub oSub in oBill.DetailColl) + { + string sql = "select * from Xs_SeOrderBillSub where HInterID = " + oSub.HSourceInterID + " and HEntryID = " + oSub.HSourceEntryID; + ds = oCN.RunProcReturn(sql, "Xs_SeOrderBillSub"); + if (ds.Tables[0].Rows.Count == 0) + { + errorMessage += "婧愬崟-閿�鍞鍗曞彉鏇村崟锛氱" + oSub.HEntryID + "琛岀墿鏂欏湪婧愬崟-閿�鍞鍗曚腑涓嶅瓨鍦�!"; + } + else + { + //鑾峰彇閿�鍞鍗曞彉鏇村崟涓搴旂墿鏂欏湪婧愬崟-閿�鍞鍗曚腑鐨勫叧鑱旀暟閲� + HRelationQty = double.Parse(ds.Tables[0].Rows[0]["HRelationQty"].ToString()); + + //鍒ゆ柇鐗╂枡鏂版暟閲忔槸鍚﹀皬浜庢簮鍗曞崟鎹腑瀵瑰簲鐗╂枡鐨勫叧鑱旀暟閲� + if (oSub.HQty_New < HRelationQty) + { + errorMessage += "婧愬崟-閿�鍞鍗曞彉鏇村崟锛氱" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬婧愬崟-閿�鍞鍗曡鍏宠仈鏁伴噺!"; + } + //鍒ゆ柇鏂颁氦璐ф棩鏈熸槸鍚︽棭浜庡綋鏃� + if (oSub.HDate_New.CompareTo(today) < 0) + { + errorMessage += "婧愬崟-閿�鍞鍗曞彉鏇村崟锛氱" + oSub.HEntryID + "琛屾柊浜よ揣鏃ユ湡鏃╀簬褰撴棩!"; + } + + } + } + if (errorMessage != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + errorMessage; + objJsonResult.data = null; + return objJsonResult; + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = null; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟涓嶅瓨鍦�!"; + objJsonResult.data = null; + return objJsonResult; + } + } + catch (Exception e) + { + oCN.RollBack(); + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion #endregion #region 鐗规壒鐢宠鍗� 鍏抽棴/鍙嶅叧闂� -- Gitblit v1.9.1