コード例 #1
0
 public void AddNewUser()
 {
     _selectedUser = new User("",
                              "",
                              "",
                              "",
                              User.SexOfPerson.Male);
     this.updateViewDetailValues(_selectedUser);
     this._view.CanModifyID = true;
 }
コード例 #2
0
        public void UpdateGrid(User usr)
        {
            ListViewItem rowToUpdate = null;
            foreach (ListViewItem row in this.listUser.Items)
            {
                if (row.Text == usr.ID)
                {
                    rowToUpdate = row;
                }

                if (rowToUpdate != null)
                {
                    rowToUpdate.Text = usr.ID;
                    rowToUpdate.SubItems[1].Text = usr.FirstName;
                    rowToUpdate.SubItems[2].Text = usr.LastName;
                    rowToUpdate.SubItems[3].Text = usr.Departement;
                    rowToUpdate.SubItems[4].Text = Enum.GetName(typeof(User.SexOfPerson), usr.Sex);
                }
            }
        }
コード例 #3
0
 public void SetSelectedUser(User usr)
 {
     foreach (ListViewItem row in this.listUser.Items)
     {
         if (row.Text == usr.ID)
         {
             row.Selected = true;
         }
     }
 }
コード例 #4
0
        public void RemoveUser(User usr)
        {
            ListViewItem rowToRemove = null;
            foreach (ListViewItem row in this.listUser.Items)
            {
                if (row.Text == usr.ID)
                {
                    rowToRemove = row;
                }

                if (rowToRemove != null)
                {
                    this.listUser.Items.Remove(rowToRemove);
                    this.listUser.Focus();
                }
            }
        }
コード例 #5
0
 public void AddUserToGrid(User usr)
 {
     ListViewItem parent;
     parent = this.listUser.Items.Add(usr.ID);
     parent.SubItems.Add(usr.FirstName);
     parent.SubItems.Add(usr.LastName);
     parent.SubItems.Add(usr.Departement);
     parent.SubItems.Add(Enum.GetName(typeof(User.SexOfPerson), usr.Sex));
 }
コード例 #6
0
 private void updateViewDetailValues(User usr)
 {
     _view.ID = usr.ID;
     _view.FirstName = usr.FirstName;
     _view.LastName = usr.LastName;
     _view.Departement = usr.Departement;
     _view.Sex = usr.Sex;
 }
コード例 #7
0
 private void updateUserWithViewValues(User usr)
 {
     usr.ID = _view.ID;
     usr.FirstName = _view.FirstName;
     usr.LastName = _view.LastName;
     usr.Departement = _view.Departement;
     usr.Sex = _view.Sex;
 }
コード例 #8
0
 public void SelectedUserChanged(string selectedUserID)
 {
     foreach (User usr in this._users)
     {
         if (usr.ID == selectedUserID)
         {
             _selectedUser = usr;
             updateViewDetailValues(usr);
             _view.SetSelectedUser(usr);
             this._view.CanModifyID = false;
             break;
         }
     }
 }