示例#1
0
        private void BindControls()
        {
            UsersRepository usersRepository = new UsersRepository();
                bindingSourceUsers.Clear();
                bindingSourceUsers.DataSource = usersRepository.GetAll();
                dataGridViewUsers.DataSource = bindingSourceUsers;

                AdjustControlsVisibilitty();
        }
示例#2
0
        private void toolStripButtonAdd_Click(object sender, EventArgs e)
        {
            User user = new User();
            FormAddEditUser formAddUser = new FormAddEditUser(user);

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

                BindControls();
            }
        }
示例#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();
            }
        }
 public static User AuthenticateUser(string username, string password)
 {
     UsersRepository userRepository = new UsersRepository();
     LoggedUser = userRepository.GetByUsernameAndPassword(username, password);
     return LoggedUser;
 }