protected void btnDangBai_Click(object sender, EventArgs e)
        {
            //if (Page.IsValid && fHinhAnh.HasFile)
            //{
            //    string fileName = "images/" + fHinhAnh.FileName;
            //    string filePath = MapPath(fileName);
            //    fHinhAnh.SaveAs(filePath);
            //}
            string      tieuDe          = txtTieuDe.Text;
            int         chuyenMuc       = Convert.ToInt32(ddlChuyenMuc.Text);
            string      moTaNgan        = txtMoTaNgan.Text;
            string      hinhAnh         = fHinhAnh.FileName;
            string      thongTinChiTiet = txtThongTinChiTiet.Text;
            int         dacSan          = Convert.ToInt32(ddlDacSan.Text);
            decimal     giaBan          = Convert.ToDecimal(txtGiaBan.Text);
            int         trangThai       = Convert.ToInt32(ddlTrangThai.Text);
            BaiViet     obj             = new BaiViet(tieuDe, chuyenMuc, moTaNgan, hinhAnh, thongTinChiTiet, 1, dacSan, giaBan, trangThai);
            XuLyBaiViet xl = new XuLyBaiViet();

            if (xl.ThemBaiViet(obj) <= 0)
            {
                lblError.Text = "Đăng bài không thành công. Vui lòng kiểm tra lại dữ liệu nhập vào";
            }
            else
            {
                Response.Redirect("Post.aspx");
            }
        }
Пример #2
0
        private void LoadBaiViet()
        {
            XuLyBaiViet xl = new XuLyBaiViet();

            gvBaiViet.DataSource = xl.ListBaiViet();
            gvBaiViet.DataBind();
        }
Пример #3
0
        protected void btnXoa_Click(object sender, EventArgs e)
        {
            LinkButton b = (LinkButton)sender;

            if (b.CommandName == "Delete")
            {
                XuLyBaiViet xl = new XuLyBaiViet();
                int         id = Convert.ToInt16(b.CommandArgument);
                xl.XoaBaiViet(id);
                LoadBaiViet();
            }
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["ID"] != null)
         {
             LoadChuyenMuc();
             LoadNguoiDung();
             int         id = Convert.ToInt32(Request.QueryString["ID"]);
             XuLyBaiViet xl = new XuLyBaiViet();
             DataTable   dt = new DataTable();
             dt                = xl.GetBaiViet(id);
             txtTieuDe.Text    = dt.Rows[0]["TieuDe"].ToString();
             ddlChuyenMuc.Text = dt.Rows[0]["ChuyenMuc"].ToString();
             txtMoTaNgan.Text  = dt.Rows[0]["MoTaNgan"].ToString();
             txtGiaBan.Text    = dt.Rows[0]["GiaBan"].ToString();
             if (dt.Rows[0]["DacSan"].ToString() == "1" || dt.Rows[0]["DacSan"].ToString().ToLower() == "true")
             {
                 ddlDacSan.SelectedIndex = 0;
             }
             else
             {
                 ddlDacSan.SelectedIndex = 1;
             }
             if (dt.Rows[0]["TrangThai"].ToString() == "1" || dt.Rows[0]["TrangThai"].ToString().ToLower() == "true")
             {
                 ddlDacSan.SelectedIndex = 0;
             }
             else
             {
                 ddlDacSan.SelectedIndex = 1;
             }
             imgHinhAnh.ImageUrl     = dt.Rows[0]["HinhAnh"].ToString();
             txtThongTinChiTiet.Text = dt.Rows[0]["ThongTinChiTiet"].ToString();
         }
         else
         {
             Response.Redirect("Post.aspx");
         }
     }
 }
Пример #5
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            int         id              = Convert.ToInt32(Request.QueryString["ID"]);
            string      tieuDe          = txtTieuDe.Text;
            int         chuyenMuc       = Convert.ToInt32(ddlChuyenMuc.Text);
            string      moTaNgan        = txtMoTaNgan.Text;
            string      hinhAnh         = fHinhAnh.FileName;
            string      thongTinChiTiet = txtThongTinChiTiet.Text;
            int         dacSan          = Convert.ToInt32(ddlDacSan.Text);
            decimal     giaBan          = Convert.ToDecimal(txtGiaBan.Text);
            int         trangThai       = Convert.ToInt32(ddlTrangThai.Text);
            BaiViet     obj             = new BaiViet(id, tieuDe, chuyenMuc, moTaNgan, hinhAnh, thongTinChiTiet, 1, dacSan, giaBan, trangThai);
            XuLyBaiViet xl              = new XuLyBaiViet();

            if (xl.SuaBaiViet(obj) <= 0)
            {
                lblError.Text = "Sửa bài viết không thành công. Vui lòng kiểm tra lại dữ liệu nhập vào";
            }
            else
            {
                Response.Redirect("Post.aspx");
            }
        }