Пример #1
0
        private async void mtEdit_Click(object sender, EventArgs e)
        {
            Customerss obj = customerBindingSource.Current as Customerss;

            if (obj != null)
            {
                using (addNewCustomer add = new addNewCustomer(obj))
                {
                    if (add.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            customerBindingSource.EndEdit();
                            await db.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
        }
Пример #2
0
 private async void mtAdd_Click(object sender, EventArgs e)
 {
     using (addNewCustomer add = new addNewCustomer(new Customerss()
     {
         Gender = false
     }))
     {
         // add.ShowDialog();
         if (add.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 //customerBindingSource.Add(add.CustomerInfor);
                 customerBindingSource.Add(add.CustomerInfor);
                 db.Customersses.Add(add.CustomerInfor);
                 await db.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }