//Tree递归调用 public List <tree> getChildren(string tableName, string fid, int RoleId) { DBHelperSql Dbhelper = new DBHelperSql(); List <tree> list = new List <tree>(); DataTable dt = Dbhelper.GetDataTable(tableName, " ParentId='" + fid + "' "); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { tree tree = new tree(); tree.id = dt.Rows[i]["NavName"].ToString(); tree.text = dt.Rows[i]["TitleName"].ToString(); if (OperateBll.IsOkRoleoperateDataExist(dt.Rows[i]["NavName"].ToString(), RoleId)) { tree.@checked = true; } tree.children = getChildren(tableName, dt.Rows[i]["id"].ToString(), RoleId); list.Add(tree); } } else { list = null; } return(list); }
//Tree递归调用 public List <tree> getChildren(string tableName, string fid) { DBHelperSql Dbhelper = new DBHelperSql(); List <tree> list = new List <tree>(); if (fid == "0") { tree tree1 = new tree(); tree1.id = "0"; tree1.text = "一级主栏目"; list.Add(tree1); } DataTable dt = Dbhelper.GetDataTable(tableName, " ParentId='" + fid + "' and ViewFlag='1' "); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { tree tree = new tree(); tree.id = dt.Rows[i]["id"].ToString(); tree.text = dt.Rows[i]["TitleName"].ToString(); tree.children = getChildren(tableName, dt.Rows[i]["id"].ToString()); list.Add(tree); } } else { list = null; } return(list); }
/// <summary> /// 获取数据表 /// </summary> /// <returns></returns> public DataTable GetDataTable() { this.Item_db = new DBHelperSql(); return(Item_db.GetDataTable(tablename, ConditionStr)); }