protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] == null) { Response.Redirect("default.aspx"); } int MaLoaiBaiViet = int.Parse(Request.QueryString["id"]); BUSBaiViet BaiVietBUS = new BUSBaiViet(); List<BAIVIET> DSBaiViet = BaiVietBUS.TimKiemTheoLoaiBaiViet(MaLoaiBaiViet); if (DSBaiViet.Count() == 0) { Label1.Visible = false; } else { Label1.Visible = true; } string str = @"<table class='dsBaiViet'><thead><tr><th></th></tr></thead><tbody>"; for (int j = 0; j < DSBaiViet.Count(); j++) { str += "<tr><td>"; str += "<div class='tieude'>"; str += "<img src='images/ico/favicon_002.png' height = '40px width = '40px'/>"; str += DSBaiViet[j].TieuDe + "</div>"; str += "<div>"; if (DSBaiViet[j].HinhAnh != "") str += @"<img style='margin:5px;width:300px;float:left' src='Uploads/" + DSBaiViet[j].HinhAnh + "'/>"; str += "<a class='tomtat'>" + DSBaiViet[j].TomTat + "</a>"; str += "<a class='XemTiep' href ='" + "BaiViet.aspx?id=" + DSBaiViet[j].MaBaiViet + "'><i>" + "(Xem tiếp >>)" + "</i></a>"; str += "</div>"; str += "<div style='clear:both'><hr width='50%'></div>"; str += @"</div></td></tr>"; } str += @"</tbody></table>"; Label1.Text = str; }
protected void XoaBai(int maloai) { try { //xac nhan truoc khi xoa BUSBaiViet busBaiViet = new BUSBaiViet(); List<BAIVIET> lstBaiViet = busBaiViet.TimKiemTheoLoaiBaiViet(maloai); if (lstBaiViet != null) { foreach (BAIVIET bv in lstBaiViet) { BUSTapTinBaiViet busTapTin = new BUSTapTinBaiViet(); List<TAPTINBAIVIET> lstTapTin = busTapTin.TimKiemMaBaiViet(bv.MaBaiViet); if (lstTapTin != null) { foreach (TAPTINBAIVIET taptin in lstTapTin) { busTapTin.Xoa(taptin.MaTapTin); } } busBaiViet.Xoa(bv.MaBaiViet); } } BUSLoaiBaiViet bus = new BUSLoaiBaiViet(); if (bus.Xoa(maloai) == 0) { //Thong bao Response.Redirect("LoaiBaiViet.aspx"); } } catch { } }