예제 #1
0
 protected void btnDN_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = XLDL.GetData("SELECT [MaTK], [TenTK], [TenDN], [MatKhau], [LoaiTK] FROM [TaiKhoan] where TenDN='" + tbTK.Text + "' and MatKhau='" + tbMK.Text + "'");
         if (dt.Rows.Count > 0)
         {
             int LTK = int.Parse(dt.Rows[0]["LoaiTK"].ToString());
             if (LTK == 1)
             {
                 Session["TenDNAdmin"] = tbTK.Text;
                 Response.Redirect("~/QuanTri.aspx");
             }
             else if (LTK == 2)
             {
                 Session["TenDN"] = tbTK.Text;
                 Session["MaTK"]  = dt.Rows[0]["MaTK"];
                 Response.Redirect("Default.aspx");
             }
         }
         else
         {
             lbThongBao.Text = "Tên đăng nhập hoặc mật khẩu khoặc chính xác!!!";
         }
     }
     catch
     {
         lbThongBao.Text = "Thất Bại";
     }
 }
예제 #2
0
 protected void btnDN_Click(object sender, EventArgs e)
 {
     try
     {
         string ktr = @"select 1 from taikhoan where tendn=N'" + tbTK.Text + "'";
         if (XLDL.GetData(ktr).Rows.Count > 0)
         {
             lbThongBao.Text = "Tên tài khoản đã tồn tại!!!";
             tbTK.Focus();
         }
         else
         {
             string tentk = tbTenTK.Text;
             string email = tbEmail.Text;
             string dc    = tbDiaChi.Text;
             string sdt   = tbSDT.Text;
             string tendn = tbTK.Text;
             string mk    = tbMK.Text;
             string sql   = "insert into Taikhoan  values (N'" + tentk + "','" + email + "',N'" + dc + "','" + sdt + "','" + tendn + "','" + mk + "',2)";
             XLDL.Excute(sql);
             Response.Redirect("DangNhap.aspx");
         }
     }
     catch
     {
         lbThongBao.Text = "Thất bại";
     }
 }
예제 #3
0
        private void loaddata()
        {
            if (Request.QueryString["MaBlog"] != null)
            {
                string MaBlog = Request.QueryString["MaBlog"].ToString();

                string sql = "SELECT [MaBlog], [HinhAnh], [TieuDe], [TTND], [NoiDung], [SoLanXem], [NgayDang], [MaTK] FROM [Blog] Where MaBlog=" + MaBlog;

                DataTable dt = XLDL.GetData(sql);
                tbMaBlog.Text = dt.Rows[0]["MaBlog"].ToString();
                tbTieuDe.Text = dt.Rows[0]["TieuDe"].ToString();
                lbnd.Visible  = true;
                string nd = dt.Rows[0]["NoiDung"].ToString();
                lbnd.Text = nd;

                tbNguoiDang.Text = dt.Rows[0]["MaTK"].ToString();
                tbSoLanXem.Text  = dt.Rows[0]["SoLanXem"].ToString();

                string filename = dt.Rows[0]["HinhAnh"].ToString();

                tbTTND.Text = dt.Rows[0]["TTND"].ToString();

                string matk = dt.Rows[0]["MaTK"].ToString();
            }
        }
예제 #4
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try

            {
                string MaBlog = Session["MaTK"].ToString();

                string mkc = tbMK.Text;
                string mkm = tbMKM.Text;
                string str = @"Select Matkhau from taikhoan where matk=" + MaBlog;
                if (XLDL.GetData(str).Rows[0]["MatKhau"].ToString() == mkc)
                {
                    string sql = "update TaiKhoan set matkhau='" + mkm + "' where MaTK=" + MaBlog;
                    XLDL.Excute(sql);

                    Response.Redirect("DoiMatKhau.Aspx");
                }
                else
                {
                    lbThongBao.Text = "Mật khẩu cũ không chính xác.";
                }
            }
            catch
            {
                Response.Redirect("Default.aspx");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["TenDN"] == null)
            {
                Response.Write("<script>alert('Bạn chưa đăng nhập');</script>");
                Server.Transfer("Default.aspx", true);
            }
            else
            {
                string matk = Session["MaTk"].ToString();
                string ktra = Request.QueryString["MaDH"];
                string sql1 = "sELECT matk FROM DonHang where EXISTS( select matk from taikhoan where DonHang.matk = taikhoan.matk  and donhang.madh= " + ktra + "); ";

                DataTable dt = XLDL.GetData(sql1);

                if (dt.Rows[0]["matk"].ToString() == matk)
                {
                    loaddata();
                }
                else
                {
                    Response.Redirect("QuanLiThongTin.aspx");
                }
            }
        }
