Example #1
0
 private async void BtnAdd_Click(object sender, EventArgs e)
 {
     using (FormAddAccount frm = new FormAddAccount(new Account()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 accountBindingSource.Add(frm.AccountInfo);
                 db.Accounts.Add(frm.AccountInfo);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Example #2
0
 private async void BtnAdd_Click(object sender, EventArgs e)
 {
     using (frmAddClass frm = new frmAddClass(new Class()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 classBindingSource.Add(frm.ClassInfo);
                 db.Classes.Add(frm.ClassInfo);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }