privilegeinrolesbll.cs

来自「通用权限管理平台」· CS 代码 · 共 52 行

CS
52
字号
//----------------------------------------------------------------
// <copyright file="PrivilegeInRolesBLL.cs" >
//    Copyright (c) Wenzy , All rights reserved.
//    author:温正宇 E-Mail:wenzy@tom.com MyBlog:wenzy.cnblogs.com
//    All rights reserved.
// </copyright>
//----------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using MemberShipDAL.DataObject.DataResourcesTableAdapters;
using MemberShipDAL.DataObject;
using System.Windows.Forms;

namespace WMFConfig.Bussiness
{
    public class PrivilegeInRolesBLL
    {
        /// <summary>
        /// 删除正在使用的权限
        /// </summary>
        /// <param name="operationId"></param>
        /// <param name="resourcesId"></param>
        public void DeletePrivilegeInRoles(int operationId, Guid resourcesId)
        {
            //获得当前权限的ID
            Guid? privilegeId = new wmf_PrivilegeTableAdapter().GetPrivilegeIdByOptResId(operationId, resourcesId);

            DeletePrivilegeInRoles(privilegeId.Value);
        }

        public void DeletePrivilegeInRoles(Guid privilegeId)
        {
            wmf_PrivilegeInRolesTableAdapter pDa = new wmf_PrivilegeInRolesTableAdapter();

            int i = (int)pDa.CountByPrivilegeId(privilegeId);

            //如果PrivilegeID有在PrivilegeInRoles表里面,表示有在使用,那么就要删除
            if (i != 0)
            {
                //如果用户确认删除
                if (MessageBox.Show("您确认要删除正在使用的权限[" + privilegeId + "]吗?", "删除提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    i = pDa.DeleteByPrivilegeId(privilegeId);
                }
                //要做一个系统优化的功能,把没有删除干净的权限清理掉
            }

        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?