/// <summary> /// 更新一条数据 /// </summary> public void Update(MesWeb.Model.T_ModelMaintain model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_ModelMaintain_Update"); db.AddInParameter(dbCommand, "MouldMaintainID", DbType.Int32, model.MouldMaintainID); db.AddInParameter(dbCommand, "MouldID", DbType.Int32, model.MouldID); db.AddInParameter(dbCommand, "MouldMaintainNumber", DbType.Int32, model.MouldMaintainNumber); db.AddInParameter(dbCommand, "MouldMaintainPersonID", DbType.Int32, model.MouldMaintainPersonID); db.AddInParameter(dbCommand, "DateTime", DbType.DateTime, model.DateTime); db.AddInParameter(dbCommand, "IsMaintained", DbType.Boolean, model.IsMaintained); db.AddInParameter(dbCommand, "Comment", DbType.String, model.Comment); db.ExecuteNonQuery(dbCommand); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_ModelMaintain GetModel(int MouldMaintainID) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_ModelMaintain_GetModel"); db.AddInParameter(dbCommand, "MouldMaintainID", DbType.Int32, MouldMaintainID); MesWeb.Model.T_ModelMaintain model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_ModelMaintain DataRowToModel(DataRow row) { MesWeb.Model.T_ModelMaintain model = new MesWeb.Model.T_ModelMaintain(); if (row != null) { if (row["MouldMaintainID"] != null && row["MouldMaintainID"].ToString() != "") { model.MouldMaintainID = int.Parse(row["MouldMaintainID"].ToString()); } if (row["MouldID"] != null && row["MouldID"].ToString() != "") { model.MouldID = int.Parse(row["MouldID"].ToString()); } if (row["MouldMaintainNumber"] != null && row["MouldMaintainNumber"].ToString() != "") { model.MouldMaintainNumber = int.Parse(row["MouldMaintainNumber"].ToString()); } if (row["MouldMaintainPersonID"] != null && row["MouldMaintainPersonID"].ToString() != "") { model.MouldMaintainPersonID = int.Parse(row["MouldMaintainPersonID"].ToString()); } if (row["DateTime"] != null && row["DateTime"].ToString() != "") { model.DateTime = DateTime.Parse(row["DateTime"].ToString()); } if (row["IsMaintained"] != null && row["IsMaintained"].ToString() != "") { if ((row["IsMaintained"].ToString() == "1") || (row["IsMaintained"].ToString().ToLower() == "true")) { model.IsMaintained = true; } else { model.IsMaintained = false; } } if (row["Comment"] != null) { model.Comment = row["Comment"].ToString(); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public MesWeb.Model.T_ModelMaintain ReaderBind(IDataReader dataReader) { MesWeb.Model.T_ModelMaintain model = new MesWeb.Model.T_ModelMaintain(); object ojb; ojb = dataReader["MouldMaintainID"]; if (ojb != null && ojb != DBNull.Value) { model.MouldMaintainID = (int)ojb; } ojb = dataReader["MouldID"]; if (ojb != null && ojb != DBNull.Value) { model.MouldID = (int)ojb; } ojb = dataReader["MouldMaintainNumber"]; if (ojb != null && ojb != DBNull.Value) { model.MouldMaintainNumber = (int)ojb; } ojb = dataReader["MouldMaintainPersonID"]; if (ojb != null && ojb != DBNull.Value) { model.MouldMaintainPersonID = (int)ojb; } ojb = dataReader["DateTime"]; if (ojb != null && ojb != DBNull.Value) { model.DateTime = (DateTime)ojb; } ojb = dataReader["IsMaintained"]; if (ojb != null && ojb != DBNull.Value) { model.IsMaintained = (bool)ojb; } model.Comment = dataReader["Comment"].ToString(); return(model); }