private void OkButton_Click(object sender, RoutedEventArgs e) { if (CitiesComboBox.SelectedItem == null) { MessageBox.Show("Select city!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (ModelsListView.SelectedItem == null) { MessageBox.Show("Select model!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrWhiteSpace(NumberTextBox.Text)) { MessageBox.Show("Input number!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if ((DateTime)DateCalender.SelectedDate == null) { MessageBox.Show("Select date!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } db.BuyCar((CitiesComboBox.SelectedItem as City).id, (ModelsListView.SelectedItem as CarModelCargoType).id, (DateTime)DateCalender.SelectedDate, NumberTextBox.Text); Close(); }
private void OkButton_Click(object sender, RoutedEventArgs e) { double cost = 0; if (CitiesComboBox.SelectedItem == null || CarTypeComboBox.SelectedItem == null || !double.TryParse(CostTextBox.Text, out cost) || string.IsNullOrWhiteSpace(NumberTextBox.Text)) // data??? { MessageBox.Show("Check input data", "", MessageBoxButton.OK, MessageBoxImage.Error); //change return; } db.BuyCar(CitiesComboBox.SelectedItem as City, CarTypeComboBox.SelectedItem as CarModel, DateCalender.DisplayDate, cost, NumberTextBox.Text); Close(); }
private void OkButton_Click(object sender, RoutedEventArgs e) { char[] name; if (CitiesComboBox.SelectedItem == null) { MessageBox.Show("Select city!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (ModelsListView.SelectedItem == null) { MessageBox.Show("Select model!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (string.IsNullOrWhiteSpace(NumberTextBox.Text)) { MessageBox.Show("Input number!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } name = NumberTextBox.Text.ToCharArray(0, NumberTextBox.Text.Length); if (NumberTextBox.Text.Length != 6 || !char.IsLetter(name[0]) || !char.IsLetter(name[4]) || !char.IsLetter(name[5]) || !char.IsDigit(name[1]) || !char.IsDigit(name[2]) || !char.IsDigit(name[3])) { MessageBox.Show("Input number as: a000aa, where a - any letter, 0 - any number!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } if (DateCalender.SelectedDate == null) { MessageBox.Show("Select date!", "", MessageBoxButton.OK, MessageBoxImage.Error); return; } db.BuyCar((CitiesComboBox.SelectedItem as City).id, (ModelsListView.SelectedItem as CarModelCargoType).id, (DateTime)DateCalender.SelectedDate, NumberTextBox.Text); Close(); }