public ResultModel Complete(UserModel user, int pricingId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = pricingDAL.Get(user, pricingId); if (result.ResultStatus != 0) return result; Model.Pricing resultObj = result.ReturnValue as Pricing; if (resultObj == null || resultObj.PricingId <= 0) { result.ResultStatus = -1; result.Message = "该数据不存在,不能进行执行完成操作"; return result; } //执行完成 result = pricingDAL.Complete(user, resultObj); if (result.ResultStatus != 0) return result; //加载明细 DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL(); result = pricingDetailDAL.Load(user, resultObj.PricingId); if (result.ResultStatus != 0) return result; List<Model.PricingDetail> details = result.ReturnValue as List<Model.PricingDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取点价明细失败"; return result; } foreach (Model.PricingDetail detail in details) { result = pricingDetailDAL.Complete(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.Message = ex.Message; } finally { if (result.ResultStatus != 0) log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); else if (log.IsInfoEnabled) log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue); } return result; }
public ResultModel CompleteCancel(UserModel user, int pricingId) { ResultModel result = new ResultModel(); try { DAL.PricingDetailDAL pricingDetailDAL = new PricingDetailDAL(); DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证点价 result = pricingDAL.Get(user, pricingId); if (result.ResultStatus != 0) return result; Model.Pricing pricing = result.ReturnValue as Pricing; if (pricing == null || pricing.PricingId <= 0) { result.ResultStatus = -1; result.Message = "该数据不存在,不能进行执行完成取消操作"; return result; } //点价完成取消 result = pricingDAL.CompleteCancel(user, pricing); if (result.ResultStatus != 0) return result; //获取已完成点价明细 result = pricingDetailDAL.Load(user, pricing.PricingId, Common.StatusEnum.已完成); if (result.ResultStatus != 0) return result; List<Model.PricingDetail> details = result.ReturnValue as List<Model.PricingDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取点价明细错误"; return result; } //将所有已完成点价明细更新至已生效 foreach (Model.PricingDetail detail in details) { result = pricingDetailDAL.CompleteCancel(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }