private void buttonOk_Click(object sender, RoutedEventArgs e) { if (SpeciesNameEN.Text == "" || SpeciesNameRU.Text == "" || DustingTime.Text == "" || PollenSculpture.Text == "" || ApertureStructure.Text == "" || ApertureNumber.Text == "" || AperturePosition.Text == "" || ApertureType.Text == "" || PollenPolarMinSize.Text == "" || PollenPolarMaxSize.Text == "" || PollenEquatorialMinSize.Text == "" || PollenEquatorialMaxSize.Text == "" || ExinePolarMin.Text == "" || ExinePolarMax.Text == "" || ExineEquatorialMin.Text == "" || ExineEquatorialMax.Text == "") { MessageBox.Show("Заполните форму", "ПРЕДУПРЕЖДЕНИЕ", MessageBoxButton.OK, MessageBoxImage.Information); } else { string strRU = SpeciesNameRU.Text.ToLower(); string strEN = SpeciesNameEN.Text.ToLower(); bool RUisOK = true; bool ENisOK = true; foreach (char b in strEN) { if (b >= 'а' && b <= 'я') { MessageBox.Show("Поле \"ЛАТИНСКОЕ НАЗВАНИЕ\" должно содержать только литинские символы!!!", "ПРЕДУПРЕЖДЕНИЕ", MessageBoxButton.OK, MessageBoxImage.Information); ENisOK = false; break; } } foreach (char a in strRU) { if (a >= 'a' && a <= 'z') { MessageBox.Show("Поле \"РУССКОЕ НАЗВАНИЕ\" должно содержать только символы кириллицы!!!", "ПРЕДУПРЕЖДЕНИЕ", MessageBoxButton.OK, MessageBoxImage.Information); RUisOK = false; break; } } if (RUisOK && ENisOK) { try { var plantTypeVM = new PlantTypeViewModel(); plantTypeVM.NameEN = SpeciesNameEN.Text; plantTypeVM.NameRU = SpeciesNameRU.Text; var genus = (GenusViewModel)GenusName.SelectedItem; genus.PlantTypes.Add(plantTypeVM); genusService.AddPlantTypeToGenus(genus.ID, plantTypeVM); genus.PlantTypes.Add(plantTypeVM); Close(); } catch (System.Data.Entity.Infrastructure.DbUpdateException) { MessageBox.Show("Проверьте \"ЛАТИНСКОЕ НАЗВАНИЕ\" и \"РУССКОЕ НАЗВАНИЕ\" возможно они уже присутствуют в базе данных!!!", "ПРЕДУПРЕЖДЕНИЕ", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show(ex.InnerException.Message, "ПРЕДУПРЕЖДЕНИЕ", MessageBoxButton.OK, MessageBoxImage.Information); } } } }