示例#1
0
        private void btnCreateTestdata_Click(object sender, RoutedEventArgs e)
        {
            // create new client connection
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            // create a bunch of foodplaces
            var foodplaces = GenerateTestData.CreateFoodPlaces();

            foreach (var f in foodplaces)
            {
                client.WriteFoodPlace(f);
            }

            // create a bunch of people at foodplaces
            var patientsatfps = GenerateTestData.CreatePatientAtFoodPlaces(int.Parse(txtNumberofTestdata.Text));

            foreach (var f in patientsatfps)
            {
                client.WriteRelation(f);
            }



            // Show success msgbox
            System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);


            client.Close();
        }
        public static List <PatientAtFoodPlace> CreatePatientAtFoodPlaces(int userinput)
        {
            WpfWebClient.ServiceReferenceEHEC.ServiceClient    client     = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
            List <WpfWebClient.ServiceReferenceEHEC.FoodPlace> foodPlaces = new List <ServiceReferenceEHEC.FoodPlace>(client.GetFoodPlaces());
            List <WpfWebClient.ServiceReferenceEHEC.Person>    patients   = new List <ServiceReferenceEHEC.Person>(client.GetPersons());



            int i = 0;

            do
            {
                PatientAtFoodPlace patfgen = new PatientAtFoodPlace();

                int       randnumFP = random.Next(0, foodPlaces.Count());
                FoodPlace foodpl    = foodPlaces[randnumFP];

                int    randnumP = random.Next(0, patients.Count());
                Person patient  = patients[randnumP];

                patfgen.FoodPlace   = foodpl;
                patfgen.Patient     = patient;
                patfgen.VistingDate = new DateTime(2005, 12, 20);

                PatientsAtFoodPlaces.Add(patfgen);

                i++;
            } while (i < userinput);

            client.Close();

            return(PatientsAtFoodPlaces);
        }
        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();
        }
示例#4
0
        private void btnRandomStrainGenerator_Click(object sender, RoutedEventArgs e)
        {
            // create new client connection
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            // msgbox to confirm action
            if (MessageBox.Show("This could take a while, are you sure?", "More strains?",
                                MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                // Get the number of words and letters per word.
                int num_letters = int.Parse(txtNumLetters.Text);
                int num_words   = int.Parse(txtNumStrains.Text);

                // Make an array of the letters we will use.
                char[] letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToCharArray();

                // Make a random number generator.
                Random rand = new Random();

                // Make the words.
                for (int i = 1; i <= num_words; i++)
                {
                    // Make a word.
                    string word = "";
                    for (int j = 1; j <= num_letters; j++)
                    {
                        // Pick a random number between 0 and 25
                        // to select a letter from the letters array.
                        int letter_num = rand.Next(2, letters.Length - 1);

                        // Append the letter.
                        word += letters[letter_num];
                    }

                    // Write the strains into a list
                    List <string> generatedStrains = new List <string>();

                    generatedStrains.Add(word);

                    foreach (var item in generatedStrains)
                    {
                        Strain s = new Strain();
                        s.Name = "EHEC-" + item;
                        client.WriteStrain(s);
                    }
                }
            }

            // Show success msgbox
            System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);

            client.Close();
        }
        public ViewDoctors()

        {
            InitializeComponent();

            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            // call method GetDoctors and save them to doctorlist

            List <WpfWebClient.ServiceReferenceEHEC.Doctor> doctorlist = new List <ServiceReferenceEHEC.Doctor>(client.GetDoctors());

            DataGridViewDoctors.ItemsSource = doctorlist;

            client.Close();
        }
示例#6
0
        public ViewStrains()
        {
            InitializeComponent();

            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            // call method GetStrains and save them to strainlist

            List <WpfWebClient.ServiceReferenceEHEC.Strain> strainlist = new List <ServiceReferenceEHEC.Strain>(client.GetStrains());

            DataGridViewStrains.ItemsSource = strainlist;


            client.Close();
        }
示例#7
0
        public FoodplaceForm()
        {
            InitializeComponent();

            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            // Retrieve all cities and save them into "citylist"
            List <WpfWebClient.ServiceReferenceEHEC.City> citylist = new List <ServiceReferenceEHEC.City>(client.GetCities());

            // Display all cities with name in Combobox
            ComboBoxFPCities.ItemsSource       = citylist;
            ComboBoxFPCities.DisplayMemberPath = "Name";

            client.Close();
        }
