/// <summary> /// Reader returns fields: /// GroupId, GroupName, HasChildren /// </summary> public static IDataReader GetListChildGroups(int group_id) { if (!CanRead(group_id)) { throw new AccessDeniedException(); } return(DBGroup.GetListChildGroups(group_id)); }
private static void GenerateTree(int ParentGroupId, int CurrentLevel, ref DataTable dt) { List <GroupInfo> groups = new List <GroupInfo>(); using (IDataReader reader = DBGroup.GetListChildGroups(ParentGroupId)) { while (reader.Read()) { GroupInfo gi = new GroupInfo((int)reader["GroupId"], Common.GetWebResourceString(reader["GroupName"].ToString()), (bool)reader["HasChildren"]); groups.Add(gi); } } // sorting groups.Sort(delegate(GroupInfo x, GroupInfo y) { return(x.GroupName.CompareTo(y.GroupName)); }); string Prefix = ""; for (int i = 0; i < CurrentLevel; i++) { Prefix += " "; } CurrentLevel++; foreach (GroupInfo group in groups) { DataRow dr = dt.NewRow(); dr["GroupId"] = group.GroupId; dr["GroupName"] = Prefix + group.GroupName; dt.Rows.Add(dr); if (group.HasChildren) { GenerateTree(group.GroupId, CurrentLevel, ref dt); } } }