/// <summary> /// this is a click event for save changes /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveChangesButton_Clicked(object sender, RoutedEventArgs e) { decimal fuelQuantity = decimal.Parse(TextBoxFuelQuantity.Text); decimal fuelPrice = decimal.Parse(TextBoxFuelPrice.Text); FuelPurchase fuelPurchase = new FuelPurchase(fuelQuantity, fuelPrice); string selectedVehicle = TextBoxSelectedVehicle.Text; string FuelQuantity = fuelPurchase.FuelQuantity.ToString(); string FuelPrice = fuelPurchase.FuelPrice.ToString(); string totalCost = fuelPurchase.TotalCost.ToString(); EditFuelPurchaseToDB(id, selectedVehicle, FuelQuantity, FuelPrice, totalCost); this.DialogResult = true; this.Close(); }
/// <summary> /// this is a click event for delete fuel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void deleteFuelButton_Clicked(object sender, RoutedEventArgs e) { Button deleteFuelButton = (Button)sender; FuelPurchase fuelPurchase = deleteFuelButton.DataContext as FuelPurchase; fuelPurchaseList.Remove(fuelPurchase); string deleteBookingSQL = "DELETE FROM `nmt_fleet_manager`.`fuel_purchases`" + " WHERE `id`='" + fuelPurchase.id + "'"; using (MySqlCommand cmdSel = new MySqlCommand(deleteBookingSQL, connection)) { DataTable dt = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(cmdSel); da.SelectCommand = cmdSel; da.Fill(dt); } }
/// <summary> /// this is a click event for edit fuel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editFuelButton_Clicked(object sender, RoutedEventArgs e) { Button fuelEditButton = sender as Button; FuelPurchase fuelPurchase = fuelEditButton.DataContext as FuelPurchase; EditFuelPurchases editFuelWindow = new EditFuelPurchases(fuelPurchase.id, fuelPurchase.FuelQuantity, fuelPurchase.FuelPrice, fuelPurchase.SelectedVehicle); editFuelWindow.Owner = this; editFuelWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (editFuelWindow.ShowDialog() == true) { UpdateStatus(5000, "Fuel Updated"); FillFuelPurchaseTable(); UpdateStatus(50, "Ready..."); } editFuelWindow.Close(); }