Ejemplo n.º 1
0
 private async void btnAddCustomers_Click(object sender, EventArgs e)
 {
     using (frmAddEditCustomer frm = new frmAddEditCustomer(new CustomersTable()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 customersTableBindingSource.Add(frm.CustomerInfo);
                 db.CustomersTables.Add(frm.CustomerInfo);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private async void btnEditCustomers_Click(object sender, EventArgs e)
        {
            CustomersTable obj = customersTableBindingSource.Current as CustomersTable;

            if (obj != null)
            {
                using (frmAddEditCustomer frm = new frmAddEditCustomer(obj))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            customersTableBindingSource.EndEdit();
                            await db.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }