Exemplo n.º 1
0
        private SystemTreeNodeInfo GetNode(string id, DataTable dt)
        {
            SystemTreeInfo     info     = this.FindByID(id);
            SystemTreeNodeInfo nodeInfo = new SystemTreeNodeInfo(info);

            DataRow[] dChildRows = dt.Select(string.Format(" PID='{0}'", id));
            for (int i = 0; i < dChildRows.Length; i++)
            {
                string             childId       = dChildRows[i]["ID"].ToString();
                SystemTreeNodeInfo childNodeInfo = GetNode(childId, dt);
                nodeInfo.Children.Add(childNodeInfo);
            }
            return(nodeInfo);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取树形结构的菜单列表
        /// </summary>
        public List <SystemTreeNodeInfo> GetTree(string category)
        {
            string condition = !string.IsNullOrEmpty(category) ? string.Format("AND Category='{0}'", category) : "";
            List <SystemTreeNodeInfo> nodeList = new List <SystemTreeNodeInfo>();
            string sql = string.Format("Select * From {0} Where Visible > 0 {1} Order By PID, Seq ", tableName, condition);

            DataTable dt = base.SqlTable(sql);

            DataRow[] dataRows = dt.Select(string.Format(" PID = '{0}' ", -1));
            for (int i = 0; i < dataRows.Length; i++)
            {
                string             id       = dataRows[i]["ID"].ToString();
                SystemTreeNodeInfo nodeInfo = GetNode(id, dt);
                nodeList.Add(nodeInfo);
            }

            return(nodeList);
        }