예제 #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (Session["TenDN"] == null)
            {
                lbThongBao.Text = "Vui lòng đăng nhập trước khi bình luận!!!";
            }
            else
            {
                string nd = HttpUtility.HtmlEncode(Request.Form["tbND"]);
                if (nd == "")
                {
                    lbThongBao.Text = "Chưa nhập nội dung!!!";
                }
                else
                {
                    string    tendn = Session["TenDN"].ToString();
                    string    sql   = "SELECT [MaTK], [TenDN] FROM [TaiKhoan] where TenDN=N'" + tendn + "'";
                    DataTable dt    = XLDL.GetData(sql);
                    string    matk  = dt.Rows[0]["MaTK"].ToString();

                    string mablog = Request.QueryString["MaSP"].ToString();


                    DateTime dateTime = DateTime.Now;
                    string   ngay     = dateTime.ToString("dd/MM/yyyy HH:mm:ss");
                    string   sql1     = "Insert into BinhLuanSP values (" + mablog + "," + matk + ",'" + ngay + "',N'" + nd + "')";
                    XLDL.Excute(sql1);
                    Response.Redirect("~/ChiTietSanPham.aspx?MaSP=" + mablog);
                }
            }
        }
예제 #7
0
        public void loaddata()
        {
            string sql = "SELECT BLOG.MaBlog, BLOG.HinhAnh, BLOG.TieuDe, BLOG.TTND, BLOG.NgayDang, TaiKhoan.TenTK FROM BLOG INNER JOIN TaiKhoan ON BLOG.MaTK = TaiKhoan.MaTK";

            DataList2.DataSource = XLDL.GetData(sql);
            DataList2.DataBind();
        }
예제 #8
0
        public void loaddata()
        {
            try
            {
                string nd = Session["TimKiemSP"].ToString();

                string    sql = "select  LOAISANPHAM.TenLoaiSP, SANPHAM.TenSP, SANPHAM.HinhAnh, SANPHAM.TienSP, SANPHAM.MaSP, LOAISANPHAM.MaLoaiSP,dbo.ufn_removeMark(TenSP) as  tensp_khongdau FROM LOAISANPHAM INNER JOIN SANPHAM ON LOAISANPHAM.MaLoaiSP = SANPHAM.MaLoaiSP   where dbo.ufn_removeMark(tensp) like N'%" + nd + "%' or sanpham.tensp like N'%" + nd + "%'";
                DataTable dt  = XLDL.GetData(sql);

                string tenspcd = dt.Rows[0]["TenSP"].ToString();
                if (dt.Rows.Count > 0)
                {
                    lbThongBao.Text    = "<p style='font-weight:bold;padding:10px'>Kết quả tìm kiếm: " + nd + "</p>";
                    themdiv.DataSource = XLDL.GetData(sql);
                    themdiv.DataBind();
                }
                else
                {
                    lbThongBao.Text = "<p style='font-weight:bold;padding:10px'>Kết quả tìm kiếm: " + nd + "</p><br>Không tìm thấy sản phẩm.";
                }
            }
            catch
            {
                lbThongBao.Text = "<p style='font-weight:bold;padding:10px'>Kết quả tìm kiếm:</p><br>Không tìm thấy sản phẩm.";
            }
        }
예제 #9
0
        public void loaddata()
        {
            string sql = "SELECT [HinhAnh], [TieuDe], [TTND], [NgayDang], [NguoiDang], [MaBlog], [NoiDung] FROM [BLOG]";

            DataList2.DataSource = XLDL.GetData(sql);
            DataList2.DataBind();
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    sql = "Select MaSP,TenSP,TienSP,NgayCapNhat,SoLuongBan,SoLanXem from sanpham";
            DataTable dt  = XLDL.GetData(sql);

            gvSP.DataSource = dt;
            gvSP.DataBind();
        }
