Пример #1
0
        private void btn_amendBooking_Click(object sender, RoutedEventArgs e)
        {//Amend booking object
            //Simulate Add button click to re-evaluate all the new input that the user might have amended
            //Save guest list, extras, car hire details and price of selected booking
            Booking selectedBooking = Bookings.getBooking(getSelectedKey_BookingRef());
            //Save refNo as the listbox will lose it's selected item, but we need to re-select it again
            int          selectedBookingRefNo = selectedBooking.ReferenceNo;
            List <Guest> guestList            = Bookings.getGuestList(selectedBooking);
            CarHire      carhire     = selectedBooking.CarHire;
            bool         eveningMeal = selectedBooking.EveningMeal;
            bool         breakfast   = selectedBooking.Breakfast;
            bool         carHire     = selectedBooking.Carhire;

            //Remove old booking and add the new booking
            Bookings.RemoveBooking(selectedBookingRefNo);
            btn_addBooking_Click(sender, e);

            //Select same booking from the listbox using the refNo
            selectedBooking = Bookings.getBooking(selectedBookingRefNo);
            //Readd the guest list, extras and price to the new booking
            Bookings.setGuestList(selectedBooking, guestList);
            selectedBooking.CarHire     = carhire;
            selectedBooking.EveningMeal = eveningMeal;
            selectedBooking.Breakfast   = breakfast;
            selectedBooking.Carhire     = carHire;

            //Exit Amend mode
            Amend_Exit(Target.Booking);

            //set the selected item to null, (if there is one booking in the list it will stay selected, this ensured the user can amend it again)
            listbox_bookingsList.SelectedItem = null;
        }
Пример #2
0
        public void CarHireTest()
        {
            // Create booking with ID '100'
            Booking booking = new Booking(100);
            CarHire carHire = new CarHire();

            bool hired = true;

            carHire.Hired = hired;
            Assert.AreEqual(hired, carHire.Hired, "Car hire - Hired Test");

            DateTime start = Convert.ToDateTime("10/10/2010");

            carHire.DateStart = start;
            Assert.AreEqual(start, carHire.DateStart, "Car Hire - Date Start Test");

            DateTime end = Convert.ToDateTime("20/10/2010");

            carHire.DateEnd = end;
            Assert.AreEqual(end, carHire.DateEnd, "Car Hire - Date End Test");

            int cost = 500;

            carHire.Cost = cost;
            Assert.AreEqual(cost, carHire.Cost, "Car Hire - Cost Test");

            string name = "Person Person";

            carHire.DriverName = name;
            Assert.AreEqual(name, carHire.DriverName, "Car Hire - Driver Name Test");
        }
Пример #3
0
        public void GetCost_Method_Calculates_Cost_Of_Bookings_Correctly()
        {
            Booking aBooking = new Booking();

            // Booking for 2 nights
            aBooking.ArrivalDate   = DateTime.Parse("2000-01-01");
            aBooking.DepartureDate = DateTime.Parse("2000-01-03");

            //Create 2 guests
            Guest guest1 = new Guest();

            guest1.Age = 12; //Create a guest (child charged at £30.00/night)
            aBooking.AddGuest(guest1);
            Guest guest2 = new Guest();

            guest2.Age = 32; //Create a guest (adult charged at £50.00/night)
            aBooking.AddGuest(guest2);

            //Create Extras
            Breakfast breakfast1 = new Breakfast(); //Breakfast charged at £5.00 per guest per night
            CarHire   carhire1   = new CarHire();   //CarHire charged at £50.00/day

            //Car hire booked for 1 day
            carhire1.StartDate  = DateTime.Parse("2000-01-01");
            carhire1.ReturnDate = DateTime.Parse("2000-01-02");
            aBooking.AddExtra(breakfast1);
            aBooking.AddExtra(carhire1);


            double expected   = 230.00;             //expected cost for booking
            double calculated = aBooking.GetCost(); //Cost returned from the GetCost method

            Assert.AreEqual(expected, calculated, "GetCost method calculated booking costs correctly!");
        }
Пример #4
0
 public BookNow()
 {
     holdLuggage     = new HoldLuggage();
     flightExtras    = new List <FlightExtras>();
     airportTransfer = new AirportTransfer();
     carHire         = new CarHire();
     airportParking  = new AirportParking();
 }
