Beispiel #1
0
        public ResultModel Complete(UserModel user, int pledgeApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Get(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    Model.PledgeApply pledgeApply = result.ReturnValue as PledgeApply;

                    if (pledgeApply == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能完成";
                        return result;
                    }

                    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.ApplyStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "非已生效状态的数据不允许完成";
                        return result;
                    }

                    DAL.PledgeDAL pledgeDAL = new PledgeDAL();
                    result = pledgeDAL.GetPledgeIdByApplyId(user, pledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(result.ReturnValue.ToString()))
                    {
                        Model.Pledge pledge = new Pledge();
                        foreach (string s in result.ReturnValue.ToString().Split(','))
                        {
                            result = pledgeDAL.Get(user, Convert.ToInt32(s));
                            if (result.ResultStatus != 0)
                                return result;
                            pledge = result.ReturnValue as Model.Pledge;

                            if (pledge.Status != StatusEnum.已完成)
                            {
                                result.ResultStatus = -1;
                                result.Message = "该质押申请对应的质押并未全部完成";
                                return result;
                            }
                        }
                    }

                    result = applyDAL.Confirm(user, apply);

                    if (result.ResultStatus == 0)
                        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;
        }
Beispiel #2
0
        public ResultModel Invalid(UserModel user, int pricingApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取点价申请
                    result = pricingApplyDAL.Get(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApply pricingApply = result.ReturnValue as NFMT.DoPrice.Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价申请验证失败";
                        return result;
                    }

                    //获取申请
                    result = applyDAL.Get(user, pricingApply.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 = pricingApplyDetailDAL.InvalidAll(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

            return result;
        }
Beispiel #3
0
        public ResultModel Update(UserModel user, NFMT.Operate.Model.Apply apply, NFMT.DoPrice.Model.PricingApply pricingApply, List<NFMT.DoPrice.Model.PricingApplyDetail> pricingApplyDetails)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
            DAL.PricingApplyDetailDAL pricingApplyDetailDAL = new PricingApplyDetailDAL();
            NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
            NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = applyDAL.Get(user, apply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    NFMT.Operate.Model.Apply getApply = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (getApply == null || getApply.ApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取申请错误";
                        return result;
                    }

                    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;
                    }

                    getApply.EmpId = user.EmpId;
                    getApply.ApplyTime = DateTime.Now;
                    getApply.ApplyDept = apply.ApplyDept;
                    getApply.ApplyCorp = apply.ApplyCorp;
                    getApply.ApplyDesc = apply.ApplyDesc;
                    result = applyDAL.Update(user, getApply);
                    if (result.ResultStatus != 0)
                        return result;

                    result = pricingApplyDAL.Get(user, pricingApply.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApply getPricingApply = result.ReturnValue as NFMT.DoPrice.Model.PricingApply;
                    if (getPricingApply == null || getPricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取点价申请错误";
                        return result;
                    }

                    getPricingApply.StartTime = pricingApply.StartTime;
                    getPricingApply.EndTime = pricingApply.EndTime;
                    getPricingApply.MinPrice = pricingApply.MinPrice;
                    getPricingApply.MaxPrice = pricingApply.MaxPrice;
                    getPricingApply.CurrencyId = pricingApply.CurrencyId;
                    getPricingApply.PricingCorpId = pricingApply.PricingCorpId;
                    getPricingApply.PricingWeight = pricingApply.PricingWeight;
                    getPricingApply.MUId = pricingApply.MUId;
                    getPricingApply.AssertId = pricingApply.AssertId;
                    getPricingApply.PricingPersoinId = pricingApply.PricingPersoinId;

                    //验证子合约
                    result = subDAL.Get(user, pricingApply.SubContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                    if (sub == null || sub.SubId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约不存在";
                        return result;
                    }

                    if (sub.SubStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约状态非已生效,不能进行点价申请";
                        return result;
                    }

                    //获取合约
                    result = contractDAL.Get(user, sub.ContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                    if (contract == null || contract.ContractId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "关联合约不存在";
                        return result;
                    }

                    if (contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.Buy)
                        getPricingApply.PricingDirection = (int)NFMT.DoPrice.PricingDirection.空头;
                    else
                        getPricingApply.PricingDirection = (int)NFMT.DoPrice.PricingDirection.多头;

                    result = pricingApplyDAL.Update(user, getPricingApply);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废明细
                    result = pricingApplyDetailDAL.InvalidAll(user, getPricingApply.PricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    //写入明细
                    foreach (Model.PricingApplyDetail detail in pricingApplyDetails)
                    {
                        detail.PricingApplyId = getPricingApply.PricingApplyId;
                        detail.DetailStatus = StatusEnum.已生效;

                        result = pricingApplyDetailDAL.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 Confirm(UserModel user, int customApplyId)
        {
            ResultModel result = new ResultModel();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证报关申请
                    result = customsclearanceapplyDAL.Get(user, customApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearanceApply customsClearanceApply = result.ReturnValue as Model.CustomsClearanceApply;
                    if (customsClearanceApply == null || customsClearanceApply.CustomsApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, customsClearanceApply.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 = customsclearanceapplyDAL.CheckCustomCanConfirm(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    //获取已生效报关申请明细
                    result = customsApplyDetailDAL.Load(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

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

            return result;
        }
Beispiel #5
0
        public ResultModel Goback(UserModel user, int pricingApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.PricingApplyDAL pricingApplyDAL = new PricingApplyDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取点价申请
                    result = pricingApplyDAL.Get(user, pricingApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.DoPrice.Model.PricingApply pricingApply = result.ReturnValue as NFMT.DoPrice.Model.PricingApply;
                    if (pricingApply == null || pricingApply.PricingApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "点价申请验证失败";
                        return result;
                    }

                    //获取申请
                    result = applyDAL.Get(user, pricingApply.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.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;
        }
Beispiel #6
0
        public ResultModel Invalid(UserModel user, int repoApplyId)
        {
            ResultModel result = new ResultModel();

            DAL.StockDAL stockDAL = new StockDAL();
            DAL.RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.RepoApplyDetailDAL detailDAL = new RepoApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库申请
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.RepoApply repoApply = result.ReturnValue as Model.RepoApply;
                    if (repoApply == null || repoApply.RepoApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "回购申请不存在";
                        return result;
                    }

                    //获取主申请实体
                    result = applyDAL.Get(user, repoApply.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 = detailDAL.Load(user, repoApply.RepoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    //作废主申请
                    result = applyDAL.Invalid(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废申请明细
                    foreach (Model.RepoApplyDetail detail in details)
                    {
                        if (detail.DetailStatus == StatusEnum.已生效)
                            detail.DetailStatus = StatusEnum.已录入;
                        result = detailDAL.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;
        }
Beispiel #7
0
        public ResultModel RepoApplyUpdateHandle(UserModel user, NFMT.Operate.Model.Apply apply, int repoApplyId, List<Model.RepoApplyDetail> details)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Get(user, apply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply applyRes = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (applyRes == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取申请失败";
                        return result;
                    }

                    applyRes.ApplyTime = apply.ApplyTime;
                    applyRes.EmpId = apply.EmpId;
                    applyRes.ApplyDept = apply.ApplyDept;
                    applyRes.ApplyCorp = apply.ApplyCorp;
                    applyRes.ApplyDesc = apply.ApplyDesc;

                    result = applyDAL.Update(user, applyRes);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.DAL.RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    result = repoApplyDetailDAL.InvalidAll(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.RepoApplyDetail detail in details)
                    {
                        result = repoApplyDetailDAL.Insert(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;
        }
Beispiel #8
0
        public ResultModel UpdateStockOutApply(UserModel user, int stockOutApplyId, List<Model.StockOutApplyDetail> details, int deptId, string memo, int corpId, int buyCorpId)
        {
            ResultModel result = new ResultModel();

            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
            NFMT.WareHouse.DAL.StockOutApplyDAL outApplyDAL = new DAL.StockOutApplyDAL();
            NFMT.WareHouse.DAL.StockOutApplyDetailDAL detailDAL = new DAL.StockOutApplyDetailDAL();
            NFMT.WareHouse.DAL.StockExclusiveDAL exclusiveDAL = new DAL.StockExclusiveDAL();
            NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL();
            NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证分配库存
                    if (details == null || details.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "未分配任务库存";
                        return result;
                    }

                    //验证出库申请
                    result = outApplyDAL.Get(user, stockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    NFMT.WareHouse.Model.StockOutApply stockOutApply = result.ReturnValue as NFMT.WareHouse.Model.StockOutApply;
                    if (stockOutApply == null || stockOutApply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请不存在";
                        return result;
                    }

                    //验证子合约
                    result = subDAL.Get(user, stockOutApply.SubContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                    if (sub == null || sub.SubId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约不存在";
                        return result;
                    }

                    //验证合约
                    result = contractDAL.Get(user, sub.ContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                    if (contract == null || contract.ContractId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "合约不存在";
                        return result;
                    }

                    //获取部门信息
                    NFMT.User.Model.Department dept = User.UserProvider.Departments.Single(temp => temp.DeptId == deptId);
                    if (dept == null || dept.DeptId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "部门不存在";
                        return result;
                    }

                    //更新主申请表
                    result = applyDAL.Get(user, stockOutApply.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;
                    }

                    apply.ApplyDept = dept.DeptId;
                    apply.ApplyCorp = corpId;
                    apply.ApplyDesc = memo;
                    apply.ApplyId = stockOutApply.ApplyId;
                    apply.EmpId = user.EmpId;
                    result = applyDAL.Update(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //更新出库申请表
                    decimal sumGrossAmount = details.Sum(temp => temp.GrossAmount);
                    decimal sumNetAmount = details.Sum(temp => temp.NetAmount);
                    int sumBundles = details.Sum(temp => temp.Bundles);

                    stockOutApply.GrossAmount = sumGrossAmount;
                    stockOutApply.NetAmount = sumNetAmount;
                    stockOutApply.Bundles = sumBundles;
                    stockOutApply.Status = StatusEnum.已录入;
                    stockOutApply.BuyCorpId = buyCorpId;
                    result = this.stockoutapplyDAL.Update(user, stockOutApply);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废出库申请明细表
                    result = detailDAL.Load(user, stockOutApply.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    List<NFMT.WareHouse.Model.StockOutApplyDetail> resultDetails = result.ReturnValue as List<NFMT.WareHouse.Model.StockOutApplyDetail>;
                    if (resultDetails == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请明细获取失败";
                        return result;
                    }
                    foreach (NFMT.WareHouse.Model.StockOutApplyDetail d in resultDetails)
                    {
                        d.DetailStatus = StatusEnum.已录入;
                        result = detailDAL.Invalid(user, d);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //作废排他表
                    result = exclusiveDAL.Load(user, stockOutApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    List<NFMT.WareHouse.Model.StockExclusive> exculsives = result.ReturnValue as List<NFMT.WareHouse.Model.StockExclusive>;
                    if (exculsives == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "排他表获取失败";
                        return result;
                    }
                    foreach (NFMT.WareHouse.Model.StockExclusive e in exculsives)
                    {
                        e.ExclusiveStatus = StatusEnum.已录入;
                        result = exclusiveDAL.Invalid(user, e);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //新增出库申请明细表
                    foreach (Model.StockOutApplyDetail detail in details)
                    {
                        //验证库存
                        result = stockDAL.Get(user, detail.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        NFMT.WareHouse.Model.Stock stock = result.ReturnValue as NFMT.WareHouse.Model.Stock;
                        if (stock == null || stock.StockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存不存在";
                            return result;
                        }

                        //判断库存品种是否与合约品种相同
                        if (stock.AssetId != contract.AssetId)
                        {
                            result.ResultStatus = -1;
                            result.Message = "分配库存的品种与合约品种不一致";
                            return result;
                        }

                        //不允许配货库存
                        int planStockInStatus = (int)NFMT.WareHouse.StockStatusEnum.预入库存;
                        int planCustomsStatus = (int)NFMT.WareHouse.StockStatusEnum.预报关库存;
                        int stockStatus = (int)stock.StockStatus;
                        if (stockStatus > planCustomsStatus || stockStatus < planStockInStatus)
                        {
                            result.ResultStatus = -1;
                            result.Message = "访笔库存不能进行出库申请分配";
                            return result;
                        }

                        detail.ContractId = sub.ContractId;
                        detail.DetailStatus = StatusEnum.已生效;
                        detail.SubContractId = sub.SubId;
                        detail.StockOutApplyId = stockOutApply.StockOutApplyId;

                        if (contract.TradeBorder == (int)NFMT.Contract.TradeBorderEnum.ForeignTrade)
                            detail.GrossAmount = stock.GrossAmount;
                        else
                            detail.GrossAmount = detail.NetAmount;

                        result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;

                        int detailApplyId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out detailApplyId) || detailApplyId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存明细添加失败";
                            return result;
                        }

                        //排他表校验
                        result = exclusiveDAL.LoadByStockId(user, stock.StockId);
                        if (result.ResultStatus != 0)
                            return result;

                        List<Model.StockExclusive> excs = result.ReturnValue as List<Model.StockExclusive>;
                        if (excs == null)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取排他库存信息失败";
                            return result;
                        }

                        decimal excAmount = excs.Sum(temp => temp.ExclusiveAmount);
                        if (excAmount >= stock.CurNetAmount)
                        {
                            result.ResultStatus = -1;
                            result.Message = "该笔库存剩余净重不足,配货失败";
                            return result;
                        }

                        //排他表新增
                        NFMT.WareHouse.Model.StockExclusive exculsive = new StockExclusive();
                        exculsive.ApplyId = apply.ApplyId;
                        exculsive.DetailApplyId = detailApplyId;
                        exculsive.ExclusiveStatus = StatusEnum.已生效;
                        exculsive.StockApplyId = stockOutApply.StockOutApplyId;
                        exculsive.StockId = stock.StockId;
                        exculsive.ExclusiveAmount = detail.NetAmount;

                        result = exclusiveDAL.Insert(user, exculsive);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //验证出库申请与子合约签订数量
                    if (sumNetAmount > sub.SignAmount)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请数量不能大于子合约签订数量";
                        return result;
                    }

                    //获取当前子合约下所有出库申请明细
                    result = detailDAL.LoadBySubId(user, sub.SubId, NFMT.Common.StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.StockOutApplyDetail> ds = result.ReturnValue as List<Model.StockOutApplyDetail>;
                    sumNetAmount = ds.Sum(temp => temp.NetAmount);

                    if (sumNetAmount > sub.SignAmount)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请数量不能大于子合约可分配数量";
                        return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                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;
        }
Beispiel #9
0
        public ResultModel GoBack(UserModel user, int stopLossId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = stoplossDAL.Get(user, stopLossId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StopLoss stopLoss = result.ReturnValue as StopLoss;
                    if (stopLoss == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能撤返";
                        return result;
                    }

                    //获取止损申请实体
                    DAL.StopLossApplyDAL stopLossApplyDAL = new StopLossApplyDAL();
                    result = stopLossApplyDAL.Get(user, stopLoss.StopLossApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StopLossApply stopLossApply = result.ReturnValue as Model.StopLossApply;

                    //获取申请实体
                    NFMT.Operate.DAL.ApplyDAL applyDAl = new Operate.DAL.ApplyDAL();
                    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.Status != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "止损对应的申请非已生效,不能进行撤返操作";
                        return result;
                    }

                    result = stoplossDAL.Goback(user, stopLoss);
                    if (result.ResultStatus != 0)
                        return result;

                    //同步工作流状态
                    NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBLL = new WorkFlow.BLL.DataSourceBLL();
                    result = dataSourceBLL.SynchronousStatus(user, stopLoss);
                    if (result.ResultStatus != 0)
                        return result;

                    if (result.ResultStatus == 0)
                        result.Message = "撤返成功";
                    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;
        }
Beispiel #10
0
        /// <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;
        }
Beispiel #11
0
        public ResultModel Invalid(UserModel user, int stockOutApplyId)
        {
            ResultModel result = new ResultModel();

            DAL.StockDAL stockDAL = new StockDAL();
            DAL.StockExclusiveDAL exclusiveDAL = new StockExclusiveDAL();
            DAL.StockOutApplyDAL outApplyDAL = new StockOutApplyDAL();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.StockOutApplyDetailDAL detailDAL = new StockOutApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库申请
                    result = outApplyDAL.Get(user, stockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockOutApply outApply = result.ReturnValue as Model.StockOutApply;
                    if (outApply == null || outApply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请不存在";
                        return result;
                    }

                    //获取主申请实体
                    result = applyDAL.Get(user, outApply.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 = detailDAL.Load(user, outApply.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    //获取排他表数据
                    result = exclusiveDAL.Load(user, outApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<StockExclusive> exclusives = result.ReturnValue as List<StockExclusive>;
                    if (exclusives == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "排他明细获取失败";
                        return result;
                    }

                    //作废主申请
                    result = applyDAL.Invalid(user, apply);
                    if (result.ResultStatus != 0)
                        return result;
                    //作废申请明细
                    foreach (Model.StockOutApplyDetail detail in details)
                    {
                        detail.DetailStatus = StatusEnum.已录入;
                        result = detailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }
                    //作废排他表
                    foreach (Model.StockExclusive exclusive in exclusives)
                    {
                        exclusive.ExclusiveStatus = StatusEnum.已录入;
                        result = exclusiveDAL.Invalid(user, exclusive);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
Beispiel #12
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;
        }
Beispiel #13
0
        public ResultModel Goback(UserModel user, int invoiceApplyId)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = invoiceapplyDAL.Get(user, invoiceApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.InvoiceApply invoiceApply = result.ReturnValue as Model.InvoiceApply;
                    if (invoiceApply == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取发票申请失败";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, invoiceApply.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.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (this.Log.IsInfoEnabled)
                    this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Beispiel #14
0
        public ResultModel Confirm(UserModel user, int invoiceApplyId)
        {
            ResultModel result = new ResultModel();
            Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.InvoiceApplyDetailDAL invoiceApplyDetailDAL = new InvoiceApplyDetailDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证报关申请
                    result = invoiceapplyDAL.Get(user, invoiceApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.InvoiceApply invoiceApply = result.ReturnValue as Model.InvoiceApply;
                    if (invoiceApply == null || invoiceApply.InvoiceApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, invoiceApply.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;
                    }

                    //验证是否执行完成 TODO

                    result = invoiceApplyDetailDAL.Load(user, invoiceApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    result = applyDAL.Confirm(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.InvoiceApplyDetail detail in details)
                    {
                        result = invoiceApplyDetailDAL.Confirm(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
Beispiel #15
0
        public ResultModel ConfirmCancel(UserModel user, int repoApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                DAL.RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证回购申请
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.RepoApply repoApply = result.ReturnValue as Model.RepoApply;
                    if (repoApply == null || repoApply.RepoApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "回购申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, repoApply.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 = repoApplyDetailDAL.Load(user, repoApply.RepoApplyId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;

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

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

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

            return result;
        }
Beispiel #16
0
        public ResultModel CompleteCancel(UserModel user, int stockOutId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                DAL.StockDAL stockDAL = new StockDAL();
                DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                DAL.StockOutDAL stockOutDAL = new StockOutDAL();
                DAL.StockOutDetailDAL stockOutDetailDAL = new StockOutDetailDAL();
                DAL.StockOutApplyDAL outApplyDAL = new StockOutApplyDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证出库
                    result = stockoutDAL.Get(user, stockOutId);
                    if (result.ResultStatus != 0)
                        return result;
                    StockOut stockOut = result.ReturnValue as StockOut;
                    if (stockOut == null || stockOut.StockOutId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "该数据不存在,不能进行执行完成操作";
                        return result;
                    }

                    //撤销出库
                    result = this.stockoutDAL.CompleteCancel(user, stockOut);
                    if (result.ResultStatus != 0)
                        return result;

                    //验证出库申请
                    result = outApplyDAL.Get(user, stockOut.StockOutApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockOutApply outApply = result.ReturnValue as Model.StockOutApply;
                    if (outApply == null || outApply.StockOutApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "出库申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, outApply.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;
                    }

                    //判断主申请状态是否为已生效,
                    if (apply.ApplyStatus != StatusEnum.已生效)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请状态只有在已生效下才能进行执行完成撤销";
                        return result;
                    }

                    //获取已完成出库明细
                    result = stockOutDetailDAL.Load(user, stockOut.StockOutId, Common.StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;
                    List<Model.StockOutDetail> details = result.ReturnValue as List<Model.StockOutDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取出库明细错误";
                        return result;
                    }

                    //将所有已完成出库明细更新至已生效
                    foreach (Model.StockOutDetail detail in details)
                    {
                        result = stockOutDetailDAL.CompleteCancel(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.CompleteCancel(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        //获取库存
                        result = stockDAL.Get(user,stockLog.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;
                        }

                        //库存重量添加
                        stock.CurGrossAmount += detail.GrossAmount;
                        stock.CurNetAmount += detail.NetAmount;
                        stock.Bundles += detail.Bundles;

                        //明细关联库存状态更新至前一状态
                        if (stock.StockStatus == StockStatusEnum.已售库存)
                            stock.StockStatus = StockStatusEnum.预售库存;

                        result = stockDAL.Update(user, stock);
                        if (result.ResultStatus != 0)
                            return result;

                    }

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

            return result;
        }
Beispiel #17
0
        public ResultModel Goback(UserModel user, int repoApplyId)
        {
            ResultModel result = new ResultModel();
            try
            {
                DAL.RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证回购申请
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.RepoApply repoApply = result.ReturnValue as Model.RepoApply;
                    if (repoApply == null || repoApply.RepoApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "回购申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, repoApply.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;
        }
Beispiel #18
0
        public ResultModel GoBack(UserModel user, int stockMoveApplyId)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = stockmoveapplyDAL.Get(user, stockMoveApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockMoveApply stockMoveApply = result.ReturnValue as Model.StockMoveApply;
                    if (stockMoveApply == null || stockMoveApply.StockMoveApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "数据不存在,无法撤返";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, stockMoveApply.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 e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
Beispiel #19
0
        public ResultModel Confirm(UserModel user, int repoApplyId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockDAL stockDAL = new StockDAL();
                DAL.RepoApplyDAL repoApplyDAL = new RepoApplyDAL();
                Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                DAL.RepoApplyDetailDAL detailDAL = new RepoApplyDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证回购申请
                    result = repoApplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.RepoApply repoApply = result.ReturnValue as Model.RepoApply;
                    if (repoApply == null || repoApply.RepoApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "回购申请不存在";
                        return result;
                    }

                    //验证主申请
                    result = applyDAL.Get(user, repoApply.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 = repoapplyDAL.CheckStockOutCanConfirm(user, repoApply.RepoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    //获取已生效回购申请明细
                    result = detailDAL.Load(user, repoApply.RepoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

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

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

            return result;
        }
Beispiel #20
0
        public ResultModel Complete(UserModel user, StockMoveApply stockMoveApply)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.Get(user, stockMoveApply.StockMoveApplyId);
                    stockMoveApply = result.ReturnValue as StockMoveApply;

                    if (stockMoveApply == null)
                    {
                        result.Message = "该数据不存在,不能完成";
                        return result;
                    }

                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Get(user, stockMoveApply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply apply = result.ReturnValue as NFMT.Operate.Model.Apply;

                    if (apply.ApplyStatus != StatusEnum.已生效)
                    {
                        result.Message = "非已生效状态的数据不允许完成";
                        return result;
                    }

                    DAL.StockMoveDAL stockMoveDAL = new StockMoveDAL();
                    result = stockMoveDAL.GetStockMoveIdByApplyId(user, stockMoveApply.StockMoveApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    int stockMoveId = (int)result.ReturnValue;
                    result = stockMoveDAL.Get(user, stockMoveId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockMove stockMove = result.ReturnValue as StockMove;
                    if (stockMove.Status != StatusEnum.已完成)
                    {
                        result.Message = "该申请对应的移库操作未完成,不能申请完成";
                        result.ResultStatus = -1;
                        return result;
                    }

                    result = applyDAL.Confirm(user, apply);
                    //result = stockmoveapplyDAL.Complete(user, stockMoveApply);

                    if (result.ResultStatus == 0)
                        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;
        }
Beispiel #21
0
        public ResultModel Update(UserModel user, int repoApplyId, List<int> stockIds, string memo, int deptId)
        {
            ResultModel result = new ResultModel();

            //获取质押申请
            try
            {
                DAL.StockDAL stockDAL = new StockDAL();
                DAL.RepoApplyDetailDAL detailDAL = new RepoApplyDetailDAL();
                NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证质押申请
                    result = repoapplyDAL.Get(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.RepoApply repoApply = result.ReturnValue as Model.RepoApply;
                    if (repoApply == null || repoApply.RepoApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "质押申请获取失败";
                        return result;
                    }

                    //获取主申请
                    result = applyDAL.Get(user, repoApply.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;
                    }

                    //更新主申请
                    NFMT.User.Model.Department dept = NFMT.User.UserProvider.Departments.FirstOrDefault(temp => temp.DeptId == deptId);
                    if (dept == null || dept.DeptId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "申请部门不存在";
                        return result;
                    }

                    apply.ApplyDesc = memo;
                    apply.ApplyDept = dept.DeptId;
                    //apply.ApplyDeptName = dept.DeptName;
                    result = applyDAL.Update(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    //获了质押申请明细
                    result = detailDAL.Load(user, repoApply.RepoApplyId);
                    if (result.ResultStatus != 0)
                        return result;
                    List<Model.RepoApplyDetail> details = result.ReturnValue as List<Model.RepoApplyDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "明细获取失败";
                        return result;
                    }

                    //作废明细
                    foreach (Model.RepoApplyDetail detail in details)
                    {
                        if (detail.DetailStatus == StatusEnum.已生效)
                            detail.DetailStatus = StatusEnum.已录入;
                        result = detailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //获取库存
                    foreach (int stockId in stockIds)
                    {
                        result = stockDAL.Get(user, 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;
                        }

                        if (stock.StockStatus != StockStatusEnum.质押库存)
                        {
                            result.ResultStatus = -1;
                            result.Message = "库存非质押状态,不能进行回购操作";
                            return result;
                        }

                        //添加明细
                        Model.RepoApplyDetail detail = new RepoApplyDetail();
                        detail.DetailStatus = StatusEnum.已生效;
                        detail.RepoApplyId = repoApply.RepoApplyId;
                        detail.StockId = stock.StockId;
                        result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
        public ResultModel Update(UserModel user, NFMT.Operate.Model.Apply apply, Model.CustomsClearanceApply customsClearanceApply, List<Model.CustomsApplyDetail> details)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
            DAL.CustomsApplyDetailDAL customsApplyDetailDAL = new CustomsApplyDetailDAL();

            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;
                    if (applyResult == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取数据失败";
                        return result;
                    }

                    applyResult.ApplyType = apply.ApplyType;
                    applyResult.EmpId = user.EmpId;
                    applyResult.ApplyTime = DateTime.Now;
                    applyResult.ApplyDept = apply.ApplyDept;
                    applyResult.ApplyDesc = apply.ApplyDesc;

                    result = applyDAL.Update(user, applyResult);
                    if (result.ResultStatus != 0)
                        return result;

                    result = customsclearanceapplyDAL.Get(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.Model.CustomsClearanceApply customsClearanceApplyResult = result.ReturnValue as NFMT.WareHouse.Model.CustomsClearanceApply;
                    if (customsClearanceApplyResult == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取数据失败";
                        return result;
                    }

                    customsClearanceApplyResult.ApplyId = customsClearanceApply.ApplyId;
                    customsClearanceApplyResult.AssetId = customsClearanceApply.AssetId;
                    customsClearanceApplyResult.GrossWeight = customsClearanceApply.GrossWeight;
                    customsClearanceApplyResult.NetWeight = customsClearanceApply.NetWeight;
                    customsClearanceApplyResult.UnitId = customsClearanceApply.UnitId;
                    customsClearanceApplyResult.OutCorpId = customsClearanceApply.OutCorpId;
                    customsClearanceApplyResult.InCorpId = customsClearanceApply.InCorpId;
                    customsClearanceApplyResult.CustomsCorpId = customsClearanceApply.CustomsCorpId;
                    customsClearanceApplyResult.CustomsPrice = customsClearanceApply.CustomsPrice;
                    customsClearanceApplyResult.CurrencyId = customsClearanceApply.CurrencyId;

                    customsClearanceApplyResult.Status = Common.StatusEnum.已录入;
                    result = customsclearanceapplyDAL.Update(user, customsClearanceApplyResult);
                    if (result.ResultStatus != 0)
                        return result;

                    result = customsApplyDetailDAL.Load(user, customsClearanceApply.CustomsApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CustomsApplyDetail> customsApplyDetails = result.ReturnValue as List<Model.CustomsApplyDetail>;
                    if (customsApplyDetails == null || !customsApplyDetails.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取数据失败";
                        return result;
                    }

                    foreach (Model.CustomsApplyDetail detail in customsApplyDetails)
                    {
                        if (detail.DetailStatus == Common.StatusEnum.已生效)
                            detail.DetailStatus = Common.StatusEnum.已录入;
                        result = customsApplyDetailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (details != null && details.Any())
                    {
                        foreach (Model.CustomsApplyDetail detail in details)
                        {
                            detail.CustomsApplyId = customsClearanceApply.CustomsApplyId;
                            result = customsApplyDetailDAL.Insert(user, detail);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }
                    if (result.ResultStatus == 0)
                        result.ReturnValue = customsClearanceApply.CustomsApplyId;
                    scope.Complete();
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }