private void btnAddPatient_Click(object sender, RoutedEventArgs e) { WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient(); Person p = new Person(); if (ComboBoxSalutations.SelectedValue != null && ComboBoxSalutations.SelectedValue is Salutation) { if (ComboBoxGenders.SelectedValue != null && ComboBoxGenders.SelectedValue is Gender) { if (ComboBoxCities.SelectedValue != null && ComboBoxCities.SelectedValue is City) { // Pick all selected fields and send object to client p.Salutation = (Salutation)ComboBoxSalutations.SelectedValue; } } } p.Gender = (Gender)ComboBoxGenders.SelectedValue; p.LastName = txtLastName.Text; p.FirstName = txtFirstName.Text; p.StreetName = txtStreetName.Text; p.StreetNumber = txtHouseNumber.Text; p.City = (City)ComboBoxCities.SelectedValue; client.WritePatient(p); // Show success msgbox System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); client.Close(); }