private bool kiemtra() { string f1 = "", f2 = ""; bool bFound = true; switch (i_loai) { case 1: f1 = "xxx.d_dutru"; break; case 2: f1 = "xxx.d_xtutruc"; break; case 3: f1 = "xxx.d_hoantra"; break; default: f1 = "xxx.d_haophi"; break; } f2 = f1 + "ct"; f1 += "ll"; sql = "select distinct b.idduyet from xxx.d_duyet a," + f1 + " b," + f2 + " c," + user + ".d_dmbd d "; sql += "where a.id=b.idduyet and b.id=c.id and c.mabd=d.id "; sql += "and to_char(a.ngay,'dd/mm/yyyy')='" + s_ngay + "'"; sql += "and a.loai=" + i_loai + " and a.phieu=" + i_phieu; if (i_loai == 2) { if (bIntheocstt) { sql += " and a.makp=" + i_makp; } else { sql += " and a.makhoa=" + i_makp; } } else { sql += " and a.makhoa=" + i_makp; } DataTable dt = d.get_thuoc(s_ngay, s_ngay, sql).Tables[0]; bFound = dt.Rows.Count > 0; if (bFound) { decimal id = decimal.Parse(dt.Rows[0]["idduyet"].ToString()); sql = "update " + f2 + " set slthuc=0 where id in (select a.id from " + f1 + " a,xxx.d_duyet b where a.idduyet=b.id "; sql += "and b.id=" + id; sql += ")"; d.exe_thuoc(s_ngay, s_ngay, sql); d.upd_duyet(s_mmyy, i_makp, i_nhom, i_loai, i_phieu, s_ngay, ""); } return(bFound); }