/// <summary> /// 增加一条数据 /// </summary> public bool Add(TextileCity.Entity.Category model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into category("); strSql.Append("parentid,name,type,order_index)"); strSql.Append(" values ("); strSql.Append("?parentid,?name,?type,?order_index)"); MySqlParameter[] parameters = { new MySqlParameter("?parentid", MySqlDbType.Int32,10), new MySqlParameter("?name", MySqlDbType.VarChar,50), new MySqlParameter("?type", MySqlDbType.Enum), new MySqlParameter("?order_index", MySqlDbType.Int32,10)}; parameters[0].Value = model.ParentID; parameters[1].Value = model.Name; parameters[2].Value = model.Type; parameters[3].Value = model.OrderIndex; int rows=MysqlHelper.ExecuteNonQuery(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(TextileCity.Entity.Material model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into material("); strSql.Append("category_id,type,name,price,price_high,price_fancy,styles,intro,main_image,images)"); strSql.Append(" values ("); strSql.Append("?category_id,?type,?name,?price,?price_high,?price_fancy,?styles,?intro,?main_image,?images)"); MySqlParameter[] parameters = { new MySqlParameter("?category_id", MySqlDbType.Int32,10), new MySqlParameter("?type", MySqlDbType.Enum), new MySqlParameter("?name", MySqlDbType.VarChar,200), new MySqlParameter("?price", MySqlDbType.Decimal,12), new MySqlParameter("?price_high", MySqlDbType.Decimal,12), new MySqlParameter("?price_fancy", MySqlDbType.Decimal,12), new MySqlParameter("?styles", MySqlDbType.Text), new MySqlParameter("?intro", MySqlDbType.VarChar,500), new MySqlParameter("?main_image", MySqlDbType.VarChar,500), new MySqlParameter("?images", MySqlDbType.Text)}; parameters[0].Value = model.CategoryID; parameters[1].Value = model.CategoryType; parameters[2].Value = model.Name; parameters[3].Value = model.Price; parameters[4].Value = model.PriceHigh; parameters[5].Value = model.PriceFancy; parameters[6].Value = model.StylesList; parameters[7].Value = model.Intro; parameters[8].Value = model.MainImage; parameters[9].Value = model.Images; int rows = MysqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(TextileCity.Entity.Material model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update material set "); strSql.Append("category_id=?category_id,"); strSql.Append("type=?type,"); strSql.Append("name=?name,"); strSql.Append("price=?price,"); strSql.Append("price_high=?price_high,"); strSql.Append("price_fancy=?price_fancy,"); strSql.Append("styles=?styles,"); strSql.Append("intro=?intro,"); strSql.Append("main_image=?main_image,"); strSql.Append("images=?images"); strSql.Append(" where id=?id"); MySqlParameter[] parameters = { new MySqlParameter("?category_id", MySqlDbType.Int32,10), new MySqlParameter("?type", MySqlDbType.Enum), new MySqlParameter("?name", MySqlDbType.VarChar,200), new MySqlParameter("?price", MySqlDbType.Decimal,12), new MySqlParameter("?price_high", MySqlDbType.Decimal,12), new MySqlParameter("?price_fancy", MySqlDbType.Decimal,12), new MySqlParameter("?styles", MySqlDbType.Text), new MySqlParameter("?intro", MySqlDbType.VarChar,500), new MySqlParameter("?main_image", MySqlDbType.VarChar,500), new MySqlParameter("?images", MySqlDbType.Text), new MySqlParameter("?id", MySqlDbType.Int32,10)}; parameters[0].Value = model.CategoryID; parameters[1].Value = model.CategoryType; parameters[2].Value = model.Name; parameters[3].Value = model.Price; parameters[4].Value = model.PriceHigh; parameters[5].Value = model.PriceFancy; parameters[6].Value = model.StylesList; parameters[7].Value = model.Intro; parameters[8].Value = model.MainImage; parameters[9].Value = model.Images; parameters[10].Value = model.MaterialID; int rows = MysqlHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(TextileCity.Entity.Category model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update category set "); strSql.Append("parentid=?parentid,"); strSql.Append("name=?name,"); strSql.Append("type=?type,"); strSql.Append("order_index=?order_index"); strSql.Append(" where id=?id"); MySqlParameter[] parameters = { new MySqlParameter("?parentid", MySqlDbType.Int32,10), new MySqlParameter("?name", MySqlDbType.VarChar,50), new MySqlParameter("?type", MySqlDbType.Enum), new MySqlParameter("?order_index", MySqlDbType.Int32,10), new MySqlParameter("?id", MySqlDbType.Int32,10)}; parameters[0].Value = model.ParentID; parameters[1].Value = model.Name; parameters[2].Value = model.Type; parameters[3].Value = model.OrderIndex; parameters[4].Value = model.CategoryID; int rows=MysqlHelper.ExecuteNonQuery(strSql.ToString(),parameters); if (rows > 0) { return true; } else { return false; } }