Пример #1
0
        public ResultModel ReceivableCorpAllotCreateHandle(UserModel user, List<Model.ContractReceivable> contractReceivables, int curId, string memo,int allotFrom)
        {
            ResultModel result = new ResultModel();
            DAL.ReceivableDAL receivableDAL = new ReceivableDAL();
            DAL.ContractReceivableDAL contractReceivableDAL = new ContractReceivableDAL();
            DAL.CorpReceivableDAL corpReceivableDAL = new CorpReceivableDAL();
            Model.Receivable receivable = new Receivable();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    decimal allotBala = 0;
                    foreach (Model.ContractReceivable ContractReceivable in contractReceivables)
                    {
                        //allotBala += ContractReceivable.AllotBala;
                    }

                    Model.ReceivableAllot receivableAllot = new ReceivableAllot()
                    {
                        AllotFrom = allotFrom,
                        AllotBala = allotBala,
                        CurrencyId = curId,
                        AllotDesc = memo,
                        EmpId = user.EmpId,
                        AllotTime = DateTime.Now
                    };

                    result = receivableallotDAL.Insert(user, receivableAllot);
                    if (result.ResultStatus != 0)
                        return result;

                    int receivableAllotId = (int)result.ReturnValue;

                    foreach (Model.ContractReceivable contractReceivable in contractReceivables)
                    {
                        contractReceivable.AllotId = receivableAllotId;
                        result = corpReceivableDAL.Get(user, contractReceivable.CorpRefId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.CorpReceivable corpReceivable = result.ReturnValue as Model.CorpReceivable;
                        if (corpReceivable == null)
                            return result;

                        contractReceivable.RecId = corpReceivable.RecId;

                        result = contractReceivableDAL.Insert(user, contractReceivable);
                        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;
        }
Пример #2
0
        public ResultModel ReceivableStockUpdateForCorpHandle(UserModel user, List<Model.ContractReceivable> contractReceivables, int curId, string memo, int allotId, int stockId, int stockNameId, int allotFrom)
        {
            ResultModel result = new ResultModel();
            DAL.ReceivableDAL receivableDAL = new ReceivableDAL();
            DAL.CorpReceivableDAL corpReceivableDAL = new CorpReceivableDAL();
            DAL.ContractReceivableDAL contractReceivableDAL = new ContractReceivableDAL();
            DAL.StcokReceivableDAL stcokReceivableDAL = new StcokReceivableDAL();
            NFMT.User.DAL.CorporationDAL corporationDAL = new User.DAL.CorporationDAL();
            NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new WareHouse.DAL.StockLogDAL();
            Model.Receivable receivable = new Receivable();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    decimal allotBala = 0;
                    foreach (Model.ContractReceivable contractReceivable in contractReceivables)
                    {
                        //allotBala += contractReceivable.AllotBala;
                    }

                    result = receivableallotDAL.Get(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.ReceivableAllot receivableAllot = result.ReturnValue as Model.ReceivableAllot;
                    receivableAllot.AllotDesc = memo;
                    receivableAllot.AllotBala = allotBala;
                    receivableAllot.CurrencyId = curId;
                    receivableAllot.AllotFrom = allotFrom;

                    //更新收款分配表
                    result = receivableallotDAL.Update(user, receivableAllot);
                    if (result.ResultStatus != 0)
                        return result;

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

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

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

                    //获取合约Id
                    result = stockLogDAL.GetStockContractId(user, stockId);
                    if (result.ResultStatus != 0)
                        return result;

                    string contractStr = result.ReturnValue.ToString();

                    foreach (Model.ContractReceivable contractReceivable in contractReceivables)
                    {
                        result = corpReceivableDAL.Get(user,contractReceivable.CorpRefId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.CorpReceivable corpReceivable = result.ReturnValue as Model.CorpReceivable;

                        contractReceivable.RecId = corpReceivable.RecId;
                        contractReceivable.ContractId = Convert.ToInt32(contractStr.Split(',')[0]);
                        contractReceivable.SubContractId = Convert.ToInt32(contractStr.Split(',')[1]);

                        //写入合约收款分配
                        result = contractReceivableDAL.Insert(user, contractReceivable);
                        if (result.ResultStatus != 0)
                            return result;

                        int contractRefId = (int)result.ReturnValue;

                        Model.StcokReceivable stcokReceivable = new StcokReceivable()
                        {
                            AllotId = allotId,
                            CorpRefId = contractReceivable.CorpRefId,
                            ContractRefId = contractRefId,
                            RecId = corpReceivable.RecId,
                            StockId = stockId,
                            StockNameId = stockNameId,
                            //AllotBala = corpReceivable.AllotBala
                        };

                        //写入库存收款分配
                        result = stcokReceivableDAL.Insert(user, stcokReceivable);
                        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;
        }
Пример #3
0
        public ResultModel ReceAllotCorpUpdateHandle(UserModel user, List<Model.ContractReceivable> contractReceivables, int curId, string memo, int allotId, int contractId, int subId)
        {
            ResultModel result = new ResultModel();
            DAL.ReceivableDAL receivableDAL = new ReceivableDAL();
            DAL.ContractReceivableDAL contractReceivableDAL = new ContractReceivableDAL();
            DAL.CorpReceivableDAL corpReceivableDAL = new CorpReceivableDAL();
            NFMT.User.DAL.CorporationDAL corporationDAL = new User.DAL.CorporationDAL();
            Model.Receivable receivable = new Receivable();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    decimal allotBala = 0;
                    foreach (Model.ContractReceivable contractReceivable in contractReceivables)
                    {
                        //allotBala += contractReceivable.AllotBala;
                    }

                    result = receivableallotDAL.Get(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.ReceivableAllot receivableAllot = result.ReturnValue as Model.ReceivableAllot;
                    receivableAllot.AllotDesc = memo;
                    receivableAllot.AllotBala = allotBala;

                    //更新分配信息
                    result = receivableallotDAL.Update(user, receivableAllot);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废所有allotId下的合约收款分配
                    result = contractReceivableDAL.InvalidAll(user, allotId);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.ContractReceivable contractReceivable in contractReceivables)
                    {
                        result = corpReceivableDAL.Get(user, contractReceivable.CorpRefId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.CorpReceivable corpReceivable = result.ReturnValue as Model.CorpReceivable;

                        contractReceivable.RecId = corpReceivable.RecId;

                        //写入合约收款分配表
                        result = contractReceivableDAL.Insert(user, contractReceivable);
                        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;
        }