private string XemTKB(string namHoc) { G9Service.G9_Service sv = new G9Service.G9_Service(); string temp = ""; ThoiKhoaBieu[] list = sv.GetTKB(namHoc); if (list == null || list.Count() <= 0) { return "Chưa có thời khóa biểu"; } string strLop = ""; foreach (ThoiKhoaBieu tkb in list) { Lop lop = sv.GetLopFromTKB(tkb.MaTKB); strLop += " | <span id=\"span" + lop.MaLop + "\" onClick='Show(\"div" + lop.MaLop + "\")' class='menuLop'>" + lop.TenLop + "</span>"; temp += "<div id=\"div" + lop.MaLop + "\" class=\"divTKB\">"; temp += "<div><a href='Sua?lop=" + lop.MaLop + "&namHoc=" + namHoc + "'>" + lop.TenLop + "</a></div>"; temp += "<div>Tổng số môn: $TongSoMon</div>"; temp += "<div>Số môn chưa xếp: $TongSoConLai</div>"; temp += " <table>"; temp += " <tr>"; temp += " <th></th>"; temp += " <th>Hai</th>"; temp += " <th>Ba</th>"; temp += " <th>Tư</th>"; temp += " <th>Năm</th>"; temp += " <th>Sáu</th>"; temp += " <th>Bảy</th>"; temp += " <th>Chủ nhật</th>"; temp += " </tr>"; for (int j = 1; j < 13; j++) { temp += " <tr>"; temp += " <td>Tiết " + j + "</td>"; for (int i = 2; i <= 8; i++) { temp += " <td>&" + tkb.MaTKB + i + j + "&</td>"; } temp += " </tr>"; } temp += "</table>"; temp += "</div>"; ChiTietTKB[] chiTiets = sv.GetDanhSachChiTietTKB(tkb.MaTKB); int tongSoMon = 0; string soMonConLai = ""; List<MonHoc> lstMonHoc = sv.GetDanhSachMonHoc().ToList(); List<MonHoc> lstTemp = new List<MonHoc>(); foreach (ChiTietTKB chiTiet in chiTiets) { ChiTietTKB oChiTiet = sv.GetChiTietTKB(chiTiet.MaChiTietTKB); MonHoc mh = sv.GetMonHocFromTKB(oChiTiet.MaChiTietTKB); GiaoVien gv = sv.GetGiaoVienFromTKB(oChiTiet.MaChiTietTKB); temp = temp.Replace(String.Format("&{0}{1}{2}&", tkb.MaTKB, oChiTiet.Thu, oChiTiet.TietBatDau), mh.TenMonHoc + "<br/>" + gv.TenGiaoVien); foreach (var mhoc in lstMonHoc) { if (mhoc.MaMonHoc == mh.MaMonHoc) { tongSoMon++; lstTemp.Add(mhoc); } } } foreach (var mhoc in lstMonHoc) { if (!lstTemp.Contains(mhoc)) { soMonConLai += mhoc.TenMonHoc + ","; } } temp = temp.Replace("$TongSoMon", tongSoMon.ToString()); if (soMonConLai.Length > 0) { temp = temp.Replace("$TongSoConLai", soMonConLai.Substring(0, soMonConLai.Length - 1)); } else { temp = temp.Replace("$TongSoConLai", "Không có"); } for (int j = 1; j < 13; j++) { for (int i = 2; i <= 8; i++) { temp = temp.Replace(String.Format("&{0}{1}{2}&", tkb.MaTKB, i, j), ""); } } } ViewData["menuLop"] = strLop; return temp; }