oop_AM-6/WebClient/WpfWebClient/PatientForm.xaml.cs

94 lines
3.5 KiB
C#
Raw Normal View History

2018-06-03 17:24:48 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WpfWebClient.ServiceReferenceEHEC;
namespace WpfWebClient
{
/// <summary>
/// Interaction logic for PatientForm.xaml
/// </summary>
public partial class PatientForm : Page
{
public PatientForm()
{
InitializeComponent();
WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
2018-07-01 15:32:50 +02:00
2018-06-03 17:24:48 +02:00
// Retrieve all salutations and save them into "salutationlist"
2018-07-01 15:32:50 +02:00
List<WpfWebClient.ServiceReferenceEHEC.Salutation> salutationlist = new List<ServiceReferenceEHEC.Salutation>(client.GetSalutations());
2018-06-10 19:34:30 +02:00
// Display all salutations with name in Combobox
2018-07-01 15:32:50 +02:00
ComboBoxSalutations.ItemsSource = salutationlist;
ComboBoxSalutations.DisplayMemberPath = "Name";
2018-06-17 17:08:06 +02:00
// Retrieve all genders and save them into "genderlist"
2018-08-06 23:25:32 +02:00
List<WpfWebClient.ServiceReferenceEHEC.Gender> genderlist = new List<ServiceReferenceEHEC.Gender>(client.GetGenders());
// Display all genders with name in Combobox
2018-08-06 23:25:32 +02:00
ComboBoxGenders.ItemsSource = genderlist;
ComboBoxGenders.DisplayMemberPath = "Name";
// Retrieve all cities and save them into "citylist"
2018-07-01 15:32:50 +02:00
List<WpfWebClient.ServiceReferenceEHEC.City> citylist = new List<ServiceReferenceEHEC.City>(client.GetCities());
// Display all cities with name in Combobox
2018-07-01 15:32:50 +02:00
ComboBoxCities.ItemsSource = citylist;
ComboBoxCities.DisplayMemberPath = "Name";
// Retrieve all salutations and save them into "countrylist"
2018-07-01 15:32:50 +02:00
List<WpfWebClient.ServiceReferenceEHEC.Country> countrylist = new List<ServiceReferenceEHEC.Country>(client.GetCountries());
// Display all countries with name in Combobox
2018-07-01 15:32:50 +02:00
ComboBoxCountries.ItemsSource = countrylist;
ComboBoxCountries.DisplayMemberPath = "Name";
2018-08-06 23:25:32 +02:00
client.Close();
2018-06-10 19:34:30 +02:00
2018-08-06 23:25:32 +02:00
}
2018-06-10 19:34:30 +02:00
2018-08-06 23:25:32 +02:00
private void btnAddPatient_Click(object sender, RoutedEventArgs e)
{
2018-06-10 19:34:30 +02:00
2018-08-06 23:25:32 +02:00
WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
Person p = new Person();
2018-09-20 21:36:41 +02:00
if (ComboBoxSalutations.SelectedValue != null && ComboBoxSalutations.SelectedValue is Salutation)
if (ComboBoxGenders.SelectedValue != null && ComboBoxGenders.SelectedValue is Gender)
if (ComboBoxCities.SelectedValue != null && ComboBoxCities.SelectedValue is City)
2018-08-06 23:25:32 +02:00
// Pick all selected fields and send object to client
2018-08-06 23:25:32 +02:00
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);
2018-08-12 20:33:28 +02:00
// Show success msgbox
System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
2018-08-06 23:25:32 +02:00
client.Close();
2018-06-03 17:24:48 +02:00
}
}
}