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

151 lines
5.4 KiB
C#
Raw Permalink Normal View History

2018-07-01 15:32:50 +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;
2018-07-28 13:47:47 +02:00
using System.Windows.Navigation;
2018-07-01 15:32:50 +02:00
using System.Windows.Shapes;
2018-07-28 13:47:47 +02:00
using WpfWebClient.ServiceReferenceEHEC;
2018-07-01 15:32:50 +02:00
namespace WpfWebClient
{
/// <summary>
2018-07-28 13:47:47 +02:00
/// Interaction logic for CaseForm.xaml
2018-07-01 15:32:50 +02:00
/// </summary>
2018-07-28 13:47:47 +02:00
public partial class ExamForm : Page
2018-07-01 15:32:50 +02:00
{
2018-07-28 13:47:47 +02:00
public ExamForm()
2018-07-01 15:32:50 +02:00
{
InitializeComponent();
2018-08-06 23:25:32 +02:00
WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
// Retrieve all doctors and save them into "doctorlist"
2018-08-06 23:25:32 +02:00
List<WpfWebClient.ServiceReferenceEHEC.Doctor> doctorlist = new List<ServiceReferenceEHEC.Doctor>(client.GetDoctors());
// Display all doctors with name in Combobox
2018-08-06 23:25:32 +02:00
ComboBoxDoctors.ItemsSource = doctorlist;
ComboBoxDoctors.DisplayMemberPath = "FirstName";
// Retrieve all patients and save them into "patientlist"
2018-08-06 23:25:32 +02:00
List<WpfWebClient.ServiceReferenceEHEC.Person> patientlist = new List<ServiceReferenceEHEC.Person>(client.GetPersons());
// Display all patients with name in Combobox
2018-08-06 23:25:32 +02:00
ComboBoxPatients.ItemsSource = patientlist;
ComboBoxPatients.DisplayMemberPath = "FirstName";
// Retrieve all strains and save them into "strainlist"
2018-08-06 23:25:32 +02:00
List<WpfWebClient.ServiceReferenceEHEC.Strain> strainlist = new List<ServiceReferenceEHEC.Strain>(client.GetStrains());
// Display all strains with name in Combobox
2018-08-06 23:25:32 +02:00
ComboBoxStrains.ItemsSource = strainlist;
ComboBoxStrains.DisplayMemberPath = "Name";
2018-08-19 15:58:02 +02:00
// Retrieve all foodplaces and save them into "fplist"
List<WpfWebClient.ServiceReferenceEHEC.FoodPlace> fplist = new List<ServiceReferenceEHEC.FoodPlace>(client.GetFoodPlaces());
// Display all foodplaces with name in Combobox
ComboBoxFoodPlace.ItemsSource = fplist;
ComboBoxFoodPlace.DisplayMemberPath = "Name";
2018-08-19 18:37:09 +02:00
// check for proper data
if (strainlist.Count == 0)
{
System.Windows.MessageBox.Show("Please create at least one Strain", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (fplist.Count == 0)
{
System.Windows.MessageBox.Show("Please create at least one Food Place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
2018-08-06 23:25:32 +02:00
client.Close();
}
private void btnAddFoodPlace_Click(object sender, RoutedEventArgs e)
{
WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
Exam exam = new Exam();
2018-08-19 18:37:09 +02:00
// check if any box is empty
if (ComboBoxDoctors.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Please choose a doctor", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (dateboxExamDate.SelectedDate == null)
{
System.Windows.MessageBox.Show("Please enter a date of consultation", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (ComboBoxPatients.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("No Patient? Really?", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
if (ComboBoxStrains.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Why would you fill out an exam when there is no strain?", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
exam.Date = dateboxExamDate.SelectedDate.Value;
exam.Doctor = (Doctor)ComboBoxDoctors.SelectedValue;
exam.Patient = (Person)ComboBoxPatients.SelectedValue;
exam.Description = txtDescription.Text;
exam.Strain = (Strain)ComboBoxStrains.SelectedValue;
2018-08-06 23:25:32 +02:00
2018-08-19 18:37:09 +02:00
client.WriteExam(exam);
2018-09-02 18:28:24 +02:00
2018-08-19 18:37:09 +02:00
}
2018-08-19 15:58:02 +02:00
2018-08-19 18:37:09 +02:00
PatientAtFoodPlace patf = new PatientAtFoodPlace();
2018-08-19 15:58:02 +02:00
2018-08-19 18:37:09 +02:00
// check if any box is empty
2018-08-19 15:58:02 +02:00
2018-08-19 18:37:09 +02:00
if (ComboBoxFoodPlace.SelectedIndex == -1)
{
System.Windows.MessageBox.Show("Please choose a food place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
2018-08-19 15:58:02 +02:00
2018-08-19 18:37:09 +02:00
if (dateboxFoodplaceDate.SelectedDate == null)
{
System.Windows.MessageBox.Show("Please enter a date at Foodplace", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
else
{
patf.FoodPlace = (FoodPlace)ComboBoxFoodPlace.SelectedValue;
patf.Patient = (Person)ComboBoxPatients.SelectedValue;
patf.PatientID = ComboBoxPatients.SelectedIndex;
patf.VistingDate = dateboxFoodplaceDate.SelectedDate.Value;
client.WriteRelation(patf);
// Show success msgbox
System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
}
2018-08-12 20:33:28 +02:00
2018-08-06 23:25:32 +02:00
client.Close();
2018-08-19 18:37:09 +02:00
2018-07-01 15:32:50 +02:00
}
}
}