| | |
| | | { |
| | | 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"); |
| | | } |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | //进行 会计期间 结账 的判断和控制 |
| | | 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; |
| | | } |
| | | |
| | | //保存 |
| | | //保存完毕后处理 |
| | |
| | | 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; |
| | | } |
| | |
| | | //进行需要进行的审核/反审核操作 |
| | | 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 != "") |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //检验源单是否存在 |
| | | string 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(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.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "审核成功"; |
| | |
| | | } |
| | | else |
| | | { |
| | | oCN.RollBack(); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | |
| | | } |
| | | 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; |
| | | } |
| | | //=========================================================== |
| | | |
| | | //反审核提交AbandonCheck |
| | | 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; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); |