diff --git a/WebClient/WpfWebClient/App.config b/WebClient/WpfWebClient/App.config index bd946c2..39ddb92 100644 --- a/WebClient/WpfWebClient/App.config +++ b/WebClient/WpfWebClient/App.config @@ -6,7 +6,7 @@ - + diff --git a/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.cs b/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.cs index d14c6e5..25d42c9 100644 --- a/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.cs +++ b/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.cs @@ -427,6 +427,9 @@ namespace WpfWebClient.ServiceReferenceEHEC { [System.Runtime.Serialization.OptionalFieldAttribute()] private WpfWebClient.ServiceReferenceEHEC.Person PatientField; + [System.Runtime.Serialization.OptionalFieldAttribute()] + private int PatientAtFoodPlaceIDField; + [System.Runtime.Serialization.OptionalFieldAttribute()] private int PatientIDField; @@ -482,6 +485,19 @@ namespace WpfWebClient.ServiceReferenceEHEC { } } + [System.Runtime.Serialization.DataMemberAttribute()] + public int PatientAtFoodPlaceID { + get { + return this.PatientAtFoodPlaceIDField; + } + set { + if ((this.PatientAtFoodPlaceIDField.Equals(value) != true)) { + this.PatientAtFoodPlaceIDField = value; + this.RaisePropertyChanged("PatientAtFoodPlaceID"); + } + } + } + [System.Runtime.Serialization.DataMemberAttribute()] public int PatientID { get { diff --git a/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.svcmap b/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.svcmap index bad882e..eddd7d5 100644 --- a/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.svcmap +++ b/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Reference.svcmap @@ -1,5 +1,5 @@ - + false true @@ -22,11 +22,11 @@ - - - - - + + + + + diff --git a/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Service2.xsd b/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Service2.xsd index 0fa48e2..9931714 100644 --- a/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Service2.xsd +++ b/WebClient/WpfWebClient/Connected Services/ServiceReferenceEHEC/Service2.xsd @@ -48,6 +48,7 @@ + diff --git a/WebClient/WpfWebClient/ExamForm.xaml.cs b/WebClient/WpfWebClient/ExamForm.xaml.cs index 99e1486..6a3c2bc 100644 --- a/WebClient/WpfWebClient/ExamForm.xaml.cs +++ b/WebClient/WpfWebClient/ExamForm.xaml.cs @@ -55,6 +55,17 @@ namespace WpfWebClient ComboBoxFoodPlace.ItemsSource = fplist; ComboBoxFoodPlace.DisplayMemberPath = "Name"; + // 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); + } + client.Close(); } @@ -64,29 +75,75 @@ namespace WpfWebClient Exam exam = new Exam(); - exam.Date = dateboxExamDate.SelectedDate.Value; - exam.Doctor = (Doctor)ComboBoxDoctors.SelectedValue; - exam.Patient = (Person)ComboBoxPatients.SelectedValue; - exam.Description = txtDescription.Text; - exam.Strain = (Strain)ComboBoxStrains.SelectedValue; + // check if any box is empty - client.WriteExam(exam); + if (ComboBoxDoctors.SelectedIndex == -1) + { + System.Windows.MessageBox.Show("Please choose a doctor", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + + } - PatientAtFoodPlace patf = new PatientAtFoodPlace(); + 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; - patf.FoodPlace = (FoodPlace)ComboBoxFoodPlace.SelectedValue; - patf.Patient = (Person)ComboBoxPatients.SelectedValue; - patf.PatientID = ComboBoxPatients.SelectedIndex; - patf.VistingDate = dateboxFoodplaceDate.SelectedDate.Value; + + client.WriteExam(exam); + } - client.WriteRelation(patf); + PatientAtFoodPlace patf = new PatientAtFoodPlace(); - // Show success msgbox - System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + // check if any box is empty + + if (ComboBoxFoodPlace.SelectedIndex == -1) + { + System.Windows.MessageBox.Show("Please choose a food place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + } + + 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); + + } client.Close(); + } } } diff --git a/WebClient/WpfWebClient/FoodplaceForm.xaml.cs b/WebClient/WpfWebClient/FoodplaceForm.xaml.cs index 6697c79..1c38509 100644 --- a/WebClient/WpfWebClient/FoodplaceForm.xaml.cs +++ b/WebClient/WpfWebClient/FoodplaceForm.xaml.cs @@ -44,7 +44,30 @@ namespace WpfWebClient FoodPlace fp = new FoodPlace(); + // check if any box is empty + if (ComboBoxFPCities.SelectedIndex == -1) + { + System.Windows.MessageBox.Show("Please select a city", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + } + + if (txtFoodPlaceName.Text == null) + { + System.Windows.MessageBox.Show("Please enter a name for the food place", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + } + + if (txtFoodPlaceHouseNumber.Text == null) + { + System.Windows.MessageBox.Show("Please enter a house number", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + } + + if (txtFoodPlaceStreetName.Text == null) + { + System.Windows.MessageBox.Show("Please enter a street name", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + } + + else + { fp.Streetname = txtFoodPlaceStreetName.Text; fp.Streetnumber = txtFoodPlaceHouseNumber.Text; fp.Name = txtFoodPlaceName.Text; @@ -53,8 +76,9 @@ namespace WpfWebClient client.WriteFoodPlace(fp); - // Show success msgbox - System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + // Show success msgbox + System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information); + } client.Close(); } diff --git a/WebClient/WpfWebClient/Helper/GenerateTestData.cs b/WebClient/WpfWebClient/Helper/GenerateTestData.cs index 01175be..8db75b0 100644 --- a/WebClient/WpfWebClient/Helper/GenerateTestData.cs +++ b/WebClient/WpfWebClient/Helper/GenerateTestData.cs @@ -10,6 +10,7 @@ namespace WpfWebClient.Helper public static class GenerateTestData { private static List Foodplaces = new List(); + private static List PatientsAtFoodPlaces = new List(); private static List Exams = new List(); private static Random random = new Random(); @@ -53,10 +54,10 @@ namespace WpfWebClient.Helper int Description = random.Next(FoodPlaceDescription.Count); string FoodPlaceDescr = FoodPlaceDescription[Description]; int StreetName = random.Next(FoodPlaceStreetName.Count); - string FoodPlacesm = FoodPlaceStreetName[StreetName]; + string FoodPlacesn = FoodPlaceStreetName[StreetName]; string FoodPlaceName = FoodPlaceNameFirstPart[FirstPart] + FoodPlaceNameSecondPart[SecondPart]; - string streetname = FoodPlacesm; + string streetname = FoodPlacesn; string fpdescr = FoodPlaceDescr; int StreetNumber = random.Next(1, 100); int CityID = random.Next(1, cities.Count()); @@ -77,5 +78,41 @@ namespace WpfWebClient.Helper return Foodplaces; } + + + + public static List CreatePatientAtFoodPlaces() + { + WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient(); + List foodPlaces = new List(client.GetFoodPlaces()); + List patients = new List(client.GetPersons()); + + + + int i = 0; + + do + { + PatientAtFoodPlace patf = new PatientAtFoodPlace(); + + int randnumFP = random.Next(0, foodPlaces.Count()); + FoodPlace foodpl = foodPlaces[randnumFP]; + + int randnumP = random.Next(0, patients.Count()); + Person patient = patients[randnumP]; + + patf.FoodPlace = foodpl; + patf.Patient = patient; + //patf.PatientID = i; + patf.VistingDate = new DateTime(2005, 12, 20); + + PatientsAtFoodPlaces.Add(patf); + + i++; + + } while (i < 5); + + return PatientsAtFoodPlaces; + } } } diff --git a/WebClient/WpfWebClient/Helper/RandomDateTime.cs b/WebClient/WpfWebClient/Helper/RandomDateTime.cs new file mode 100644 index 0000000..1fa93ab --- /dev/null +++ b/WebClient/WpfWebClient/Helper/RandomDateTime.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WpfWebClient.Helper +{ + class RandomDateTime + { + DateTime start; + Random gen; + int range; + + public RandomDateTime() + { + start = new DateTime(1995, 1, 1); + gen = new Random(); + range = (DateTime.Today - start).Days; + } + + public DateTime Next() + { + return start.AddDays(gen.Next(range)).AddHours(gen.Next(0, 24)).AddMinutes(gen.Next(0, 60)).AddSeconds(gen.Next(0, 60)); + } + } +} diff --git a/WebClient/WpfWebClient/Home.xaml b/WebClient/WpfWebClient/Home.xaml index 94e9aef..f557fc0 100644 --- a/WebClient/WpfWebClient/Home.xaml +++ b/WebClient/WpfWebClient/Home.xaml @@ -10,17 +10,15 @@