private void OlympiadComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { GetPropForSelectedService getService = new GetPropForSelectedService(); PersonComboBox.ItemsSource = getService.GetPersons() .Where(x => x.Country.Name == (OlympiadComboBox.SelectedValue as Olympiad).Country.Name); }
private void Add_Click(object sender, RoutedEventArgs e) { OlympResult newType = new OlympResult(); GetPropForSelectedService getService = new GetPropForSelectedService(); newType.OlympID = getService.GetOlympiads().FirstOrDefault(x => x.Date == (OlympiadComboBox.SelectedItem as Olympiad).Date).ID; newType.SportTypeID = getService.GetSportTypes().FirstOrDefault(x => x.Name == (OlympiadComboBox.SelectedItem as SportType).Name).ID; newType.PersonID = getService.GetPersons().FirstOrDefault(x => x.FirstName == (OlympiadComboBox.SelectedItem as Person).FirstName && x.SecondName == (OlympiadComboBox.SelectedItem as Person).SecondName && x.ThirdName == (OlympiadComboBox.SelectedItem as Person).ThirdName).ID; newType.Place = Convert.ToInt32(PlaceTextBox.Text); foreach (var or in getService.GetOlympsResult()) { if (or.Olympiad.Date == newType.Olympiad.Date) { if (or.SportType.Name == newType.SportType.Name) { //if(or.City.Name == newType.City.Name) if (or.Person.FirstName == newType.Person.FirstName) { if (or.Person.SecondName == newType.Person.SecondName) { if (or.Person.ThirdName == newType.Person.ThirdName) { if (or.Place == newType.Place) { MessageBox.Show("This node alredy exist."); return; } } } } } } } AddingService addService = new AddingService(); addService.AddOlympiadResultNode(newType); MessageBox.Show("New result node adding."); }
private void Add_Click(object sender, RoutedEventArgs e) { if (DatePicker.DisplayDate == null) { MessageBox.Show("Date can`t be null."); return; } if (PhotoPath == null) { MessageBox.Show("Photo can`t be null."); return; } Person newType = new Person(); GetPropForSelectedService getService = new GetPropForSelectedService(); newType.FirstName = FirstName; newType.SecondName = SecondName; newType.ThirdName = ThirdName; newType.CountryID = getService.GetCountry(false).FirstOrDefault(x => x.Name == (CountryComboBox.SelectedItem as Country).Name).ID; newType.DateOfBirth = DatePicker.SelectedDate.Value; newType.PhotoPath = PhotoPath; foreach (var p in getService.GetPersons()) { if (p.FirstName == newType.FirstName) { if (p.SecondName == newType.SecondName) { if (p.ThirdName == newType.ThirdName) { MessageBox.Show($"{p.FirstName} {p.SecondName} {p.ThirdName} alredy exist`s."); return; } } } } AddingService addService = new AddingService(); addService.AddPerson(newType); MessageBox.Show("New person added."); }
public AddOlympResultNode() { InitializeComponent(); GetPropForSelectedService getService = new GetPropForSelectedService(); Olympiads = RemakeOlymp(getService.GetOlympiads()); SportTypes = getService.GetSportTypes(); //Cities = getService.GetCities(); Persons = getService.GetPersons(); DataCheck(); OlympiadComboBox.ItemsSource = Olympiads; SportTypeComboBox.ItemsSource = SportTypes; PersonComboBox.ItemsSource = Persons; this.DataContext = this; }