// This event handler is fired when the roles to user roles button is clicked. It adds the selected role to // the list of user roles private void BtnRolesToUserRoles_Click(object sender, RoutedEventArgs e) { try { if (lbRoles.SelectedItems.Count == 0) { MessageBox.Show("You must make a role selection."); return; } if (_addMode) { return; } if (MessageBox.Show("Are you sure?", "Change Role Assignment", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { chkActive.IsChecked = !(bool)chkActive.IsChecked; return; } try { try { _userManager.DeleteUserRole(_user.PersonID, (string)lbRoles.SelectedItem); } catch (Exception) { } if (_userManager.AddUserRole(_user.PersonID, (string)lbRoles.SelectedItem)) { populateRoles(); } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); } } catch (Exception ex) { MessageBox.Show("You must make a role selection"); } }