// modify the reservation that is selected private void modifyButton_Click(object sender, EventArgs e) { if (reservationComboBox.SelectedIndex == -1) { MessageBox.Show("Please select a reservation."); } else { // retrieve the reservation from the user input information ParkingReservation selectedReservation = reservationComboBox.SelectedItem as ParkingReservation; ModifyReservationForm modifyForm = new ModifyReservationForm(this, Database, selectedReservation, CustomerClock, Mailer); int indexOfChange = reservationComboBox.SelectedIndex; // show the form for modifying a reservation this.Visible = false; modifyForm.ShowDialog(); // update the details view based on any changes made List<ParkingReservation> res = Database.GetCurrentAndFutureReservations(Customer.CustomerID); Reservations[indexOfChange].Date = res[indexOfChange].Date; Reservations[indexOfChange].DurationMinutes = res[indexOfChange].DurationMinutes; Reservations[indexOfChange].ReservationVehicle = res[indexOfChange].ReservationVehicle; Reservations[indexOfChange].ParkingSpotID = res[indexOfChange].ParkingSpotID; UpdateDetails(); } }
// modify the reservation that has been selected, if any exist private void modifyButton_Click(object sender, EventArgs e) { Garage.ParkingSpot selectedSpot = parkingSpotComboBox.SelectedItem as Garage.ParkingSpot; ParkingReservation currentReservation = Database.GetRelevantReservation(selectedSpot.ParkingSpotID); if (currentReservation == null) { MessageBox.Show("No reservation to modify."); } else { // show the form for modifying a reservation ModifyReservationForm modifyForm = new ModifyReservationForm(this, Database, currentReservation, OverviewClock, Mailer); this.Visible = false; modifyForm.ShowDialog(); // update the details view currentReservation = Database.GetRelevantReservation(selectedSpot.ParkingSpotID); FillReservationDetails(currentReservation); } }