Exemple #1
0
        //display patients from ward when that ward is selected
        private void LbxWards_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //determine what ward was selected
            Ward selectedWard = lbxWards.SelectedItem as Ward;

            if (selectedWard != null)
            {
                //display patients from that ward
                lbxPatients.ItemsSource = selectedWard.Patients;
            }
        }
Exemple #2
0
        //add ward button
        private void BtnWard_Click(object sender, RoutedEventArgs e)
        {
            //read data from screen
            string name     = tbxWardName.Text;
            int    capacity = Convert.ToInt32(sldrCapacity.Value);

            //create ward object
            Ward newWard = new Ward(name, capacity);

            //add to collection of wards
            wardList.Add(newWard);

            //update ward count
            tblkCount.Text = Convert.ToString($" ({ wardList.Count})");
        }
Exemple #3
0
        //add patient button
        private void BtnPatient_Click(object sender, RoutedEventArgs e)
        {
            //read data from screen
            string name = tbxPatientName.Text;

            //check dob is datetime
            try
            {
                dob = Convert.ToDateTime(tbxDOB.Text);
            }
            //if not show error and return - stops executing rest of code
            catch
            {
                DOBErrorWindow DOBNotValid = new DOBErrorWindow();
                //displays new window
                DOBNotValid.ShowDialog();
                return;
            }

            //checking which bloodtype is picked
            if (rbtnA.IsChecked == true)
            {
                blood = BloodType.A;
            }
            else if (rbtnB.IsChecked == true)
            {
                blood = BloodType.B;
            }
            else if (rbtnAB.IsChecked == true)
            {
                blood = BloodType.AB;
            }
            else if (rbtnO.IsChecked == true)
            {
                blood = BloodType.O;
            }
            //error message if no blood type is chosen
            else
            {
                BloodErrorWindow bloodTypeError = new BloodErrorWindow();
                bloodTypeError.ShowDialog();
                return;
            }

            Ward selectedWard = lbxWards.SelectedItem as Ward;

            //create patient object
            Patient newPatient = new Patient(name, dob, blood);

            //Add patient to ward if there is space
            if (selectedWard.Patients.Count < selectedWard.Capacity)
            {
                selectedWard.Patients.Add(newPatient);
            }
            //else return error message
            else
            {
                WardErrorWindow capacityReached = new WardErrorWindow();
                //displays new window
                capacityReached.ShowDialog();
            }
        }