Example #1
0
        // logic for the save changes button. Saves other changes to the booking in the current object and
        // in the database
        private void btnSaveCh_Click(object sender, RoutedEventArgs e)
        {
            DateTime arrivalDate      = datePickArrival.SelectedDate.Value.Date;
            DateTime departureDate    = datePickDepart.SelectedDate.Value.Date;
            int      chaletId         = Convert.ToInt32(comBoxChaletId.SelectionBoxItem);
            bool     isBreakfastDec   = checkBoxBreakfast.IsChecked.Value;
            bool     isEveningMealDec = checkBoxEvMeal.IsChecked.Value;

            DataLayerFacade.AmendBooking(bookingRef, arrivalDate, departureDate,
                                         chaletId, isBreakfastDec, isEveningMealDec);
            bool isCarHireDec = checkBoxCarHire.IsChecked.Value;

            if (isCarHireDec)
            {
                DateTime hireStart = datePickHireStart.SelectedDate.Value.Date;
                DateTime hireEnd   = datePickHireEnd.SelectedDate.Value.Date;
                string   driver    = comBoxDriver.SelectionBoxItem.ToString();
                if (booking.GetType() == typeof(CarHireDecorator))
                {
                    DataLayerFacade.AmendCarHire(driver, bookingRef,
                                                 hireStart, hireEnd);
                }
                else
                {
                    DataLayerFacade.AddCarHire(driver, bookingRef,
                                               hireStart, hireEnd);
                }
            }
            else
            {
                if (booking.GetType() == typeof(CarHireDecorator))
                {
                    DataLayerFacade.RemoveCarHire(bookingRef);
                }
            }
            this.Close();
            MessageBox.Show("The booking has been amended.");
        }