/// <summary> /// 修改止损申请 /// </summary> /// <param name="user"></param> /// <param name="apply"></param> /// <param name="stopLossApply"></param> /// <param name="details"></param> /// <returns></returns> public ResultModel Update(UserModel user, NFMT.Operate.Model.Apply apply, NFMT.DoPrice.Model.StopLossApply stopLossApply, List<NFMT.DoPrice.Model.StopLossApplyDetail> details) { ResultModel result = new ResultModel(); NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); DAL.StopLossApplyDetailDAL stopLossApplyDetailDAL = new StopLossApplyDetailDAL(); try { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { result = applyDAL.Get(user, apply.ApplyId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Apply applyResult = result.ReturnValue as NFMT.Operate.Model.Apply; applyResult.ApplyDept = apply.ApplyDept; applyResult.ApplyCorp = apply.ApplyCorp; applyResult.ApplyDesc = apply.ApplyDesc; result = applyDAL.Update(user, applyResult); if (result.ResultStatus != 0) return result; //修改止损申请 result = stoplossapplyDAL.Get(user, stopLossApply.StopLossApplyId); if (result.ResultStatus != 0) return result; NFMT.DoPrice.Model.StopLossApply stopLossApplyResult = result.ReturnValue as NFMT.DoPrice.Model.StopLossApply; stopLossApplyResult.StopLossPrice = stopLossApply.StopLossPrice; stopLossApplyResult.StopLossWeight = stopLossApply.StopLossWeight; stopLossApplyResult.Status = StatusEnum.已录入; result = stoplossapplyDAL.Update(user, stopLossApplyResult); if (result.ResultStatus != 0) return result; if (details.Any()) { result = stopLossApplyDetailDAL.InvalidAll(user, stopLossApply.StopLossApplyId); if (result.ResultStatus != 0) return result; foreach (Model.StopLossApplyDetail detail in details) { detail.StopLossApplyId = stopLossApply.StopLossApplyId; detail.ApplyId = apply.ApplyId; result = stopLossApplyDetailDAL.Insert(user, detail); if (result.ResultStatus != 0) return result; } } scope.Complete(); } } catch (Exception e) { result.ResultStatus = -1; result.Message = e.Message; } return result; }
public ResultModel Invalid(UserModel user, int stopLossApplyId) { ResultModel result = new ResultModel(); try { NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL(); DAL.StopLossApplyDetailDAL stopLossApplyDetailDAL = new StopLossApplyDetailDAL(); using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { //获取止损申请 result = stoplossapplyDAL.Get(user, stopLossApplyId); if (result.ResultStatus != 0) return result; NFMT.DoPrice.Model.StopLossApply stopLossApply = result.ReturnValue as NFMT.DoPrice.Model.StopLossApply; if (stopLossApply == null || stopLossApply.StopLossApplyId <= 0) { result.ResultStatus = -1; result.Message = "止损申请验证失败"; return result; } //获取申请 result = applyDAL.Get(user, stopLossApply.ApplyId); if (result.ResultStatus != 0) return result; NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply; if (apply == null || apply.ApplyId <= 0) { result.ResultStatus = -1; result.Message = "申请获取失败"; return result; } //作废申请 result = applyDAL.Invalid(user, apply); if (result.ResultStatus != 0) return result; //作废明细 result = stopLossApplyDetailDAL.InvalidAll(user, stopLossApplyId); if (result.ResultStatus != 0) return result; scope.Complete(); } } catch (Exception ex) { result.ResultStatus = -1; result.Message = ex.Message; } return result; }