private void UpdateButton_Click(object sender, RoutedEventArgs e) { nameInput = NameTextBox.Text.Trim(); mailInput = MailTextBox.Text.Replace(" ", ""); if (!IsNameAndMailCorrect(nameInput, mailInput, "Updating user")) { return; } if (currentUser != null) { currentUser.Name = nameInput; currentUser.Mail = mailInput; RefreshListBoxes(); ClearTextFields(); UserListBox.UnselectAll(); SetUserButtons(false); } else if (currentAdmin != null) { currentAdmin.Name = nameInput.Trim(); currentAdmin.Mail = mailInput.Replace(" ", ""); RefreshListBoxes(); ClearTextFields(); AdminListBox.UnselectAll(); SetAdminButtons(false); } }
private void UserCreationButton_Click(object sender, RoutedEventArgs e) //todo = conecta till CheckInput { NewUser(); EnterNameTextbox.Clear(); EnterEmailTextbox.Clear(); AdminListBox.UnselectAll(); UserListBox.UnselectAll(); ButtonsDisabled(); }
private void ToAdminButton_Click(object sender, RoutedEventArgs e) { User.ToAdmin(currentUser); currentUser = null; UserListBox.UnselectAll(); RefreshListBoxes(); ClearTextFields(); UserListBox.UnselectAll(); SetUserButtons(false); }
private void AdminListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (AdminListBox.SelectedItem != null) { UserListBox.UnselectAll(); ClearTextFields(); SetUserButtons(false); SetAdminButtons(true); currentUser = null; currentAdmin = (AdminListBox.SelectedItem as User); NameTextBox.Text = currentAdmin.Name; MailTextBox.Text = currentAdmin.Mail; MailAdminLabel.Content = $"Mail: {currentAdmin.Mail}"; } }
private void AdminListBox_SelectionChange(object sender, SelectionChangedEventArgs e) { DemoteButton.IsEnabled = true; UserDeletionButton.IsEnabled = true; UsrerModificationButton.IsEnabled = true; if ((User)AdminListBox.SelectedItem != null) { UserListBox.UnselectAll(); UserInfoLabel.Content = "Admin: " + ((User)AdminListBox.SelectedItem).UserName + "\nEmail Adress: " + ((User)AdminListBox.SelectedItem).Email; } else { UserInfoLabel.Content = string.Empty; } }
private void DeleteButton_Click(object sender, RoutedEventArgs e) { if (currentUser != null) { User.users.Remove(currentUser); currentUser = null; RefreshListBoxes(); ClearTextFields(); UserListBox.UnselectAll(); SetUserButtons(false); } else if (currentAdmin != null) { User.admins.Remove(currentAdmin); currentAdmin = null; RefreshListBoxes(); ClearTextFields(); AdminListBox.UnselectAll(); SetAdminButtons(false); } }