Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strPageNo = Request["PageNo"];

            Int32.TryParse(strPageNo, out PageNo);
            if (PageNo == 0)
            {
                PageNo = 1;
            }

            if (!Page.IsPostBack)
            {
                BOLNews NewsBOL = new BOLNews();
                rptItems.DataSource = NewsBOL.GetLatestNewsList(null, new int[] {}, PageSize, PageNo, null, "", 5);
                rptItems.DataBind();


                int ResultCount = NewsBOL.GetLatestNewsListCount(null, new int[] { }, PageSize, PageNo, null, "", 5);
                int PageCount   = (int)ResultCount / PageSize;
                if (ResultCount % PageSize > 0)
                {
                    PageCount++;
                }

                ConcatUrl           += "";
                pgrToolbar.PageNo    = PageNo;
                pgrToolbar.PageCount = PageCount;
                pgrToolbar.ConcatUrl = ConcatUrl;
                pgrToolbar.PageBind();
            }
        }
Exemplo n.º 2
0
        public int[] ShowLatestNews(int?HCNewsCatCode, int PageSize, int[] ExcludeCodeArray, int?HCContentTypeCode, int?paramPageNo, bool ShowPager, string strDate, int HCNewsTypeCode)
        {
            if (!_showHeader)
            {
                pnlHeader.Visible = false;
            }
            //if(ExcludeCodeArray.Length > 0)
            //    ShowTime = true;
            _pageSize = PageSize;
            strPageNo = Request["PageNo"];
            try
            {
                PageNo = Convert.ToInt32(strPageNo);
            }
            catch
            {
            }
            if (PageNo == 0)
            {
                PageNo = 1;
            }

            if (paramPageNo != null)
            {
                PageNo = (int)paramPageNo;
            }

            BOLNews NewsBOL = new BOLNews();
            IQueryable <vLatestNews> ItemList = NewsBOL.GetLatestNewsList(HCNewsCatCode, ExcludeCodeArray, _pageSize, PageNo, HCContentTypeCode, strDate, HCNewsTypeCode);

            rptNewsList.DataSource = ItemList;
            rptNewsList.DataBind();

            int[] NewCodeArray = new int[50];
            if (ExcludeCodeArray != null)
            {
                if (ExcludeCodeArray.Length > 0)
                {
                    NewCodeArray[0] = ExcludeCodeArray[0];
                }
            }

            int Counter = 1;

            foreach (var item in ItemList)
            {
                NewCodeArray[Counter] = item.Code;
                Counter++;
            }

            string MainHeader = "";

            if (HCNewsTypeCode != 0)
            {
                switch (HCNewsTypeCode)
                {
                case 1:
                    ltrHeader.Text = "آخرین اخبار";
                    break;

                case 2:
                    ltrHeader.Text = "یادداشت";
                    break;

                case 3:
                    ltrHeader.Text = "گزارش";
                    break;

                case 4:
                    ltrHeader.Text = "گفتگو";
                    break;

                default:
                    break;
                }
            }

            if (HCNewsCatCode != null)
            {
                BOLHardCode HardCodeBOL = new BOLHardCode();
                HardCodeBOL.TableOrViewName = "HCNewsCats";
                ltrHeader.Text = HardCodeBOL.GetNameByCode((int)HCNewsCatCode);
                switch (HCNewsCatCode)
                {
                case 0:
                    CaptionClass = "Latest";
                    break;

                case 1:
                    CaptionClass = "Politics";
                    break;

                case 2:
                    CaptionClass = "Socity";
                    break;

                case 3:
                    CaptionClass = "Sport";
                    break;

                case 4:
                    CaptionClass = "Event";
                    break;

                case 5:
                    CaptionClass = "Tech";
                    break;

                case 6:
                    CaptionClass = "Culture";
                    break;

                case 7:
                    CaptionClass = "Reading";
                    break;

                default:
                    CaptionClass = "Latest";
                    break;
                }
            }
            if (!string.IsNullOrEmpty(strDate))
            {
                ltrHeader.Text = "اخبار تاریخ " + Tools.ChageEnc(strDate);
                ConcatUrl     += "&d=" + Request["d"];
            }


            if (ShowPager)
            {
                string CatCode = Request["CatCode"];
                if (!string.IsNullOrEmpty(CatCode))
                {
                    ConcatUrl += "&CatCode=" + CatCode;
                }

                int ResultCount = NewsBOL.GetLatestNewsListCount(HCNewsCatCode, ExcludeCodeArray, _pageSize, PageNo, HCContentTypeCode, strDate, HCNewsTypeCode);
                int PageCount   = ResultCount / _pageSize;
                if (ResultCount % _pageSize > 0)
                {
                    PageCount++;
                }
                pgrToolbar.PageNo    = PageNo;
                pgrToolbar.PageCount = PageCount;
                pgrToolbar.ConcatUrl = ConcatUrl;
                pgrToolbar.PageBind();
            }
            else
            {
                pgrToolbar.Visible = false;
            }

            return(NewCodeArray);
        }