/// <summary>
        /// 修改系统权限
        /// </summary>
        /// <param name="permission">
        /// 权限对象
        /// </param>
        public void ModifyPermission(System_Permission permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException("permission");
            }

            this.systemPermissionDA.Update(permission);
        }
        /// <summary>
        /// 添加系统权限
        /// </summary>
        /// <param name="permission">
        /// 权限对象
        /// </param>
        /// <returns>
        /// 权限编号
        /// </returns>
        public int AddPermission(System_Permission permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException("permission");
            }

            return this.systemPermissionDA.Insert(permission);
        }
예제 #3
0
        /// <summary>
        /// 修改权限
        /// </summary>
        /// <param name="permission">
        /// 权限对象
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// 参数为空异常
        /// </exception>
        /// <exception cref="Exception">
        /// 操作数据库异常
        /// </exception>
        public void Update(System_Permission permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException("permission");
            }

            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ID",
                                         SqlDbType.Int,
                                         permission.ID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ParentID",
                                         SqlDbType.Int,
                                         permission.ParentID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         permission.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Layer",
                                         SqlDbType.Int,
                                         permission.Layer,
                                         ParameterDirection.Input),
                                 };

            try
            {
                this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Permission_Update", parameters, null);
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }
예제 #4
0
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="permission">
        /// 权限对象
        /// </param>
        /// <returns>
        /// 主键编号
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// 参数为空异常
        /// </exception>
        /// <exception cref="Exception">
        /// 数据库操作异常
        /// </exception>
        public int Insert(System_Permission permission)
        {
            if (permission == null)
            {
                throw new ArgumentNullException("permission");
            }

            int id;
            var parameters = new List<SqlParameter>
                                 {
                                     this.SqlServer.CreateSqlParameter(
                                         "ParentID",
                                         SqlDbType.Int,
                                         permission.ParentID,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Name",
                                         SqlDbType.NVarChar,
                                         permission.Name,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "Layer",
                                         SqlDbType.Int,
                                         permission.Layer,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "CreateTime",
                                         SqlDbType.DateTime,
                                         permission.CreateTime,
                                         ParameterDirection.Input),
                                     this.SqlServer.CreateSqlParameter(
                                         "ReferenceID",
                                         SqlDbType.Int,
                                         null,
                                         ParameterDirection.Output)
                                 };

            try
            {
                this.SqlServer.ExecuteNonQuery(CommandType.StoredProcedure, "sp_System_Permission_Insert", parameters, null);
                id = (int)parameters.Find(parameter => parameter.ParameterName == "ReferenceID").Value;
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }

            return id;
        }