Exemple #1
0
 private async void addbtn_Click(object sender, EventArgs e)
 {
     using (groupsaddform gradd = new groupsaddform(new Groups()))
     {
         if (gradd.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 groupsBindingSource.Add(gradd.GroupsInfo);
                 test.Groups.Add(gradd.GroupsInfo);
                 await test.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Exemple #2
0
        private async void editbtn_Click(object sender, EventArgs e)
        {
            Groups obj = groupsBindingSource.Current as Groups;

            if (obj != null)
            {
                using (groupsaddform gradd = new groupsaddform(obj))
                {
                    if (gradd.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            groupsBindingSource.EndEdit();
                            await test.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }