private void fillTime()
        {
            WorkShifts workShifts;
            Doctor     selectedDoctor;

            if (cmbDoctor.SelectedItem != null)
            {
                selectedDoctor = (Doctor)cmbDoctor.SelectedItem;
                workShifts     = workingTimeController.getShiftForDoctor(selectedDoctor.Jmbg);
            }
            else
            {
                selectedDoctor = doctorForSelection;
                workShifts     = workingTimeController.getShiftForDoctor(examination.Doctor);
            }

            DateTime firstShift;
            DateTime secondShift;
            DateTime thirdShift;

            if (dpDate.SelectedDate != null)
            {
                DateTime dp = (DateTime)dpDate.SelectedDate;

                firstShift  = Convert.ToDateTime(dp.ToShortDateString() + " " + "8:00 AM", CultureInfo.InvariantCulture);  //pocetak prve smjene
                secondShift = Convert.ToDateTime(dp.ToShortDateString() + " " + "4:00 PM", CultureInfo.InvariantCulture);  //pocetak druge smjene
                thirdShift  = Convert.ToDateTime(dp.ToShortDateString() + " " + "12:00 AM", CultureInfo.InvariantCulture); //pocetak trece smjene
            }
            else
            {
                firstShift  = Convert.ToDateTime(examination.Date + " " + "8:00 AM", CultureInfo.InvariantCulture);  //pocetak prve smjene
                secondShift = Convert.ToDateTime(examination.Date + " " + "4:00 PM", CultureInfo.InvariantCulture);  //pocetak druge smjene
                thirdShift  = Convert.ToDateTime(examination.Date + " " + "12:00 AM", CultureInfo.InvariantCulture); //pocetak trece smjene
            }

            if (workShifts == WorkShifts.FIRST)
            {
                allAppointments = examinationController.getAllAppointments(selectedDoctor, firstShift);
            }
            else if (workShifts == WorkShifts.SECOND)
            {
                allAppointments = examinationController.getAllAppointments(selectedDoctor, secondShift);
            }
            else
            {
                allAppointments = examinationController.getAllAppointments(selectedDoctor, thirdShift);
            }

            freeAppointments.Clear();
            tpTime.DataContext = null;
            foreach (Examination exm in allAppointments)
            {
                if (exm.room.Number == 0) //ovo je slobodan termin

                {
                    freeAppointments.Add(new TimeDTO(exm.DateAndTime.ToShortTimeString()));
                }
            }

            tpTime.DataContext = freeAppointments;
        }
        private void displayAppointments()
        {
            setFirstDoctor();

            TimeSpan ts = new TimeSpan(FIRST_SHIFT_TIME, 0, 0);
            DateTime dt = (DateTime)dpDate.SelectedDate;

            if (first.IsSelected)
            {
                ts = new TimeSpan(FIRST_SHIFT_TIME, 0, 0);
                dt = dt + ts;
            }
            else if (second.IsSelected)
            {
                ts = new TimeSpan(SECOND_SHIFT_TIME, 0, 0);
                dt = dt + ts;
            }
            else if (third.IsSelected)
            {
                ts = new TimeSpan(THIRD_SHIFT_TIME, 0, 0);
                dt = dt + ts;
                dt = dt.AddDays(-1);
            }

            Doctor selectedDoctor = (Doctor)cmbDoctors.SelectedItem;

            if (selectedDoctor != null)
            {
                allAppointments = examinationController.getAllAppointments(selectedDoctor, dt);

                List <ExaminationDTO> examinationDTOs = new List <ExaminationDTO>();
                foreach (Examination exm in allAppointments)
                {
                    string room = "";
                    string type = "";
                    if (exm.room.Number != 0)
                    {
                        room = exm.room.Number.ToString();
                    }
                    if (room.Equals(""))
                    {
                        type = "";
                    }
                    else
                    {
                        if (exm.Type == TypeOfExamination.Opsti)
                        {
                            type = "Opšti pregled";
                        }
                        else if (exm.Type == TypeOfExamination.Specijalisticki)
                        {
                            type = "Specijalistički pregled";
                        }
                        else if (exm.Type == TypeOfExamination.Operacija)
                        {
                            type = "Operacija";
                        }
                        {
                        }
                    }
                    examinationDTOs.Add(new ExaminationDTO(exm.IdExamination, exm.doctor.Name + " " + exm.doctor.Surname + " " + exm.doctor.Jmbg,
                                                           exm.patientCard.patient.Name + " " + exm.patientCard.patient.Surname + " " + exm.patientCard.patient.Jmbg, room, type, exm.DateAndTime.ToShortDateString(), exm.DateAndTime.ToShortTimeString()));
                }
                dgExaminations.ItemsSource = examinationDTOs;
            }
        }
