Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        private void mnuAddUser_Click(object sender, System.EventArgs e)
        {
            TreeNode   node = treeView1.SelectedNode;
            Department dep  = DepartmentData.GetDepartmentFromName(node.Text);
            AddUser    au   = new AddUser();

            if (au.ShowDialog() == DialogResult.OK)
            {
                string User_ID  = au.UserID;
                string UserName = au.UserName;
                string UserPass = au.UserPass;
                string UserSex  = au.UserSex;

                UserData.SaveUser(User_ID, UserName, UserSex, UserPass, dep);
                ListViewItem item = new ListViewItem();
                item.Text = User_ID;
                item.SubItems.Add(UserName);
                item.SubItems.Add(UserSex);
                item.SubItems.Add(UserPass);
                listView1.Items.Add(item);
            }
        }