public override IModel CreateModel(SqlDataReader dr) { Receivable receivable = new Receivable(); int indexReceivableId = dr.GetOrdinal("ReceivableId"); receivable.ReceivableId = Convert.ToInt32(dr[indexReceivableId]); int indexReceiveEmpId = dr.GetOrdinal("ReceiveEmpId"); if (dr["ReceiveEmpId"] != DBNull.Value) { receivable.ReceiveEmpId = Convert.ToInt32(dr[indexReceiveEmpId]); } int indexReceiveDate = dr.GetOrdinal("ReceiveDate"); if (dr["ReceiveDate"] != DBNull.Value) { receivable.ReceiveDate = Convert.ToDateTime(dr[indexReceiveDate]); } int indexReceivableGroupId = dr.GetOrdinal("ReceivableGroupId"); if (dr["ReceivableGroupId"] != DBNull.Value) { receivable.ReceivableGroupId = Convert.ToInt32(dr[indexReceivableGroupId]); } int indexReceivableCorpId = dr.GetOrdinal("ReceivableCorpId"); if (dr["ReceivableCorpId"] != DBNull.Value) { receivable.ReceivableCorpId = Convert.ToInt32(dr[indexReceivableCorpId]); } int indexCurrencyId = dr.GetOrdinal("CurrencyId"); if (dr["CurrencyId"] != DBNull.Value) { receivable.CurrencyId = Convert.ToInt32(dr[indexCurrencyId]); } int indexPayBala = dr.GetOrdinal("PayBala"); if (dr["PayBala"] != DBNull.Value) { receivable.PayBala = Convert.ToDecimal(dr[indexPayBala]); } int indexReceivableBank = dr.GetOrdinal("ReceivableBank"); if (dr["ReceivableBank"] != DBNull.Value) { receivable.ReceivableBank = Convert.ToInt32(dr[indexReceivableBank]); } int indexReceivableAccoontId = dr.GetOrdinal("ReceivableAccoontId"); if (dr["ReceivableAccoontId"] != DBNull.Value) { receivable.ReceivableAccoontId = Convert.ToInt32(dr[indexReceivableAccoontId]); } int indexPayGroupId = dr.GetOrdinal("PayGroupId"); if (dr["PayGroupId"] != DBNull.Value) { receivable.PayGroupId = Convert.ToInt32(dr[indexPayGroupId]); } int indexPayCorpId = dr.GetOrdinal("PayCorpId"); if (dr["PayCorpId"] != DBNull.Value) { receivable.PayCorpId = Convert.ToInt32(dr[indexPayCorpId]); } int indexPayCorpName = dr.GetOrdinal("PayCorpName"); if (dr["PayCorpName"] != DBNull.Value) { receivable.PayCorpName = Convert.ToString(dr[indexPayCorpName]); } int indexPayBankId = dr.GetOrdinal("PayBankId"); if (dr["PayBankId"] != DBNull.Value) { receivable.PayBankId = Convert.ToInt32(dr[indexPayBankId]); } int indexPayBank = dr.GetOrdinal("PayBank"); if (dr["PayBank"] != DBNull.Value) { receivable.PayBank = Convert.ToString(dr[indexPayBank]); } int indexPayAccountId = dr.GetOrdinal("PayAccountId"); if (dr["PayAccountId"] != DBNull.Value) { receivable.PayAccountId = Convert.ToInt32(dr[indexPayAccountId]); } int indexPayAccount = dr.GetOrdinal("PayAccount"); if (dr["PayAccount"] != DBNull.Value) { receivable.PayAccount = Convert.ToString(dr[indexPayAccount]); } int indexPayWord = dr.GetOrdinal("PayWord"); if (dr["PayWord"] != DBNull.Value) { receivable.PayWord = Convert.ToString(dr[indexPayWord]); } int indexBankLog = dr.GetOrdinal("BankLog"); if (dr["BankLog"] != DBNull.Value) { receivable.BankLog = Convert.ToString(dr[indexBankLog]); } int indexReceiveStatus = dr.GetOrdinal("ReceiveStatus"); if (dr["ReceiveStatus"] != DBNull.Value) { receivable.ReceiveStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexReceiveStatus]); } int indexCreatorId = dr.GetOrdinal("CreatorId"); if (dr["CreatorId"] != DBNull.Value) { receivable.CreatorId = Convert.ToInt32(dr[indexCreatorId]); } int indexCreateTime = dr.GetOrdinal("CreateTime"); if (dr["CreateTime"] != DBNull.Value) { receivable.CreateTime = Convert.ToDateTime(dr[indexCreateTime]); } int indexLastModifyId = dr.GetOrdinal("LastModifyId"); if (dr["LastModifyId"] != DBNull.Value) { receivable.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]); } int indexLastModifyTime = dr.GetOrdinal("LastModifyTime"); if (dr["LastModifyTime"] != DBNull.Value) { receivable.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]); } return receivable; }
public ResultModel ReceivableStockUpdateHandle(UserModel user, List<Model.CorpReceivable> corpReceivables, 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.CorpReceivable corpReceivable in corpReceivables) { //allotBala += corpReceivable.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.CorpReceivable corpReceivable in corpReceivables) { result = corporationDAL.Get(user, corpReceivable.CorpId); if (result.ResultStatus != 0) return result; User.Model.Corporation corp = result.ReturnValue as User.Model.Corporation; 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 = allotId, 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 = allotId, 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; }
public ResultModel ReceivableStockUpdateForContractHandle(UserModel user, List<Model.StcokReceivable> stcokReceivables, int curId, string memo, int allotId, 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; } 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; foreach (Model.StcokReceivable stcokReceivable in stcokReceivables) { 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; }
public ResultModel ReceivableCorpUpdateHandle(UserModel user, List<Model.CorpReceivable> corpReceivables, int curId, string memo, int allotId) { 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; } 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; result = corpReceivableDAL.InvalidAll(user, allotId); if (result.ResultStatus != 0) return result; foreach (Model.CorpReceivable corpReceivable in corpReceivables) { corpReceivable.AllotId = allotId; 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; }
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; }
public ResultModel ReceivableAllotUpdateHandle(UserModel user, List<Model.CorpReceivable> corpReceivables, 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.CorpReceivable corpReceivable in corpReceivables) { //allotBala += corpReceivable.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; //作废所有allotId下的公司收款分配 result = corpReceivableDAL.InvalidAll(user, allotId); if (result.ResultStatus != 0) return result; foreach (Model.CorpReceivable corpReceivable in corpReceivables) { corpReceivable.AllotId = allotId; 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) return result; corpReceivable.BlocId = corp.ParentId; //写入公司收款分配表 result = corpReceivableDAL.Insert(user, corpReceivable); if (result.ResultStatus != 0) return result; int refId = (int)result.ReturnValue; Model.ContractReceivable contractReceivable = new ContractReceivable() { CorpRefId = refId, AllotId = corpReceivable.AllotId, RecId = corpReceivable.RecId, ContractId = contractId, SubContractId = subId, //AllotBala = corpReceivable.AllotBala }; //写入合约收款分配表 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; }