コード例 #1
0
 private void tempBtnAddContactClick(object sender, RoutedEventArgs e)
 {
     try
     {
         DataLayer dl      = new DataLayer();
         Contact   contact = new Contact();
         contact.companyId     = 1106;
         contact.contact_name  = "vinayContact2";
         contact.contact_email = "email2";
         contact.contact_phone = "phone2";
         Response res = dl.AddContact(contact);
         if (res.success)
         {
             MessageBox.Show("Contact Added with name : " + contact.contact_name);
         }
         else if (res.isException)
         {
             MessageBox.Show("Cannot add contact : " + res.exception);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        private void btnAddContact_Click(object sender, RoutedEventArgs e)
        {
            if (cmbCompanies.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a company first");
                return;
            }
            Contact contact = new Contact();

            contact.companyId     = ((Company)cmbCompanies.SelectedItem).companyId;
            contact.contact_name  = txtContactName.Text;
            contact.contact_email = txtContactEmail.Text;
            contact.contact_phone = txtContactPhone.Text;

            DataLayer dl  = new DataLayer();
            Response  res = dl.AddContact(contact);

            Trace.WriteLine(res.success);
            Trace.WriteLine(res.isException);
            if (res.success)
            {
                txtContactName.Text      = "";
                txtContactEmail.Text     = "";
                txtContactPhone.Text     = "";
                lblContactStatus.Content = "Adding...";
                Thread.Sleep(1000);
                lblContactStatus.Content = "Added";
                populateContacts(getCurrentSelectedCompany().companyId);
            }
            else if (res.isException)
            {
                MessageBox.Show(res.exception);
            }
        }