Beispiel #1
0
        private void clientDel_Click(object sender, RoutedEventArgs e)
        {
            switch (mainTab.SelectedIndex)
            {
            case 0:
                Trips  selTrip = (Trips)tripGrid.SelectedItem;
                String sqlt    = "DELETE FROM Trips WHERE ID = " + selTrip.ID + ";";
                dbConnection.Open();
                SQLiteCommand scmdt = new SQLiteCommand(sqlt, dbConnection);
                scmdt.ExecuteNonQuery();
                dbConnection.Close();

                tripGrid.ItemsSource = null;
                tripGrid.ItemsSource = LoadTrips(dbConnection);
                break;

            case 1:
                /*Clients selClient = (Clients)clientGrid.SelectedItem;
                 * //String sqlQ = "DELETE FROM Clients WHERE ID = " + clientList[clientGrid.SelectedIndex].ID + ";";
                 * String sqlQ = "DELETE FROM Clients WHERE ID = " + selClient.ID + ";";
                 * dbConnection.Open();
                 * SQLiteCommand scmd = new SQLiteCommand(sqlQ, dbConnection);
                 * scmd.ExecuteNonQuery();
                 * dbConnection.Close();
                 *
                 * clientGrid.ItemsSource = null;
                 * clientGrid.ItemsSource = LoadClients(dbConnection);
                 *
                 * if (clientGrid.Items.Count == 0)
                 * {
                 *  clientDel.IsEnabled = false;
                 * }*/
                break;

            case 2:
                /* Cadets selCadet = (Cadets)cadetGrid.SelectedItem;
                 * String sqlQc = "DELETE FROM Cadets WHERE ID = " + selCadet.ID + ";";
                 * dbConnection.Open();
                 * SQLiteCommand scmdc = new SQLiteCommand(sqlQc, dbConnection);
                 * scmdc.ExecuteNonQuery();
                 * dbConnection.Close();
                 *
                 * cadetGrid.ItemsSource = null;
                 * cadetGrid.ItemsSource = LoadCadets(dbConnection);
                 *
                 * if (cadetGrid.Items.Count == 0)
                 * {
                 *   clientDel.IsEnabled = false;
                 * }*/
                break;
            }
        }
Beispiel #2
0
        private void tripFinish_Click(object sender, RoutedEventArgs e)
        {
            Trips selTrip = (Trips)tripGrid.SelectedItem;

            dbConnection = new SQLiteConnection("Data Source=" + DATABASE_FILE_NAME + ";Version=3");
            dbConnection.Open();

            string        sqlQ = "UPDATE trips SET isFinished = 1 WHERE ID = " + selTrip.ID;
            SQLiteCommand scmd = new SQLiteCommand(sqlQ, dbConnection);

            scmd.ExecuteNonQuery();

            dbConnection.Close();
            tripGrid.ItemsSource = null;
            tripGrid.ItemsSource = LoadTrips(dbConnection);
        }