public static HocPhi getHocPhi() { HocPhi hocPhi = new HocPhi(); DiemThi dT = new DiemThi(); List <CTHocPhi> listCT = new List <CTHocPhi>(); HtmlDocument document = new HtmlDocument(); document.LoadHtml(getTrangHocPhi()); HtmlNode nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblNHHKOnline']"); hocPhi.ThoiGian = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_SoTinChiHP']"); hocPhi.TongSoTC = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblphaiDong']"); hocPhi.TongSoTien = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblDongLanDau1']"); hocPhi.TienDongTTLD = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblDaDongHKOffline']"); hocPhi.TienDaDong = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblConNoHocKy']"); hocPhi.TienConNo = nodeHP.InnerText; HtmlNodeCollection nodes; int k = 2; do { nodes = document.DocumentNode.SelectNodes("//*[@id='ctl00_ContentPlaceHolder1_ctl00_gvHocPhi']/tr[" + k + "]/td[3]/span"); if (nodes != null) { CTHocPhi ct = new CTHocPhi(); MonHoc monHoc = new MonHoc(); for (int j = 2; j <= 10; j++) { HtmlNodeCollection nodesChiTiet = document.DocumentNode.SelectNodes("//*[@id='ctl00_ContentPlaceHolder1_ctl00_gvHocPhi']/tr[" + k + "]/td[" + j + "]/span"); foreach (HtmlNode node in nodesChiTiet) { switch (j) { case 2: monHoc.MaMH = node.InnerText; break; case 3: monHoc.TenMH = node.InnerText; break; case 4: ct.MaNhom = node.InnerText; break; case 6: monHoc.SoTC = node.InnerText; break; case 8: ct.HocPhi = node.InnerText; break; case 9: ct.MienGiam = node.InnerText; break; case 10: ct.PhaiDong = node.InnerText; break; } } } ct.monHoc = monHoc; listCT.Add(ct); } k++; }while (nodes != null); hocPhi.ListCTHP = listCT; return(hocPhi); }
public static HocPhi getHocPhi() { HocPhi hocPhi = new HocPhi(); DiemThi dT = new DiemThi(); List<CTHocPhi> listCT = new List<CTHocPhi>(); HtmlDocument document = new HtmlDocument(); document.LoadHtml(getTrangHocPhi()); HtmlNode nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblNHHKOnline']"); hocPhi.ThoiGian = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_SoTinChiHP']"); hocPhi.TongSoTC = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblphaiDong']"); hocPhi.TongSoTien = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblDongLanDau1']"); hocPhi.TienDongTTLD = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblDaDongHKOffline']"); hocPhi.TienDaDong = nodeHP.InnerText; nodeHP = document.DocumentNode.SelectSingleNode("//*[@id='ctl00_ContentPlaceHolder1_ctl00_lblConNoHocKy']"); hocPhi.TienConNo = nodeHP.InnerText; HtmlNodeCollection nodes; int k = 2; do { nodes = document.DocumentNode.SelectNodes("//*[@id='ctl00_ContentPlaceHolder1_ctl00_gvHocPhi']/tr[" + k + "]/td[3]/span"); if (nodes != null) { CTHocPhi ct = new CTHocPhi(); MonHoc monHoc = new MonHoc(); for (int j = 2; j <= 10; j++) { HtmlNodeCollection nodesChiTiet = document.DocumentNode.SelectNodes("//*[@id='ctl00_ContentPlaceHolder1_ctl00_gvHocPhi']/tr[" + k + "]/td[" + j + "]/span"); foreach (HtmlNode node in nodesChiTiet) { switch (j) { case 2: monHoc.MaMH = node.InnerText; break; case 3: monHoc.TenMH = node.InnerText; break; case 4: ct.MaNhom = node.InnerText; break; case 6: monHoc.SoTC = node.InnerText; break; case 8: ct.HocPhi = node.InnerText; break; case 9: ct.MienGiam = node.InnerText; break; case 10: ct.PhaiDong = node.InnerText; break; } } } ct.monHoc = monHoc; listCT.Add(ct); } k++; } while (nodes != null); hocPhi.ListCTHP = listCT; return hocPhi; }