//Add a guest to the booking
 public void addGuest(Guest guest)
 {
     guests.Add(guest);
 }
Esempio n. 2
0
 /*
  * Check if textboxes are empty,
  * converts the textboxes text from string to integer where you need to.
  * Stores the guests details entered in the form.
  */
 private void BtnAddGuest_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         //check if the textboxes are empty
         if (String.IsNullOrEmpty(TxtGuestName.Text) ||
             String.IsNullOrEmpty(TxtGuestPassportNum.Text) ||
             String.IsNullOrEmpty(TxtGuestAge.Text))
         {
             throw new ArgumentException("error");
         }
         else if (TxtGuestPassportNum.Text.Length > 10)
         {
             MessageBox.Show("Passport number should be 10 chars long.");
         }
         else if (ComboBoxBookingRef.SelectedItem == null)
         {
             MessageBox.Show("Please select your booking reference number to proceed.");
         }
         else
         {
             try
             {
                 //local variables to keep the parametres for storing new guest
                 string name     = TxtGuestName.Text;
                 string passport = TxtGuestPassportNum.Text;
                 int    age      = Int32.Parse(TxtGuestAge.Text);
                 //store new guest
                 BusinessObjects.Guest newGuest = new BusinessObjects.Guest(name, passport, age);
                 Guestss.Add(newGuest);
                 //empty the textboxes - clear selected booking reference number from drop down menu
                 TxtGuestAge.Text         = String.Empty;
                 TxtGuestName.Text        = String.Empty;
                 TxtGuestPassportNum.Text = String.Empty;
                 //clear the selection of combobox-drop down menu
                 ComboBoxBookingRef.SelectedIndex = -1;
                 //increase counter by one
                 CountGuests++;
                 //check if there are more than 6 guests per booking
                 if (CountGuests > 6)
                 {
                     MessageBox.Show("Only 6 guest per booking are allowed.Please make a new Booking!");
                 }
                 else
                 {
                     MessageBox.Show("Booking reference number:" + ComboBoxBookingRef.SelectedItem + " has" + CountGuests + "Guests");
                 }
                 //assigns the number of guests counted to variable _totalGuests
                 _totalGuests = CountGuests;
             }
             catch (ArgumentException)
             {
                 MessageBox.Show("error empty fields.");
             }
             catch (FormatException)
             {
                 MessageBox.Show("Age cant take letters");
             }
         }
     }
     catch (ArgumentException)
     {
         MessageBox.Show("Empty fields within the form.\nFill them up to proceed!");
     }
 }
Esempio n. 3
0
 //adds a guest to the list
 public void AddGuest(Guest guest)
 {
     guestList.Add(guest);
 }