protected void btnThem_Click(object sender, EventArgs e) { try { //lay thong tin tu textbox GIOITHIEU lpDTO = new GIOITHIEU(); lpDTO.TieuDe = this.txttengioithieu.Text; lpDTO.NoiDung = this.txtnoidung.Content; //Goi ham cap nhat BUSGioiThieu BUSGioiThieu = new BUSGioiThieu(); if (BUSGioiThieu.Them(lpDTO) == 1) { //Thong bao lbThongBao.Text = "Thêm Thành Công"; lbThongBao.Visible = true; Response.Redirect("GioiThieu.aspx"); } else { lbThongBao.Text = "Thêm Không Thành Công"; lbThongBao.Visible = true; } } catch { lbThongBao.Text = "Thêm Không Thành Công"; lbThongBao.Visible = true; } }
protected void btnCapNhat_Click(object sender, EventArgs e) { try { //lay thong tin tu textbox GIOITHIEU lpDTO = new GIOITHIEU(); lpDTO.MaBai = int.Parse(Request.QueryString["id"]); lpDTO.TieuDe = this.txttengioithieu.Text; lpDTO.NoiDung = this.txtnoidung.Content; //Goi ham cap nhat BUSGioiThieu BUSGioiThieu = new BUSGioiThieu(); if (BUSGioiThieu.CapNhat(lpDTO) == 0) { //Thong bao lbThongBao.Text = "Cập Nhật Thành Công"; lbThongBao.Visible = true; Response.Redirect("GioiThieu.aspx"); } else { lbThongBao.Text = "Cập Nhật Không Thành Công"; lbThongBao.Visible = true; } } catch { lbThongBao.Text = "Cập nhật Không Thành Công"; lbThongBao.Visible = true; } }
private void loadGioiThieu(int magioithieu) { BUSGioiThieu BUSGioiThieu = new BUSGioiThieu(); int MaBaiViet = int.Parse(Request.QueryString["id"]); GIOITHIEU GIOITHIEU = BUSGioiThieu.TimKiem(MaBaiViet); this.lblNoiDungBaiViet.Text = GIOITHIEU.NoiDung; lblTieuDe.Text = GIOITHIEU.TieuDe; lblTieuDe.Font.Bold = true; lblTieuDe.Font.Size = 18; }
private void loadDSGioiThieu() { BUSGioiThieu GioiThieuBus = new BUSGioiThieu(); List<GIOITHIEU> DSGioiThieu = GioiThieuBus.SelectGIOITHIEUsAll(); string noidung = ""; lblTieuDe.Font.Bold = true; lblTieuDe.Font.Size = 18; for (int i = 0; i < DSGioiThieu.Count(); i++) { noidung += "<a href='" + "gioithieu.aspx?id=" + DSGioiThieu[i].MaBai + "'> " + DSGioiThieu[i].TieuDe + "</a>"; noidung += "<br />"; noidung += DSGioiThieu[i].NoiDung; noidung += "<br /><hr><br />"; } ltrNoiDung.Text = noidung; }
public string strMenuGioiThieu() { BUSGioiThieu GioiThieuBUS = new BUSGioiThieu(); int i; List<GIOITHIEU> DSGioiThieu = GioiThieuBUS.SelectGIOITHIEUsAll(); string str = ""; str += "<li>"; str += "<a class='parent' href='GioiThieu.aspx'><span>Giới Thiệu</span></a>"; str += "<div><ul>"; for (i = 0; i < DSGioiThieu.Count(); i++) { str += "<li><a href='GioiThieu.aspx?id="+DSGioiThieu[i].MaBai.ToString()+"'><span>"+DSGioiThieu[i].TieuDe+"</span></a>"; // MenuItem mn = new MenuItem(DSGioiThieu[i].TieuDe, "", "", "~/GioiThieu.aspx?id=" + DSGioiThieu[i].MaBai); // mnGioiThieu.ChildItems.Add(mn); str += "</li>"; } str += "</ul></div"; str += "</li>"; return str; }
//Load public int LoadGioiThieu() { List<GIOITHIEU> lt = new List<GIOITHIEU>(); BUSGioiThieu BUSGioiThieu = new BUSGioiThieu(); lt = BUSGioiThieu.SelectGIOITHIEUsAll(); if (lt.Count > 0) { this.GridViewGioiThieu.DataSource = lt; GridViewGioiThieu.DataBind(); PanelDanhSach.Visible = true; PanelMessage.Visible = false; return lt.Count; } else { PanelDanhSach.Visible = false; PanelMessage.Visible = true; return 0; } }
protected void XoaGioiThieu(int maBai) { try { //xac nhan truoc khi xoa BUSGioiThieu busGioiThieu = new BUSGioiThieu(); if (busGioiThieu.Xoa(maBai) == 0) { //Thong bao Response.Redirect("GioiThieu.aspx"); } } catch { } }
protected void btnXoa_Click(object sender, EventArgs e) { try { //lay thong tin tu textbox int magioithieu = int.Parse(Request.QueryString["id"]); //xac nhan truoc khi xoa BUSGioiThieu BUSGioiThieu = new BUSGioiThieu(); if (BUSGioiThieu.Xoa(magioithieu) == 0) { //Thong bao lbThongBao.Text = "Xóa Thành Công"; lbThongBao.Visible = true; Response.Redirect("GioiThieu.aspx"); } } catch { lbThongBao.Text = "Xoa Không Thành Công"; lbThongBao.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { //Thong tin nguoi dung if (!IsPostBack) { if (Request.QueryString["id"] != null) { //lay ma int magioithieu = int.Parse(Request.QueryString["id"]); //lay thong tin va load len cac textbox BUSGioiThieu BUSGioiThieu = new BUSGioiThieu(); GIOITHIEU lpDTO = BUSGioiThieu.TimKiem(magioithieu); this.txttengioithieu.Text = lpDTO.TieuDe; this.txtnoidung.Content = lpDTO.NoiDung; } } }