예제 #1
0
        private void EditContact()
        {
            var contact = this.contactsBindingSource.Current as Contact;

            using (var form = new ContactForm(contact, this.groupsBindingSource.DataSource as List <Group>))
            {
                DialogResult ok = form.ShowDialog(this);
                if (ok == DialogResult.OK)
                {
                    this.db.UpdateContact(form.Contact);
                    this.LoadContacts();
                    this.LoadGroups();
                }
            }
        }
예제 #2
0
 private void AddContactButtonClick(object sender, EventArgs e)
 {
     using (var form = new ContactForm(this.groupsBindingSource.DataSource as List <Group>))
     {
         DialogResult ok = form.ShowDialog(this);
         if (ok == DialogResult.OK)
         {
             if (form.EditMode)
             {
                 this.db.UpdateContact(form.Contact);
             }
             else
             {
                 this.db.SaveContact(form.Contact);
             }
             this.LoadContacts();
             this.LoadGroups();
             this.removeContactButton.Enabled = true;
             this.editContactButton.Enabled   = true;
         }
     }
 }