public async void GetTuaTruyen() { var dt = await ExecSQL.ExecQueryDataAsyncAsDataTable("SELECT DISTINCT a.matua, b.tuatruyen FROM dbo.tbl_tentruyen a INNER JOIN dbo.tbl_tuatruyen b ON b.matua = a.matua WHERE a.filetruyen=1 ORDER BY b.tuatruyen"); cbo_tuatruyen.Properties.DataSource = dt; cbo_tuatruyen.Properties.ValueMember = "matua"; cbo_tuatruyen.Properties.DisplayMember = "tuatruyen"; }
public async void GetTenTruyen() { if (string.IsNullOrEmpty(cbo_tuatruyen.Text)) { return; } var dt = await ExecSQL.ExecQueryDataAsyncAsDataTable($"SELECT a.matruyen, CASE WHEN LEN(a.ghichu)>0 THEN a.ghichu ELSE (CASE WHEN LEN(a.tentruyen)>6 THEN CONCAT(FORMAT(a.tap,'000'),' - ', a.tentruyen) ELSE a.tentruyen END) END AS tentruyen, a.matua FROM dbo.tbl_tentruyen a INNER JOIN dbo.tbl_tuatruyen b ON b.matua = a.matua WHERE a.filetruyen=1 AND a.matua='{cbo_tuatruyen.EditValue}' ORDER BY a.tap"); dgv_tentruyen.BeginInvoke(new Action(() => { dgv_tentruyen.DataSource = dt; lbl_matruyen.DataBindings.Clear(); lbl_matua.DataBindings.Clear(); lbl_matua.DataBindings.Add("text", dt, "matua"); lbl_matruyen.DataBindings.Add("text", dt, "matruyen"); })); }