Example #1
0
        /// <summary>
        /// 递归获取子节点
        /// </summary>
        /// <param name="pid">父节点参数</param>
        /// <returns></returns>
        private List <yyyu.Common.TreeList.TreeObject> GetChild(string pid)
        {
            yyyu.BLL.yyyu_tblSysMenu bll = new yyyu.BLL.yyyu_tblSysMenu();
            DataTable dt = bll.GetList("Menu_ParentId=" + pid).Tables[0];//获取数据
            List <yyyu.Common.TreeList.TreeObject> list = new List <yyyu.Common.TreeList.TreeObject>();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                yyyu.Common.TreeList.TreeObject tree = new yyyu.Common.TreeList.TreeObject();
                tree.Id       = dt.Rows[i]["Menu_Id"].ToString();
                tree.Name     = dt.Rows[i]["Name"].ToString();
                tree.Pid      = dt.Rows[i]["Menu_ParentId"].ToString();
                tree.ShowName = dt.Rows[i]["ShowName"].ToString();
                if (dt.Rows[i]["NodeUrl"].ToString() == "" || dt.Rows[i]["NodeUrl"] == null)
                {
                    tree.url = "";
                }
                else
                {
                    tree.url = dt.Rows[i]["NodeUrl"].ToString();
                }
                DataTable dt1 = bll.GetList("Menu_ParentId=" + tree.Id).Tables[0];//获取数据
                if (dt1 != null)
                {
                    tree.Children = GetChild(tree.Id);
                }
                list.Add(tree);
            }
            return(list);
        }
Example #2
0
        //递归读取菜单
        public string GetMenu()
        {
            yyyu.BLL.yyyu_tblSysMenu bll = new yyyu.BLL.yyyu_tblSysMenu();
            DataSet ds = bll.GetList("IsActive=1");                     //获取数据
            List <yyyu.Common.TreeList.TreeObject> list = GetPNode(ds); //转换数据为树结构
            //传入list,转化为HTML代码输出
            string strJson = MenuForHtml(list);

            return(strJson);
        }