Beispiel #1
0
        private IQueryable <ForumArticle> GetAllDataList(ForPaging Paging, string Search)
        {
            IQueryable <ForumArticle> Data = repo.All().Where(p => p.Members.Name.Contains(Search) || p.Title.Contains(Search) || p.Content.Contains(Search));

            Paging.SetMaxPage(Data.Count());
            Paging.SetRightPage();
            return(Data);
        }
Beispiel #2
0
        public IQueryable <ForumAlbum> GetAllDataList(ForPaging Paging)
        {
            IQueryable <ForumAlbum> Data = db.ForumAlbum;

            Paging.SetMaxPage(Data.Count());
            Paging.SetRightPage();
            return(Data);
        }
Beispiel #3
0
        private IQueryable <ForumArticle> GetAllDataList(ForPaging Paging)
        {
            IQueryable <ForumArticle> Data = repo.All();

            Paging.SetMaxPage(Data.Count());
            Paging.SetRightPage();
            return(Data);
        }
Beispiel #4
0
        public IQueryable <ForumMessage> GetAllDataList(ForPaging Paging, int AId)
        {
            IQueryable <ForumMessage> Data = db.ForumMessage.Where(p => p.AId == AId);

            Paging.SetMaxPage(Data.Count());
            Paging.SetRightPage();
            return(Data);
        }
Beispiel #5
0
        public IQueryable <FileContent> GetAllFileList(ForPaging Paging)
        {
            IQueryable <FileContent> fileList = db.FileContent;

            Paging.SetMaxPage(fileList.Count());
            Paging.SetRightPage();

            return(fileList);
        }
Beispiel #6
0
        public IQueryable <Guestbooks> GetDataList(ForPaging Paging)
        {
            IQueryable <Guestbooks> data = db.Guestbooks;

            Paging.MaxPage = (int)Math.Ceiling(Convert.ToDouble(data.Count() / Paging.ItemNo));
            Paging.SetRightPage();

            return(data);
        }
Beispiel #7
0
        public IQueryable <Guestbooks> GetDataList(ForPaging Paging, string Search)
        {
            IQueryable <Guestbooks> data = db.Guestbooks.AsQueryable();

            if (string.IsNullOrEmpty(Search) == false)
            {
                data = db.Guestbooks.Where(p => p.Account.Contains(Search) || p.Content.Contains(Search) || p.Reply.Contains(Search));

                Paging.MaxPage = (int)Math.Ceiling(Convert.ToDouble(data.Count() / Paging.ItemNo));
                Paging.SetRightPage();
            }
            return(data);
        }
Beispiel #8
0
        public void SetMaxPaging(ForPaging Paging)
        {
            //計算列數
            int Row = 0;
            //Sql語法
            string sql = $@" select * from Item ";

            //確保程式不會因執行錯誤而整個中斷
            try
            {
                //開啟資料庫連線
                conn.Open();
                //執行Sql指令
                SqlCommand cmd = new SqlCommand(sql, conn);
                //取得Sql資料
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read()) //獲得下一筆資料直到沒有資料
                {
                    Row++;
                }
            }
            catch (Exception e)
            {
                //丟出錯誤
                throw new Exception(e.Message.ToString());
            }
            finally
            {
                //關閉資料庫連線
                conn.Close();
            }
            //計算所需的總頁數
            Paging.MaxPage = Convert.ToInt32(Math.Ceiling(Convert.ToDouble(Row) / Paging.ItemNum));
            //重新設定正確的頁數,避免有不正確值傳入
            Paging.SetRightPage();
        }