Esempio n. 1
0
        public ResultModel Complete_NewVersion(UserModel user, int allotId)
        {
            ResultModel result = new ResultModel();
            DAL.CashInCorpDAL cashInCorpDAL = new CashInCorpDAL();
            DAL.CashInContractDAL cashInContractDAL = new CashInContractDAL();
            DAL.CashInStcokDAL cashInStcokDAL = new CashInStcokDAL();
            DAL.FundsLogDAL fundsLogDAL = new FundsLogDAL();
            DAL.CashInInvoiceDAL cashInInvoiceDAL = new CashInInvoiceDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取主收款分配
                    result = cashinallotDAL.Get(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CashInAllot cashInAllot = result.ReturnValue as Model.CashInAllot;
                    if (cashInAllot == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取收款分配失败";
                        return result;
                    }

                    //完成主收款分配
                    result = cashinallotDAL.Complete(user, cashInAllot);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取已生效的收款分配至公司
                    result = cashInCorpDAL.Load(user, cashInAllot.AllotId, NFMT.Common.StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CashInCorp> cashInCorps = result.ReturnValue as List<Model.CashInCorp>;
                    if (cashInCorps == null || !cashInCorps.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取收款分配至公司失败";
                        return result;
                    }

                    Model.CashInCorp cashInCorp = cashInCorps.FirstOrDefault(a => a.RefId > 0);

                    //完成收款分配至公司
                    result = cashInCorpDAL.Complete(user, cashInCorp);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取已生效的收款分配至合约
                    result = cashInContractDAL.LoadDetail(user, cashInAllot.AllotId, StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CashInContract> cashInContracts = result.ReturnValue as List<Model.CashInContract>;
                    if (cashInContracts == null || !cashInContracts.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取收款分配至合约失败";
                        return result;
                    }

                    Model.CashInContract cashInContract = cashInContracts.FirstOrDefault(a => a.RefId > 0);

                    //完成收款分配至合约
                    result = cashInContractDAL.Complete(user, cashInContract);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取已生效的收款分配至库存
                    result = cashInStcokDAL.LoadByAllot(user, cashInAllot.AllotId, StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CashInStcok> cashInStcoks = result.ReturnValue as List<Model.CashInStcok>;
                    if (cashInStcoks == null || !cashInStcoks.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取收款分配至库存失败";
                        return result;
                    }

                    foreach (Model.CashInStcok cashInStcok in cashInStcoks)
                    {
                        //完成收款分配至库存
                        result = cashInStcokDAL.Complete(user, cashInStcok);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //获取已生效的收款分配至发票
                    result = cashInInvoiceDAL.LoadByAllot(user, cashInAllot.AllotId, StatusEnum.已生效);
                    if (result.ResultStatus == 0)
                    {
                        List<Model.CashInInvoice> cashInInvoices = result.ReturnValue as List<Model.CashInInvoice>;
                        if (cashInInvoices == null || !cashInInvoices.Any())
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取收款分配至发票失败";
                            return result;
                        }

                        foreach (Model.CashInInvoice cashInInvoice in cashInInvoices)
                        {
                            //完成收款分配至发票
                            result = cashInInvoiceDAL.Complete(user, cashInInvoice);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    //获取资金流水
                    result = fundsLogDAL.Get(user, cashInCorp.FundsLogId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.FundsLog fundsLog = result.ReturnValue as Model.FundsLog;
                    if (fundsLog == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取资金流水失败";
                        return result;
                    }

                    //资金流水完成
                    result = fundsLogDAL.Complete(user, fundsLog);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                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;
        }
Esempio n. 2
0
        public ResultModel Complete(UserModel user, int allotId)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.CashInAllotDAL cashInAllotDAL = new CashInAllotDAL();
                DAL.FundsLogDAL fundsLogDAL = new FundsLogDAL();
                Model.FundsLog fundsLog = null;
                DAL.CashInCorpDAL cashInCorpDAL = new CashInCorpDAL();
                DAL.CashInContractDAL cashInContractDAL = new CashInContractDAL();

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

                    Model.CashInAllot cashInAllot = result.ReturnValue as Model.CashInAllot;
                    if (cashInAllot == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取失败";
                        return result;
                    }

                    //完成付款分配
                    result = cashInAllotDAL.Complete(user, cashInAllot);
                    if (result.ResultStatus != 0)
                        return result;

                    result = cashinstcokDAL.LoadByAllot(user, allotId, StatusEnum.已生效);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CashInStcok> cashInStcoks = result.ReturnValue as List<Model.CashInStcok>;
                    if (cashInStcoks == null || !cashInStcoks.Any())
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取明细失败";
                        return result;
                    }

                    foreach (Model.CashInStcok cashInStcok in cashInStcoks)
                    {
                        //完成明细
                        result = cashinstcokDAL.Complete(user, cashInStcok);
                        if (result.ResultStatus != 0)
                            return result;

                        result = cashInContractDAL.Get(user, cashInStcok.ContractRefId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.CashInContract cashInContract = result.ReturnValue as Model.CashInContract;
                        if (cashInContract == null)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取失败";
                            return result;
                        }

                        result = cashInContractDAL.Complete(user, cashInContract);
                        if (result.ResultStatus != 0)
                            return result;

                        result = cashInCorpDAL.Get(user, cashInContract.CorpRefId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.CashInCorp cashInCorp = result.ReturnValue as Model.CashInCorp;
                        if (cashInCorp == null)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取失败";
                            return result;
                        }

                        result = cashInCorpDAL.Complete(user, cashInCorp);
                        if (result.ResultStatus != 0)
                            return result;

                        result = fundsLogDAL.Get(user, cashInStcok.FundsLogId);
                        if (result.ResultStatus != 0)
                            return result;

                        fundsLog = result.ReturnValue as Model.FundsLog;
                        if (fundsLog == null)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取资金流水失败";
                            return result;
                        }

                        //完成流水
                        result = fundsLogDAL.Complete(user, fundsLog);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                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;
        }
Esempio n. 3
0
        public ResultModel Complete(UserModel user, int allotId)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    //验证主分配
                    result = this.cashinallotDAL.Get(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CashInAllot allot = result.ReturnValue as Model.CashInAllot;
                    if (allot == null || allot.AllotId <= 0)
                    {
                        result.Message = "收款分配不存在";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //获取当前分配在库存款存中的剩余
                    result = this.cashinallotDAL.GetLastBalaByAllotId(user, allot.AllotId);
                    if (result.ResultStatus != 0)
                        return result;

                    object obj = result.ReturnValue;
                    decimal lastBala = 0;
                    if (result.ReturnValue == null || !decimal.TryParse(result.ReturnValue.ToString(), out lastBala))
                    {
                        result.Message = "获取失败";
                        result.ResultStatus = -1;
                        return result;
                    }

                    if (lastBala > 0)
                    {
                        result.Message = "有余款未分配,不能关闭";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //获取公司分配明细并完成
                    CashInCorpDAL cashInCorpDAL = new CashInCorpDAL();
                    result = cashInCorpDAL.Load(user, allot.AllotId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CashInCorp> cashInCorps = result.ReturnValue as List<Model.CashInCorp>;
                    if (cashInCorps == null || cashInCorps.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "公司分配明细获取失败";
                        return result;
                    }

                    foreach (Model.CashInCorp cashInCorp in cashInCorps)
                    {
                        result = cashInCorpDAL.Complete(user, cashInCorp);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //获取合约分配明细并完成
                    DAL.CashInContractDAL cashInContractDAL = new CashInContractDAL();
                    result = cashInContractDAL.LoadByAllot(user, allot.AllotId);
                    if (result.ResultStatus != 0)
                        return result;
                    List<Model.CashInContract> cashInContracts = result.ReturnValue as List<Model.CashInContract>;
                    if (cashInContracts == null || cashInContracts.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "合约分配明细获取失败";
                        return result;
                    }

                    foreach (Model.CashInContract cashInContract in cashInContracts)
                    {
                        result = cashInContractDAL.Complete(user, cashInContract);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //获取库存分配明细并完成
                    DAL.CashInStcokDAL cashInStockDAL = new CashInStcokDAL();
                    result = cashInStockDAL.LoadByAllot(user, allot.AllotId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CashInStcok> cashInStocks = result.ReturnValue as List<Model.CashInStcok>;
                    if (cashInStocks == null || cashInStocks.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "库存分配明细获取失败";
                        return result;
                    }

                    foreach (Model.CashInStcok cashInStock in cashInStocks)
                    {
                        result = cashInStockDAL.Complete(user, cashInStock);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //完成主分配
                    result = this.cashinallotDAL.Complete(user, allot);
                    if (result.ResultStatus != 0)
                        return result;

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

            return result;
        }