示例#1
0
    protected void DisplayRoleRighMenu()
    {
        ////根据角色Id和父节点Id从RoleRight表中获得当前孩子菜单拥有的权限
        //IList<RoleRight> currentRoleChildNodes = RoleRightManager.GetParentNodesByRoleIdOrParentId(this.RoleId,this.ParentNodeId);
        //ArrayList arrRoleChildNodes = new ArrayList();
        //foreach (RoleRight roleRight in currentRoleChildNodes)
        //{
        //    arrRoleChildNodes.Add(roleRight.Node.NodeId.ToString());
        //}
        ////根据父节点Id得到对应的所有子节点信息
        //IList<SysFun> sysFuns = SysFunManager.GetSysFunByParentNodeIdAndUserId(this.ParentNodeId,null);
        ////将子节点循环追加到CheckBoxList控件中
        //foreach(SysFun sf in sysFuns){
        //    ListItem li = new ListItem();
        //    li.Value = sf.NodeId.ToString();
        //    li.Text = sf.DisplayName;
        //    if(arrRoleChildNodes.Contains(li.Value)) li.Selected = true;
        //    chklstChildMenu.Items.Add(li);
        //}


        IList <SysFun> childLists        = SysFunManager.GetNodeByParentId(parentNodeId);
        IList <SysFun> currentChildLists = SysFunManager.GetNodeByParentIdAndRoleId(roleId, parentNodeId);
        ArrayList      currentSysLists   = new ArrayList();

        foreach (SysFun childSys in currentChildLists)
        {
            currentSysLists.Add(childSys.NodeId.ToString());
        }

        foreach (SysFun sys in childLists)
        {
            ListItem li = new ListItem(sys.DisplayName, sys.NodeId.ToString());
            if (currentSysLists.Contains(sys.NodeId.ToString()))
            {
                li.Selected = true;
            }
            this.chklstChildMenu.Items.Add(li);
        }
    }
示例#2
0
    /// <summary>
    /// 递归添加节点
    /// </summary>
    /// <param name="treeNodeCollection">父级节点</param>
    /// <param name="nodeId">SysFun表中的父ID</param>
    private void CreateTreeNode(TreeNodeCollection treeNodeCollection, int nodeId)
    {
        IList <SysFun> lists = SysFunManager.GetNodeByParentId(nodeId);

        foreach (SysFun sys in lists)
        {
            TreeNode tn = null;
            if (nodeId == 0)
            {
                tn = new TreeNode(sys.DisplayName, sys.NodeId.ToString());
            }
            else
            {
                tn = new TreeNode(sys.DisplayName, sys.NodeId.ToString(), "~/images/CloseTree.gif");
            }
            if (tn.Value.Equals(ViewState["nodeId"]))
            {
                tn.Selected = true;
            }
            treeNodeCollection.Add(tn);

            CreateTreeNode(tn.ChildNodes, sys.NodeId);
        }
    }