예제 #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    sql = "select MaBlog,TieuDe,TTND,NoiDung,NgayDang,SoLanXem,NguoiDang from BLOG";
            DataTable dt  = XLDL.GetData(sql);

            gvBlog.DataSource = dt;
            gvBlog.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            string    sql = "SELECT BLOG.MaBlog, BLOG.HinhAnh, BLOG.TieuDe, BLOG.TTND, BLOG.NoiDung, BLOG.SoLanXem, BLOG.NgayDang, TaiKhoan.TenTK FROM BLOG INNER JOIN TaiKhoan ON BLOG.MaTK = TaiKhoan.MaTK";
            DataTable dt  = XLDL.GetData(sql);

            gvBlog.DataSource = dt;
            gvBlog.DataBind();
        }
예제 #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    sql = "Select MaTK,TenTK,Email,DiaChi,SDT,TenDN,MatKhau from TaiKhoan where LoaiTK=2";
            DataTable dt  = XLDL.GetData(sql);

            gvSP.DataSource = dt;
            gvSP.DataBind();
        }
예제 #14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string    sql = "select MaDH,MaTK,NgayLapDH,TenKH,DiaChi,SDT,PTTT,ThanhTien from DonHang";
            DataTable dt  = XLDL.GetData(sql);

            gvBlog.DataSource = dt;
            gvBlog.DataBind();
        }
예제 #15
0
        public void loaddata()
        {
            string    matk = Session["MaTK"].ToString();
            string    sql  = "SELECT [MaTK], [TenTK], [Email], [DiaChi], [SDT] FROM [TaiKhoan] where MaTK=" + matk;
            DataTable dt   = XLDL.GetData(sql);

            txtTenNguoiNhan.Text  = dt.Rows[0]["TenTK"].ToString();
            txtDienThoaiNhan.Text = dt.Rows[0]["SDT"].ToString();
            txtDiaChiNhan.Text    = dt.Rows[0]["DiaChi"].ToString();
        }
 public void loaddata()
 {
     try
     {
         string mablog = Request.QueryString["MaBlog"].ToString();
         string sql    = "SELECT [MaBlog], [HinhAnh], [TieuDe], [NoiDung], [NgayDang], [MaTK] FROM [BLOG] Where MaBlog=" + mablog;
         DataList5.DataSource = XLDL.GetData(sql);
         DataList5.DataBind();
     }
     catch
     {
     }
 }
예제 #17
0
        public void loaddata()
        {
            string sql = "SELECT LOAISANPHAM.TenLoaiSP, SANPHAM.TenSP, SANPHAM.HinhAnh, SANPHAM.TienSP, SANPHAM.MaSP, LOAISANPHAM.MaLoaiSP FROM LOAISANPHAM INNER JOIN SANPHAM ON LOAISANPHAM.MaLoaiSP = SANPHAM.MaLoaiSP order by Sanpham.MaSP asc";

            DataList3.DataSource = XLDL.GetData(sql);

            DataList3.DataBind();

            string sql1 = "SELECT TOP (4) LOAISANPHAM.TenLoaiSP, SANPHAM.TenSP, SANPHAM.HinhAnh, SANPHAM.TienSP, SANPHAM.MaSP, LOAISANPHAM.MaLoaiSP, SANPHAM.SoLuongBan FROM LOAISANPHAM INNER JOIN SANPHAM ON LOAISANPHAM.MaLoaiSP = SANPHAM.MaLoaiSP ORDER BY SANPHAM.SoLuongBan desc";

            DataList2.DataSource = XLDL.GetData(sql1);
            DataList2.DataBind();
        }
예제 #18
0
 public void loaddata()
 {
     try
     {
         string masp = Request.QueryString["MaSP"].ToString();
         string sql  = "SELECT SANPHAM.MaSP, SANPHAM.MaLoaiSP, SANPHAM.TenSP, SANPHAM.SoLuongSP, SANPHAM.HinhAnh, SANPHAM.NhaCC, SANPHAM.TienSP, SANPHAM.Mota, LOAISANPHAM.TenLoaiSP FROM SANPHAM INNER JOIN LOAISANPHAM ON SANPHAM.MaLoaiSP = LOAISANPHAM.MaLoaiSP WHERE SANPHAM.MaSP = " + masp;
         DataList7.DataSource = XLDL.GetData(sql);
         DataList7.DataBind();
     }
     catch
     {
     }
 }
