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