private void BtnRedactClick(object sender, RoutedEventArgs e) { var selected = DataGrid.SelectedItem as AccountRole; if (selected != null) { if (selected.RoleName == RepositoryAccountUser.MainRoleName) { MessageBox.Show(Properties.Resources.MessageIsAdmin, Properties.Resources.LabelWarning, MessageBoxButton.OK, MessageBoxImage.Warning); } else { var window = new AddRole(selected); if (window.ShowDialog() == true) { selected.RoleName = window.RoleName; selected.Privelegies = window.Priveleges; RepositoryAccountRole.SaveFile(); DataGrid.ItemsSource = null; DataGrid.ItemsSource = RepositoryAccountRole.AccountRoles; } } } }
private void BtnAddClick(object sender, RoutedEventArgs e) { var window = new AddRole(); if (window.ShowDialog() == true) { RepositoryAccountRole.AccountRoles.Add(new AccountRole(Guid.NewGuid(), window.RoleName, window.Priveleges)); RepositoryAccountRole.SaveFile(); DataGrid.ItemsSource = null; DataGrid.ItemsSource = RepositoryAccountRole.AccountRoles; } }