Пример #5
0
        private void btnSaveCustomerAndBooking_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure of the details?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
            {
                return;
            }
            else
            {
                try
                {
                    if (facade.Guests.Count < 1 && lstBoxViewGuests.Items.Count < 1)
                    {
                        throw new ArgumentException("There are no guests! Add guests!");
                    }

                    if (checkBoxCar.IsChecked != true && car != null)
                    {
                        car = null;
                    }

                    int breakfast   = checkBreakfast();
                    int eveningMeal = checkEveningMeal();

                    if (addBooking == true)
                    {
                        facade.SaveCustomerAndBooking(customer, facade.Guests, booking, car, breakfast, eveningMeal, addBooking);


                        MessageBox.Show("Succesfully Saved!", "Confirmation");

                        facade.Guests.Clear();

                        ExistingCustomer win = new ExistingCustomer();
                        win.Show();
                        this.Close();
                    }
                    else
                    {
                        facade.SaveCustomerAndBooking(customer, facade.Guests, booking, car, breakfast, eveningMeal, false);


                        MessageBox.Show("Succesfully Saved!", "Confirmation");

                        facade.Guests.Clear();

                        MainWindow win = new MainWindow();
                        win.Show();
                        this.Close();
                    }
                }
                catch (Exception ee)
                {
                    MessageBox.Show(ee.Message, "Save");
                }
            }
        }
