private void btn1_Click(object sender, RoutedEventArgs e) { string s = data1.SelectedDate.ToString(); string[] lines = s.Split(' '); string datum = lines[0]; if (String.IsNullOrEmpty(datum)) { MessageBox.Show("Morate izdabrati datum za koji želite pregledati raspored.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); data1.Focus(); return; } //WorkingTime wt = wc.ViewWorkingTime(d.Jmbg); WorkShifts ws = wc.getShiftForDoctor(d.Jmbg); TimeSpan ts; DateTime dt = (DateTime)data1.SelectedDate; if (ws == WorkShifts.FIRST) { ts = new TimeSpan(FIRST_SHIFT_TIME, 0, 0); dt = dt + ts; } else if (ws == WorkShifts.SECOND) { ts = new TimeSpan(SECOND_SHIFT_TIME, 0, 0); dt = dt + ts; } else { ts = new TimeSpan(THIRD_SHIFT_TIME, 0, 0); dt = dt + ts; dt = dt.AddDays(-1); } //TimeSpan ts = new TimeSpan(8, 0, 0); List <Examination> exams = new List <Examination>(); List <Examination> exams2 = new List <Examination>(); double hours = 0; for (int i = 0; i < 16; i++) { exams = ser.ViewExaminationsByDoctorAndDate(d, dt.AddHours(hours)); hours += 0.5; if (exams.Count != 0) { foreach (Examination e1 in exams) { exams2.Add(e1); } } } List <ExaminationDTO> examDTO = new List <ExaminationDTO>(); foreach (Examination ee in exams2) { ExaminationDTO e1 = new ExaminationDTO(); e1.IdExamination = ee.IdExamination; e1.doctor = ee.doctor.Name + " " + ee.doctor.Surname; e1.DateAndTime = ee.DateAndTime.ToShortTimeString(); e1.IdExamination = ee.IdExamination; e1.patientCard = ee.patientCard.patient.Name + " " + ee.patientCard.patient.Surname + " " + ee.patientCard.patient.Jmbg; e1.Type = ee.Type.ToString(); e1.room = ee.room.Number.ToString(); examDTO.Add(e1); } if (examDTO.Count == 0) { MessageBox.Show("Nema zakazanih pregelda za odabrani datum.", "Upozorenje!", MessageBoxButton.OK, MessageBoxImage.Warning); data1.Focus(); return; } DataGrid2.ItemsSource = examDTO; }