Exemple #1
0
 private void BindControls()
 {
     UsersRepository usersRepository = new UsersRepository();
     bindingSourceUsers.Clear();
     bindingSourceUsers.DataSource = usersRepository.GetAll();
     dataGridViewUsers.DataSource = bindingSourceUsers;
 }
Exemple #2
0
        private void toolStripButtonEdit_Click(object sender, EventArgs e)
        {
            User user = (User)bindingSourceUsers.Current;
            FormAddEditUser formAddUser = new FormAddEditUser(user);

            if (formAddUser.ShowDialog() == DialogResult.OK)
            {
                UsersRepository usersRepository = new UsersRepository();
                usersRepository.Save(user);

                BindControls();
            }
        }
Exemple #3
0
        private void toolStripButtonDelete_Click(object sender, EventArgs e)
        {
            User user = (User)bindingSourceUsers.Current;
            DialogResult result = MessageBox.Show("Are you sure you want to delete this user?",
                "Confirmation",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                UsersRepository usersRepository = new UsersRepository();
                usersRepository.Delete(user);
                BindControls();
            }
        }