Exemple #1
0
        private void btnDeleteUser_Click(object sender, RoutedEventArgs e)
        {
            if (!IsTrueDbConfig())
            {
                MessageBox.Show("Need right db configuration on the first tab.");
                return;
            }

            if (SelectedUser == null)
            {
                MessageBox.Show("Please select the user to delete.");
                return;
            }

            User           userToDelete = SelectedUser;
            DatabaseConfig config       = DbConfig;

            new Task((Action)(() =>
            {
                MsSqlDataProvider provider = new MsSqlDataProvider();
                DragonflyEntities context = provider.Initizlize(config) as DragonflyEntities;
                try
                {
                    provider.DeleteUser(userToDelete.Login);
                    Dispatcher.Invoke((Action)(() =>
                    {
                        LoadUsersRunner(config);
                    }));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            })).Start();
        }