public void LoadData(object sender, DoWorkEventArgs e)
        {
            PatientList = hms.getPatientList();
            DoctorList  = hms.getDoctors();
            NurseList   = hms.getNurses();
            RoomList    = hms.getRooms();
            IndoorList  = hms.getIndoors();
            this.Dispatcher.Invoke(new Action(delegate
            {
                Add_Employee.IsEnabled = true;
                Add_Patient.IsEnabled  = true;
                btnAdd_Nurse.IsEnabled = true;
                btnAdd_Room.IsEnabled  = true;

                dataGrid_Doctor.ItemsSource  = DoctorList;
                dataGrid_Patient.ItemsSource = PatientList;
                dataGrid_Nurse.ItemsSource   = NurseList;
                dataGrid_Room.ItemsSource    = RoomList;
                dataGrid_Indoor.ItemsSource  = IndoorList;

                cboGovernedBy.ItemsSource = NurseList;
                cboRoomNo.ItemsSource     = RoomList;
                cboCategory.ItemsSource   = hms.getCategories();
            }));
        }
Example #2
0
        private void btnUpdatePres_Click(object sender, RoutedEventArgs e)
        {
            if (presSelected == null)
            {
                return;
            }



            String patType = cboPatientType_Pres.Text;
            int    mid     = int.Parse(cboMed_Pres.SelectedValue.ToString());
            String Dosage  = txtDosage_Pres.Text;
            String disease = null;

            if (string.IsNullOrEmpty(patType) || string.IsNullOrEmpty(Dosage))
            {
                MessageBox.Show("Please make sure all attributes are compelted.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }


            string prevType = presSelected.patient.type;

            presSelected.patient.type = patType.ToLower();
            presSelected.mid          = mid;
            presSelected.dosage       = Dosage;



            disease = txtDisease_Pres.Text;

            indoor indo = hms.getIndoorByPid(presSelected.pid);

            if (patType.ToLower().Equals("indoor") && prevType.Equals("outdoor"))
            {
                if (!String.IsNullOrEmpty(disease))
                {
                    indoor i = new indoor();
                    i.disease = disease;
                    i.pid     = presSelected.pid;
                    i.status  = "admitted";
                    hms.addIndoor(i);
                }
                else
                {
                    MessageBox.Show("Please enter a diesease.");
                    return;
                }
            }
            else if (patType.ToLower().Equals("outdoor"))
            {
                if (indo != null)
                {
                    hms.remove(indo);
                }
            }
            else
            {
                indo.disease = disease;
                hms.updateIndoor(indo);
            }



            hms.updatePrescription(presSelected);


            MessageBox.Show("Record updated success.", "Success", MessageBoxButton.OK, MessageBoxImage.Information);
            dataGrid_Pres.Items.Refresh();
            NewPatientList = hms.getPatientList();
            dataGrid_NewPatient.Items.Refresh();
        }