示例#1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            QuanLyBaoHiem.Models.QLBHContext dbContext = new QuanLyBaoHiem.Models.QLBHContext();

            // Call the LoadAsync method to asynchronously get the data for the given DbSet from the database.
            dbContext.NhanViens.LoadAsync().ContinueWith(loadTask =>
            {
                // Bind data to control when loading complete
                dgvNhanVien.DataSource = dbContext.NhanViens.Where(p => p.Status == true).Where(p => p.MaNVQuanLi == manvhientai).ToList();
            }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());
        }
        public ucQuanLyThongTinNhanVien()
        {
            InitializeComponent();
            // This line of code is generated by Data Source Configuration Wizard
            // Instantiate a new DBContext
            QuanLyBaoHiem.Models.QLBHContext dbContext = new QuanLyBaoHiem.Models.QLBHContext();
            // Call the LoadAsync method to asynchronously get the data for the given DbSet from the database.
            dbContext.NhanViens.LoadAsync().ContinueWith(loadTask =>
            {
                // Bind data to control when loading complete
                dgvNhanVien.DataSource = dbContext.NhanViens.Where(p => p.Status == true).ToList();
            }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());



            loadcomboboxMaCVvacomboboxQuyenhanvacomboboxMaNVQL();
            //gridView1.ShowFindPanel();
        }
        public void loaddatabse()
        {
            QuanLyBaoHiem.Models.QLBHContext dbContext = new QuanLyBaoHiem.Models.QLBHContext();
            // Call the LoadAsync method to asynchronously get the data for the given DbSet from the database.
            dbContext.NhanViens.LoadAsync().ContinueWith(loadTask =>
            {
                // Bind data to control when loading complete
                gridChucvu.DataSource = (from a in dbContext.NhanViens
                                         join b in dbContext.ChucVus
                                         on a.MaCV equals b.MaCV
                                         where a.Status == true && a.MaCV == "TP" || a.MaCV == "NV"

                                         select new
                {
                    a.MaNV,
                    a.TenNV,
                    b.TenCV,
                    a.MaCV,
                    a.MaNVQuanLi
                }).ToList();
            }, System.Threading.Tasks.TaskScheduler.FromCurrentSynchronizationContext());
        }