예제 #1
0
        private void btn_addWard_Click(object sender, RoutedEventArgs e)
        {
            //read info from screen
            string name = tblk_name.Text;

            //check if string is correct length for display
            if (name.Length < 10 || name.Length > 22)
            {
                MessageBox.Show("Please enter a Ward Name between 10 and 22 characters in length.");
            }

            else
            {
                //error check not required on the below as user can only input int via the slider
                int capacity = Convert.ToInt16(tblk_num.Text);

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

                //add object to collection
                Wards.Add(newWard);
                //updates wardCount
                wardCount     = Wards.Count();
                tblkWard.Text = $"Ward List ({wardCount})";

                //resets values
                tblk_name.Clear();
                slider_ward.Value = 0;
            }
        }
예제 #2
0
        private void lbxWards_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            //enables save button once a ward is chosen
            btnSave.IsEnabled = true;

            //determine what ward is selected
            Ward selectedWard = lbxWards.SelectedItem as Ward;

            if (selectedWard != null)
            {
                //displays patients in the ward
                lbxPatients.ItemsSource = selectedWard.Patients;
            }
        }
예제 #3
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //create two wards
            Ward W1 = new Ward()
            {
                Name = "Marx Brothers Ward", Capacity = 3
            };
            Ward W2 = new Ward()
            {
                Name = "Addams Family Ward", Capacity = 7
            };

            //add wards to the observable collection
            Wards.Add(W1);
            //updates wardCount
            wardCount     = Wards.Count();
            tblkWard.Text = $"Ward List ({wardCount})";

            //as above
            Wards.Add(W2);
            wardCount     = Wards.Count();
            tblkWard.Text = $"Ward List ({wardCount})";

            //create four patients
            Patient P1 = new Patient("John Reilly", Convert.ToDateTime("1990/11/18"), BloodType.O);
            Patient P2 = new Patient("Bill Reilly", Convert.ToDateTime("1990/11/17"), BloodType.A);
            Patient P3 = new Patient("Pat Reilly", Convert.ToDateTime("1990/11/16"), BloodType.B);
            Patient P4 = new Patient("Rick Reilly", Convert.ToDateTime("1990/11/15"), BloodType.AB);

            //add patients to wards
            W1.Patients.Add(P1);
            W1.Patients.Add(P2);
            W2.Patients.Add(P3);
            W2.Patients.Add(P4);

            //display
            lbxWards.ItemsSource = Wards;
        }
예제 #4
0
        private void btn_addPatient_Click(object sender, RoutedEventArgs e)
        {
            //determine the ward
            Ward selectedWard = lbxWards.SelectedItem as Ward;

            //read info from screen
            string name = tblk_patientName.Text;

            //check if string is correct length for display
            if (name.Length < 10 || name.Length > 22)
            {
                MessageBox.Show("Please enter a Patient Name between 10 and 22 characters in length.");
            }

            else
            {
                //no error possible as user can not input text (focusable = false) and input must be entered to focus addPatient button
                DateTime dob = Convert.ToDateTime(datepick.SelectedDate);

                //checks which blootype is selected
                BloodType blood;

                if (rbnO.IsChecked == true)
                {
                    blood = BloodType.O;
                }

                else if (rbnA.IsChecked == true)
                {
                    blood = BloodType.A;
                }

                else if (rbnB.IsChecked == true)
                {
                    blood = BloodType.B;
                }

                else
                {
                    blood = BloodType.AB;
                }

                //makes sure a ward is selected
                if (selectedWard == null)
                {
                    MessageBox.Show("You must select a Ward for this patient first");
                }

                //check ward has not exceeded capacity
                else if (selectedWard.Patients.Count >= selectedWard.Capacity)
                {
                    MessageBox.Show("New patient denied. Ward at capacity.");
                }

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

                    //add patient to collection
                    selectedWard.Patients.Add(patient);
                }
            }
            //clear values from inputs
            tblk_patientName.Clear();
            datepick.SelectedDate = null;
            rbnO.IsChecked        = false;
            rbnA.IsChecked        = false;
            rbnB.IsChecked        = false;
            rbnAB.IsChecked       = false;
        }