Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.itemId = int.Parse(getParam("id"));
        }
        catch { }

        if (itemId == 0)
        {
            Response.Redirect("tin-tuc");
        }

        objData = objNews.getData(itemId);

        if (objData == null)
        {
            Response.Redirect("tin-tuc");
        }

        group = (int)objData["CatId"];

        if (group != 0)
        {
            groupname = objGroup.getNameById(group);
        }
        else
        {
            groupname = "Tin Tức";
        }

        Context.Items["strTitle"] = objData["Title"].ToString();


        DataTable tinMoi = objNews.tinLienQuan(itemId, (DateTime)objData["DayPost"], true, 5);

        if (tinMoi.Rows.Count > 0)
        {
            dtlTinMoi.DataSource = tinMoi.DefaultView;
            dtlTinMoi.DataBind();
        }

        DataTable tinCu = objNews.tinLienQuan(itemId, (DateTime)objData["DayPost"], false, 5);

        if (tinCu.Rows.Count > 0)
        {
            dtlTinCu.DataSource = tinCu.DefaultView;
            dtlTinCu.DataBind();
        }
    }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this.itemId = int.Parse(getParam("id"));
        }
        catch { }

        try
        {
            this.sapXep = (getParam("sapxep") != "1") ? "DESC" : "ASC";
        }
        catch { }

        try
        {
            this.page = int.Parse(Request["page"].ToString());
        }
        catch { }



        if (!Page.IsPostBack)
        {
            #region phan trang
            maxitem = objNews.getDataCount(itemId);
            maxPage = maxitem / numItem;
            if (maxitem % numItem > 0 || maxPage == 0)
            {
                maxPage++;
            }
            if (page > maxPage)
            {
                page = maxPage;
            }
            if (page < 1)
            {
                page = 1;
            }

            String link = "";
            if (itemId != 0)
            {
                link = "&id=" + itemId;
            }
            if (sapXep == "ASC")
            {
                link += "&sapxep=1";
            }
            //link += "#listnews";

            if (page - 1 >= 1)
            {
                pager.Add(new PageData("Trước", "?page=" + (page - 1) + link));
            }
            if (page != 1)
            {
                pager.Add(new PageData("1", "?page=1" + link));
            }

            int a = page - 5;
            if (a < 2)
            {
                a = 2;
            }
            for (int i = a; i < page; i++)
            {
                pager.Add(new PageData(i.ToString(), "?page=" + i + link));
            }

            pager.Add(new PageData(page.ToString(), "#", true));

            a = page + 5;
            if (a > maxPage)
            {
                a = maxPage;
            }
            for (int i = page + 1; i < a; i++)
            {
                pager.Add(new PageData(i.ToString(), "?page=" + i + link));
            }

            if (page != maxPage)
            {
                pager.Add(new PageData(maxPage.ToString(), "?page=" + maxPage + link));
            }
            if (page + 1 <= maxPage)
            {
                pager.Add(new PageData("Sau", "?page=" + (page + 1) + link));
            }
            #endregion
            //ddlpager.DataSource = pager;
            //ddlpager.DataBind();

            DataTable objData = objNews.getDataTop(numItem, itemId, page, false, "", sapXep);


            DanhSachTin.BindData(objData);

            DataNewsGroup objGroup = new DataNewsGroup();
            if (itemId != 0)
            {
                groupname = objGroup.getNameById(itemId);
            }
            else
            {
                groupname = "Tin Tức";
            }

            Context.Items["strTitle"] = groupname;
        }
    }