예제 #1
0
    public void InitSmartTree()
    {
        this.sTreeModule.Nodes.Clear();
        try
        {
            string    strUserName  = Session["G_User"].ToString();
            DataTable dtModules    = objUser.GetUserOperateModule(strUserName).Tables[0];    //dc.GetModules(strUserName);
            DataTable dtSubModules = objUser.GetUserOperateSubModule(strUserName).Tables[0]; //dc.GetSubModules(strUserName);

            foreach (DataRow dr in dtModules.Rows)
            {
                TreeNode tnRoot = new TreeNode(dr["MenuTitle"].ToString(), dr["ID"].ToString());
                tnRoot.SelectAction = TreeNodeSelectAction.Expand;
                tnRoot.ShowCheckBox = true;
                this.sTreeModule.Nodes.Add(tnRoot);
            }

            if (dtModules.Rows.Count > 0)
            {
                foreach (DataRow drSub in dtSubModules.Rows)
                {
                    for (int i = 0; i < sTreeModule.Nodes.Count; i++)
                    {
                        if (sTreeModule.Nodes[i].Text == drSub["MenuParent"].ToString())
                        {
                            TreeNode tnChild = new TreeNode(drSub["MenuTitle"].ToString(), drSub["ID"].ToString());
                            tnChild.ShowCheckBox = true;
                            tnChild.SelectAction = TreeNodeSelectAction.Expand;
                            this.sTreeModule.Nodes[i].ChildNodes.Add(tnChild);
                            break;
                        }
                    }
                }
            }
        }
        catch (Exception e)
        {
            Session["ModuleName"]             = "浏览公共模块";
            Session["FunctionName"]           = "Page_Load";
            Session["ExceptionalType"]        = e.GetType().FullName;
            Session["ExceptionalDescription"] = e.Message;
            Response.Redirect("~/Common/MistakesPage.aspx");
        }
    }