public ResultModel Invalid(UserModel user, int pledgeApplyId) { ResultModel result = new ResultModel(); DAL.StockDAL stockDAL = new StockDAL(); DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); DAL.PledgeApplyDetailDAL pledgeApplyDetailDAL = new PledgeApplyDetailDAL(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证出库申请 result = pledgeApplyDAL.Get(user, pledgeApplyId); if (result.ResultStatus != 0) return result; Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply; if (pledgeApply == null || pledgeApply.PledgeApplyId <= 0) { result.ResultStatus = -1; result.Message = "质押申请不存在"; return result; } //获取主申请实体 result = applyDAL.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //获取申请明细 result = pledgeApplyDetailDAL.Load(user, pledgeApply.PledgeApplyId); if (result.ResultStatus != 0) return result; List<PledgeApplyDetail> details = result.ReturnValue as List<PledgeApplyDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "申请明细获取失败"; return result; } //作废主申请 result = applyDAL.Invalid(user, apply); if (result.ResultStatus != 0) return result; //作废申请明细 foreach (Model.PledgeApplyDetail detail in details) { if (detail.DetailStatus == StatusEnum.已生效) detail.DetailStatus = StatusEnum.已录入; result = pledgeApplyDetailDAL.Invalid(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; return result; } return result; }
public ResultModel PledgeApplyInvalid(UserModel user, int pledgeApplyId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { NFMT.WareHouse.DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); result = pledgeApplyDAL.Get(user, pledgeApplyId); if (result.ResultStatus != 0) return result; NFMT.WareHouse.Model.PledgeApply pledgeApply = result.ReturnValue as NFMT.WareHouse.Model.PledgeApply; NFMT.Operate.BLL.ApplyBLL applyBLL = new Operate.BLL.ApplyBLL(); result = applyBLL.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply; result = applyBLL.Invalid(user, apply); if (result.ResultStatus != 0) return result; NFMT.WareHouse.DAL.PledgeApplyDetailDAL pledgeApplyDetailDAL = new PledgeApplyDetailDAL(); result = pledgeApplyDetailDAL.Invalid(user, pledgeApplyId, string.Empty); if (result.ResultStatus != 0) return result; //NFMT.WareHouse.DAL.StockExclusiveDAL stockExclusiveDAL = new StockExclusiveDAL(); //result = stockExclusiveDAL.Invalid(user, apply.ApplyId, pledgeApplyId, string.Empty); //if (result.ResultStatus != 0) // return result; scope.Complete(); } } catch (Exception ex) { result.Message = string.Format("操作失败,{0}", ex.Message); result.ResultStatus = -1; } 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 Goback(UserModel user, int pledgeApplyId) { ResultModel result = new ResultModel(); try { DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证质押申请 result = pledgeApplyDAL.Get(user, pledgeApplyId); if (result.ResultStatus != 0) return result; Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply; if (pledgeApply == null || pledgeApply.PledgeApplyId <= 0) { result.ResultStatus = -1; result.Message = "质押申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //主申请状态修改至已撤返 result = applyDAL.Goback(user, apply); if (result.ResultStatus != 0) return result; //工作流任务关闭 WorkFlow.DAL.DataSourceDAL sourceDAL = new WorkFlow.DAL.DataSourceDAL(); result = sourceDAL.SynchronousStatus(user, apply); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel ConfirmCancel(UserModel user, int pledgeApplyId) { ResultModel result = new ResultModel(); try { DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); DAL.PledgeApplyDetailDAL pledgeApplyDetailDAL = new PledgeApplyDetailDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证质押申请 result = pledgeApplyDAL.Get(user, pledgeApplyId); if (result.ResultStatus != 0) return result; Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply; if (pledgeApply == null || pledgeApply.PledgeApplyId <= 0) { result.ResultStatus = -1; result.Message = "质押申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //主申请状态更新至已生效 result = applyDAL.ConfirmCancel(user, apply); if (result.ResultStatus != 0) return result; //质押申请明细,在已完成状态下的更新至已生效 //获取已关闭的明细 result = pledgeApplyDetailDAL.Load(user, pledgeApply.PledgeApplyId, Common.StatusEnum.已完成); if (result.ResultStatus != 0) return result; List<Model.PledgeApplyDetail> details = result.ReturnValue as List<Model.PledgeApplyDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取申请明细失败"; return result; } foreach (Model.PledgeApplyDetail detail in details) { result = pledgeApplyDetailDAL.ConfirmCancel(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
public ResultModel Confirm(UserModel user, int pledgeApplyId) { ResultModel result = new ResultModel(); try { DAL.StockDAL stockDAL = new StockDAL(); DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); DAL.PledgeApplyDetailDAL pledgeApplyDetailDAL = new PledgeApplyDetailDAL(); using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证质押申请 result = pledgeApplyDAL.Get(user, pledgeApplyId); if (result.ResultStatus != 0) return result; Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply; if (pledgeApply == null || pledgeApply.PledgeApplyId <= 0) { result.ResultStatus = -1; result.Message = "质押申请不存在"; return result; } //验证主申请 result = applyDAL.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "主申请不存在"; return result; } //验证是否执行完成 result = pledgeApplyDAL.CheckPledgeCanConfirm(user, pledgeApply.PledgeApplyId); if (result.ResultStatus != 0) return result; Common.StatusEnum status = (Common.StatusEnum)result.ReturnValue; //获取已生效质押申请明细 result = pledgeApplyDetailDAL.Load(user, pledgeApply.PledgeApplyId); if (result.ResultStatus != 0) return result; List<Model.PledgeApplyDetail> details = result.ReturnValue as List<Model.PledgeApplyDetail>; if (details == null) { result.ResultStatus = -1; result.Message = "获取质押申请明细失败"; return result; } //主申请更新状态至已完成 if (status == StatusEnum.已完成) result = applyDAL.Confirm(user, apply); else if (status == StatusEnum.部分完成) result = applyDAL.PartiallyConfirm(user, apply); else { result.ResultStatus = -1; result.Message = "更新主申请状态失败"; return result; } if (result.ResultStatus != 0) return result; //质押申请明细更新状态至已完成 foreach (Model.PledgeApplyDetail detail in details) { //质押申请明细更新状态至已完成 result = pledgeApplyDetailDAL.Confirm(user, detail); if (result.ResultStatus != 0) return result; } scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }
/// <summary> /// 数据撤返 /// </summary> /// <param name="user">当前操作用户</param> /// <param name="pledge">Pledge对象</param> /// <returns></returns> public ResultModel GoBack(UserModel user, int pledgeId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = this.Get(user, pledgeId); if (result.ResultStatus != 0) return result; Model.Pledge pledge = result.ReturnValue as Pledge; if (pledge == null) { result.ResultStatus = -1; result.Message = "该数据不存在,不能撤返"; return result; } if (pledge.Status != StatusEnum.待审核 && pledge.Status != StatusEnum.已生效) { result.ResultStatus = -1; result.Message = "非待审核或已生效状态的数据不允许撤返"; return result; } //获取质押申请实体 DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); result = pledgeApplyDAL.Get(user, pledge.PledgeApplyId); if (result.ResultStatus != 0) return result; Model.PledgeApply pledgeApply = result.ReturnValue as Model.PledgeApply; //获取申请实体 NFMT.Operate.DAL.ApplyDAL applyDAl = new Operate.DAL.ApplyDAL(); result = applyDAl.Get(user, pledgeApply.ApplyId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply; if (apply.Status == Common.StatusEnum.已关闭 || apply.Status == Common.StatusEnum.已完成) { result.ResultStatus = -1; result.Message = "质押对应的申请已完成或已关闭,不能进行撤返操作"; return result; } result = pledgeDAL.Goback(user, pledge); if (result.ResultStatus != 0) return result; if (pledge.Status == StatusEnum.待审核) { //同步工作流状态 NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBLL = new WorkFlow.BLL.DataSourceBLL(); result = dataSourceBLL.SynchronousStatus(user, pledge); if (result.ResultStatus != 0) return result; } NFMT.WareHouse.DAL.PledgeDetialDAL pledgeDetialDAL = new DAL.PledgeDetialDAL(); result = pledgeDetialDAL.GetStockId(user, pledgeId); if (result.ResultStatus != 0) return result; if (!string.IsNullOrEmpty(result.ReturnValue.ToString())) { NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL(); NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new StockNameDAL(); NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL(); NFMT.WareHouse.Model.StockName stockName = new StockName(); NFMT.WareHouse.Model.Stock stock = new Stock(); NFMT.WareHouse.Model.StockLog stockLog = new StockLog(); foreach (string s in result.ReturnValue.ToString().Split(',')) { result = stockDAL.Get(user, Convert.ToInt32(s)); if (result.ResultStatus != 0) return result; stock = result.ReturnValue as Model.Stock; result = stockNameDAL.Get(user, stock.StockNameId); if (result.ResultStatus != 0) return result; stockName = result.ReturnValue as Model.StockName; ////创建stockLog对象 //stockLog = new StockLog() //{ // StockId = stock.StockId, // StockNameId = stock.StockNameId, // RefNo = stockName.RefNo, // //LogDirection = // LogType = LogEnum.质押冲销, // //ContractId = , // //SubContractId = , // LogDate = DateTime.Now, // OpPerson = user.EmpId, // Bundles = stock.Bundles, // GrossAmount = stock.GrossAmount, // NetAmount = stock.NetAmount, // MUId = stock.UintId, // BrandId = stock.BrandId, // DeliverPlaceId = stock.DeliverPlaceId, // PaperNo = stock.PaperNo, // PaperHolder = stock.PaperHolder, // CardNo = stock.CardNo, // Memo = stock.Memo, // LogStatus = StatusEnum.已生效, // LogSourceBase = "NFMT", // LogSource = "dbo.St_Pledge", // SourceId = pledgeId //}; //result = stockLogDAL.Insert(user, stockLog); //if (result.ResultStatus != 0) // return result; result = stockDAL.UpdateStockStatusToPrevious(user, stock); 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 Complete(UserModel user, int pledgeId) { ResultModel result = new ResultModel(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //验证质押 result = pledgeDAL.Get(user, pledgeId); if (result.ResultStatus != 0) return result; Pledge pledge = result.ReturnValue as Pledge; if (pledge == null || pledge.PledgeId <= 0) { result.ResultStatus = -1; result.Message = "该数据不存在,不能进行执行完成操作"; return result; } //执行完成 result = pledgeDAL.Complete(user, pledge); if (result.ResultStatus != 0) return result; //加载明细 PledgeDetialDAL pledgeDetialDAL = new PledgeDetialDAL(); result = pledgeDetialDAL.Load(user, pledge.PledgeId); if (result.ResultStatus != 0) return result; List<Model.PledgeDetial> details = result.ReturnValue as List<Model.PledgeDetial>; if (details == null || !details.Any()) { result.ResultStatus = -1; result.Message = "获取质押明细失败"; return result; } //加载对应质押申请 PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL(); result = pledgeApplyDAL.Get(user, pledge.PledgeApplyId); if (result.ResultStatus != 0) return result; PledgeApply pledgeApply = result.ReturnValue as PledgeApply; if (pledgeApply == null || pledgeApply.PledgeApplyId <= 0) { result.ResultStatus = -1; result.Message = "对应质押申请加载失败"; return result; } //明细执行完成 //更新库存状态至质押库存 StockDAL stockDAL = new StockDAL(); StockLogDAL stockLogDAL = new StockLogDAL(); StockNameDAL stockNameDAL = new StockNameDAL(); foreach (Model.PledgeDetial detail in details) { //明细完成 result = pledgeDetialDAL.Complete(user, detail); if (result.ResultStatus != 0) return result; //获取质押流水 result = stockLogDAL.Get(user, detail.StockLogId); if (result.ResultStatus != 0) return result; Model.StockLog stockLog = result.ReturnValue as Model.StockLog; if (stockLog == null || stockLog.StockLogId <= 0) { result.ResultStatus = -1; result.Message = "质押流水获取失败"; return result; } //完成质押流水 result = stockLogDAL.Complete(user, stockLog); if (result.ResultStatus != 0) return result; //获取库存 result = stockDAL.Get(user, detail.StockId); if (result.ResultStatus != 0) return result; Model.Stock stock = result.ReturnValue as Model.Stock; if (stock == null || stock.StockId <= 0) { result.ResultStatus = -1; result.Message = "库存获取失败"; return result; } result = stockDAL.UpdateStockStatusDirect(stock, StockStatusEnum.质押库存); 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; }