void LoadData() { try { using (var db = new UnsafeRecordDAL()) { _unsafeRecords = db.RetrieveAll(); } dgRecords.ItemsSource = _unsafeRecords; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void DeleteRecord() { if (dgRecords.SelectedItem != null) { using (var db = new UnsafeRecordDAL()) { if (db.Delete(((UnsafeRecord)dgRecords.SelectedItem).Id) > 0) { LoadData(); } } } else { MessageBox.Show("Please select a Record"); } }