/*
         * Refreshes all booking detail fields displayed in the window
         * according to current booking state.
         */
        private void refreshBookDetailDisplay()
        {
            if (mFacade.IsABookingLoaded())
            {
                // update field contents:
                DateTime start;
                DateTime end;
                mFacade.GetCurrentBookDates(out start, out end);
                lblArrivalValue.Content   = start.ToString().Substring(0, 10);
                lblDepartureValue.Content = end.ToString().Substring(0, 10);
                lblCustNameValue.Content  = mFacade.GetCurrentCustName();
                lstGuests.Items.Clear();

                foreach (String g in mFacade.GetGuestNames())
                {
                    lstGuests.Items.Add(g);
                }

                // make labels visible:
                lblArrivalValue.Visibility   = Visibility.Visible;
                lblDepartureValue.Visibility = Visibility.Visible;
                lblCustNameValue.Visibility  = Visibility.Visible;
            }
            else
            {
                refreshDisplay();
            }
        }
        // METHODS RELATED TO CURRENT BOOKING:

        /*
         * Refreshes the booking fields displayed in the window.
         */
        private void refreshBookingDisplay()
        {
            if (mFacade.IsABookingLoaded())
            {
                DateTime arrival;
                DateTime departure;
                mFacade.GetCurrentBookDates(out arrival, out departure);
                dtpArrival.SelectedDate   = arrival;
                dtpDeparture.SelectedDate = departure;

                lblBookingRef.Content += mFacade.GetCurrentBookNb()
                                         .ToString();
                lblBookingRef.Visibility = Visibility.Visible;
            }
        }
Esempio n. 3
0
        /*
         * True if all the window fields are valid to create a car hire extra,
         * otherwise false.
         * Displays error message windows.
         */
        private bool areAllValuesValid()
        {
            bool     areValidValues = true;
            DateTime arrival;
            DateTime departure;

            mFacade.GetCurrentBookDates(out arrival, out departure);

            if (String.IsNullOrWhiteSpace(txtDriverName.Text))
            {
                areValidValues = false;
                MessageBox.Show("Please enter a driver name for the"
                                + "car hire.");
            }
            else if (dtpStart.SelectedDate == null)
            {
                areValidValues = false;
                MessageBox.Show("Please select a start date for the"
                                + " car hire.");
            }
            else if (dtpStart.SelectedDate < arrival ||
                     dtpStart.SelectedDate >= departure)
            {
                areValidValues = false;
                MessageBox.Show("The selected start date is outwith "
                                + " the booking dates.\r\n"
                                + "Please select a start date between"
                                + " booking arrival and departure dates.");
            }
            else if (dtpEnd.SelectedDate == null)
            {
                areValidValues = false;
                MessageBox.Show("Please select an end date for the"
                                + " car hire.");
            }
            else if (dtpEnd.SelectedDate <= arrival ||
                     dtpEnd.SelectedDate > departure)
            {
                areValidValues = false;
                MessageBox.Show("The selected end date is outwith "
                                + " the booking dates.\r\n"
                                + "Please select a start date between"
                                + " booking arrival and departure dates.");
            }

            return(areValidValues);
        }
        /*
         * Refreshes the booking fields displayed in the window.
         */
        private void refreshBookingDisplay()
        {
            DateTime start;
            DateTime end;

            mFacade.GetCurrentBookDates(out start, out end);

            // update labels content:
            lblBookingNbValue.Content = mFacade.GetCurrentBookNb().ToString();
            lblArrivalValue.Content   = start.ToString().Substring(0, 10);
            lblDepartureValue.Content = end.ToString().Substring(0, 10);

            // make labels visible:
            lblBooking.Visibility        = Visibility.Visible;
            lblBookingNb.Visibility      = Visibility.Visible;
            lblBookingNbValue.Visibility = Visibility.Visible;
            lblArrival.Visibility        = Visibility.Visible;
            lblArrivalValue.Visibility   = Visibility.Visible;
            lblDeparture.Visibility      = Visibility.Visible;
            lblDepartureValue.Visibility = Visibility.Visible;
        }