예제 #19
0
        public void loaddata()
        {
            string sql = "SELECT [MaLoaiSP],[TenLoaiSP] FROM[LOAISANPHAM]";

            Danhmuc.DataSource = XLDL.GetData(sql);
            Danhmuc.DataBind();

            DataList1.DataSource = XLDL.GetData(sql);
            DataList1.DataBind();

            string sql1 = "SELECT top(2) [MaBlog], [HinhAnh], [NgayDang],[TieuDe], [TTND] FROM [BLOG] order by [NgayDang] desc";

            DataList2.DataSource = XLDL.GetData(sql1);
            DataList2.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["TenDN"] == null)
     {
         Response.Write("<script>alert('Bạn chưa đăng nhập');</script>");
         Server.Transfer("Default.aspx", true);
     }
     else
     {
         string    matk = Session["MaTK"].ToString();
         string    sql  = "select MaDH,MaTK,NgayLapDH,TenKH,DiaChi,SDT,PTTT,ThanhTien from DonHang where MaTK=' " + matk + "'";
         DataTable dt   = XLDL.GetData(sql);
         gvBlog.DataSource = dt;
         gvBlog.DataBind();
     }
 }
예제 #21
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         DataTable dt = XLDL.GetData("Select MaLoaiSP,TenLoaiSP from LOAISANPHAM");
         if (dt.Rows.Count > 0)
         {
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 rdLSP.Items.Add("i");
                 rdLSP.Items[i].Text  = dt.Rows[i][1].ToString();
                 rdLSP.Items[i].Value = dt.Rows[i][0].ToString();
             }
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["TenDN"] == null)
     {
         Response.Write("<script>alert('Bạn chưa đăng nhập');</script>");
         Server.Transfer("Default.aspx", true);
     }
     else
     {
         string    matk = Session["MaTK"].ToString();
         string    sql  = "SELECT BLOG.MaBlog, BLOG.HinhAnh, BLOG.TieuDe, BLOG.TTND, BLOG.NoiDung, BLOG.SoLanXem, BLOG.NgayDang, TaiKhoan.TenTK FROM BLOG INNER JOIN TaiKhoan ON BLOG.MaTK = TaiKhoan.MaTK where taikhoan.matk=" + matk;
         DataTable dt   = XLDL.GetData(sql);
         gvBlog.DataSource = dt;
         gvBlog.DataBind();
     }
 }
        private void loaddata()
        {
            if (Request.QueryString["MaDH"] != null)
            {
                string MaBlog = Request.QueryString["MaDH"].ToString();

                string sql = "select MaDH,NgayLapDH,TenKH,DiaChi,SDT,PTTT,ThanhTien from DonHang Where MaDH=" + MaBlog;

                DataTable dt = XLDL.GetData(sql);

                string sql1 = "SELECT SANPHAM.MaSP, SANPHAM.TenSP, SANPHAM.TienSP, ChiTietDonHang.SL, ChiTietDonHang.MaDH , SANPHAM.TienSP* ChiTietDonHang.SL AS ThanhTien FROM SANPHAM INNER JOIN ChiTietDonHang ON SANPHAM.MaSP = ChiTietDonHang.MaSP WHERE ChiTietDonHang.MaDH = " + MaBlog;

                DataTable dt1 = XLDL.GetData(sql1);
                gvGioHang.DataSource = dt1;
                gvGioHang.DataBind();
            }
        }
예제 #24
0
        private void loaddata()
        {
            if (Session["MaTK"].ToString() != null)
            {
                string MaBlog = Session["MaTK"].ToString();

                string sql = "Select MaTK, TenTK, Email, DiaChi, SDT, TenDN, MatKhau from TaiKhoan Where MaTK=" + MaBlog;

                DataTable dt = XLDL.GetData(sql);
                tbMaTK.Text = dt.Rows[0]["MaTK"].ToString();

                tbTenKH.Text  = dt.Rows[0]["TenTK"].ToString();
                tbDiaChi.Text = dt.Rows[0]["DiaCHi"].ToString();
                tbSDT.Text    = dt.Rows[0]["SDT"].ToString();
                tbEmail.Text  = dt.Rows[0]["Email"].ToString();
            }
        }
