// populates customer details when an existing customer is selected from combobox
        private void comBoxSearchResult_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comBoxSearchResult.SelectedIndex == -1)
            {
                return;
            }
            string       selectedCustomer = Convert.ToString(comBoxSearchResult.SelectedItem);
            CustomerItem customer         = DataLayerFacade.GetOneCustomerDetails(selectedCustomer);

            txtBoxCustName.Text    = customer.Name;
            txtBoxCustAddress.Text = customer.Address;
        }
 // populates guest details if client is also a guest
 private void checkBoxGuest_Checked(object sender, RoutedEventArgs e)
 {
     txtBoxGuestName.Text = txtBoxCustName.Text;
     if (checkBoxExistCust.IsChecked == true)
     {
         // for an existing customer a check is done if he/she was also a guest so the
         // guest details can be used in a new booking
         var selectedCustomer = DataLayerFacade.GetOneCustomerDetails(txtBoxCustName.Text);
         var guestDetailsList = DataLayerFacade.GetGuestDecorator(selectedCustomer.Id, 0);
         if (guestDetailsList.Count != 0)
         {
             GuestDecorator guest = (GuestDecorator)guestDetailsList.ElementAt(0);
             txtBoxGuestAge.Text     = guest.Age.ToString();
             txtBoxGuestPasspNo.Text = guest.PassportNumber;
         }
     }
 }
        // logic for add guest button. Adds a guest to guest list
        private void btnAddGuest_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtBoxGuestName.Text.Equals(String.Empty) ||
                    txtBoxGuestAge.Text.Equals(String.Empty) ||
                    txtBoxGuestPasspNo.Text.Equals(String.Empty))
                {
                    MessageBox.Show("Please provide all guest's details");
                    return;
                }
                string guestName  = txtBoxGuestName.Text;
                string passportNo = txtBoxGuestPasspNo.Text;
                int    age;
                try
                {
                    age = Convert.ToInt32(txtBoxGuestAge.Text);
                }
                catch (Exception)
                {
                    MessageBox.Show("Please provide age up to 101 as a number.");
                    return;
                }

                string         address = txtBoxCustAddress.Text;
                var            facade  = BusinessFacadeSingleton.Instance();
                GuestDecorator guest   = null;
                // below code checks retreives details of an existing customer(s) if an existing customer
                // wished to make a new booking
                if (checkBoxAddAsGuest.IsChecked == true && checkBoxExistCust.IsChecked == false)
                {
                    if (txtBoxCustName.Text == String.Empty || txtBoxCustAddress.Text == String.Empty)
                    {
                        MessageBox.Show("Please provide customer details.");
                        return;
                    }
                    int customerNumber = DataLayerFacade.GetNextCustomerNumber();
                    client = facade.CreateClient(customerNumber, guestName, address);
                    guest  = facade.CreateClientGuest(client, passportNo, age);
                }
                else
                {
                    guest = facade.CreateGuest(guestName, passportNo, age);
                    if (client == null)
                    {
                        // checks if the existing customer was also a guest so the guest details can be used
                        if (checkBoxExistCust.IsChecked == true)
                        {
                            var existingCustomerDetails = DataLayerFacade.GetOneCustomerDetails(txtBoxCustName.Text);
                            existingClient = new Client(existingCustomerDetails.Id, existingCustomerDetails.Name, existingCustomerDetails.Address);
                            if (existingClient == null)
                            {
                                MessageBox.Show("Please provide client's details.");
                                return;
                            }
                            client = existingClient;
                        }
                        else
                        {
                            if (txtBoxCustName.Text == String.Empty || txtBoxCustAddress.Text == String.Empty)
                            {
                                MessageBox.Show("Please provide customer details.");
                                return;
                            }
                            int    customerNumber = DataLayerFacade.GetNextCustomerNumber();
                            string clientName     = txtBoxCustName.Text;
                            string clinetAddress  = txtBoxCustAddress.Text;
                            client = facade.CreateClient(customerNumber, clientName, clinetAddress);
                        }
                    }
                }
                guests.Add(guest);
                if (guests.Count == 6)
                {
                    MessageBox.Show("You have reached the maxumum number of guests");
                    txtBoxGuestName.IsReadOnly    = true;
                    txtBoxGuestAge.IsReadOnly     = true;
                    txtBoxGuestPasspNo.IsReadOnly = true;
                }

                listBoxGuestList.Items.Add(guestName);
                comBoxDriver.Items.Add(guestName);// ads the name to a combo box so it can be selected as a driver
                txtBoxGuestName.Text         = "";
                txtBoxGuestPasspNo.Text      = "";
                txtBoxGuestAge.Text          = "";
                checkBoxAddAsGuest.IsChecked = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
        }