public ResultModel Load(UserModel user, int sIId, StatusEnum status = StatusEnum.已生效) { ResultModel result = new ResultModel(); try { string cmdText = string.Format("select * from dbo.Inv_SIDetail where SIId={0} and DetailStatus ={1}", sIId, (int)status); DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, cmdText, null, CommandType.Text); List<SIDetail> sIDetails = new List<SIDetail>(); foreach (DataRow dr in dt.Rows) { SIDetail sidetail = new SIDetail(); sidetail.SIDetailId = Convert.ToInt32(dr["SIDetailId"]); if (dr["SIId"] != DBNull.Value) { sidetail.SIId = Convert.ToInt32(dr["SIId"]); } if (dr["PayDept"] != DBNull.Value) { sidetail.PayDept = Convert.ToInt32(dr["PayDept"]); } if (dr["FeeType"] != DBNull.Value) { sidetail.FeeType = Convert.ToInt32(dr["FeeType"]); } if (dr["StockId"] != DBNull.Value) { sidetail.StockId = Convert.ToInt32(dr["StockId"]); } if (dr["StockLogId"] != DBNull.Value) { sidetail.StockLogId = Convert.ToInt32(dr["StockLogId"]); } if (dr["ContractId"] != DBNull.Value) { sidetail.ContractId = Convert.ToInt32(dr["ContractId"]); } if (dr["ContractSubId"] != DBNull.Value) { sidetail.ContractSubId = Convert.ToInt32(dr["ContractSubId"]); } if (dr["DetailBala"] != DBNull.Value) { sidetail.DetailBala = Convert.ToDecimal(dr["DetailBala"]); } if (dr["DetailStatus"] != DBNull.Value) { sidetail.DetailStatus = (Common.StatusEnum)Convert.ToInt32(dr["DetailStatus"]); } if (dr["Memo"] != DBNull.Value) { sidetail.Memo = Convert.ToString(dr["Memo"]); } if (dr["CreatorId"] != DBNull.Value) { sidetail.CreatorId = Convert.ToInt32(dr["CreatorId"]); } if (dr["CreateTime"] != DBNull.Value) { sidetail.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["LastModifyId"] != DBNull.Value) { sidetail.LastModifyId = Convert.ToInt32(dr["LastModifyId"]); } if (dr["LastModifyTime"] != DBNull.Value) { sidetail.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]); } sIDetails.Add(sidetail); } result.AffectCount = dt.Rows.Count; result.Message = "获取列表成功"; result.ResultStatus = 0; result.ReturnValue = sIDetails; } catch (Exception ex) { result.Message = ex.Message; } return result; }
public override IModel CreateModel(SqlDataReader dr) { SIDetail sidetail = new SIDetail(); int indexSIDetailId = dr.GetOrdinal("SIDetailId"); sidetail.SIDetailId = Convert.ToInt32(dr[indexSIDetailId]); int indexSIId = dr.GetOrdinal("SIId"); if (dr["SIId"] != DBNull.Value) { sidetail.SIId = Convert.ToInt32(dr[indexSIId]); } int indexPayDept = dr.GetOrdinal("PayDept"); if (dr["PayDept"] != DBNull.Value) { sidetail.PayDept = Convert.ToInt32(dr[indexPayDept]); } int indexFeeType = dr.GetOrdinal("FeeType"); if (dr["FeeType"] != DBNull.Value) { sidetail.FeeType = Convert.ToInt32(dr[indexFeeType]); } int indexStockId = dr.GetOrdinal("StockId"); if (dr["StockId"] != DBNull.Value) { sidetail.StockId = Convert.ToInt32(dr[indexStockId]); } int indexStockLogId = dr.GetOrdinal("StockLogId"); if (dr["StockLogId"] != DBNull.Value) { sidetail.StockLogId = Convert.ToInt32(dr[indexStockLogId]); } int indexContractId = dr.GetOrdinal("ContractId"); if (dr["ContractId"] != DBNull.Value) { sidetail.ContractId = Convert.ToInt32(dr[indexContractId]); } int indexContractSubId = dr.GetOrdinal("ContractSubId"); if (dr["ContractSubId"] != DBNull.Value) { sidetail.ContractSubId = Convert.ToInt32(dr[indexContractSubId]); } int indexDetailBala = dr.GetOrdinal("DetailBala"); if (dr["DetailBala"] != DBNull.Value) { sidetail.DetailBala = Convert.ToDecimal(dr[indexDetailBala]); } int indexDetailStatus = dr.GetOrdinal("DetailStatus"); if (dr["DetailStatus"] != DBNull.Value) { sidetail.DetailStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexDetailStatus]); } int indexMemo = dr.GetOrdinal("Memo"); if (dr["Memo"] != DBNull.Value) { sidetail.Memo = Convert.ToString(dr[indexMemo]); } int indexCreatorId = dr.GetOrdinal("CreatorId"); if (dr["CreatorId"] != DBNull.Value) { sidetail.CreatorId = Convert.ToInt32(dr[indexCreatorId]); } int indexCreateTime = dr.GetOrdinal("CreateTime"); if (dr["CreateTime"] != DBNull.Value) { sidetail.CreateTime = Convert.ToDateTime(dr[indexCreateTime]); } int indexLastModifyId = dr.GetOrdinal("LastModifyId"); if (dr["LastModifyId"] != DBNull.Value) { sidetail.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]); } int indexLastModifyTime = dr.GetOrdinal("LastModifyTime"); if (dr["LastModifyTime"] != DBNull.Value) { sidetail.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]); } return sidetail; }