Example #3
0
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            string s = dataExam.SelectedDate.ToString();

            string[] lines = s.Split(' ');
            string   datum = lines[0];

            if (String.IsNullOrEmpty(datum))
            {
                MessageBox.Show("Morate izabrati datum za koji želite zakazati prelged.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);

                dataExam.Focus();
                return;
            }
            else if (String.IsNullOrEmpty(textBoxDoctorExam.Text))
            {
                MessageBox.Show("Morate izabrati doktora kod kog želite zakazati pregled.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);

                textBoxDoctorExam.Focus();
                return;
            }
            else if (String.IsNullOrEmpty(txtSmjena.Text))
            {
                MessageBox.Show("Morate izabrati smjenu u kojoj zelite zakazati pregled.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);

                txtSmjena.Focus();
                return;
            }

            TimeSpan ts = new TimeSpan(FIRST_SHIFT_TIME, 0, 0);
            DateTime dt = (DateTime)dataExam.SelectedDate;

            if (first.IsSelected)
            {
                ts = new TimeSpan(FIRST_SHIFT_TIME, 0, 0);
                dt = dt + ts;
            }
            else if (second.IsSelected)
            {
                ts = new TimeSpan(SECOND_SHIFT_TIME, 0, 0);
                dt = dt + ts;
            }
            else if (third.IsSelected)
            {
                ts = new TimeSpan(THIRD_SHIFT_TIME, 0, 0);
                dt = dt + ts;
                dt = dt.AddDays(-1);
            }

            List <Examination> allAppointments;
            Doctor             selectedDoctor = (Doctor)textBoxDoctorExam.SelectedItem;

            List <String> typesExam = new List <string>();

            if (selectedDoctor.Type == TypeOfDoctor.drOpstePrakse)
            {
                typesExam.Add(TypeOfExamination.Opsti.ToString());
            }
            else
            {
                typesExam.Add(TypeOfExamination.Operacija.ToString());
                typesExam.Add(TypeOfExamination.Specijalisticki.ToString());
            }
            txtVrsta.DataContext = typesExam;


            allAppointments = ec.getAllAppointments(selectedDoctor, dt);

            List <ExaminationDTO> examDTO = new List <ExaminationDTO>();

            foreach (Examination exm in allAppointments)
            {
                string room = "";
                string type = "";
                if (exm.room.Number != 0)
                {
                    room = exm.room.Number.ToString();
                }
                if (room.Equals(""))
                {
                    type = "";
                }
                else
                {
                    type = exm.Type.ToString();
                }
                ExaminationDTO e1 = new ExaminationDTO();
                e1.IdExamination = exm.IdExamination;
                e1.doctor        = exm.doctor.Name + " " + exm.doctor.Name;
                e1.patientCard   = exm.patientCard.patient.Name + " " + exm.patientCard.patient.Surname + " " + exm.patientCard.patient.Jmbg;
                e1.DateAndTime   = exm.DateAndTime.ToString();
                e1.room          = room;
                e1.Type          = type;

                examDTO.Add(e1);
            }

            if (examDTO.Count == 0)
            {
                MessageBox.Show("Nema slobodnih pregelda za odabrani datum.", "Upozorenje!",
                                MessageBoxButton.OK, MessageBoxImage.Warning);

                return;
            }
            DataGrid4.ItemsSource = examDTO;
        }