/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.users.user_groups model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "user_groups set "); strSql.Append("title=@title,"); strSql.Append("grade=@grade,"); strSql.Append("upgrade_exp=@upgrade_exp,"); strSql.Append("amount=@amount,"); strSql.Append("point=@point,"); strSql.Append("discount=@discount,"); strSql.Append("is_default=@is_default,"); strSql.Append("is_upgrade=@is_upgrade,"); strSql.Append("is_lock=@is_lock"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@grade", SqlDbType.Int, 4), new SqlParameter("@upgrade_exp", SqlDbType.Int, 4), new SqlParameter("@amount", SqlDbType.Decimal, 5), new SqlParameter("@point", SqlDbType.Int, 4), new SqlParameter("@discount", SqlDbType.Int, 4), new SqlParameter("@is_default", SqlDbType.TinyInt, 1), new SqlParameter("@is_upgrade", SqlDbType.TinyInt, 1), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.title; parameters[1].Value = model.grade; parameters[2].Value = model.upgrade_exp; parameters[3].Value = model.amount; parameters[4].Value = model.point; parameters[5].Value = model.discount; parameters[6].Value = model.is_default; parameters[7].Value = model.is_upgrade; parameters[8].Value = model.is_lock; parameters[9].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.users.user_groups model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "user_groups("); strSql.Append("title,grade,upgrade_exp,amount,point,discount,is_default,is_upgrade,is_lock)"); strSql.Append(" values ("); strSql.Append("@title,@grade,@upgrade_exp,@amount,@point,@discount,@is_default,@is_upgrade,@is_lock)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@grade", SqlDbType.Int, 4), new SqlParameter("@upgrade_exp", SqlDbType.Int, 4), new SqlParameter("@amount", SqlDbType.Decimal, 5), new SqlParameter("@point", SqlDbType.Int, 4), new SqlParameter("@discount", SqlDbType.Int, 4), new SqlParameter("@is_default", SqlDbType.TinyInt, 1), new SqlParameter("@is_upgrade", SqlDbType.TinyInt, 1), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1) }; parameters[0].Value = model.title; parameters[1].Value = model.grade; parameters[2].Value = model.upgrade_exp; parameters[3].Value = model.amount; parameters[4].Value = model.point; parameters[5].Value = model.discount; parameters[6].Value = model.is_default; parameters[7].Value = model.is_upgrade; parameters[8].Value = model.is_lock; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.users.user_groups model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.users.user_groups model) { return(dal.Add(model)); }