private void DeleteVehicleBtn_Click(object sender, RoutedEventArgs e) { IList iL = DisplayLvw.SelectedItems; //selected items from list view (vehicles) if (iL.Count == 1) //Only proceed if theere is a single selection { beforeEffects(); DeleteVehiclesWindow deleteVehiclesWin = new DeleteVehiclesWindow("Standard"); //Delete vehicle verification using standard proceedure (message) deleteVehiclesWin.ShowDialog(); if (deleteVehiclesWin.deletionVerified()) //Check that the user said Yes to the delete action! { //Removal of the selected vehicle int vId = ((Vehicle)iL[0]).getVehicleID(); //Get the id vehicles.Remove(iL[0]); //remove the object from vehicles allServices = Service.RemoveServices(allServices, vId); //Remove the services for that vehicle id allJournies = Journey.RemoveJournies(allJournies, vId); //Remove the journies for that vehicle id allFuelPurchases = FuelPurchase.RemoveFuelPurchases(allFuelPurchases, vId); //Remove the fuelPurchases for that vehicle id } afterEffects(); } else { MessageBox.Show("Select a single vehicle to delete"); } }
private void DeleteFuelBtn_Click(object sender, RoutedEventArgs e) { IList iL = FuelPurchasesDisplayLvw.SelectedItems; //selected items from list view (fuel purchase) if (iL.Count == 1) //Only proceed if theere is a single selection { beforeEffects(); DeleteVehiclesWindow deleteVehiclesWin = new DeleteVehiclesWindow("Standard"); //Delete vehicle verification using standard proceedure (message) deleteVehiclesWin.ShowDialog(); if (deleteVehiclesWin.deletionVerified()) //Check that the user said Yes to the delete action! { //Removal of the selected service FPurchases.Remove((FuelPurchase)iL[0]); //Remove from fpurchase list for this vehicle allFuelPurchases.Remove((FuelPurchase)iL[0]); //Remove for all fpurchase data } afterEffects(); } else { MessageBox.Show("Select a single item to delete"); } }