/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.chest_type model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update chest_type set "); strSql.Append("type_length=@type_length,"); strSql.Append("type_high=@type_high,"); strSql.Append("type_wide=@type_wide"); strSql.Append(" where type_id=@type_id "); MySqlParameter[] parameters = { new MySqlParameter("@type_length", MySqlDbType.Decimal, 10), new MySqlParameter("@type_high", MySqlDbType.Decimal, 10), new MySqlParameter("@type_wide", MySqlDbType.Decimal, 10), new MySqlParameter("@type_id", MySqlDbType.Int32, 32) }; parameters[0].Value = model.type_length; parameters[1].Value = model.type_high; parameters[2].Value = model.type_wide; parameters[3].Value = model.type_id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Model.chest_type model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into chest_type("); strSql.Append("type_id,type_length,type_high,type_wide)"); strSql.Append(" values ("); strSql.Append("@type_id,@type_length,@type_high,@type_wide)"); MySqlParameter[] parameters = { new MySqlParameter("@type_id", MySqlDbType.Int32, 32), new MySqlParameter("@type_length", MySqlDbType.Decimal, 10), new MySqlParameter("@type_high", MySqlDbType.Decimal, 10), new MySqlParameter("@type_wide", MySqlDbType.Decimal, 10) }; parameters[0].Value = model.type_id; parameters[1].Value = model.type_length; parameters[2].Value = model.type_high; parameters[3].Value = model.type_wide; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.chest_type DataRowToModel(DataRow row) { Model.chest_type model = new Model.chest_type(); if (row != null) { if (row["type_id"] != null && row["type_id"].ToString() != "") { model.type_id = int.Parse(row["type_id"].ToString()); } if (row["type_length"] != null && row["type_length"].ToString() != "") { model.type_length = decimal.Parse(row["type_length"].ToString()); } if (row["type_high"] != null && row["type_high"].ToString() != "") { model.type_high = decimal.Parse(row["type_high"].ToString()); } if (row["type_wide"] != null && row["type_wide"].ToString() != "") { model.type_wide = decimal.Parse(row["type_wide"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.chest_type GetModel(int type_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select type_id,type_length,type_high,type_wide from chest_type "); strSql.Append(" where type_id=@type_id "); MySqlParameter[] parameters = { new MySqlParameter("@type_id", MySqlDbType.Int32, 32) }; parameters[0].Value = type_id; Model.chest_type model = new Model.chest_type(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }