private void dataGrid1_CurrentCellChanged(object sender, EventArgs e) { d = new LibDuoc.AccessData(); string mmyy = txtThang.Value.ToString().PadLeft(2, '0') + txtNam.Value.ToString().Substring(2); if (d.bMmyy(mmyy)) { string user = d.user; string d_user = user + mmyy; //string file = "d_dutrull"; string sql = ""; switch (dataGrid1[dataGrid1.CurrentRowIndex, 1].ToString()) { case "2": sql = "select distinct to_char(a.ngay,'dd/mm/yyyy') as ngay,b.ten as tenphieu from xxx.d_xuatsdll a," + user + ".d_loaiphieu b,xxx.d_bucstt c where a.id=c.id and a.phieu=b.id and a.idduyet in(select id from " + d_user + ".d_xtutrucll where idduyet in(select id from " + d_user + ".d_duyet where id =" + dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString() + "))"; break; case "3": sql = "select distinct to_char(a.ngay,'dd/mm/yyyy') as ngay,b.ten as tenphieu from xxx.d_xuatsdll a," + user + ".d_loaiphieu b where a.phieu=b.id and a.idduyet in(select id from " + d_user + ".d_hoantrall where idduyet in(select id from " + d_user + ".d_duyet where id =" + dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString() + "))"; break; case "4": sql = "select distinct to_char(a.ngay,'dd/mm/yyyy') as ngay,b.ten as tenphieu from xxx.d_xuatsdll a," + user + ".d_loaiphieu b where a.phieu=b.id and a.idduyet in(select id from " + d_user + ".d_haophill where idduyet in(select id from " + d_user + ".d_duyet where id =" + dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString() + "))"; break; default: sql = "select distinct to_char(a.ngay,'dd/mm/yyyy') as ngay,b.ten as tenphieu from xxx.d_xuatsdll a," + user + ".d_loaiphieu b where a.phieu=b.id and a.idduyet in(select id from " + d_user + ".d_dutrull where idduyet in(select id from " + d_user + ".d_duyet where id =" + dataGrid1[dataGrid1.CurrentRowIndex, 0].ToString() + "))"; break; } ; dslinh = d.get_data_mmyy(sql, txtTungay.Text, txtDenngay.Text, true); dataGrid2.DataSource = dslinh.Tables[0]; } }