Example #1
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Вы уверены, что хотите удалить эту запись?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                int flag = sqlManager.Delete("DELETE FROM " + (tables.SelectedItem as DataRowView).Row.ItemArray[0].ToString() +
                                             " WHERE " + dataTable.Columns[0] + " = " + (datagrid.SelectedItem as DataRowView).Row.ItemArray[0]);
                if (flag == 0)
                {
                    MessageBox.Show("Запись невозможно удалить из-за ограничения!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else if (flag == -2)
                {
                    ShowConnectionError();
                }
                else
                {
                    dataTable.Rows.Remove((datagrid.SelectedItem as DataRowView).Row);
                    ShowTable();
                    MessageBox.Show("Запись успешно удалена.", "", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                AddNew.Visibility = Visibility.Visible;
                Update.Visibility = Visibility.Hidden;
                Delete.Visibility = Visibility.Hidden;
                Save.Visibility   = Visibility.Hidden;
                Reset.Visibility  = Visibility.Hidden;
            }
        }
Example #2
0
        private void Delete_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult res = MessageBox.Show("Вы уверены, что хотите удалить свой аккаунт?", "", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (res == MessageBoxResult.Yes)
            {
                int flag = sqlManager.Delete("DELETE FROM Tourists WHERE Num_tourist = " + DataPerson.id);
                if (flag != -2)
                {
                    foreach (Window window in Application.Current.Windows)
                    {
                        if (window is TourismWindow)
                        {
                            MainWindow mw = new MainWindow();
                            mw.Show();
                            window.Close();
                        }
                    }
                }
                else if (flag == -2)
                {
                    PagesManager.ShowConnectionError();
                }
            }
        }