} // AddRolodexEntry public void UpdateRolodexEntry() { if (listView1.SelectedItems.Count == 0) { return; } RolodexEntry current; using (RolodexContext context = new RolodexContext()) { int id = (int)listView1.SelectedItems[0].Tag; current = context.Rolodex.Find(id); } if (current == null) { MessageBox.Show("Could not find record"); return; } RolodexEntryDialog red = new RolodexEntryDialog(); red.RolodexEntry = current; if (red.ShowDialog() == DialogResult.OK) { using (RolodexContext context = new RolodexContext()) { context.Rolodex.Update(red.RolodexEntry); context.SaveChanges(); LoadListView(); } } } // UpdateRolodexEntry
} // LoadListView public void AddRolodexEntry() { RolodexEntryDialog red = new RolodexEntryDialog(); if (red.ShowDialog() == DialogResult.OK) { using (RolodexContext context = new RolodexContext()) { context.Rolodex.Add(red.RolodexEntry); context.SaveChanges(); LoadListView(); } } } // AddRolodexEntry