/// <summary> /// 更新一条数据 /// </summary> public bool Update(XHD.Model.ecs_goods_attr model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ecs_goods_attr set "); strSql.Append("goods_id=@goods_id,"); strSql.Append("attr_id=@attr_id,"); strSql.Append("attr_value=@attr_value,"); strSql.Append("attr_price=@attr_price"); strSql.Append(" where goods_attr_id=@goods_attr_id"); MySqlParameter[] parameters = { new MySqlParameter("@goods_id", MySqlDbType.Int32, 8), new MySqlParameter("@attr_id", MySqlDbType.Int16, 5), new MySqlParameter("@attr_value", MySqlDbType.Text), new MySqlParameter("@attr_price", MySqlDbType.VarChar, 255), new MySqlParameter("@goods_attr_id", MySqlDbType.Int32, 10) }; parameters[0].Value = model.goods_id; parameters[1].Value = model.attr_id; parameters[2].Value = model.attr_value; parameters[3].Value = model.attr_price; parameters[4].Value = model.goods_attr_id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.ecs_goods_attr DataRowToModel(DataRow row) { XHD.Model.ecs_goods_attr model = new XHD.Model.ecs_goods_attr(); if (row != null) { if (row["goods_attr_id"] != null && row["goods_attr_id"].ToString() != "") { model.goods_attr_id = int.Parse(row["goods_attr_id"].ToString()); } //model.goods_id=row["goods_id"].ToString(); if (row["attr_id"] != null && row["attr_id"].ToString() != "") { model.attr_id = int.Parse(row["attr_id"].ToString()); } if (row["attr_value"] != null) { model.attr_value = row["attr_value"].ToString(); } if (row["attr_price"] != null) { model.attr_price = row["attr_price"].ToString(); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(XHD.Model.ecs_goods_attr model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ecs_goods_attr("); strSql.Append("goods_id,attr_id,attr_value,attr_price)"); strSql.Append(" values ("); strSql.Append("@goods_id,@attr_id,@attr_value,@attr_price)"); MySqlParameter[] parameters = { new MySqlParameter("@goods_id", MySqlDbType.Int32, 8), new MySqlParameter("@attr_id", MySqlDbType.Int16, 5), new MySqlParameter("@attr_value", MySqlDbType.Text), new MySqlParameter("@attr_price", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.goods_id; parameters[1].Value = model.attr_id; parameters[2].Value = model.attr_value; parameters[3].Value = model.attr_price; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public XHD.Model.ecs_goods_attr GetModel(int goods_attr_id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select goods_attr_id,goods_id,attr_id,attr_value,attr_price from ecs_goods_attr "); strSql.Append(" where goods_attr_id=@goods_attr_id"); MySqlParameter[] parameters = { new MySqlParameter("@goods_attr_id", MySqlDbType.Int32) }; parameters[0].Value = goods_attr_id; XHD.Model.ecs_goods_attr model = new XHD.Model.ecs_goods_attr(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }