示例#1
0
        public static void createAddOfferPopupWindow()
        {
            DataModels database = DataModels.GetInstance();
            Window     popup    = new Window
            {
                Width  = 330,
                Height = 400,
                WindowStartupLocation = WindowStartupLocation.CenterScreen,
                Title = "Add Offer"
            };

            StackPanel stackPanel = new StackPanel
            {
                Background = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                Margin     = new Thickness(10, popup.Height / 4, 10, 10)
            };

            Grid popupGrid = new Grid
            {
                Background        = new SolidColorBrush(Color.FromRgb(255, 255, 255)),
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    },
                    new ColumnDefinition {
                        Width = GridLength.Auto
                    }
                },
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = GridLength.Auto
                    },                                            // Website combo
                    new RowDefinition {
                        Height = GridLength.Auto
                    },                                            // Hotel Combo
                    new RowDefinition {
                        Height = GridLength.Auto
                    },                                            // Room # Combo
                    new RowDefinition {
                        Height = GridLength.Auto
                    }                                            // Price TextBox
                }
            };

            popup.Content = stackPanel;
            stackPanel.Children.Add(popupGrid);


            //
            Label websiteLabel = new Label
            {
                Content  = "Website: ",
                FontSize = 17
            };

            Grid.SetColumn(websiteLabel, 0);
            Grid.SetRow(websiteLabel, 0);
            popupGrid.Children.Add(websiteLabel);

            //
            Label hotelLicenceLabel = new Label
            {
                Content  = "Hotel: ",
                FontSize = 17
            };

            Grid.SetColumn(hotelLicenceLabel, 0);
            Grid.SetRow(hotelLicenceLabel, 1);
            popupGrid.Children.Add(hotelLicenceLabel);

            //
            Label roomNumberLabel = new Label
            {
                Content  = "Room number: ",
                FontSize = 17
            };

            Grid.SetColumn(roomNumberLabel, 0);
            Grid.SetRow(roomNumberLabel, 2);
            popupGrid.Children.Add(roomNumberLabel);

            //
            Label offerPriceLabel = new Label
            {
                Content  = "Offer Price: ",
                FontSize = 17
            };

            Grid.SetColumn(offerPriceLabel, 0);
            Grid.SetRow(offerPriceLabel, 3);
            popupGrid.Children.Add(offerPriceLabel);


            //
            ComboBox websiteCombo = new ComboBox
            {
                Width    = 150,
                Height   = 30,
                FontSize = 15
            };

            Grid.SetColumn(websiteCombo, 1);
            Grid.SetRow(websiteCombo, 0);
            websiteCombo.ItemsSource   = database.GetAllWebsites();
            websiteCombo.SelectedIndex = 0;
            popupGrid.Children.Add(websiteCombo);

            //
            ComboBox hotelLicenceCombo = new ComboBox
            {
                Width    = 150,
                Height   = 30,
                FontSize = 15
            };

            Grid.SetColumn(hotelLicenceCombo, 1);
            Grid.SetRow(hotelLicenceCombo, 1);
            hotelLicenceCombo.ItemsSource       = database.GetAllHotels();
            hotelLicenceCombo.SelectedIndex     = 0;
            hotelLicenceCombo.SelectionChanged += HotelLicenceCombo_SelectionChanged;
            popupGrid.Children.Add(hotelLicenceCombo);

            //
            ComboBox roomNumberCombo = new ComboBox
            {
                Width    = 150,
                Height   = 30,
                FontSize = 15
            };

            Grid.SetColumn(roomNumberCombo, 1);
            Grid.SetRow(roomNumberCombo, 2);

            roomNumberCombo.ItemsSource   = database.GetHotelRooms(((Hotel)hotelLicenceCombo.SelectedItem).licenseNumber);
            roomNumberCombo.SelectedIndex = 0;
            popupGrid.Children.Add(roomNumberCombo);
            hotelLicenceCombo.Tag = roomNumberCombo;

            //
            TextBox offerPriceTextBox = new TextBox
            {
                Width    = 150,
                Height   = 20,
                FontSize = 15
            };

            Grid.SetColumn(offerPriceTextBox, 1);
            Grid.SetRow(offerPriceTextBox, 3);
            popupGrid.Children.Add(offerPriceTextBox);

            Button addOfferConfirmButton = FrontEndHelper.CreateButton(80, 40, "Add");

            addOfferConfirmButton.Margin = new Thickness(0, 10, 0, 0);

            List <Object> data = new List <Object>();

            data.Add(websiteCombo);
            data.Add(hotelLicenceCombo);
            data.Add(roomNumberCombo);
            data.Add(offerPriceTextBox);

            addOfferConfirmButton.Tag    = data;
            addOfferConfirmButton.Click += AddOfferConfirmButton_Click;;
            stackPanel.Children.Add(addOfferConfirmButton);

            popup.Owner = GetAdminWindow();
            popup.ShowDialog();
        }
示例#2
0
        private void Websites_Button_Click(object sender, RoutedEventArgs e)
        {
            if (currentCanvas != null)
            {
                currentCanvas.Hide();
            }
            DataModels model = DataModels.GetInstance();
            Admin_WebsitesControlCanvas websitesCanvas = Admin_WebsitesControlCanvas.GetInstance(WebsitesCanvas, model.GetAllWebsites());

            websitesCanvas.SetCanvasCoord(TabsRectangle.Width, HeaderRectangle.Height);
            websitesCanvas.SetCanvasDimensions(Width - TabsRectangle.Width, Height - HeaderRectangle.Height);
            websitesCanvas.Show();
        }