Ejemplo n.º 1
0
 private async void btnAddCompany_Click(object sender, EventArgs e)
 {
     using (frmAddEditCompany frm = new frmAddEditCompany(new CompanyTable()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 companyTableBindingSource.Add(frm.CompanyInfo);
                 db.CompanyTables.Add(frm.CompanyInfo);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private async void btnEditCompany_Click(object sender, EventArgs e)
        {
            CompanyTable obj = companyTableBindingSource.Current as CompanyTable;

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