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