Exemplo n.º 1
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            float weight = 0;

            if (CitiesFromComboBox.SelectedItem == null || CitiesToComboBox.SelectedItem == null ||
                CarTypeComboBox.SelectedItem == null || (!float.TryParse(PayloadTextBox.Text, out weight)) ||
                weight <= 0)                                                                         // data??
            {
                MessageBox.Show("Check input data", "", MessageBoxButton.OK, MessageBoxImage.Error); //change
                return;
            }

            CarsListView.ItemsSource =
                db.FindCarForTransaction(CitiesFromComboBox.SelectedItem as City,
                                         CitiesToComboBox.SelectedItem as City,
                                         DateCalender.DisplayDate,
                                         CarTypeComboBox.SelectedItem as CargoType,
                                         weight);
        }
Exemplo n.º 2
0
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            float weight = 0;

            if (CitiesFromComboBox.SelectedItem == null)
            {
                MessageBox.Show("Select city from!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (CitiesToComboBox.SelectedItem == null)
            {
                MessageBox.Show("Select city to!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (CitiesFromComboBox.SelectedItem == CitiesToComboBox.SelectedItem) // не работает почему-то :(
            {
                MessageBox.Show("Choose another city to!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (CarTypeComboBox.SelectedItem == null)
            {
                MessageBox.Show("Select cargo type!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (!float.TryParse(PayloadTextBox.Text, out weight) || weight <= 0)
            {
                MessageBox.Show("Input payload > 0!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if ((DateTime)DateCalender.SelectedDate == null)
            {
                MessageBox.Show("Select date!", "", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            CarsListView.ItemsSource =
                db.FindCarForTransaction(CitiesFromComboBox.SelectedItem as City,
                                         CitiesToComboBox.SelectedItem as City,
                                         (DateTime)DateCalender.SelectedDate,
                                         CarTypeComboBox.SelectedItem as CargoType,
                                         weight);
        }