Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int     NewsCode = Convert.ToInt32(ViewState["_newsCode"]);
                BOLNews NewsBOL  = new BOLNews();
                rptNews.DataSource = NewsBOL.GetRelatedNews(NewsCode, 5, 1);
                rptNews.DataBind();

                //int RelatedCount = NewsBOL.GetRelatedNewsCount(NewsCode);
                //if (RelatedCount == 0)
                //    this.Visible = false;
                //else if (RelatedCount > 3)
                //{
                MoreLink.Text        = "تمام اخبار مرتبط... ";
                MoreLink.NavigateUrl = "~/News/RelatedNews.aspx?Code=" + NewsCode;
                //}
                //else
                //    MoreLink.Visible = false;
            }
            catch (Exception exp)
            {
                BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs();
                ErrorLogsBOL.Insert(exp.Message, DateTime.Now, Request.Url.AbsolutePath, "UCRelatedNews");
            }
        }
        public void GetRelatedNews(int Code)
        {
            BOLNews NewsBOL = new BOLNews();

            rptRelatedNews.DataSource = NewsBOL.GetRelatedNews(Code, 10);
            rptRelatedNews.DataBind();
            this.Visible = true;
        }
        public void ShowRelatedNews(int Code)
        {
            strPageNo = Request["PageNo"];
            try
            {
                PageNo = Convert.ToInt32(strPageNo);
                if (PageNo == 0)
                {
                    PageNo = 1;
                }
                if (PageNo > 50)
                {
                    PageNo = 50;
                }

                BOLNews NewsBOL = new BOLNews();
                IQueryable <vRelatedNews> ItemList = NewsBOL.GetRelatedNews(Code, _pageSize, PageNo);
                int ResultCount = NewsBOL.GetRelatedNewsCount(Code);
                rptNewsList.DataSource = ItemList;
                rptNewsList.DataBind();

                ConcatUrl = "&Code=" + Code;
                int PageCount = ResultCount / _pageSize;
                if (ResultCount % _pageSize > 0)
                {
                    PageCount++;
                }
                pgrToolbar.PageNo    = PageNo;
                pgrToolbar.PageCount = PageCount;
                pgrToolbar.ConcatUrl = ConcatUrl;
                pgrToolbar.PageBind();
            }
            catch (Exception err)
            {
                BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs();
                ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "UCNewsList::ShowRelatedNews");
            }
        }