Exemple #1
0
        private void menuEdit_Click(object sender, EventArgs e)
        {
            Contact selectedItem = null;

            try
            {
                selectedItem = GetSelectedItem();

                if (selectedItem == null)
                {
                    MessageBox.Show("Please select item.", "Warning");
                }
                else
                {
                    using (ContactViewForm dlg = new ContactViewForm(selectedItem))
                    {
                        var res = dlg.ShowDialog();
                        if (res == DialogResult.OK)
                        {
                            httpClient.UpdateContact(dlg.ContactItem);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failed to update Contact");
            }
            finally
            {
                RefreshContacts();
            }
        }
Exemple #2
0
 private void menuAdd_Click(object sender, EventArgs e)
 {
     try
     {
         using (ContactViewForm dlg = new ContactViewForm(null))
         {
             var res = dlg.ShowDialog();
             if (res == DialogResult.OK)
             {
                 httpClient.CreateContact(dlg.ContactItem);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Failed to create Contact");
     }
     finally
     {
         RefreshContacts();
     }
 }