Exemplo n.º 1
0
        private void yesBtn_Click(object sender, RoutedEventArgs e)
        {
            Patient selectedPatient = (Patient)txtPatient.SelectedItem;
            Room    selectedRoom    = (Room)cmbNumberOfRoom.SelectedItem;

            if (selectedPatient == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati pacijenta!";
                okMbx.ShowDialog();
                return;
            }
            if (cmbTypeOfExamination.SelectedItem == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati vrstu pregleda!";
                okMbx.ShowDialog();
                return;
            }
            if (selectedRoom == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati sobu!";
                okMbx.ShowDialog();
                return;
            }
            TypeOfExamination    type;
            TypeOfExaminationDTO selectedType = (TypeOfExaminationDTO)cmbTypeOfExamination.SelectedItem;

            if (selectedType.Type.Equals("Opšti pregled"))
            {
                type = TypeOfExamination.Opsti;
            }
            else if (selectedType.Type.Equals("Specijalistički pregled"))
            {
                type = TypeOfExamination.Specijalisticki;
            }
            else
            {
                type = TypeOfExamination.Operacija;
            }
            DateTime date = Convert.ToDateTime(examination.Date + " " + examination.Time, CultureInfo.InvariantCulture);

            string[]    partsDoctor         = examination.Doctor.Split(' ');
            Doctor      selectedDoctor      = (Doctor)userDoctorController.ViewProfile(partsDoctor[partsDoctor.Length - 1]);
            PatientCard selectedPatientCard = patientCardController.ViewPatientCard(selectedPatient.Jmbg);

            if (examinationController.ScheduleExamination(new Examination(examination.Id, type, date, selectedDoctor, selectedRoom, selectedPatientCard)) == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Došlo je do greške, doktor/soba su već zauzeti u izabranom terminu!";
                okMbx.ShowDialog();
                return;
            }

            int    lastId  = notificationController.getLastId();
            string message = "Zakazan pregled\n" + "Doktor: " + selectedDoctor.Name + " " + selectedDoctor.Surname
                             + "\nBroj sobe: " + selectedRoom.Number + "\nDatum:" + date.ToShortDateString() + "\nVrijeme: " + date.ToShortTimeString();

            notificationController.SendNotification(new Notification(++lastId, TypeOfNotification.Pregled, message, selectedPatientCard.patient.Jmbg));


            var okMb = new OKMessageBox(this, 0);

            okMb.titleMsgBox.Text = "Obavještenje";
            okMb.textMsgBox.Text  = "Uspješno ste zakazali pregled.";
            okMb.ShowDialog();
            this.Close();

            foreach (Window window in Application.Current.Windows)
            {
                if (window.GetType() == typeof(MainWindow))
                {
                    (window as MainWindow).Main.Content = new ExaminationViewByDoctor(selectedDoctor.Jmbg);
                }
            }
        }
        private void yesBtn_Click(object sender, RoutedEventArgs e)
        {
            if (txtPatient.Text.Equals(""))
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati pacijenta!";
                okMbx.ShowDialog();
                return;
            }
            if (cmbDoctor.SelectedItem == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati doktora!";
                okMbx.ShowDialog();
                return;
            }
            if (cmbTypeOfExamination.SelectedItem == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati vrstu pregleda!";
                okMbx.ShowDialog();
            }
            if (cmbNumberOfRoom.SelectedItem == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati sobu!";
                okMbx.ShowDialog();
                return;
            }
            if (dpDate.SelectedDate == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati datum!";
                okMbx.ShowDialog();
                return;
            }
            if (tpTime.SelectedItem == null)
            {
                var okMbx = new OKMessageBox(this, 4);
                okMbx.titleMsgBox.Text = "Greška";
                okMbx.textMsgBox.Text  = "Morate odabrati vrijeme!";
                okMbx.ShowDialog();
                return;
            }


            DateTime selectedDate   = (DateTime)dpDate.SelectedDate;
            Room     selectedRoom   = (Room)cmbNumberOfRoom.SelectedItem;
            Doctor   selectedDoctor = (Doctor)cmbDoctor.SelectedItem;
            TimeDTO  timeDTO        = (TimeDTO)tpTime.SelectedItem;
            DateTime date           = Convert.ToDateTime(selectedDate.ToShortDateString() + " " + timeDTO.Time, CultureInfo.InvariantCulture);

            string[]    partsPatient        = examination.Patient.Split(' ');
            PatientCard selectedPatientCard = patientCardController.ViewPatientCard(partsPatient[partsPatient.Length - 1]);

            TypeOfExamination    type;
            TypeOfExaminationDTO selectedType = (TypeOfExaminationDTO)cmbTypeOfExamination.SelectedItem;

            if (selectedType.Type.Equals("Opšti pregled"))
            {
                type = TypeOfExamination.Opsti;
            }
            else if (selectedType.Type.Equals("Specijalistički pregled"))
            {
                type = TypeOfExamination.Specijalisticki;
            }
            else
            {
                type = TypeOfExamination.Operacija;
            }

            if (parent.GetType() == typeof(CanceledExaminationsView))
            {
                if (examinationController.ScheduleExamination(new Examination(examination.Id, type, date, selectedDoctor, selectedRoom, selectedPatientCard)) == null)
                {
                    var okMbx = new OKMessageBox(this, 4);
                    okMbx.titleMsgBox.Text = "Greška";
                    okMbx.textMsgBox.Text  = "Došlo je do greške, doktor ili soba su zauzeti u odabranom terminu!";
                    okMbx.ShowDialog();
                    return;
                }

                else
                {
                    int    lastId  = notificationController.getLastId();
                    string message = "Ponovo zakazan otkazani pregled\n" + "Doktor: " + selectedDoctor.Name + " " + selectedDoctor.Surname

                                     + "\nBroj sobe: " + selectedRoom.Number + "\nDatum:" + date.ToShortDateString() + "\nVrijeme: " + date.ToShortTimeString();
                    notificationController.SendNotification(new Notification(++lastId, TypeOfNotification.Pregled, message, selectedPatientCard.patient.Jmbg));


                    var okMb = new OKMessageBox(this, 0);
                    okMb.titleMsgBox.Text = "Obavještenje";
                    okMb.textMsgBox.Text  = "Uspješno ste zakazali pregled koji je bio otkazan. Pacijent je obaviješten o izmjeni.";
                    okMb.ShowDialog();
                    this.Close();
                }

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Main.Content = new CanceledExaminationsView();
                    }
                }
            }
            else if (parent.GetType() == typeof(ExaminationViewByDoctor))
            {
                if (examinationController.EditExamination(new Examination(examination.Id, type, date, selectedDoctor, selectedRoom, selectedPatientCard)) == null)
                {
                    var okMbx = new OKMessageBox(this, 4);
                    okMbx.titleMsgBox.Text = "Greška";
                    okMbx.textMsgBox.Text  = "Došlo je do greške, doktor ili soba su zauzeti u odabranom terminu!";
                    okMbx.ShowDialog();
                    return;
                }
                else
                {
                    int    lastId  = notificationController.getLastId();
                    string message = "Pregled izmijenjen\n" + "Doktor: " + selectedDoctor.Name + " " + selectedDoctor.Surname

                                     + "\nBroj sobe: " + selectedRoom.Number + "\nDatum:" + date.ToShortDateString() + "\nVrijeme: " + date.ToShortTimeString();
                    notificationController.SendNotification(new Notification(++lastId, TypeOfNotification.Pregled, message, selectedPatientCard.patient.Jmbg));


                    var okMb = new OKMessageBox(this, 0);
                    okMb.titleMsgBox.Text = "Obavještenje";
                    okMb.textMsgBox.Text  = "Uspješno ste izmijenili pregled. Pacijent je obaviješten o izmjeni.";
                    okMb.ShowDialog();
                    this.Close();
                }

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Main.Content = new ExaminationViewByDoctor(selectedDoctor.Jmbg);
                    }
                }
            }
            else if (parent.GetType() == typeof(SearchExaminations))
            {
                if (examinationController.EditExamination(new Examination(examination.Id, type, date, selectedDoctor, selectedRoom, selectedPatientCard)) == null)
                {
                    var okMbx = new OKMessageBox(this, 4);
                    okMbx.titleMsgBox.Text = "Greška";
                    okMbx.textMsgBox.Text  = "Došlo je do greške, doktor ili soba su zauzeti u odabranom terminu!";
                    okMbx.ShowDialog();
                    return;
                }
                else
                {
                    int    lastId  = notificationController.getLastId();
                    string message = "Pregled izmijenjen\n" + "Doktor: " + selectedDoctor.Name + " " + selectedDoctor.Surname

                                     + "\nBroj sobe: " + selectedRoom.Number + "\nDatum:" + date.ToShortDateString() + "\nVrijeme: " + date.ToShortTimeString();
                    notificationController.SendNotification(new Notification(++lastId, TypeOfNotification.Pregled, message, selectedPatientCard.patient.Jmbg));


                    var okMb = new OKMessageBox(this, 0);
                    okMb.titleMsgBox.Text = "Obavještenje";
                    okMb.textMsgBox.Text  = "Uspješno ste izmijenili pregled. Pacijent je obaviješten o izmjeni.";
                    okMb.ShowDialog();
                    this.Close();
                }

                foreach (Window window in Application.Current.Windows)
                {
                    if (window.GetType() == typeof(MainWindow))
                    {
                        (window as MainWindow).Main.Content = new SearchExaminations();
                    }
                }
            }
        }