Пример #6
0
        public void CarHireTest()
        {
            Booking  target    = new Booking();
            DateTime start     = new DateTime(2018, 01, 01);
            DateTime end       = new DateTime(2018, 02, 02);
            CarHire  targetCar = new CarHire(start, end, "Andrei");

            target.Car = targetCar;
            Assert.AreEqual(targetCar, target.Car);
        }
        public void updateBookingDates(Booking b)
        {
            CarHire car = facade.getCarHireForBooking(b);

            if (car != null)
            {
                if (car.StartDate < b.ArrivalDate || car.StartDate > b.DepartureDate || car.EndDate > b.DepartureDate || car.EndDate < b.ArrivalDate)
                {
                    if (MessageBox.Show("Your car hire start and end dates aren't between your newly selected booking dates. If you want to continue, the car hire wil be cancelled and you will have to enter a new one.", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                    {
                        return;
                    }
                    else
                    {
                        facade.deleteCarHire(b);
                    }
                }
            }

            facade.updateBookingDates(b);

            /*
             * bookings.Remove(oldB);
             *
             * if(!this.bookings.Contains(b))
             * {
             *  this.bookings.Add(b);
             * }
             *
             * this.dataGridBooking.ItemsSource = bookings;
             * this.dataGridBooking.Items.Refresh();
             * this.btnModifyBooking.IsEnabled = false;
             *
             * CarHire car = facade.getCarHire(b.BookingReferenceNumber);
             *
             * if(car != null)
             * {
             *  if (car.StartDate < b.ArrivalDate || car.StartDate > b.DepartureDate || car.EndDate > b.DepartureDate || car.EndDate < b.ArrivalDate)
             *  {
             *      if (MessageBox.Show("Your car hire start and end dates aren't between your newly selected booking dates. If you want to continue, the car hire wil be cancelled and you will have to enter a new one.", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
             *      {
             *          return;
             *      }
             *      else
             *      {
             *          data.deleteCarHire(b.BookingReferenceNumber);
             *      }
             *  }
             * }
             *
             *
             * data.updateBookingDates(b.BookingReferenceNumber, c.CustomerReferenceNumber, b.ArrivalDate, b.DepartureDate);
             *
             */
        }
        public InvoiceWindow(ExistingCustomer win, CarHire car, int guests)
        {
            this.existingCustomer = win;
            InitializeComponent();


            int breakfast      = 0;
            int carHire        = 0;
            int eveningMeal    = 0;
            int numberOfGuests = guests;
            int totalDays      = (this.existingCustomer.getBooking().DepartureDate - this.existingCustomer.getBooking().ArrivalDate).Days;

            int chaletPrice = (60 + numberOfGuests * 25) * totalDays;

            lblCustomerName.Content   = this.existingCustomer.getCustomer().Name;
            lblNumberOfDays.Content   = totalDays;
            lblNumberOfGuests.Content = numberOfGuests + " Guests";


            if (car != null)
            {
                int carHireRentalDays = (car.EndDate - car.StartDate).Days;
                carHire            = carHireRentalDays * 50;
                lblCarHire.Content = carHire + " $";
            }
            else if (car == null)
            {
                lblCarHire.Content = "Not Included";
            }
            if (existingCustomer.getBooking().Breakfast == true)
            {
                breakfast            = (numberOfGuests * 5) * totalDays;
                lblBreakfast.Content = breakfast + " $";
            }
            else if (this.existingCustomer.getBooking().Breakfast == false)
            {
                lblBreakfast.Content = "Not Included";
            }

            if (this.existingCustomer.getBooking().EveningMeal == true)
            {
                eveningMeal            = (numberOfGuests * 10) * (totalDays - 1);
                lblEveningMeal.Content = eveningMeal + " $";
            }
            else if (this.existingCustomer.getBooking().EveningMeal == false)
            {
                lblEveningMeal.Content = "Not Included";
            }



            int totalPrice = chaletPrice + breakfast + eveningMeal + carHire;

            lblTotal.Content = totalPrice + " $";
        }
Пример #9
0
        //View the currently selected Car_Hire
        private void ViewCarHireBtn_Click(object sender, RoutedEventArgs e)
        {
            CarHire       hire = CarHireListBox.SelectedItem as CarHire;
            CarHireWindow win  = new CarHireWindow();

            win.StartDatePicker.DisplayDate = hire.StartDate;
            win.EndDatePicker.DisplayDate   = hire.EndDate;
            win.DriverBox.Text = hire.Driver;

            win.StartDatePicker.Focusable = false;
            win.EndDatePicker.Focusable   = false;
            win.DriverBox.IsReadOnly      = true;
        }
Пример #10
0
        public CarHire getCar()
        {
            if (this.car == null)
            {
                this.car = new CarHire();
            }
            else
            {
                return(this.car);
            }

            return(this.car);
        }
Пример #11
0
        public static CarHire GetCarHire(string pickuplocation, string dropofflocation, string dropoffdate, string pickupdate)
        {
            string  appId        = "i4CjuKj4UwpiMla4r0Z1r648IaYjIoii";
            CarHire activityList = new CarHire();

            string url = string.Format("http://terminal2.expedia.com:80/x/cars/search?pickupdate=2016-08-15T10%3A00&dropoffdate=2016-08-17T16%3A30&pickuplocation=PMI&dropofflocation=PMI&limit=10&apikey={0}", appId);

            using (WebClient client = new WebClient())
            {
                string json = client.DownloadString(url);
                activityList = (new JavaScriptSerializer()).Deserialize <CarHire>(json);
            }

            return(activityList);
        }
Пример #12
0
        // Returns a null extra if extra cannot be found in the list
        public void GetExtra_Method_Returns_Null_If_Extra_Does_Not_Exist()
        {
            Booking aBooking = new Booking();
            //Create Extras
            Extra Extra1 = new Breakfast();
            Extra Extra2 = new CarHire();

            //Add Extras to booking list
            aBooking.AddExtra(Extra1);
            aBooking.AddExtra(Extra2);

            int   index  = 2;
            Extra extra3 = aBooking.GetExtra(index); //Should return a null Extra

            Assert.AreEqual(extra3, null, "Guest can not be found! (null)");
        }
Пример #13
0
        public void RemoveExtra_Method_Removes_Guest_If_Guest_Does_Exist()
        {
            Booking aBooking = new Booking();
            //Create Extras
            Extra Extra1 = new Breakfast();
            Extra Extra2 = new CarHire();

            //Add Extras to booking list
            aBooking.AddExtra(Extra1);
            aBooking.AddExtra(Extra2);

            int index = 1;

            aBooking.RemoveExtra(index); // Should remove the Extra at index 1
            Assert.AreEqual(aBooking.Extras.Count, 1, "Extra was removed successfuly");
        }
Пример #14
0
        //Delete Car Hire from the current booking
        private void DeleteCarHireBtn_Click(object sender, RoutedEventArgs e)
        {
            CarHire hire = CarHireListBox.SelectedItem as CarHire;

            switch (caseSwitch)
            {
            case 1:
                bookingInstance.CarHireList.Remove(hire);
                break;

            case 2:

                bookingInstance.CarHireList.Remove(hire);
                carHireToDelete.Add(hire.CarHireRef);
                break;
            }
        }
        private void btn_saveCarHire_Click(object sender, RoutedEventArgs e)
        {//Save Carhire details in booking object and close window
            try
            {
                CarHire carhire = new CarHire(selectedBooking.ArrivalDate, selectedBooking.DepartureDate);
                carhire.DriverName = txtb_driverName.Text;
                carhire.HireStart  = datepicker_carHireStart.SelectedDate.Value.Date;
                carhire.HireEnd    = datepicker_carHireEnd.SelectedDate.Value.Date;

                selectedBooking.CarHire = carhire;

                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #16
0
        // Should return the right extra given its index
        public void GetExtra_Method_Returns_The_Right_Extra_If_It_Does_Exist_In_The_List()
        {
            Booking aBooking = new Booking();
            //Create Extras
            Extra Extra1 = new Breakfast();
            Extra Extra2 = new CarHire();
            Extra Extra3 = new Breakfast();

            aBooking.AddExtra(Extra1);
            aBooking.AddExtra(Extra2);
            aBooking.AddExtra(Extra3);

            CarHire carhire1 = (CarHire)Extra2;
            int     index    = 1;
            CarHire carhire2 = (CarHire)aBooking.GetExtra(index); //Should return Extra2

            Assert.AreEqual(carhire1.DriverName, carhire2.DriverName, "Method returns the right extra");
        }
Пример #17
0
        public BookingDetails(Booking booking, List <Guest> guests, Customer customer, ExistingCustomer win, CarHire car)
        {
            InitializeComponent();

            this.booking  = booking;
            this.customer = customer;
            this.win      = win;

            this.lblDIsplayCustomerName.Content    = customer.Name;
            this.lblDIsplayCustomerAddress.Content = customer.Address;


            this.lblArrivalDate.Content   = booking.ArrivalDate.Date;
            this.lblDepartureDate.Content = booking.DepartureDate.Date;

            this.checkBoxBreakfast.IsChecked = booking.Breakfast;
            this.checkBoxEvening.IsChecked   = booking.EveningMeal;

            this.disableButtons();

            if (car != null)
            {
                this.car = car;
                this.checkBoxCar.IsChecked = true;
                this.btnAddCar.IsEnabled   = true;
            }

            this.btnUpdateBooking.Visibility          = Visibility.Visible;
            this.btnSaveCustomerAndBooking.Visibility = Visibility.Hidden;


            facade.Guests.Clear();


            foreach (Guest x in guests)
            {
                if (lstBoxViewGuests.Items.Contains(x.PassportNo) == false)
                {
                    this.facade.Guests.Add(x);
                    lstBoxViewGuests.Items.Add(x.PassportNo);
                    countGuest++;
                }
            }
        }
Пример #18
0
        public AddCarHire(DateTime arrival, DateTime departure, BookingDetails win, CarHire car)
        {
            InitializeComponent();

            this.win       = win;
            this.arrival   = arrival;
            this.departure = departure;
            this.datePickerStart.DisplayDateStart = arrival;
            this.datePickerEnd.DisplayDateStart   = arrival;
            this.datePickerStart.DisplayDateEnd   = departure;
            this.datePickerEnd.DisplayDateEnd     = departure;

            lblArrivalDate.Content   = arrival.Date;
            lblDepartureDate.Content = departure.Date;
            txtBoxDriverName.Text    = car.DriverName;

            this.datePickerStart.SelectedDate = car.StartDate;
            this.datePickerEnd.SelectedDate   = car.EndDate;
        }
Пример #19
0
        public void Booking_CalculateCosts_WithValidAmount()
        {
            DateTime arrivalDate   = new DateTime(2017, 1, 18);
            DateTime departureDate = new DateTime(2017, 1, 25);

            Booking testBooking = new Booking(4, arrivalDate, departureDate);

            Guest guest1 = new Guest("Andrea", "ya11121314", 23);
            Guest guest2 = new Guest("Joseph", "ya11121315", 21);
            Guest guest3 = new Guest("Keith", "ya122221315", 22);

            testBooking.addGuest(guest1);
            testBooking.addGuest(guest2);
            testBooking.addGuest(guest3);

            Extra         newExtra1 = new Extra("Breakfast");
            Extra         newExtra2 = new Extra("Car Hire");
            ExtraSelector breakfast = new Breakfast();
            ExtraSelector carHire   = new CarHire();

            breakfast.SetExtra(breakfast);
            breakfast.ProcessExtra(newExtra1);
            breakfast.SetExtra(carHire);
            carHire.ProcessExtra(newExtra2);
            newExtra2.StartHire = new DateTime(2017, 1, 18);
            newExtra2.EndHire   = new DateTime(2017, 1, 20);
            testBooking.addExtra(newExtra1);
            testBooking.addExtra(newExtra2);

            double expectedDayCost   = 200;
            double expectedTotalCost = 1150;
            string expected1         = "The cost per day is:\n - Chalet: " + 60 + "£\n - Number of guests/cost: " + testBooking.GuestDict.Count + " / " + 25 * testBooking.GuestDict.Count
                                       + "£\n - Breakfast: " + 5 * testBooking.GuestDict.Count + "£\n - Evening Meals: " + 0 + "£\n - Car Hire: " + 50 + "£\n Total cost per day: " + expectedDayCost + "£";
            string expected2 = "The total booking cost is: " + expectedTotalCost + "£";

            // act - calling methods
            string method1 = testBooking.getCost();
            string method2 = testBooking.getTotalCost();

            // assert - test correctness
            Assert.AreEqual(expected1, method1, "Cost per day calculation is wrong.");
            Assert.AreEqual(expected2, method2, "Total cost calculation is wrong.");
        }
Пример #20
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            CarHire newHire  = new CarHire();
            Booking instance = Booking.GetInstance();

            try
            {
                newHire.Driver = DriverBox.Text;
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message);
                return;
            }

            try
            {
                newHire.StartDate = StartDatePicker.SelectedDate.GetValueOrDefault();
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message);
                return;
            }

            try
            {
                newHire.EndDate = EndDatePicker.SelectedDate.GetValueOrDefault();
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message);
                return;
            }

            instance.AddCarHire(newHire);
            this.Close();
        }
