private void BtnAdd_Click(object sender, RoutedEventArgs e) { UserWindow userWindow = new UserWindow(); userWindow.ShowDialog(); if ((bool)userWindow.DialogResult) { repo.AddNewUser(userWindow.NewUser); PopulateDataGrid(); } }
/* * Button used to add a new record to the database */ private void btnAddUser_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtName.Text) || string.IsNullOrEmpty(txtPassword.Password)) { MessageBox.Show("Name and password fields cannot be empty", "Empty fields", MessageBoxButton.OK, MessageBoxImage.Error); } else { User user = new User() { Name = txtName.Text, Password = txtPassword.Password, UserAccount = new Account() { Balance = 0 } }; // Calls the method to add a new record in the ViewModel class. repo.AddNewUser(user); this.Close(); } }