private void BtDeleteVisit_Click(object sender, RoutedEventArgs e) { Visit v1 = (Visit)visitDataGrid.SelectedItem; if (v1 != null) { MessageBoxResult result = System.Windows.MessageBox.Show("Czy usunąć wizytę dla pacjenta " + v1.Referral.Patient.Name + " " + v1.Referral.Patient.Surname + " z dnia " + v1.VisitDate.ToShortDateString() + "?", "Usuwanie pacjenta", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { Visit.DeleteVisit(v1, dbcontext); } } physiotherapistDataGrid.Items.Refresh(); }