Exemplo n.º 1
0
        public static void CreateReservePopupWindow(RoomsListShowCanvas roomListShowCanvas, int index)
        {
            DataModels database = DataModels.GetInstance();

            Window popup = new Window
            {
                Width  = 350,
                Height = 500,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                Title = "Confirm Booking"
            };

            Grid popupGrid = new Grid
            {
                Background = new SolidColorBrush(Color.FromRgb(255, 255, 255))
            };

            popup.Content = popupGrid;

            StackPanel reservePopupStackPanel = new StackPanel
            {
                Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                Margin     = new Thickness(10, 10, 10, 10)
            };

            popupGrid.Children.Add(reservePopupStackPanel);

            Grid numberofGuestsGrid = new Grid
            {
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    }
                }
            };

            reservePopupStackPanel.Children.Add(numberofGuestsGrid);

            Label numberofGuestsLabel = new Label
            {
                Content  = "Number of Guests : ",
                FontSize = 22
            };

            Grid.SetColumn(numberofGuestsLabel, 0);
            numberofGuestsGrid.Children.Add(numberofGuestsLabel);

            TextBox numberofGuestTextBox = new TextBox
            {
                Width    = 50,
                FontSize = 22
            };

            Grid.SetColumn(numberofGuestTextBox, 1);
            numberofGuestsGrid.Children.Add(numberofGuestTextBox);

            Label mealLabel = new Label
            {
                Content  = "Meal Plan : " + roomListShowCanvas.GetSelectedMealPlan(index).name,
                FontSize = 22,
                Margin   = new Thickness(0, 10, 0, 0)
            };

            reservePopupStackPanel.Children.Add(mealLabel);

            Label websiteLabel = new Label
            {
                Content  = "Website : " + roomListShowCanvas.GetSelectedWebsite(index).name,
                FontSize = 22,
                Margin   = new Thickness(0, 10, 0, 0)
            };

            reservePopupStackPanel.Children.Add(websiteLabel);

            Label priceLabel = new Label
            {
                Content  = "Price : ",
                FontSize = 22,
                Margin   = new Thickness(0, 10, 0, 0)
            };

            reservePopupStackPanel.Children.Add(priceLabel);

            Calendar datePicker = new Calendar
            {
                SelectionMode = CalendarSelectionMode.SingleRange,
                Margin        = new Thickness(0, 10, 0, 0)
            };

            datePicker.SelectedDate     = DateTime.Now;
            datePicker.DisplayDateStart = DateTime.Today;
            List <Booking> bookings = database.GetRoomBookings(roomListShowCanvas.GetSelectedRoom(index));

            foreach (Booking booking in bookings)
            {
                datePicker.BlackoutDates.Add(new CalendarDateRange(booking.startDate, booking.endDate));
            }
            reservePopupStackPanel.Children.Add(datePicker);

            Button confirmReserveButton = FrontEndHelper.CreateButton(80, 40, "Confirm");

            confirmReserveButton.Margin = new Thickness(0, 10, 0, 0);
            confirmReserveButton.Click += ConfirmReserveButton_Click;
            reservePopupStackPanel.Children.Add(confirmReserveButton);
            List <object> data = new List <object>();

            data.Add(datePicker);
            data.Add(numberofGuestTextBox);
            data.Add(roomListShowCanvas);
            data.Add(index);
            confirmReserveButton.Tag = data;

            popup.Owner = GetMainWindow();
            popup.ShowDialog();
        }