/// <summary> /// 获得所有分组集合 /// </summary> public static List <exGroup> GetGroups() { List <exGroup> Groups = new List <exGroup>(); string sql = "select * from Groups order by orderID "; System.Data.SQLite.SQLiteDataReader dr = SQLiteDBHelper.ExecuteReader(sql, null); if (dr != null) { while (dr.Read()) { exGroup group = new exGroup(); { group.GroupID = Convert.ToString(dr["GroupID"]); group.GroupName = Convert.ToString(dr["GroupName"]); group.SuperiorID = Convert.ToString(dr["SuperiorID"]); group.OrderID = Convert.ToInt32(dr["orderID"]); } Groups.Add(group); } dr.Close(); } dr.Dispose(); return(Groups); }
/// <summary> /// 在treeView中的groups中添加用户 /// </summary> /// <param name="groups"></param> /// <param name="users"></param> private void addUserToTreeView(List <exUser> users, List <exGroup> groups) { if (users == null || groups == null) { return; } foreach (exUser user in users) { exGroup group = findGroup(user.GroupID, groups); if (group != null && group.TreeNode != null) { TreeNode node = new TreeNode(); node.Text = user.UserName; node.ToolTipText = user.UserName; node.ImageIndex = 0; node.SelectedImageIndex = 0; node.Tag = user; user.TreeNode = node; TreeNode groupNode = group.TreeNode as TreeNode; if (groupNode != null) { groupNode.Nodes.Add(node); } //user.Group = group; //user.Group.UserCount++; } } }