示例#1
0
 private void ReloadData()
 {
     if (ComboBoxPickDate.SelectedIndex == -1)
     {
         DataGridListOfDoctors.ItemsSource        = null;
         DataGridListOfCalendarDoctor.ItemsSource = null;
         Status_Label.Text = "...";
         return;
     }
     try
     {
         ClassCalendar calendar = GetCalendarForSelectedCalendarInComboboxFromDataBase();
         DataGridListOfDoctors.ItemsSource        = sql.ListOfCalendarDays(calendar.CalendarId);
         DataGridListOfCalendarDoctor.ItemsSource = sql.ListOfCalendarDoctor(calendar.CalendarId);
         LoadStatusToLabel(calendar);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private ClassCalendarDoctor GetCalendarDoctorForSelectedCalendarDoctorInDataGridFromDataBase(int calendarId)
        {
            if (DataGridListOfCalendarDoctor.SelectedIndex == -1)
            {
                throw new Exception("Data grid row isn't selected");
            }
            //Get calendar from data base
            IEnumerable <ClassCalendarDoctor> query =
                from elem in ClassSqlCalendar.ListOfCalendarDoctor(calendarId)
                where elem.CalendarDoctorId == ((ClassCalendarDoctor)DataGridListOfCalendarDoctor.SelectedItem).CalendarDoctorId
                select elem;

            if (!query.Any())
            {
                throw new Exception("Unable to find selected calendar doctor in database");
            }
            return(query.First());
        }