| | |
| | | { |
| | | 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"); |
| | | } |
| | | |
| | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.Message = "您已删除单据号为" + BillOld.omodel.HBillNo + "的特批申请单!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | //进行需要进行的审核/反审核操作 |
| | | if (IsAudit == 0) //审核提交 |
| | | { |
| | | //审核提交 |
| | | //oBill.oCn.BeginTran(); |
| | | 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) |
| | | { |
| | | //if (oBill.omodel.HMainSourceBillType == "1401") //自动审核销售订单 |
| | | //{ |
| | | // objJsonResult = AuditXs_SeOrderBill((int)oBill.omodel.HMainSourceInterID, 0, CurUserName); |
| | | // if (objJsonResult.count != 0) |
| | | // { |
| | | // oBill.oCn.Commit(); |
| | | |
| | | // objJsonResult.code = "1"; |
| | | // objJsonResult.count = 1; |
| | | // objJsonResult.Message = "审核成功"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | // } |
| | | // else |
| | | // { |
| | | // //oBill.oCn = new SQLHelper.ClsCN(); |
| | | // return objJsonResult; |
| | | // } |
| | | |
| | | //} |
| | | //else if (oBill.omodel.HMainSourceBillType == "1205") //自动审核销售出库单 |
| | | //{ |
| | | // objJsonResult = AuditKf_SellOutBill((int)oBill.omodel.HMainSourceInterID, 0, CurUserName); |
| | | // if (objJsonResult.count != 0) |
| | | // { |
| | | // oBill.oCn.Commit(); |
| | | |
| | | // objJsonResult.code = "1"; |
| | | // objJsonResult.count = 1; |
| | | // objJsonResult.Message = "审核成功"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | // } |
| | | // else |
| | | // { |
| | | // //oBill.oCn = new SQLHelper.ClsCN(); |
| | | // return objJsonResult; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // //oBill.oCn = new SQLHelper.ClsCN(); |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "审核失败!原因:源单类型错误!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | } |
| | | else |
| | | { |
| | | //oBill.oCn = new SQLHelper.ClsCN(); |
| | | oCN.RollBack(); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); |
| | |
| | | } |
| | | } |
| | | |
| | | #region 审核销售订单 |
| | | public json AuditXs_SeOrderBill(int HInterID, int IsAudit, string CurUserName) |
| | | #region 审核特批申请单反写销售订单变更单状态数据检验 |
| | | public json AuditXs_ExceptiveCheckRequestBill_CheckSeOrderChangeBill(long HInterID) |
| | | { |
| | | string ModRightNameCheck = "Xs_SeOrderBill_Check"; |
| | | DBUtility.ClsPub.CurUserName = CurUserName; |
| | | |
| | | try |
| | | { |
| | | //审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //HInterID数据判断 |
| | | if (HInterID <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单HInterID小于0!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | Int64 lngBillKey = 0; |
| | | lngBillKey = DBUtility.ClsPub.isLong(HInterID); //对HInterID进行类型的转换 |
| | | DAL.ClsXs_SeOrderBill oBill = new DAL.ClsXs_SeOrderBill(); //实例化单据操作类,用于进行相关操作 |
| | | 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 (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取销售订单变更单单据的数据 |
| | | { |
| | | if (oBill.omodel.HCloseMan.Trim() != "") |
| | | if (!oBillSource.ShowBill(oBill.DetailColl[0].HSourceInterID, ref DBUtility.ClsPub.sExeReturnInfo)) //判断销售订单变更单的源单-销售订单是否存在并获取数据 |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据已关闭!不能再次审核!"; |
| | | objJsonResult.Message = "审核失败!原因:源单-销售订单变更单的源单-销售订单不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (oBill.omodel.HDeleteMan.Trim() != "") |
| | | |
| | | |
| | | if (oBill.omodel.HBillStatus > 1) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据已作废!不能再次审核!"; |
| | | objJsonResult.Message = "审核失败!原因:源单-销售订单变更单不为‘创建’状态!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (IsAudit == 0) //审核判断 |
| | | |
| | | if (oBillSource.omodel.HBillStatus != 2) |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() != "") |
| | | 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) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据已审核!不能再次审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | 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 (IsAudit == 1) //反审核判断 |
| | | if (errorMessage != "") |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据未审核!不需要反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | 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 = "源单单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.Message = "审核失败!原因:源单-销售订单变更单不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | //进行需要进行的审核/反审核操作 |
| | | if (IsAudit == 0) //审核提交 |
| | | { |
| | | //审核提交 |
| | | if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "源单审核成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | if (IsAudit == 1) //反审核提交 |
| | | { |
| | | //反审核提交AbandonCheck |
| | | if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "源单反审核成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单审核失败或者反审核失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 审核销售出库单 |
| | | public json AuditKf_SellOutBill(int HInterID, int IsAudit, string CurUserName) |
| | | { |
| | | string ModRightNameCheck = "Kf_SellOutBill_Check"; |
| | | DBUtility.ClsPub.CurUserName = CurUserName; |
| | | try |
| | | { |
| | | //审核权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单审核失败!无权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //HInterID数据判断 |
| | | if (HInterID <= 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单HInterID小于0!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | Int64 lngBillKey = 0; |
| | | lngBillKey = DBUtility.ClsPub.isLong(HInterID); //对HInterID进行类型的转换 |
| | | DAL.ClsKf_SellOutBill oBill = new DAL.ClsKf_SellOutBill(); //实例化单据操作类,用于进行相关操作 |
| | | |
| | | //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作 |
| | | if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据 |
| | | { |
| | | if (oBill.omodel.HCloseMan.Trim() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据已关闭!不能再次审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (oBill.omodel.HDeleteMan.Trim() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据已作废!不能再次审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (IsAudit == 0) //审核判断 |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据已审核!不能再次审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | if (IsAudit == 1) //反审核判断 |
| | | { |
| | | if (oBill.omodel.HChecker.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据未审核!不需要反审核!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | //进行需要进行的审核/反审核操作 |
| | | if (IsAudit == 0) //审核提交 |
| | | { |
| | | //审核提交 |
| | | if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "源单审核成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | if (IsAudit == 1) //反审核提交 |
| | | { |
| | | //反审核提交AbandonCheck |
| | | if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "源单反审核成功"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "源单审核失败或者反审核失败!" + e.ToString(); |
| | | objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |