Beispiel #1
0
 private async void tbAdd_Click(object sender, EventArgs e)
 {
     using (frmNewBatchInfo frm = new frmNewBatchInfo(new NewBatch()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 newBatchBindingSource.Add(frm.BatchInfo);
                 db.NewBatches.Add(frm.BatchInfo);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
Beispiel #2
0
        private async void tbEdit_Click(object sender, EventArgs e)
        {
            NewBatch obj = newBatchBindingSource.Current as NewBatch;

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