Ejemplo n.º 1
0
 private async void tbAdd_Click(object sender, EventArgs e)
 {
     using (frmProgrammeInfo frm = new frmProgrammeInfo(new Programme()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 programmeBindingSource.Add(frm.ProgrammeInfo);
                 db.Programmes.Add(frm.ProgrammeInfo);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Ejemplo n.º 2
0
        private async void tbEdit_Click(object sender, EventArgs e)
        {
            Programme obj = programmeBindingSource.Current as Programme;

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