示例#8
0
        public ExamForm()
        {
            InitializeComponent();
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();


            // Retrieve all doctors and save them into "doctorlist"
            List <WpfWebClient.ServiceReferenceEHEC.Doctor> doctorlist = new List <ServiceReferenceEHEC.Doctor>(client.GetDoctors());

            // Display all doctors with name in Combobox
            ComboBoxDoctors.ItemsSource       = doctorlist;
            ComboBoxDoctors.DisplayMemberPath = "FirstName";

            // Retrieve all patients and save them into "patientlist"
            List <WpfWebClient.ServiceReferenceEHEC.Person> patientlist = new List <ServiceReferenceEHEC.Person>(client.GetPersons());

            // Display all patients with name in Combobox
            ComboBoxPatients.ItemsSource       = patientlist;
            ComboBoxPatients.DisplayMemberPath = "FirstName";

            // Retrieve all strains and save them into "strainlist"
            List <WpfWebClient.ServiceReferenceEHEC.Strain> strainlist = new List <ServiceReferenceEHEC.Strain>(client.GetStrains());

            // Display all strains with name in Combobox
            ComboBoxStrains.ItemsSource       = strainlist;
            ComboBoxStrains.DisplayMemberPath = "Name";

            // 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";

            // 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();
        }
示例#9
0
        private void btnAddFoodPlace_Click(object sender, RoutedEventArgs e)
        {
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            // create new foodplace from user input

            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;
                fp.Description  = txtFoodPlaceDescription.Text;
                fp.City         = (City)ComboBoxFPCities.SelectedValue;

                client.WriteFoodPlace(fp);

                // Show success msgbox
                System.Windows.MessageBox.Show("Success", "INFO", MessageBoxButton.OK, MessageBoxImage.Information);
            }

            client.Close();
        }
        public static List <FoodPlace> CreateFoodPlaces()
        {
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();
            List <WpfWebClient.ServiceReferenceEHEC.City>   cities = new List <ServiceReferenceEHEC.City>(client.GetCities());

            int FirstPartLength  = FoodPlaceNameFirstPart.Count();
            int SecondPartLength = FoodPlaceNameSecondPart.Count();
            int Counter          = FirstPartLength * SecondPartLength;

            int i = 1;

            while (i < 20)
            {
                int    FirstPart      = random.Next(1, FirstPartLength);
                int    SecondPart     = random.Next(1, SecondPartLength);
                int    Description    = random.Next(FoodPlaceDescription.Count);
                string FoodPlaceDescr = FoodPlaceDescription[Description];
                int    StreetName     = random.Next(FoodPlaceStreetName.Count);
                string FoodPlacesn    = FoodPlaceStreetName[StreetName];

                string    FoodPlaceName = FoodPlaceNameFirstPart[FirstPart] + FoodPlaceNameSecondPart[SecondPart];
                string    streetname    = FoodPlacesn;
                string    fpdescr       = FoodPlaceDescr;
                int       StreetNumber  = random.Next(1, 100);
                int       CityID        = random.Next(1, cities.Count());
                City      city          = cities[CityID];
                FoodPlace NewFoodPlace  = new FoodPlace();

                NewFoodPlace.Name         = FoodPlaceName;
                NewFoodPlace.Streetname   = streetname;
                NewFoodPlace.Streetnumber = StreetNumber.ToString();
                NewFoodPlace.Description  = fpdescr;
                NewFoodPlace.City         = city;



                Foodplaces.Add(NewFoodPlace);
                i++;
            }

            client.Close();

            return(Foodplaces);
        }
        public PatientForm()
        {
            InitializeComponent();
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();


            // Retrieve all salutations and save them into "salutationlist"
            List <WpfWebClient.ServiceReferenceEHEC.Salutation> salutationlist = new List <ServiceReferenceEHEC.Salutation>(client.GetSalutations());

            // Display all salutations with name in Combobox
            ComboBoxSalutations.ItemsSource       = salutationlist;
            ComboBoxSalutations.DisplayMemberPath = "Name";

            // Retrieve all genders and save them into "genderlist"
            List <WpfWebClient.ServiceReferenceEHEC.Gender> genderlist = new List <ServiceReferenceEHEC.Gender>(client.GetGenders());

            // Display all genders with name in Combobox
            ComboBoxGenders.ItemsSource       = genderlist;
            ComboBoxGenders.DisplayMemberPath = "Name";

            // Retrieve all cities and save them into "citylist"
            List <WpfWebClient.ServiceReferenceEHEC.City> citylist = new List <ServiceReferenceEHEC.City>(client.GetCities());

            // Display all cities with name in Combobox
            ComboBoxCities.ItemsSource       = citylist;
            ComboBoxCities.DisplayMemberPath = "Name";

            // Retrieve all salutations and save them into "countrylist"
            List <WpfWebClient.ServiceReferenceEHEC.Country> countrylist = new List <ServiceReferenceEHEC.Country>(client.GetCountries());

            // Display all countries with name in Combobox
            ComboBoxCountries.ItemsSource       = countrylist;
            ComboBoxCountries.DisplayMemberPath = "Name";


            client.Close();
        }
示例#12
0
        private void btnAddFoodPlace_Click(object sender, RoutedEventArgs e)
        {
            WpfWebClient.ServiceReferenceEHEC.ServiceClient client = new WpfWebClient.ServiceReferenceEHEC.ServiceClient();

            Exam exam = new Exam();

            // 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;



                client.WriteExam(exam);
            }


            PatientAtFoodPlace patf = new PatientAtFoodPlace();

            // 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();
        }