public ResultModel Load(UserModel user, int receiptId, Common.StatusEnum status = StatusEnum.已生效) { ResultModel result = new ResultModel(); try { string cmdText = string.Format("select * from dbo.St_StockReceiptDetail where ReceiptId={0} and DetailStatus>={1}", receiptId, (int)status); DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, cmdText, null, CommandType.Text); List<StockReceiptDetail> stockReceiptDetails = new List<StockReceiptDetail>(); foreach (DataRow dr in dt.Rows) { StockReceiptDetail stockreceiptdetail = new StockReceiptDetail(); stockreceiptdetail.DetailId = Convert.ToInt32(dr["DetailId"]); stockreceiptdetail.ReceiptId = Convert.ToInt32(dr["ReceiptId"]); if (dr["ContractId"] != DBNull.Value) { stockreceiptdetail.ContractId = Convert.ToInt32(dr["ContractId"]); } if (dr["ContractSubId"] != DBNull.Value) { stockreceiptdetail.ContractSubId = Convert.ToInt32(dr["ContractSubId"]); } if (dr["StockId"] != DBNull.Value) { stockreceiptdetail.StockId = Convert.ToInt32(dr["StockId"]); } if (dr["StockLogId"] != DBNull.Value) { stockreceiptdetail.StockLogId = Convert.ToInt32(dr["StockLogId"]); } if (dr["PreNetAmount"] != DBNull.Value) { stockreceiptdetail.PreNetAmount = Convert.ToDecimal(dr["PreNetAmount"]); } if (dr["ReceiptAmount"] != DBNull.Value) { stockreceiptdetail.ReceiptAmount = Convert.ToDecimal(dr["ReceiptAmount"]); } if (dr["QtyMiss"] != DBNull.Value) { stockreceiptdetail.QtyMiss = Convert.ToDecimal(dr["QtyMiss"]); } if (dr["QtyRate"] != DBNull.Value) { stockreceiptdetail.QtyRate = Convert.ToDecimal(dr["QtyRate"]); } if (dr["DetailStatus"] != DBNull.Value) { stockreceiptdetail.DetailStatus = (Common.StatusEnum)Enum.Parse(typeof(Common.StatusEnum), dr["DetailStatus"].ToString()); } if (dr["CreatorId"] != DBNull.Value) { stockreceiptdetail.CreatorId = Convert.ToInt32(dr["CreatorId"]); } if (dr["CreateTime"] != DBNull.Value) { stockreceiptdetail.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["LastModifyId"] != DBNull.Value) { stockreceiptdetail.LastModifyId = Convert.ToInt32(dr["LastModifyId"]); } if (dr["LastModifyTime"] != DBNull.Value) { stockreceiptdetail.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]); } stockReceiptDetails.Add(stockreceiptdetail); } result.AffectCount = dt.Rows.Count; result.Message = "获取列表成功"; result.ResultStatus = 0; result.ReturnValue = stockReceiptDetails; } catch (Exception ex) { result.Message = ex.Message; } return result; }
public override IModel CreateModel(SqlDataReader dr) { StockReceiptDetail stockreceiptdetail = new StockReceiptDetail(); int indexDetailId = dr.GetOrdinal("DetailId"); stockreceiptdetail.DetailId = Convert.ToInt32(dr[indexDetailId]); int indexReceiptId = dr.GetOrdinal("ReceiptId"); stockreceiptdetail.ReceiptId = Convert.ToInt32(dr[indexReceiptId]); int indexContractId = dr.GetOrdinal("ContractId"); if (dr["ContractId"] != DBNull.Value) { stockreceiptdetail.ContractId = Convert.ToInt32(dr[indexContractId]); } int indexContractSubId = dr.GetOrdinal("ContractSubId"); if (dr["ContractSubId"] != DBNull.Value) { stockreceiptdetail.ContractSubId = Convert.ToInt32(dr[indexContractSubId]); } int indexStockId = dr.GetOrdinal("StockId"); if (dr["StockId"] != DBNull.Value) { stockreceiptdetail.StockId = Convert.ToInt32(dr[indexStockId]); } int indexStockLogId = dr.GetOrdinal("StockLogId"); if (dr["StockLogId"] != DBNull.Value) { stockreceiptdetail.StockLogId = Convert.ToInt32(dr[indexStockLogId]); } int indexPreNetAmount = dr.GetOrdinal("PreNetAmount"); if (dr["PreNetAmount"] != DBNull.Value) { stockreceiptdetail.PreNetAmount = Convert.ToDecimal(dr[indexPreNetAmount]); } int indexReceiptAmount = dr.GetOrdinal("ReceiptAmount"); if (dr["ReceiptAmount"] != DBNull.Value) { stockreceiptdetail.ReceiptAmount = Convert.ToDecimal(dr[indexReceiptAmount]); } int indexQtyMiss = dr.GetOrdinal("QtyMiss"); if (dr["QtyMiss"] != DBNull.Value) { stockreceiptdetail.QtyMiss = Convert.ToDecimal(dr[indexQtyMiss]); } int indexQtyRate = dr.GetOrdinal("QtyRate"); if (dr["QtyRate"] != DBNull.Value) { stockreceiptdetail.QtyRate = Convert.ToDecimal(dr[indexQtyRate]); } int indexDetailStatus = dr.GetOrdinal("DetailStatus"); if (dr["DetailStatus"] != DBNull.Value) { stockreceiptdetail.DetailStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexDetailStatus]); } int indexCreatorId = dr.GetOrdinal("CreatorId"); if (dr["CreatorId"] != DBNull.Value) { stockreceiptdetail.CreatorId = Convert.ToInt32(dr[indexCreatorId]); } int indexCreateTime = dr.GetOrdinal("CreateTime"); if (dr["CreateTime"] != DBNull.Value) { stockreceiptdetail.CreateTime = Convert.ToDateTime(dr[indexCreateTime]); } int indexLastModifyId = dr.GetOrdinal("LastModifyId"); if (dr["LastModifyId"] != DBNull.Value) { stockreceiptdetail.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]); } int indexLastModifyTime = dr.GetOrdinal("LastModifyTime"); if (dr["LastModifyTime"] != DBNull.Value) { stockreceiptdetail.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]); } return stockreceiptdetail; }