Example #1
0
        /// <summary>
        /// this is a click event for delete journey
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonDeleteJourney_Clicked(object sender, RoutedEventArgs e)
        {
            Button  deleteJourneyButton = (Button)sender;
            Journey journey             = deleteJourneyButton.DataContext as Journey;

            journeyList.Remove(journey);
            string deleteJourneySQL = "DELETE FROM `nmt_fleet_manager`.`journeys`" +
                                      " WHERE `id`='" + journey.id + "'";

            using (MySqlCommand cmdSel = new MySqlCommand(deleteJourneySQL, connection))
            {
                DataTable        dt = new DataTable();
                MySqlDataAdapter da = new MySqlDataAdapter(cmdSel);
                da.SelectCommand = cmdSel;
                da.Fill(dt);
            }
        }
Example #2
0
        /// <summary>
        /// this is a click event for editJourney
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonEditJourney_Clicked(object sender, RoutedEventArgs e)
        {
            Button      journeyEditButton = sender as Button;
            Journey     journey           = journeyEditButton.DataContext as Journey;
            EditJourney editJourneyWindow = new EditJourney(journey.id, journey.JourneyStartAt, journey.JourneyEndedAt,
                                                            journey.StartOdometer, journey.EndOdometer, journey.JourneyFrom, journey.JourneyTo, journey.selectedVehicle);

            editJourneyWindow.Owner = this;
            editJourneyWindow.WindowStartupLocation =
                WindowStartupLocation.CenterOwner;

            if (editJourneyWindow.ShowDialog() == true)
            {
                UpdateStatus(5000, "Journey Updated");
                FillJourneyTable();
                UpdateStatus(50, "Ready...");
            }
            editJourneyWindow.Close();
        }