예제 #25
0
        public void loaddata()
        {
            try
            {
                string maloai = Request.QueryString["MaLoaiSP"].ToString();
                string sql    = "SELECT LOAISANPHAM.TenLoaiSP, SANPHAM.TenSP, SANPHAM.HinhAnh, SANPHAM.TienSP, SANPHAM.MaSP, LOAISANPHAM.MaLoaiSP FROM LOAISANPHAM INNER JOIN SANPHAM ON LOAISANPHAM.MaLoaiSP = SANPHAM.MaLoaiSP where sanpham.maloaisp=" + maloai + " order by Sanpham.MaSP asc";

                DataList3.DataSource = XLDL.GetData(sql);
                DataList3.DataBind();
                string sql1 = "select TenLoaiSP from loaisanpham where MaLoaiSP=" + maloai;
                DataList4.DataSource = XLDL.GetData(sql1);
                DataList4.DataBind();
            }
            catch

            {
            }
        }
예제 #26
0
        private void loaddata()
        {
            if (Request.QueryString["Ma"] != null)
            {
                string MaSP = Request.QueryString["Ma"].ToString();

                string sql = "SELECT [MaSP], [TenSP], [TienSP], [NhaCC], [Mota], [NgayCapNhat], [HinhAnh], [MaLoaiSP], [SoLuongSP], [SoLuongBan], [SoLanXem] FROM [SANPHAM] Where MaSP='" + MaSP + "'";

                DataTable dt = XLDL.GetData(sql);
                tbMaSP.Text   = dt.Rows[0]["MaSP"].ToString();
                tbTenSP.Text  = dt.Rows[0]["TenSP"].ToString();
                tbDonGia.Text = dt.Rows[0]["TienSP"].ToString();
                tbNCC.Text    = dt.Rows[0]["NhaCC"].ToString();
                string nd = dt.Rows[0]["MoTa"].ToString();
                lbnd.Text = nd;



                string filename = dt.Rows[0]["HinhAnh"].ToString();



                tbSoLuong.Text    = dt.Rows[0]["SoLuongSP"].ToString();
                tbSoLuongBan.Text = dt.Rows[0]["SoLuongBan"].ToString();
                tbSoLanXem.Text   = dt.Rows[0]["SoLanXem"].ToString();

                string maloaisp = dt.Rows[0]["MaLoaiSP"].ToString();


                DataTable dt2 = XLDL.GetData("Select MaLoaiSP,TenLoaiSP from LOAISANPHAM");
                if (dt2.Rows.Count > 0)
                {
                    for (int i = 0; i < dt2.Rows.Count; i++)
                    {
                        rdlMaLoaiSP.Items.Add("i");

                        rdlMaLoaiSP.Items[i].Text  = dt2.Rows[i][0] + " : " + dt2.Rows[i][1].ToString();
                        rdlMaLoaiSP.Items[i].Value = dt2.Rows[i][0].ToString();
                    }
                    rdlMaLoaiSP.SelectedValue = maloaisp;
                }
            }
        }
예제 #27
0
 protected void btnDangNhap_Click(object sender, EventArgs e)
 {
     try
     {
         DataTable dt = XLDL.GetData("Select * from ADMIN where TaiKhoan='" + tbTK.Text + "' and MatKhau='" + tbMK.Text + "'");
         if (dt.Rows.Count > 0)
         {
             Session["TenDN"] = tbTK.Text;
             Response.Redirect("~/QuanTri.aspx");
         }
         else
         {
             Response.Write("<script>alert('Tên đăng nhập hoac75 mật khẩu không chính xác');</script>");
         }
     }
     catch
     {
         Response.Write("<script>alert('Đăng Nhập Thất Bại');</script>");
     }
 }
