Example #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Sigur stergi asta ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             test.Students.Remove(studentBindingSource.Current as Student);
             studentBindingSource.RemoveCurrent();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     try
     {
         studentBindingSource.EndEdit();
         test.SaveChangesAsync();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
         studentBindingSource.ResetBindings(false);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try {
         studentBindingSource.EndEdit();
         test.SaveChangesAsync();
         panel.Enabled = false;
     } catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
         studentBindingSource.ResetBindings(false);
     }
 }