コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static bool ModifyRole(Maticsoft.Model.Role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Role set ");
            strSql.Append("RoleName=@RoleName,");
            strSql.Append("IsAllow=@IsAllow,");
            strSql.Append("Weight=@Weight");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleName", SqlDbType.NVarChar, 50),
                new SqlParameter("@IsAllow",  SqlDbType.Int,       4),
                new SqlParameter("@Weight",   SqlDbType.Int,       4),
                new SqlParameter("@Id",       SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.IsAllow;
            parameters[2].Value = model.Weight;
            parameters[3].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                UpdateRoleInfo();
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static long AddRole(Maticsoft.Model.Role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Role(");
            strSql.Append("RoleName,IsAllow,Weight)");
            strSql.Append(" values (");
            strSql.Append("@RoleName,@IsAllow,@Weight)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RoleName", SqlDbType.NVarChar, 50),
                new SqlParameter("@IsAllow",  SqlDbType.Int,       4),
                new SqlParameter("@Weight",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RoleName;
            parameters[1].Value = model.IsAllow;
            parameters[2].Value = model.Weight;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                UpdateRoleInfo();
                return(Convert.ToInt64(obj));
            }
        }
コード例 #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Maticsoft.Model.Role model)
 {
     return(dal.Update(model));
 }
コード例 #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.Role model)
 {
     return(dal.Add(model));
 }