Esempio n. 1
0
        public ResultModel Update(UserModel user, Model.CashInAllot cashInAllot, Model.CashInCorp cashInCorp, Model.CashInContract cashInContract, List<Model.CashInStcok> cashInStocks, List<NFMT.Funds.Model.CashInInvoice> cashInInvoices)
        {
            ResultModel result = new ResultModel();

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

                    Model.CashInAllot cashInAllotres = result.ReturnValue as Model.CashInAllot;
                    if (cashInAllotres == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取收款分配失败";
                        return result;
                    }
                    cashInAllotres.Alloter = user.EmpId;
                    cashInAllotres.AllotTime = DateTime.Now;
                    cashInAllotres.AllotBala = cashInAllot.AllotBala;
                    cashInAllotres.AllotType = cashInAllot.AllotType;
                    cashInAllotres.CurrencyId = cashInAllot.CurrencyId;
                    cashInAllotres.AllotDesc = cashInAllot.AllotDesc;

                    result = cashinallotDAL.Update(user, cashInAllotres);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废收款分配至公司
                    DAL.CashInCorpDAL cashInCorpDAL = new CashInCorpDAL();
                    result = cashInCorpDAL.InvalidAll(user, cashInAllot.AllotId);
                    if (result.ResultStatus != 0)
                        return result;

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

                    int corpRefId = (int)result.ReturnValue;

                    //作废收款分配至合同
                    DAL.CashInContractDAL cashInContractDAL = new CashInContractDAL();
                    result = cashInContractDAL.InvalidAll(user, cashInAllot.AllotId);
                    if (result.ResultStatus != 0)
                        return result;

                    cashInContract.CorpRefId = corpRefId;
                    result = cashInContractDAL.Insert(user, cashInContract);
                    if (result.ResultStatus != 0)
                        return result;

                    int contractRefId = (int)result.ReturnValue;

                    if (cashInStocks != null && cashInStocks.Any())
                    {
                        DAL.CashInStcokDAL cashInStcokDAL = new CashInStcokDAL();
                        result = cashInStcokDAL.InvalidAll(user, cashInAllot.AllotId);
                        if (result.ResultStatus != 0)
                            return result;

                        foreach (Model.CashInStcok cashInStcok in cashInStocks)
                        {
                            cashInStcok.CashInId = cashInCorp.CashInId;
                            cashInStcok.AllotId = cashInAllot.AllotId;
                            cashInStcok.CorpRefId = corpRefId;
                            cashInStcok.ContractRefId = contractRefId;
                            result = cashInStcokDAL.Insert(user, cashInStcok);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    if (cashInInvoices != null && cashInInvoices.Any())
                    {
                        DAL.CashInInvoiceDAL cashInInvoiceDAL = new CashInInvoiceDAL();
                        result = cashInInvoiceDAL.InvalidAll(user, cashInAllot.AllotId);
                        if (result.ResultStatus != 0)
                            return result;

                        foreach (Model.CashInInvoice cashInInvoice in cashInInvoices)
                        {
                            cashInInvoice.CashInId = cashInCorp.CashInId;
                            cashInInvoice.AllotId = cashInAllot.AllotId;
                            cashInInvoice.CorpRefId = corpRefId;
                            cashInInvoice.ContractRefId = contractRefId;
                            result = cashInInvoiceDAL.Insert(user, cashInInvoice);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }
            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 Invalid(UserModel user, int allotId)
        {
            ResultModel result = new ResultModel();
            DAL.CashInCorpDAL cashInCorpDAL = new CashInCorpDAL();
            DAL.CashInContractDAL cashInContractDAL = new CashInContractDAL();
            DAL.CashInStcokDAL cashInStcokDAL = new CashInStcokDAL();
            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.Invalid(user, cashInAllot);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废收款分配至公司
                    result = cashInCorpDAL.InvalidAll(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废收款分配至合约
                    result = cashInContractDAL.InvalidAll(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废收款分配至库存
                    result = cashInStcokDAL.InvalidAll(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废收款分配至发票
                    result = cashInInvoiceDAL.InvalidAll(user, allotId);

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