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