Пример #21
0
        public void InvoiceTest()
        {
            // Create booking with ID '100'
            Booking booking = new Booking(100);

            booking.CustomerRef = 200;
            DateTime arrival = Convert.ToDateTime("10/10/2010");

            booking.Arrival = arrival;
            DateTime departure = Convert.ToDateTime("20/10/2010");

            booking.Departure = departure;

            Chalet chalet = new Chalet();
            int    id     = 10;

            chalet.ChaletID = id;

            bool breakfast = true;

            chalet.MealBreakFast = breakfast;

            bool evening = true;

            chalet.MealEvening    = evening;
            booking.BookingChalet = chalet;

            CarHire carHire = new CarHire();

            bool hired = true;

            carHire.Hired = hired;

            DateTime start = Convert.ToDateTime("10/10/2010");

            carHire.DateStart = start;

            DateTime end = Convert.ToDateTime("20/10/2010");

            carHire.DateEnd = end;

            int cost = 500;

            carHire.Cost = cost;

            string name = "Person Driver";

            carHire.DriverName     = name;
            booking.BookingCarHire = carHire;

            Guest guest = new Guest();

            int age = 30;

            guest.Age = age;

            string guestName = "Person Guest";

            guest.Name = guestName;

            string passportNumber = "0123456789";

            guest.PassportNumber = passportNumber;

            List <Guest> guests = new List <Guest>();

            guests.Add(guest);
            booking.BookingGuests = guests;

            Invoice invoice = new Invoice(booking);

            int carHireLength = 10;

            Assert.AreEqual(carHireLength, invoice.CarHireLength, "Invoice - Car Hire Length Test");

            int carHireTotalCost = 500;

            Assert.AreEqual(carHireTotalCost, invoice.CarHireTotalCost, "Invoice - Car Hire Total Cost Test");

            int chaletCost = 85;

            Assert.AreEqual(chaletCost, invoice.ChaletCost, "Invoice - Chalet Cost Test");

            int extrasCost = 15;

            Assert.AreEqual(extrasCost, invoice.ExtrasCost, "Invoice - Chalet Extras Cost Test");

            int costPerNight = 100;

            Assert.AreEqual(costPerNight, invoice.CostPerNight, "Invoice - Chalet Total Cost Per Night Test");

            int tripLength = 10;

            Assert.AreEqual(tripLength, invoice.TripLength, "Invoice - Trip Length Test");

            int guestCount = 1;

            Assert.AreEqual(guestCount, invoice.GuestCount, "Invoice - Guest Count Test");

            int mealBreakFastCost = 5;

            Assert.AreEqual(mealBreakFastCost, invoice.MealBreakfastCost, "Invoice - Meal Breakfast Cost Test");

            int mealEveningCost = 10;

            Assert.AreEqual(mealEveningCost, invoice.MealEveningCost, "Invoice - Meal Evening Cost Test");

            int totalCost = 1500;

            Assert.AreEqual(totalCost, invoice.TotalCost, "Invoice - Total Cost Test");
        }
