/// <summary> /// 获得数据列表 /// </summary> public List <PartProductModel> GetModelList(string strWhere) { DataSet ds = dal.GetList(strWhere); List <PartProductModel> modelList = new List <PartProductModel>(); int rowsCount = ds.Tables[0].Rows.Count; if (rowsCount > 0) { PartProductModel model; for (int n = 0; n < rowsCount; n++) { model = new PartProductModel(); if (ds.Tables[0].Rows[n]["ProductId"].ToString() != "") { model.ProductId = int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString()); } if (ds.Tables[0].Rows[n]["PartProductId"].ToString() != "") { model.PartProductId = int.Parse(ds.Tables[0].Rows[n]["PartProductId"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(PartProductModel model) { DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdPartProduct_Update"); dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId); dbw.AddInParameter(dbCommand, "PartProductId", DbType.Int32, model.PartProductId); dbw.ExecuteNonQuery(dbCommand); }
/// <summary> /// 对象实体绑定数据 /// </summary> public PartProductModel ReaderBind(IDataReader dataReader) { PartProductModel model = new PartProductModel(); object ojb; ojb = dataReader["ProductId"]; if (ojb != null && ojb != DBNull.Value) { model.ProductId = (int)ojb; } ojb = dataReader["PartProductId"]; if (ojb != null && ojb != DBNull.Value) { model.PartProductId = (int)ojb; } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public PartProductModel GetModel(int ProductId, int PartProductId) { DbCommand dbCommand = dbr.GetStoredProcCommand("UP_pdPartProduct_GetModel"); dbr.AddInParameter(dbCommand, "ProductId", DbType.Int32, ProductId); dbr.AddInParameter(dbCommand, "PartProductId", DbType.Int32, PartProductId); PartProductModel model = null; using (IDataReader dataReader = dbr.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(PartProductModel model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public void Add(PartProductModel model) { dal.Add(model); }