Ejemplo n.º 1
0
        public void ShowNewsByKeyword(string Keyword)
        {
            strPageNo = Request["PageNo"];
            try
            {
                PageNo = Convert.ToInt32(strPageNo);
                if (PageNo == 0)
                {
                    PageNo = 1;
                }
                if (PageNo > 50)
                {
                    PageNo = 50;
                }

                BOLNews NewsBOL     = new BOLNews();
                int     ResultCount = NewsBOL.SearchNewsByKeywordCount(Keyword);
                _keyword = Keyword;

                if (ResultCount > 0)
                {
                    lblMessage.Text        = ResultCount + " نتیجه برای " + Keyword + " پیدا شد";
                    rptNewsList.DataSource = NewsBOL.SearchNewsByKeyword(Keyword, _pageSize, PageNo);;
                    rptNewsList.DataBind();

                    ConcatUrl = "&Keyword=" + Keyword;
                    int PageCount = ResultCount / _pageSize;
                    if (ResultCount % _pageSize > 0)
                    {
                        PageCount++;
                    }
                    pgrToolbar.PageNo    = PageNo;
                    pgrToolbar.PageCount = PageCount;
                    pgrToolbar.ConcatUrl = ConcatUrl;
                    pgrToolbar.PageBind();
                }
                else
                {
                    lblMessage.Text = "هیچ نتیجه ای برای " + Keyword + " پیدا نشد.";
                }
            }
            catch (Exception err)
            {
                BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs();
                ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "UCNewsList::ShowNewsByKeyword");
            }
        }
Ejemplo n.º 2
0
        public void ShowNewsByKeywordCode(int KeywordCode)
        {
            try
            {
                strPageNo = Request["PageNo"];
                try
                {
                    PageNo = Convert.ToInt32(strPageNo);
                }
                catch
                {
                }
                if (PageNo == 0)
                {
                    PageNo = 1;
                }
                if (PageNo > 50)
                {
                    PageNo = 50;
                }

                BOLNews NewsBOL = new BOLNews();
                //IQueryable<vNewsByKeywords> ItemList = NewsBOL.GetNewsByKeywordCode(KeywordCode, _pageSize, PageNo);

                BOLKeywords KeywordsBOL    = new BOLKeywords();
                Keywords    CurrentKeyword = KeywordsBOL.GetKeywordByCode(KeywordCode);
                if (CurrentKeyword != null)
                {
                    _keyword = CurrentKeyword.Name;
                }

                int ResultCount = NewsBOL.GetNewsByKeywordCodeCount(KeywordCode);
                rptNewsList.DataSource = NewsBOL.GetNewsByKeywordCode(KeywordCode, _pageSize, PageNo);
                rptNewsList.DataBind();

                if (rptNewsList.Items.Count == 0)
                {
                    Keywords CurKeyword = ((IBaseBOL <Keywords>)KeywordsBOL).GetDetails(KeywordCode);
                    ResultCount = NewsBOL.SearchNewsByKeywordCount(CurKeyword.Name);

                    rptNewsList.DataSource = NewsBOL.SearchNewsByKeyword(CurKeyword.Name, _pageSize, PageNo);;
                    rptNewsList.DataBind();
                }

                string Keyword = Request["Keyword"];
                ConcatUrl = "&Code=" + KeywordCode + "&Keyword=" + Keyword;
                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::ShowNewsByKeywordCode");

                //string MailBody = "Page: " + Request.FilePath + " Exception: " + err.Message;
                //Tools tools = new Tools();
                //bool SendResult = tools.SendEmail(MailBody, "پارست ::Error ", "*****@*****.**", "", "", "");
            }
        }