private void treeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { TreeNode node = e.Node; string s = node.Text; hbm.Department dep = DepartmentData.GetDepartmentFromName(s); IList list; if (dep == null) { list = UserData.GetUsers(); } else { list = dep.Users; } listView1.Items.Clear(); foreach (Object o in list) { hbm._User user = (hbm._User)o; ListViewItem item = new ListViewItem(); item.Text = user.UserID; item.SubItems.Add(user.Name); item.SubItems.Add(Convert.ToString(user.Sex)); item.SubItems.Add(Convert.ToString(user.Password)); item.SubItems.Add(Convert.ToString(user.IsOnline)); listView1.Items.Add(item); } }
private void UserManager_Load(object sender, System.EventArgs e) { TreeNode node = new TreeNode(); node.Text = "技术中心"; IList deps = DepartmentData.LoadDepartments(); foreach (object o in deps) { hbm.Department dep = (hbm.Department)o; TreeNode node1 = new TreeNode(); node1.Text = dep.DepartmentName; node.Nodes.Add(node1); } treeView1.Nodes.Add(node); treeView1.ExpandAll(); }
private void treeView1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if (e.Data.GetDataPresent(typeof(ListViewItem))) { ListViewItem item = (ListViewItem)e.Data.GetData(typeof(ListViewItem)); Point pt = new Point(e.X, e.Y); pt = this.PointToClient(pt); // treeView1.Select(); TreeNode node = treeView1.GetNodeAt(pt); if (node == null) { MessageBox.Show(this, "Not Found!"); return; } hbm.Department dep = DepartmentData.GetDepartmentFromName(node.Text); hbm._User user = UserData.GetUserFromUserID(item.Text); UserData.MoveToDep(user, dep); listView1.Items.Remove(item); MessageBox.Show(this, item.Text + dep.DepartmentName); } }