private void NewButton_Click(object sender, RoutedEventArgs e) { // Controleren Coach selectedCoach = (Coach)CoachComboBox.SelectedItem; if (string.IsNullOrWhiteSpace(CoachComboBox.Text)) { _errorText = "Coachnaam is niet ingevuld, vul een naam in"; NotifyPropertyChanged("ErrorText"); return; } _selectedCoach = coachController.getOnNaam(CoachComboBox.Text); // Indien de Coach al voorkomt, mag je die niet verder gaan if (_selectedCoach != null)// De coach bestaat niet indien gevonden record leeg is. { _errorText = "Coach bestaat al, kies een andere naam"; NotifyPropertyChanged("ErrorText"); return; } if (_selectedCoach == null) { _selectedCoach = new Coach(CoachComboBox.Text); } // Uitvoeren CoachDataPage CoachDataPage = new CoachDataPage(_selectedCoach); CoachDataPage.setCoach(_selectedCoach); this.NavigationService.Navigate(CoachDataPage); }
private void EnterButton_Click(object sender, RoutedEventArgs e) { Coach selectedCoach = (Coach)CoachComboBox.SelectedItem; if (selectedCoach == null) { _errorText = "Coachnaam is niet ingevuld, vul een naam in"; NotifyPropertyChanged("ErrorText"); return; } _selectedCoach = coachController.getOnNaam(selectedCoach.Naam); if (_selectedCoach == null) { // Naam komt niet voor, wijzigen is niet mogelijk _errorText = "Coachnaam komt niet voor in bestand, kies een andere naam"; NotifyPropertyChanged("ErrorText"); return; } //coachList.Add(new Coach("xxx de Lange","xxx",true); NotifyPropertyChanged("CoachList"); // method implemented below //this.NavigationService.Navigate(new CoachDataPage()); CoachDataPage CoachDataPage = new CoachDataPage(_selectedCoach); CoachDataPage.setCoach(_selectedCoach); this.NavigationService.Navigate(CoachDataPage); }