/// <summary> /// 更新一条数据 /// </summary> public void Update(MesWeb.Model.T_MaterialType model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_MaterialType_Update"); db.AddInParameter(dbCommand, "MaterialTypeID", DbType.Int32, model.MaterialTypeID); db.AddInParameter(dbCommand, "MaterialType", DbType.String, model.MaterialType); db.AddInParameter(dbCommand, "MaterialTypeInfo", DbType.String, model.MaterialTypeInfo); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MesWeb.Model.T_MaterialType model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_MaterialType_ADD"); db.AddOutParameter(dbCommand, "MaterialTypeID", DbType.Int32, 4); db.AddInParameter(dbCommand, "MaterialType", DbType.String, model.MaterialType); db.AddInParameter(dbCommand, "MaterialTypeInfo", DbType.String, model.MaterialTypeInfo); db.ExecuteNonQuery(dbCommand); return((int)db.GetParameterValue(dbCommand, "MaterialTypeID")); }
/// <summary> /// 对象实体绑定数据 /// </summary> public MesWeb.Model.T_MaterialType ReaderBind(IDataReader dataReader) { MesWeb.Model.T_MaterialType model = new MesWeb.Model.T_MaterialType(); object ojb; ojb = dataReader["MaterialTypeID"]; if (ojb != null && ojb != DBNull.Value) { model.MaterialTypeID = (int)ojb; } model.MaterialType = dataReader["MaterialType"].ToString(); model.MaterialTypeInfo = dataReader["MaterialTypeInfo"].ToString(); return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_MaterialType GetModel(int MaterialTypeID) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_MaterialType_GetModel"); db.AddInParameter(dbCommand, "MaterialTypeID", DbType.Int32, MaterialTypeID); MesWeb.Model.T_MaterialType model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_MaterialType DataRowToModel(DataRow row) { MesWeb.Model.T_MaterialType model = new MesWeb.Model.T_MaterialType(); if (row != null) { if (row["MaterialTypeID"] != null && row["MaterialTypeID"].ToString() != "") { model.MaterialTypeID = int.Parse(row["MaterialTypeID"].ToString()); } if (row["MaterialType"] != null) { model.MaterialType = row["MaterialType"].ToString(); } if (row["MaterialTypeInfo"] != null) { model.MaterialTypeInfo = row["MaterialTypeInfo"].ToString(); } } return(model); }