Пример #1
0
 private async void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     using (CapNhat.AddKhoNoiBo frm = new CapNhat.AddKhoNoiBo(new tbl_KhachHanga()))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 tblKhachHangaBindingSource.Add(frm.KHInfor);
                 ds.tbl_KhachHanga.Add(frm.KHInfor);
                 await ds.SaveChangesAsync();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message, "Message");
             }
         }
     }
 }
Пример #2
0
        private async void barButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            tbl_KhachHanga obj = tblKhachHangaBindingSource.Current as tbl_KhachHanga;

            if (obj != null)
            {
                using (CapNhat.AddKhoNoiBo frm = new CapNhat.AddKhoNoiBo(obj))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        try
                        {
                            tblKhachHangaBindingSource.EndEdit();
                            await ds.SaveChangesAsync();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("errorr");
                        }
                    }
                }
            }
        }