Exemplo n.º 1
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            ReceivableAllot receivableallot = new ReceivableAllot();

            int indexReceivableAllotId = dr.GetOrdinal("ReceivableAllotId");
            receivableallot.ReceivableAllotId = Convert.ToInt32(dr[indexReceivableAllotId]);

            int indexAllotBala = dr.GetOrdinal("AllotBala");
            if (dr["AllotBala"] != DBNull.Value)
            {
                receivableallot.AllotBala = Convert.ToDecimal(dr[indexAllotBala]);
            }

            int indexAllotType = dr.GetOrdinal("AllotType");
            if (dr["AllotType"] != DBNull.Value)
            {
                receivableallot.AllotType = Convert.ToInt32(dr[indexAllotType]);
            }

            int indexCurrencyId = dr.GetOrdinal("CurrencyId");
            if (dr["CurrencyId"] != DBNull.Value)
            {
                receivableallot.CurrencyId = Convert.ToInt32(dr[indexCurrencyId]);
            }

            int indexAllotDesc = dr.GetOrdinal("AllotDesc");
            if (dr["AllotDesc"] != DBNull.Value)
            {
                receivableallot.AllotDesc = Convert.ToString(dr[indexAllotDesc]);
            }

            int indexEmpId = dr.GetOrdinal("EmpId");
            if (dr["EmpId"] != DBNull.Value)
            {
                receivableallot.EmpId = Convert.ToInt32(dr[indexEmpId]);
            }

            int indexAllotTime = dr.GetOrdinal("AllotTime");
            if (dr["AllotTime"] != DBNull.Value)
            {
                receivableallot.AllotTime = Convert.ToDateTime(dr[indexAllotTime]);
            }

            int indexAllotStatus = dr.GetOrdinal("AllotStatus");
            if (dr["AllotStatus"] != DBNull.Value)
            {
                receivableallot.AllotStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexAllotStatus]);
            }

            int indexAllotFrom = dr.GetOrdinal("AllotFrom");
            if (dr["AllotFrom"] != DBNull.Value)
            {
                receivableallot.AllotFrom = Convert.ToInt32(dr[indexAllotFrom]);
            }

            int indexCreatorId = dr.GetOrdinal("CreatorId");
            if (dr["CreatorId"] != DBNull.Value)
            {
                receivableallot.CreatorId = Convert.ToInt32(dr[indexCreatorId]);
            }

            int indexCreateTime = dr.GetOrdinal("CreateTime");
            if (dr["CreateTime"] != DBNull.Value)
            {
                receivableallot.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);
            }

            int indexLastModifyId = dr.GetOrdinal("LastModifyId");
            if (dr["LastModifyId"] != DBNull.Value)
            {
                receivableallot.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
            }

            int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
            if (dr["LastModifyTime"] != DBNull.Value)
            {
                receivableallot.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
            }

            return receivableallot;
        }
Exemplo n.º 2
0
        public ResultModel ReceivableStockCreateByContractHandle(UserModel user, List<Model.StcokReceivable> stcokReceivables, int curId, string memo, 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.StcokReceivable stcokReceivable in stcokReceivables)
                    {
                        //allotBala += stcokReceivable.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.StcokReceivable stcokReceivable in stcokReceivables)
                    {
                        stcokReceivable.AllotId = receivableAllotId;

                        result = contractReceivableDAL.Get(user, stcokReceivable.ContractRefId);
                        if (result.ResultStatus != 0)
                            return result;

                        Model.ContractReceivable contractReceivable = result.ReturnValue as Model.ContractReceivable;
                        stcokReceivable.CorpRefId = contractReceivable.CorpRefId;

                        stcokReceivable.RecId = contractReceivable.RecId;

                        //写入库存收款信息
                        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;
        }
Exemplo n.º 3
0
        public ResultModel ReceivableStockCreateHandle(UserModel user, List<Model.CorpReceivable> corpReceivables, int curId, string memo, int allotFrom, int stockId, int stockNameId)
        {
            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.CorpReceivable corpReceivable in corpReceivables)
                    {
                        //allotBala += corpReceivable.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;

                    result = stockLogDAL.GetStockContractId(user, stockId);
                    if (result.ResultStatus != 0)
                        return result;

                    string contractStr = result.ReturnValue.ToString();

                    foreach (Model.CorpReceivable corpReceivable in corpReceivables)
                    {
                        corpReceivable.AllotId = receivableAllotId;

                        //获取公司信息
                        result = corporationDAL.Get(user, corpReceivable.CorpId);
                        if (result.ResultStatus != 0)
                            return result;

                        NFMT.User.Model.Corporation corp = result.ReturnValue as NFMT.User.Model.Corporation;
                        if (corp == null)
                        {
                            result.ResultStatus = -1;
                            return result;
                        }
                        corpReceivable.BlocId = corp.ParentId;

                        //写入公司收款表
                        result = corpReceivableDAL.Insert(user, corpReceivable);
                        if (result.ResultStatus != 0)
                            return result;

                        int corpRefId = (int)result.ReturnValue;

                        //新建合约收款信息
                        Model.ContractReceivable contractReceivable = new ContractReceivable()
                        {
                            CorpRefId = corpRefId,
                            AllotId = receivableAllotId,
                            RecId = corpReceivable.RecId,
                            ContractId = Convert.ToInt32(contractStr.Split(',')[0]),
                            SubContractId = Convert.ToInt32(contractStr.Split(',')[1]),
                            //AllotBala = corpReceivable.AllotBala
                        };

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

                        int contractRefId = (int)result.ReturnValue;

                        //新建库存收款信息
                        Model.StcokReceivable stcokReceivable = new StcokReceivable()
                        {
                            AllotId = receivableAllotId,
                            CorpRefId = 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;
        }
Exemplo n.º 4
0
        public ResultModel ReceivableCorpCreateHandle(UserModel user, List<Model.CorpReceivable> corpReceivables, int curId, string memo)
        {
            ResultModel result = new ResultModel();
            DAL.ReceivableDAL receivableDAL = new ReceivableDAL();
            DAL.CorpReceivableDAL corpReceivableDAL = new CorpReceivableDAL();
            Model.Receivable receivable = new Receivable();

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

                    Model.ReceivableAllot receivableAllot = new ReceivableAllot()
                    {
                        AllotFrom = NFMT.Data.DetailProvider.Details(NFMT.Data.StyleEnum.分配来源)["Receivable"].StyleDetailId,
                        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.CorpReceivable corpReceivable in corpReceivables)
                    {
                        corpReceivable.AllotId = receivableAllotId;
                        result = corpReceivableDAL.Insert(user, corpReceivable);
                        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;
        }