private void LoadTours() { var tours = TourBLL.ListTours(); //Back to main thread update UI if (InvokeRequired) { BeginInvoke(new Action(() => { cbGroupTour.DataSource = tours; cbGroupTour.DisplayMember = "Name"; cbGroupTour.ValueMember = "Id"; })); } }
// Handle Event Tour public void LoadTourDataGridView(string type = null, string value = null) { if (InvokeRequired) { BeginInvoke(new Action(() => { dgvTourList.ShowLoading(true); })); } var tourData = TourBLL.ListTours(type, value); var dataSource = tourData.Select(t => new TourDataSource( t.Id, t.CurrentPrice, t.Name, t.Description, t.TourType.Name, t.TourTypeId)).ToList(); if (InvokeRequired) { BeginInvoke(new Action(() => { dgvTourList.ShowLoading(false); dgvTourList.DataSource = dataSource; //ConfigTourDataGridView dgvTourList.Columns["TourTypeId"].Visible = false; dgvTourList.Columns["Id"].HeaderText = "Mã"; dgvTourList.Columns["Name"].HeaderText = "Tên"; dgvTourList.Columns["CurrentPrice"].HeaderText = "Giá gốc"; dgvTourList.Columns["TourTypeName"].HeaderText = "Loại"; dgvTourList.Columns["Description"].HeaderText = "Mô tả"; dgvTourList.Columns["CurrentPrice"].DefaultCellStyle.Format = "N0"; })); } }