public override IModel CreateModel(SqlDataReader dr) { StcokReceivable stcokreceivable = new StcokReceivable(); int indexRefId = dr.GetOrdinal("RefId"); stcokreceivable.RefId = Convert.ToInt32(dr[indexRefId]); int indexAllotId = dr.GetOrdinal("AllotId"); if (dr["AllotId"] != DBNull.Value) { stcokreceivable.AllotId = Convert.ToInt32(dr[indexAllotId]); } int indexCorpRefId = dr.GetOrdinal("CorpRefId"); if (dr["CorpRefId"] != DBNull.Value) { stcokreceivable.CorpRefId = Convert.ToInt32(dr[indexCorpRefId]); } int indexContractRefId = dr.GetOrdinal("ContractRefId"); if (dr["ContractRefId"] != DBNull.Value) { stcokreceivable.ContractRefId = Convert.ToInt32(dr[indexContractRefId]); } int indexRecId = dr.GetOrdinal("RecId"); if (dr["RecId"] != DBNull.Value) { stcokreceivable.RecId = Convert.ToInt32(dr[indexRecId]); } int indexDetailId = dr.GetOrdinal("DetailId"); if (dr["DetailId"] != DBNull.Value) { stcokreceivable.DetailId = Convert.ToInt32(dr[indexDetailId]); } int indexStockId = dr.GetOrdinal("StockId"); if (dr["StockId"] != DBNull.Value) { stcokreceivable.StockId = Convert.ToInt32(dr[indexStockId]); } int indexStockNameId = dr.GetOrdinal("StockNameId"); if (dr["StockNameId"] != DBNull.Value) { stcokreceivable.StockNameId = Convert.ToInt32(dr[indexStockNameId]); } return stcokreceivable; }
public ResultModel GetStockReceivableByAllotId(UserModel user, int allotId) { ResultModel result = new ResultModel(); try { string sql = string.Format("select * from Fun_StcokReceivable_Ref where AllotId = {0} and RefStatus = {1}", allotId, (int)Common.StatusEnum.已生效); DataTable dt = NFMT.DBUtility.SqlHelper.ExecuteDataTable(this.ConnectString, sql, null, CommandType.Text); if (dt != null && dt.Rows.Count > 0) { List<StcokReceivable> stcokReceivables = new List<StcokReceivable>(); foreach (DataRow dr in dt.Rows) { StcokReceivable stcokreceivable = new StcokReceivable(); stcokreceivable.RefId = Convert.ToInt32(dr["RefId"]); if (dr["AllotId"] != DBNull.Value) { stcokreceivable.AllotId = Convert.ToInt32(dr["AllotId"]); } if (dr["CorpRefId"] != DBNull.Value) { stcokreceivable.CorpRefId = Convert.ToInt32(dr["CorpRefId"]); } if (dr["ContractRefId"] != DBNull.Value) { stcokreceivable.ContractRefId = Convert.ToInt32(dr["ContractRefId"]); } if (dr["RecId"] != DBNull.Value) { stcokreceivable.RecId = Convert.ToInt32(dr["RecId"]); } if (dr["DetailId"] != DBNull.Value) { stcokreceivable.DetailId = Convert.ToInt32(dr["DetailId"]); } if (dr["StockId"] != DBNull.Value) { stcokreceivable.StockId = Convert.ToInt32(dr["StockId"]); } if (dr["StockNameId"] != DBNull.Value) { stcokreceivable.StockNameId = Convert.ToInt32(dr["StockNameId"]); } stcokReceivables.Add(stcokreceivable); } result.AffectCount = dt.Rows.Count; result.Message = "获取列表成功"; result.ResultStatus = 0; result.ReturnValue = stcokReceivables; } else { result.ResultStatus = -1; result.Message = "获取列表失败"; } } catch (Exception e) { result.ResultStatus = -1; result.Message = e.Message; } return result; }
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; }