예제 #28
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            string TenSP  = tbTenSP.Text;
            string LoaiSP = rdLSP.SelectedValue.ToString();
            int    TienSP = int.Parse(tbDonGia.Text);
            string NCC    = HttpUtility.HtmlEncode(tbNCC.Text);

            string    mota      = HttpUtility.HtmlEncode(Request.Form["tbND"]);
            DataTable dt1       = XLDL.GetData("Select TenLoaiSP from LOAISANPHAM where MaLoaiSP=" + LoaiSP);
            string    tenthumuc = dt1.Rows[0]["TenLoaiSP"].ToString();
            string    savePath  = MapPath("~/Anh/CayCanh/" + tenthumuc + "/");

            if (FileUpload1.HasFile)
            {
                savePath += FileUpload1.FileName;

                FileUpload1.SaveAs(savePath);


                lbThongBao.Text = "Upload ảnh thành công.";
            }
            else
            {
                lbThongBao.Text = "Ảnh chưa được upload.";
            }
            string ha      = FileUpload1.FileName;
            string HinhAnh = FileUpload1.FileName;


            DateTime datetime = DateTime.Now;
            string   Ngay     = datetime.ToString("MM/dd/yyyy");
            int      SL       = int.Parse(tbSoLuong.Text);
            int      SLX      = 0;
            string   str      = "insert into SanPham values (" + LoaiSP + ",N'" + TenSP + "'," + SL + ",'" + HinhAnh + "',N'" + NCC + "'," + TienSP + ",'" + Ngay + "',1," + SLX + ",N'" + mota + "'" + ")";

            XLDL.Excute(str);
            Response.Write("<script>alert('Them thanh cong !!!');</script>");
            Response.Redirect("QuanTri.aspx");
        }
예제 #29
0
        private void loaddata()
        {
            if (Request.QueryString["MaBlog"] != null)
            {
                string MaBlog = Request.QueryString["MaBlog"].ToString();

                string sql = "SELECT [MaBlog], [HinhAnh], [TieuDe], [TTND], [NoiDung], [SoLanXem], [NgayDang], [MaTK] FROM [Blog] Where MaBlog=" + MaBlog;

                DataTable dt = XLDL.GetData(sql);
                tbMaBlog.Text = dt.Rows[0]["MaBlog"].ToString();
                tbTieuDe.Text = dt.Rows[0]["TieuDe"].ToString();
                lbnd.Visible  = true;
                string nd = dt.Rows[0]["NoiDung"].ToString();
                lbnd.Text = nd;

                tbNguoiDang.Text = dt.Rows[0]["MaTK"].ToString();
                tbSoLanXem.Text  = dt.Rows[0]["SoLanXem"].ToString();

                string filename = dt.Rows[0]["HinhAnh"].ToString();

                tbTTND.Text = dt.Rows[0]["TTND"].ToString();

                string matk = dt.Rows[0]["MaTK"].ToString();

                DataTable dt2 = XLDL.GetData("Select MaTK,TenTK from TaiKhoan");
                if (dt2.Rows.Count > 0)
                {
                    for (int i = 0; i < dt2.Rows.Count; i++)
                    {
                        tbNguoiDang.Items.Add("i");
                        tbNguoiDang.Items[i].Text  = dt2.Rows[i][0] + " : " + dt2.Rows[i][1].ToString();
                        tbNguoiDang.Items[i].Value = dt2.Rows[i][0].ToString();
                    }
                    tbNguoiDang.SelectedValue = matk;
                }
            }
        }
예제 #30
0
        public void load_data()
        {
            try
            {
                string sql = "SELECT BLOG.MaBlog, BLOG.HinhAnh, BLOG.TieuDe, BLOG.TTND, BLOG.NgayDang, TaiKhoan.TenTK FROM BLOG INNER JOIN TaiKhoan ON BLOG.MaTK = TaiKhoan.MaTK order by blog.NgayDang desc";

                p.DataSource = XLDL.GetData(sql).DefaultView;


                p.PageSize = 12;

                p.CurrentPageIndex = trangthu;

                p.AllowPaging = true;


                btnDau.Enabled   = true;
                btnTruoc.Enabled = true;
                btnSau.Enabled   = true;
                btnCuoi.Enabled  = true;


                if (p.IsFirstPage == true)

                {
                    btnDau.Enabled   = false;
                    btnTruoc.Enabled = false;
                    btnSau.Enabled   = true;
                    btnCuoi.Enabled  = true;
                }


                if (p.IsLastPage == true)

                {
                    btnDau.Enabled   = true;
                    btnTruoc.Enabled = true;
                    btnSau.Enabled   = false;
                    btnCuoi.Enabled  = false;
                }
                if (p.PageCount == 1)
                {
                    btnDau.Visible   = false;
                    btnTruoc.Visible = false;
                    btnSau.Visible   = false;
                    btnCuoi.Visible  = false;
                    tbTrang.Visible  = false;
                }

                tbTrang.Text = (trangthu + 1) + " / " + p.PageCount;


                DataList2.DataSource = p;

                DataList2.DataBind();
            }
            catch
            {
                Response.Redirect("Default.aspx");
            }
        }