private void amendButton_Click(object sender, RoutedEventArgs e) //Calls the appropriate classes to modify an existing guest object { AddExitGuest AEG = new AddExitGuest("A", false, currentCustomerID, currentBookingRef); AEG.Show(); AEG.titleLabel.Content = "Edit Guest"; this.Close(); }
private void addButton_Click(object sender, RoutedEventArgs e) //Calls the appropriate classes to create a new guest object { Booking currentBooking = MainWindow.AllCustomers.findBooking(currentCustomerID, currentBookingRef); if (currentBooking.Guests.Count <= 6) { AddExitGuest AEG = new AddExitGuest("N", false, currentCustomerID, currentBookingRef); AEG.Show(); AEG.titleLabel.Content = "New Guest"; this.Close(); } else { MessageBox.Show("The maximum guest capacity for this chalet has been reached!"); } }
private void addButton_Click(object sender, RoutedEventArgs e) //Controls to take in, validate and add the fields to create or amend a booking upon button press { int Errors = 0; try { currentBooking.ChaletID = Int32.Parse(idInBox.Text); idError.Content = ""; if (currentBooking.ChaletID > 10 || currentBooking.ChaletID < 1) { Errors++; idError.Content = "!"; } } catch { Errors++; idError.Content = "!"; } try { currentBooking.ArrivalDate = DateTime.Parse(arrivalInBox.Text); arrivalError.Content = ""; } catch { Errors++; arrivalError.Content = "!"; } try { currentBooking.DepartureDate = DateTime.Parse(departureInBox.Text); departureError.Content = ""; if (currentBooking.ArrivalDate.Date > currentBooking.DepartureDate.Date) { Errors++; departureError.Content = "!"; } } catch { Errors++; departureError.Content = "!"; } if (Errors == 0) { bool hit = false; foreach (var thisCustomer in MainWindow.AllCustomers.Customers) { foreach (var thisBooking in MainWindow.AllCustomers.getBookings(thisCustomer.CustomerID)) { if (thisBooking.ChaletID == currentBooking.ChaletID) { if (thisBooking.ArrivalDate <= currentBooking.DepartureDate && currentBooking.ArrivalDate <= thisBooking.DepartureDate) { hit = true; } } } } if (hit == true) { Errors++; idError.Content = "!"; MessageBox.Show("Selected Chalet is already booked for this date, try a different Chalet!"); } } if (Errors == 0) { if (newOrEdit.Equals("N")) { MainWindow.BookingRefGen++; currentBooking.BookingRef = MainWindow.BookingRefGen; currentBooking.BreakfastExtra = false; currentBooking.EveningMealExtra = false; MainWindow.AllCustomers.addBooking(currentCustomerID, currentBooking); AddExitGuest AEG = new AddExitGuest("N", true, currentCustomerID, currentBooking.BookingRef); AEG.Show(); this.Close(); } else { BookingsWindow BW = new BookingsWindow(currentCustomerID); BW.Show(); BW.BookingsBoxRefresh(); this.Close(); } } else { MessageBox.Show("There are " + Errors + " invalid entries, they have each been marked with '!'. Please fix these then try again!"); } }
private void addButton_Click(object sender, RoutedEventArgs e) //Controls to take in, validate and add the fields to create or amend a guest upon button press { int Errors = 0; try { currentGuest.GuestName = nameInBox.Text; nameError.Content = ""; if (currentGuest.GuestName.Equals("")) { Errors++; nameError.Content = "!"; } } catch { Errors++; nameError.Content = "!"; } try { currentGuest.PassportNo = passNoInBox.Text; passNoError.Content = ""; if (currentGuest.PassportNo.Equals("") || currentGuest.PassportNo.Length > 10 || currentGuest.PassportNo.Contains(" ")) { Errors++; passNoError.Content = "!"; } } catch { Errors++; passNoError.Content = "!"; } try { currentGuest.GuestAge = Int32.Parse(ageInBox.Text); ageError.Content = ""; if (currentGuest.GuestAge > 101) { Errors++; ageError.Content = "!"; } } catch { Errors++; ageError.Content = "!"; } if (Errors == 0) { if (newOrEdit.Equals("N")) { MainWindow.AllCustomers.addGuest(currentCustomerID, currentBookingRef, currentGuest); Booking currentBooking = MainWindow.AllCustomers.findBooking(currentCustomerID, currentBookingRef); if (currentBooking.Guests.Count <= 6) { MessageBoxResult makeNewBooking = MessageBox.Show("Would you like to add another Guest? This can also be done from Manage Booking Details > Add New Guest.", "Add another Guest?", MessageBoxButton.YesNo); if (makeNewBooking == MessageBoxResult.Yes) { AddExitGuest AEG = new AddExitGuest("N", true, currentCustomerID, currentBookingRef); AEG.Show(); this.Close(); } else if (newBooking == true) { AddEditExtras AEE = new AddEditExtras(currentCustomerID, currentBookingRef); AEE.Show(); this.Close(); } else { DetailsWindow DW = new DetailsWindow(currentCustomerID, currentBookingRef); DW.Show(); DW.PageRefresh(); this.Close(); } } else if (newBooking == true) { AddEditExtras AEE = new AddEditExtras(currentCustomerID, currentBookingRef); AEE.Show(); this.Close(); } else { DetailsWindow DW = new DetailsWindow(currentCustomerID, currentBookingRef); DW.Show(); DW.PageRefresh(); this.Close(); } } else { DetailsWindow DW = new DetailsWindow(currentCustomerID, currentBookingRef); DW.Show(); DW.PageRefresh(); this.Close(); } } else { MessageBox.Show("There are " + Errors + " invalid entries, they have each been marked with '!'. Please fix these then try again!"); } }