private void OverlappingCalendar() { ClassCalendar calendar = GetCalendarForSelectedCalendarInComboboxFromDataBase(); List <ClassOverlappingCalendar> list = sql.OverlappingTerms(calendar.CalendarId); if (list.Count != 0) { //Need changes in offices WindowOverlapping windowOverlapping = new WindowOverlapping(list, calendar.CalendarId); bool update = (bool)windowOverlapping.ShowDialog(); if (!update) { return; } foreach (var item in list) { if (item.NewOfficeNumber == 0) { continue; } sql.UpdateOffice(item.TermId, item.NewOfficeId); } return; } //Calendar verified sql.UpdateCalendarStatus(4, calendar.CalendarId); MessageBox.Show("Succesfully veryfied", "Succes"); ComboBoxPickDate.ItemsSource = sql.CalendarList(); if (ComboBoxPickDate.Items.Count == 0) { return; } ComboBoxPickDate.SelectedIndex = ComboBoxPickDate.Items.Count - 1; return; }
private ClassOverlappingCalendar GetCalendarForSelectedCalendarInComboboxFromDataBase() { if (DataGridListOfDoctors.SelectedIndex == -1) { throw new Exception("Day isn't selected"); } //Get overlapping from data base IEnumerable <ClassOverlappingCalendar> query = from elem in ClassSqlCalendar.OverlappingTerms(calendarId) where elem.TermId == (((ClassOverlappingCalendar)DataGridListOfDoctors.SelectedItem)).TermId select elem; if (!query.Any()) { throw new Exception("Unable to find selected day in database"); } return(query.First()); }