Beispiel #1
0
        private void BtnAddClick(object sender, RoutedEventArgs e)
        {
            var window = new AddUser();

            if (window.ShowDialog() == true)
            {
                RepositoryAccountUser.AccountUsers.Add(new AccountUser(Guid.NewGuid(), window.Fio, window.Login, window.Password, window.Role.CustomerId, window.Pin));
                RepositoryAccountUser.SaveFile();

                DataGrid.ItemsSource = null;
                DataGrid.ItemsSource = RepositoryAccountUser.AccountUsers;
            }
        }
Beispiel #2
0
        private void BtnDelClick(object sender, RoutedEventArgs e)
        {
            var selected = DataGrid.SelectedItem as AccountUser;

            if (selected != null)
            {
                if (selected.Role.RoleName == RepositoryAccountUser.MainRoleName)
                {
                    MessageBox.Show(Properties.Resources.MessageIsAdmin, Properties.Resources.LabelWarning, MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    var result = MessageBox.Show(Properties.Resources.MessageDeleteQuestion, Properties.Resources.LabelQuestion, MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        RepositoryAccountUser.AccountUsers.Remove(selected);
                        RepositoryAccountUser.SaveFile();

                        DataGrid.ItemsSource = null;
                        DataGrid.ItemsSource = RepositoryAccountUser.AccountUsers;
                    }
                }
            }
        }