/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_ProductZone DataRowToModel(DataRow row) { MesWeb.Model.T_ProductZone model = new MesWeb.Model.T_ProductZone(); if (row != null) { if (row["ProductZoneID"] != null && row["ProductZoneID"].ToString() != "") { model.ProductZoneID = int.Parse(row["ProductZoneID"].ToString()); } if (row["ProductZoneName"] != null) { model.ProductZoneName = row["ProductZoneName"].ToString(); } if (row["ProductZonePicUrl"] != null) { model.ProductZonePicUrl = row["ProductZonePicUrl"].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_ProductZone model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_ProductZone_Update"); db.AddInParameter(dbCommand, "ProductZoneID", DbType.Int32, model.ProductZoneID); db.AddInParameter(dbCommand, "ProductZoneName", DbType.String, model.ProductZoneName); db.AddInParameter(dbCommand, "ProductZonePicUrl", DbType.String, model.ProductZonePicUrl); 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_ProductZone model) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_ProductZone_ADD"); db.AddOutParameter(dbCommand, "ProductZoneID", DbType.Int32, 4); db.AddInParameter(dbCommand, "ProductZoneName", DbType.String, model.ProductZoneName); db.AddInParameter(dbCommand, "ProductZonePicUrl", DbType.String, model.ProductZonePicUrl); 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, "ProductZoneID")); }
/// <summary> /// 得到一个对象实体 /// </summary> public MesWeb.Model.T_ProductZone GetModel(int ProductZoneID) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("T_ProductZone_GetModel"); db.AddInParameter(dbCommand, "ProductZoneID", DbType.Int32, ProductZoneID); MesWeb.Model.T_ProductZone model = null; using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { model = ReaderBind(dataReader); } } return(model); }
/// <summary> /// 对象实体绑定数据 /// </summary> public MesWeb.Model.T_ProductZone ReaderBind(IDataReader dataReader) { MesWeb.Model.T_ProductZone model = new MesWeb.Model.T_ProductZone(); object ojb; ojb = dataReader["ProductZoneID"]; if (ojb != null && ojb != DBNull.Value) { model.ProductZoneID = (int)ojb; } model.ProductZoneName = dataReader["ProductZoneName"].ToString(); model.ProductZonePicUrl = dataReader["ProductZonePicUrl"].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); }