Example #1
0
        private void buttonRecommendAppointment_Click(object sender, RoutedEventArgs e)
        {
            if (comboBoxDoctor.Text.Equals("") || startDatePicker.Text.Equals("") || endDatePicker.Text.Equals(""))
            {
                ValidationMessageWindow validationWindow = new ValidationMessageWindow();
                validationWindow.Show();
            }
            else
            {
                doctor = (Doctor)comboBoxDoctor.SelectedItem;
                DateTime sDate = (DateTime)startDatePicker.SelectedDate;
                DateTime eDate = (DateTime)endDatePicker.SelectedDate;

                if (DateTime.Compare(sDate, eDate) >= 0)
                {
                    DateMessageWindow dateMessageWindow = new DateMessageWindow();
                    dateMessageWindow.caption.Text = "Pažnja, datum početka mora biti pre datuma kraja vremenskog intervala!";
                    dateMessageWindow.Show();
                }
                else
                {
                    string   dateStart = sDate.ToShortDateString();
                    string   dateEnd   = eDate.ToShortDateString();
                    string   time;
                    DateTime startDate;
                    DateTime endDate;

                    workShifts = workingTimeController.getShiftForDoctor(doctor.Jmbg);

                    if (priorityDoctor.IsChecked == true)
                    {
                        if (workShifts == WorkShifts.FIRST)
                        {
                            time                 = "8:00 AM";
                            startDate            = Convert.ToDateTime(dateStart + " " + time, CultureInfo.InvariantCulture);
                            endDate              = Convert.ToDateTime(dateEnd + " " + time, CultureInfo.InvariantCulture);
                            recommendExamination = examinationController.AppointmentRecommendationByDoctor(doctor, startDate, endDate);
                        }
                        else if (workShifts == WorkShifts.SECOND)
                        {
                            time                 = "4:00 PM";
                            startDate            = Convert.ToDateTime(dateStart + " " + time, CultureInfo.InvariantCulture);
                            endDate              = Convert.ToDateTime(dateEnd + " " + time, CultureInfo.InvariantCulture);
                            recommendExamination = examinationController.AppointmentRecommendationByDoctor(doctor, startDate, endDate);
                        }
                        else
                        {
                            time                 = "12:00 AM";
                            startDate            = Convert.ToDateTime(dateStart + " " + time, CultureInfo.InvariantCulture);
                            endDate              = Convert.ToDateTime(dateEnd + " " + time, CultureInfo.InvariantCulture);
                            recommendExamination = examinationController.AppointmentRecommendationByDoctor(doctor, startDate, endDate);
                        }


                        recommendedDate.Text = recommendExamination.DateAndTime.ToShortDateString();

                        recommendedTime.Text = recommendExamination.DateAndTime.ToShortTimeString();

                        buttonMakeAppointment.IsEnabled = true;
                    }
                    else
                    {
                        if (workShifts == WorkShifts.FIRST)
                        {
                            time                 = "8:00 AM";
                            startDate            = Convert.ToDateTime(dateStart + " " + time, CultureInfo.InvariantCulture);
                            endDate              = Convert.ToDateTime(dateEnd + " " + time, CultureInfo.InvariantCulture);
                            recommendExamination = examinationController.AppointmentRecommendationByDate(doctor, startDate, endDate);
                        }
                        else if (workShifts == WorkShifts.SECOND)
                        {
                            time                 = "4:00 PM";
                            startDate            = Convert.ToDateTime(dateStart + " " + time, CultureInfo.InvariantCulture);
                            endDate              = Convert.ToDateTime(dateEnd + " " + time, CultureInfo.InvariantCulture);
                            recommendExamination = examinationController.AppointmentRecommendationByDate(doctor, startDate, endDate);
                        }
                        else
                        {
                            time                 = "12:00 AM";
                            startDate            = Convert.ToDateTime(dateStart + " " + time, CultureInfo.InvariantCulture);
                            endDate              = Convert.ToDateTime(dateEnd + " " + time, CultureInfo.InvariantCulture);
                            recommendExamination = examinationController.AppointmentRecommendationByDate(doctor, startDate, endDate);
                        }


                        recommendedDate.Text = recommendExamination.DateAndTime.ToShortDateString();

                        recommendedTime.Text = recommendExamination.DateAndTime.ToShortTimeString();

                        buttonMakeAppointment.IsEnabled = true;
                    }
                }
            }
        }