Esempio n. 1
0
        public CarWindow_Car(SqlConnection conn, CarQh car)
        {
            InitializeComponent();
            connection  = conn;
            selectedCar = car;

            if (selectedCar != null)
            {
                var title = "Show car";
                Title = title;
                TitleTextBlock.Text        = title;
                CPNTextBox.Text            = selectedCar.Car_Plate_Number;
                CPNTextBox.IsEnabled       = false;
                CPNButton.IsEnabled        = false;
                ColourComboBox.ItemsSource = null;
                ColourComboBox.ItemsSource = new List <string>()
                {
                    selectedCar.Colour
                };
                ColourComboBox.SelectedIndex = 0;
                ColourComboBox.IsEnabled     = false;
                ModelComboBox.ItemsSource    = null;
                ModelComboBox.ItemsSource    = new List <ModelQh>()
                {
                    qm.QueryModels(connection).Find(x => x.Model_ID == selectedCar.Model_ID)
                };
                ModelComboBox.SelectedIndex = 0;
                NumOfSessionsTextBlock.Text = $"Number of sessions, where this car was used: {qm.QueryNumOfSessions(connection, selectedCar.Car_ID)}";
            }
            else
            {
                var title = "Add car";
                Title = title;
                TitleTextBlock.Text        = title;
                ColourComboBox.ItemsSource = null;
                ColourComboBox.ItemsSource = new List <string>()
                {
                    "Black",
                    "Green",
                    "White",
                    "Blue",
                    "Red",
                    "Yellow",
                    "Silver",
                    "Purple",
                    "Brown",
                    "Grey",
                    "Orange",
                    "Cyan",
                    "Graphite",
                    "Mixed colour"
                };
            }
        }
Esempio n. 2
0
        private void ShowCarButton_OnClick(object sender, RoutedEventArgs e)
        {
            CarQh selectedCar = (CarQh)CarsDataGrid.SelectedItem;

            if (selectedCar == null)
            {
                MessageBox.Show("Choose car to show");
                return;
            }
            var show = new CarWindow_Car(conn, selectedCar);

            show.ShowDialog();
            UpdateCars();
        }
        private void CarButton_OnClick(object sender, RoutedEventArgs e)
        {
            selectedCar = (CarQh)CarComboBox.SelectedItem;
            if (selectedCar == null)
            {
                MessageBox.Show("Choose car to continue");
                return;
            }

            StartComboBox.IsEnabled   = true;
            StartButton.IsEnabled     = true;
            StartComboBox.ItemsSource = null;
            StartComboBox.ItemsSource = qm.QueryRentals(connection);
            CarComboBox.IsEnabled     = false;
            CarButton.IsEnabled       = false;
        }