private void ContactEditor_Load(object sender, EventArgs e) { if (Contact == null) { Contact = new Contact(); } txtFirstName.Text = Contact.FirstName; txtLastName.Text = Contact.LastName; txtEmail.Text = Contact.EmailAddress; }
public void Update(Contact contact) { var itm = _contactStore.FirstOrDefault(c => c.ID.Equals(contact.ID)); if (itm == null) { throw new InvalidOperationException("Contact item is invalid or was not found"); } itm = contact; }
private static ListViewItem BuildListViewItem(Contact c) { var lvi = new ListViewItem(c.LastName) { Tag = c }; lvi.SubItems.Add(c.FirstName); lvi.SubItems.Add(c.EmailAddress); return lvi; }
public ContactEditor(Contact contact) : this() { Contact = contact; }
public void Insert(Contact contact) { contact.ID = _contactStore.Max(c => c.ID) + 1; _contactStore.Add(contact); System.Threading.Thread.Sleep(3000); }
public void Delete(Contact contact) { _contactStore.RemoveAll(c => c.ID.Equals(contact.ID)); }
private Contact ShowEditorDialog(Contact contact) { var ce = new ContactEditor(contact); try { DialogResult dlgres = ce.ShowDialog(); Contact cnt = ce.Contact; if (dlgres == DialogResult.Cancel) { return null; } return cnt; } finally { ce.Close(); } }