private void BtAddVisit_Click(object sender, RoutedEventArgs e) { if (RbAdding.IsChecked == true) { if (CbPatient2.SelectedIndex < 0) { MessageBox.Show("Wybierz pacjenta!"); } else { if (CbReferral.SelectedIndex < 0) { MessageBox.Show("Wybierz skierowanie!"); } else { if (CbPhysiotherapist.SelectedIndex < 0) { MessageBox.Show("Wybierz fizjoterapeutę!"); } else { if (CalendarVisit.SelectedDates.Count() < 1) { MessageBox.Show("Wybierz datę!"); } else { foreach (var date in CalendarVisit.SelectedDates) { Visit.AddVisit((Physiotherapist)CbPhysiotherapist.SelectedItem, (Referral)CbReferral.SelectedItem, date, CbVisitTime.SelectedItem.ToString(), dbcontext); } CbPhysiotherapist.SelectedIndex = -1; CbReferral.SelectedIndex = -1; CbPatient2.SelectedIndex = -1; CbVisitTime.SelectedIndex = -1; CalendarVisit.SelectedDates.Clear(); visitViewSource.Source = dbcontext.Visits.Local.Where(v => v.VisitDate.Date.Equals(DateTime.Now.Date)).ToList(); visitDataGrid.Items.Refresh(); } } } } } }