Exemplo n.º 1
0
        // Amends the selected extra
        private void btn_amendExtra_Click(object sender, RoutedEventArgs e)
        {
            Booking aBooking = facade.CurrentBooking;
            Extra   anExtra  = facade.GetExtra(cmb_bookingExtras.SelectedIndex);

            if (anExtra.GetType().ToString() == "HollydayBooking.Breakfast") //Check if extra is of type Brekfast
            {
                Breakfast aBreakfast = (Breakfast)anExtra;
                aBooking.DietaryRequirements        = txt_extraDietaryRequirements.Text;
                txt_bookingDietaryRequirements.Text = txt_extraDietaryRequirements.Text;
                MessageBox.Show("Extra details have been successfully updated!");
            }
            else if (anExtra.GetType().ToString() == "HollydayBooking.EveningMeal") //Check if extra is of type EveningMeal
            {
                EveningMeal anEveningMeal = (EveningMeal)anExtra;
                aBooking.DietaryRequirements        = txt_extraDietaryRequirements.Text;
                txt_bookingDietaryRequirements.Text = txt_extraDietaryRequirements.Text;
                MessageBox.Show("Extra details have been successfully updated!");
            }
            else if (anExtra.GetType().ToString() == "HollydayBooking.CarHire") //Check if extra is of type CarHire
            {
                DateTime arrivalDate;
                DateTime departureDate;
                if (DateTime.TryParse(txt_extraStartDate.Text, out arrivalDate))
                {
                    if (DateTime.TryParse(txt_extraEndDate.Text, out departureDate))
                    {
                        try
                        {
                            CarHire aCarHire = (CarHire)anExtra;
                            aCarHire.DriverName = txt_extraDriverName.Text;
                            aCarHire.StartDate  = arrivalDate;
                            aCarHire.ReturnDate = departureDate;
                            MessageBox.Show("Extra details have been successfully updated!");
                        }
                        catch (Exception excep)
                        {
                            MessageBox.Show(excep.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please enter a valid return date. (YYYY-MM-DD)");
                        txt_extraEndDate.Text = "";
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a valid pick-up date. (YYYY-MM-DD)");
                    txt_extraStartDate.Text = "";
                }
            }
        }
Exemplo n.º 2
0
        // Loads the extra selected extra details to Mainwindow
        private void cmb_bookingExtras_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Extra selectedExtra = null;

            if (cmb_bookingExtras.SelectedItem != null)
            {
                selectedExtra = facade.GetExtra(cmb_bookingExtras.SelectedIndex);
            }

            if (selectedExtra != null)
            {
                if (cmb_bookingExtras.SelectedItem.ToString() == "Breakfast" || cmb_bookingExtras.SelectedItem.ToString() == "Evening meal")
                {
                    lbl_extraDietaryRequirements.Visibility = System.Windows.Visibility.Visible;
                    txt_extraDietaryRequirements.Visibility = System.Windows.Visibility.Visible;
                    lbl_extraDriverName.Visibility          = System.Windows.Visibility.Hidden;
                    txt_extraDriverName.Visibility          = System.Windows.Visibility.Hidden;
                    lbl_extraStartDate.Visibility           = System.Windows.Visibility.Hidden;
                    txt_extraStartDate.Visibility           = System.Windows.Visibility.Hidden;
                    lbl_extraEndDate.Visibility             = System.Windows.Visibility.Hidden;
                    txt_extraEndDate.Visibility             = System.Windows.Visibility.Hidden;
                    txt_extraDietaryRequirements.Text       = txt_bookingDietaryRequirements.Text;
                }
                else if (cmb_bookingExtras.SelectedItem.ToString() == "Car hire")
                {
                    CarHire aCarHire = (CarHire)selectedExtra;
                    lbl_extraDietaryRequirements.Visibility = System.Windows.Visibility.Hidden;
                    txt_extraDietaryRequirements.Visibility = System.Windows.Visibility.Hidden;
                    lbl_extraDriverName.Visibility          = System.Windows.Visibility.Visible;
                    txt_extraDriverName.Visibility          = System.Windows.Visibility.Visible;
                    lbl_extraStartDate.Visibility           = System.Windows.Visibility.Visible;
                    txt_extraStartDate.Visibility           = System.Windows.Visibility.Visible;
                    lbl_extraEndDate.Visibility             = System.Windows.Visibility.Visible;
                    txt_extraEndDate.Visibility             = System.Windows.Visibility.Visible;
                    txt_extraDriverName.Text = aCarHire.DriverName;
                    txt_extraStartDate.Text  = aCarHire.StartDate.ToString("yyyy-MM-dd");
                    txt_extraEndDate.Text    = aCarHire.ReturnDate.ToString("yyyy-MM-dd");
                }
                btn_deleteExtra.IsEnabled = true;
                btn_amendExtra.IsEnabled  = true;
            }
            else
            {
                btn_deleteExtra.IsEnabled = false;
                btn_amendExtra.IsEnabled  = false;
            }
        }
Exemplo n.º 3
0
 //Adds an extra to the list of extras given an extra object
 public void AddExtra(Extra extra)
 {
     extras.Add(extra);
 }
Exemplo n.º 4
0
 //Adds an extra to the selected booking list of extras given the extra object
 public void AddExtra(Extra anExtra)
 {
     currentBooking.AddExtra(anExtra);
 }