Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void treeView_Roles_AfterSelect(object sender, TreeViewEventArgs e)
        {
            //获取根节点MenuType实体
            TreeNode parentNode = GetMenuTypeNode(e.Node);

            _curMenuType = ((MenuType)parentNode.Tag);

            //判断是否为角色节点
            if (e.Node.Parent != null)
            {
                _curRole = (Roles)e.Node.Tag;
                //查询角色权限
                _curRoleMenus = _roleMenusBll.GetModel(_curRole.RoleID);

                Init_TreeViewMenus(_curMenuType.MenuTypeID);

                Set_TreeViewMenus();
            }
        }
Exemple #2
0
        /// <summary>
        /// 获取用户权限
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        private bool GetUserRoleMenus(int userID)
        {
            _dicRoleMenus = new Dictionary <int, UserPermissions>();

            UserRoles userRoles = null;
            RoleMenus roleMenus = null;

            string[] ayyRoles = new string[0] {
            };

            //获取用户角色
            userRoles = _userRolesBll.GetModel(userID);

            if (userRoles == null || string.IsNullOrEmpty(userRoles.RoleID))
            {
                return(false);
            }

            ayyRoles = userRoles.RoleID.Split(',');

            for (int i = 0; i < ayyRoles.Length; i++)
            {
                //获取角色权限
                roleMenus = _roleMenusBll.GetModel(Convert.ToInt32(ayyRoles[i]));

                foreach (int key in roleMenus.DicPermissions.Keys)
                {
                    if (!_dicRoleMenus.ContainsKey(key))
                    {
                        //添加到权限字典
                        _dicRoleMenus.Add(key, roleMenus.DicPermissions[key]);
                    }
                }
            }

            return(true);
        }