Example #1
0
        public static AbstractBooking booking      = null; // booking from which all details are taken
        public BookingDetails()
        {
            InitializeComponent();
            disableControls();
            txtBoxEditPassp.MaxLength = 10;
            txtBoxEditName.MaxLength  = 50;

            // below code retreives booking information from the database and constructs a booking object
            // which is then used to populate booking details in the window
            booking = DataLayerFacade.RetreiveBooking(bookingRef);
            booking.BookingRefNo         = bookingRef;
            datePickArrival.SelectedDate = booking.ArrivalDate;
            datePickDepart.SelectedDate  = booking.DepartureDate;
            lblBookingRef1.Content       = bookingRef;
            lblCustName.Content          = booking.Client.Name;
            lblCustAddress.Content       = booking.Client.Address;
            foreach (var guest in booking.GuestList)
            {
                listBoxGuests.Items.Add(guest.Name);
                comBoxDriver.Items.Add(guest.Name);
            }
            if (booking.GetType() == typeof(CarHireDecorator))
            {
                checkBoxCarHire.IsChecked      = true;
                datePickHireStart.SelectedDate = ((CarHireDecorator)booking).StartDate;
                datePickHireEnd.SelectedDate   = ((CarHireDecorator)booking).EndDate;
                comBoxDriver.SelectedItem      = ((CarHireDecorator)booking).Driver;
                lblHireFrom.Visibility         = Visibility.Visible;
                lblHireTo.Visibility           = Visibility.Visible;
                lblDriver.Visibility           = Visibility.Visible;
                datePickHireStart.Visibility   = Visibility.Visible;
                datePickHireEnd.Visibility     = Visibility.Visible;
                comBoxDriver.Visibility        = Visibility.Visible;
                var carDecorator = (CarHireDecorator)booking;
                if (carDecorator.Component.GetType() == typeof(BreakfastDecorator))
                {
                    checkBoxBreakfast.IsChecked = true;
                    var breakfasrDecorator = (BreakfastDecorator)carDecorator.Component;
                    if (breakfasrDecorator.Component.GetType() == typeof(EveningMealDecorator))
                    {
                        checkBoxEvMeal.IsChecked = true;
                    }
                }
                if (carDecorator.Component.GetType() == typeof(EveningMealDecorator))
                {
                    checkBoxEvMeal.IsChecked = true;
                }
            }
            if (booking.GetType() == typeof(BreakfastDecorator))
            {
                checkBoxBreakfast.IsChecked = true;
                var breakfasrDecorator = (BreakfastDecorator)booking;
                if (breakfasrDecorator.Component.GetType() == typeof(EveningMealDecorator))
                {
                    checkBoxEvMeal.IsChecked = true;
                }
            }
            if (booking.GetType() == typeof(EveningMealDecorator))
            {
                checkBoxEvMeal.IsChecked = true;
            }

            comBoxChaletId.Items.Add(booking.ChaletId);
            comBoxChaletId.SelectedItem = booking.ChaletId;
        }