private void ABE_Edit( AddressBookEntry abEntry ) { // we make a copy of the current entry, and send that for edit. // if user approves of his/her edit, then we replace current with data from edited copy. AddressBookEntry copyOfCurrent = new AddressBookEntry( abEntry ); FormAddressBookEntry formABE = new FormAddressBookEntry( copyOfCurrent, AddressBookEntryAction.Edit ); DialogResult result = formABE.ShowDialog( this ); if ( result == DialogResult.Cancel ) { MessageBox.Show( this, "Edit cancelled" ); return; } // add update current entry with edited data abEntry.UpdateFrom( copyOfCurrent ); }
private void ABE_New() { AddressBookEntry newAbEntry = new AddressBookEntry(); FormAddressBookEntry formABE = new FormAddressBookEntry( newAbEntry, AddressBookEntryAction.Create ); DialogResult result = formABE.ShowDialog( this ); if ( result == DialogResult.Cancel ) { MessageBox.Show( this, "Create cancelled" ); return; } // add new entry to address book addressBook.AddEntry( newAbEntry ); }