Пример #22
0
        // This method is called on SAVE button click. It saves all the information about the booking, any extras, and guest list and updates the binary file. Appropriate
        // checks are done to see if data need to be edited or it is a new booking.
        private void btnSaveBooking_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ExtraSelector extraType   = new NoExtra();
                ExtraSelector breakfast   = new Breakfast();
                ExtraSelector eveningMeal = new EveningMeal();
                ExtraSelector carHire     = new CarHire();

                if (data.CustDict.StoreCustomers[_custID].DictBookings.ContainsKey(_bookingID))
                {
                    if (clrArrival.SelectedDate == null || clrDeparture.SelectedDate == null)
                    {
                        throw new ArgumentException("Please select an Arrival Date and a Departure Date");
                    }

                    data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ArrivalDate   = Convert.ToDateTime(clrArrival.SelectedDate);
                    data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].DepartureDate = Convert.ToDateTime(clrDeparture.SelectedDate);

                    if (data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ChaletID == Int32.Parse(tbxChaletID.Text))
                    {
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ChaletID = Int32.Parse(tbxChaletID.Text);
                    }

                    if (!data.CustDict.ChaletsBooked.Contains(Int32.Parse(tbxChaletID.Text)))
                    {
                        data.CustDict.ChaletsBooked.Remove(data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ChaletID);
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ChaletID = Int32.Parse(tbxChaletID.Text);
                        data.CustDict.ChaletsBooked.Add(Int32.Parse(tbxChaletID.Text));
                    }
                    else if (data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ChaletID != Int32.Parse(tbxChaletID.Text) && data.CustDict.ChaletsBooked.Contains(Int32.Parse(tbxChaletID.Text)))
                    {
                        throw new ArgumentException("Chalet already booked, please choose another chalet.");
                    }

                    if (ckbBreakfast.IsChecked == false && data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Breakfast"))
                    {
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.Remove("Breakfast");
                    }
                    else if (ckbBreakfast.IsChecked == true && !data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Breakfast"))
                    {
                        Extra extra = new Extra("Breakfast");
                        extraType.SetExtra(breakfast);
                        breakfast.ProcessExtra(extra);
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].addExtra(extra);
                    }

                    if (ckbDinner.IsChecked == false && data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Evening Meal"))
                    {
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.Remove("Evening Meal");
                    }
                    else if (ckbDinner.IsChecked == true && !data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Evening Meal"))
                    {
                        Extra extra = new Extra("Evening Meal");
                        extraType.SetExtra(eveningMeal);
                        eveningMeal.ProcessExtra(extra);
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].addExtra(extra);
                    }

                    if (ckbCarHire.IsChecked == false && data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Car Hire"))
                    {
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.Remove("Car Hire");
                        tbxDriver.Text            = null;
                        clrStartHire.SelectedDate = null;
                        clrEndHire.SelectedDate   = null;
                    }
                    else if (ckbCarHire.IsChecked == true && !data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Car Hire"))
                    {
                        if (clrStartHire.SelectedDate == null || clrEndHire.SelectedDate == null || tbxDriver.Text == null)
                        {
                            throw new ArgumentException("Please select a start hire date, an end hire date, and a driver name.");
                        }

                        if (clrStartHire.SelectedDate < clrArrival.SelectedDate || clrEndHire.SelectedDate > clrDeparture.SelectedDate)
                        {
                            throw new ArgumentException("Invalid hiring dates. Please, insert dates within your booking period of staying.");
                        }

                        Extra extra = new Extra("Car Hire");
                        extraType.SetExtra(carHire);
                        carHire.ProcessExtra(extra);
                        extra.DriverName = tbxDriver.Text;
                        extra.StartHire  = Convert.ToDateTime(clrStartHire.SelectedDate);
                        extra.EndHire    = Convert.ToDateTime(clrEndHire.SelectedDate);
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].addExtra(extra);
                    }
                    else if (ckbCarHire.IsChecked == true && data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict.ContainsKey("Car Hire"))
                    {
                        if (clrStartHire.SelectedDate < clrArrival.SelectedDate || clrEndHire.SelectedDate > clrDeparture.SelectedDate)
                        {
                            throw new ArgumentException("Invalid hiring dates. Please, insert dates within your booking period of staying.");
                        }

                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict["Car Hire"].DriverName = tbxDriver.Text;
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict["Car Hire"].EndHire    = Convert.ToDateTime(clrEndHire.SelectedDate);
                        data.CustDict.StoreCustomers[_custID].DictBookings[_bookingID].ExtraDict["Car Hire"].StartHire  = Convert.ToDateTime(clrStartHire.SelectedDate);
                    }
                }

                else
                {
                    if (clrArrival.SelectedDate == null || clrDeparture.SelectedDate == null)
                    {
                        throw new ArgumentException("Please selecet an Arrival Date and a Departure Date");
                    }

                    _newBooking = new Business.Booking(_bookingID, Convert.ToDateTime(clrArrival.SelectedDate), Convert.ToDateTime(clrDeparture.SelectedDate));

                    foreach (KeyValuePair <string, Guest> guest in _tempGuestDict)
                    {
                        _newBooking.addGuest(guest.Value);
                    }

                    if (ckbBreakfast.IsChecked == true)
                    {
                        Extra extra = new Extra("Breakfast");
                        extraType.SetExtra(breakfast);
                        breakfast.ProcessExtra(extra);
                        _newBooking.addExtra(extra);
                    }

                    if (ckbDinner.IsChecked == true)
                    {
                        Extra extra = new Extra("Evening Meal");
                        extraType.SetExtra(eveningMeal);
                        eveningMeal.ProcessExtra(extra);
                        _newBooking.addExtra(extra);
                    }

                    if (ckbCarHire.IsChecked == true)
                    {
                        if (clrStartHire.SelectedDate == null || clrEndHire.SelectedDate == null || tbxDriver.Text == null)
                        {
                            throw new ArgumentException("Please select a start hire date, an end hire date, and a driver name.");
                        }

                        Extra extra = new Extra("Car Hire");
                        extraType.SetExtra(carHire);
                        carHire.ProcessExtra(extra);
                        extra.DriverName = tbxDriver.Text;
                        extra.StartHire  = Convert.ToDateTime(clrStartHire.SelectedDate);
                        extra.EndHire    = Convert.ToDateTime(clrEndHire.SelectedDate);
                        _newBooking.addExtra(extra);
                    }

                    data.CustDict.StoreCustomers[_custID].addBooking(_newBooking);

                    if (!data.CustDict.ChaletsBooked.Contains(Int32.Parse(tbxChaletID.Text)))
                    {
                        _newBooking.ChaletID = Int32.Parse(tbxChaletID.Text);
                        data.CustDict.ChaletsBooked.Add(_newBooking.ChaletID);
                    }
                    else
                    {
                        throw new ArgumentException("Chalet already booked, please choose another chalet.");
                    }
                }

                data.updateFile();
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message);
            }
        }