예제 #1
0
        public ResultModel Confirm(UserModel user, int stopLossApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                DAL.StopLossApplyDetailDAL stopLossApplyDetailDAL = new StopLossApplyDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证止损申请
                    result = stoplossapplyDAL.Get(user, stopLossApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StopLossApply stopLossApply = result.ReturnValue as 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;

                    Operate.Model.Apply apply = result.ReturnValue as Operate.Model.Apply;
                    if (apply == null || apply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "主申请不存在";
                        return result;
                    }

                    //验证是否执行完成
                    result = stoplossapplyDAL.CheckStopLossCanConfirm(user, stopLossApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Common.StatusEnum status = (Common.StatusEnum)result.ReturnValue;

                    //获取已生效止损申请明细
                    result = stopLossApplyDetailDAL.Load(user, stopLossApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.StopLossApplyDetail> details = result.ReturnValue as List<Model.StopLossApplyDetail>;
                    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.StopLossApplyDetail detail in details)
                    {
                        //止损申请明细更新状态至已完成
                        result = stopLossApplyDetailDAL.Confirm(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
예제 #2
0
        /// <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;
        }
예제 #3
0
        /// <summary>
        /// 新增止损申请
        /// </summary>
        /// <param name="user"></param>
        /// <param name="apply"></param>
        /// <param name="stopLossApply"></param>
        /// <param name="details"></param>
        /// <returns></returns>
        public ResultModel Create(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))
                {
                    NFMT.User.Model.Department dept = NFMT.User.UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == apply.ApplyDept);
                    if (dept == null || dept.DeptId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请部门不存在";
                        return result;
                    }

                    //新增主申请
                    apply.EmpId = user.EmpId;
                    apply.ApplyTime = DateTime.Now;
                    apply.ApplyType = NFMT.Operate.ApplyType.StopLossApply;
                    apply.ApplyDept = dept.DeptId;
                    //apply.ApplyDeptName = dept.DeptName;
                    result = applyDAL.Insert(user, apply);
                    if (result.ResultStatus != 0)
                        return result;
                    int applyId = (int)result.ReturnValue;

                    //新增止损申请
                    stopLossApply.ApplyId = applyId;

                    result = stoplossapplyDAL.Insert(user, stopLossApply);
                    if (result.ResultStatus != 0)
                        return result;

                    int stopLossApplyId = (int)result.ReturnValue;

                    if (details.Any())
                    {
                        foreach (Model.StopLossApplyDetail detail in details)
                        {
                            detail.StopLossApplyId = stopLossApplyId;
                            detail.ApplyId = 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;
        }
예제 #4
0
        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;
        }
예제 #5
0
        public ResultModel ConfirmCancel(UserModel user, int stopLossApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StopLossApplyDetailDAL stopLossApplyDetailDAL = new StopLossApplyDetailDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证止损申请
                    result = stoplossapplyDAL.Get(user, stopLossApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StopLossApply stopLossApply = result.ReturnValue as 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;

                    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 = stopLossApplyDetailDAL.Load(user, stopLossApply.StopLossApplyId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.StopLossApplyDetail> details = result.ReturnValue as List<Model.StopLossApplyDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取申请明细失败";
                        return result;
                    }

                    foreach (Model.StopLossApplyDetail detail in details)
                    {
                        result = stopLossApplyDetailDAL.ConfirmCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }