Beispiel #1
0
        /// <summary>
        /// 加载指定类型的书本信息
        /// </summary>
        /// <param name="pageIndex">当前页索引</param>
        /// <param name="pageSize">页面显示条数</param>
        /// <param name="categoryId">指定类型</param>
        private void LoadAllBooksInfo(int pageIndex, int pageSize, int categoryId)
        {
            BLL.BooksBll bll = new BLL.BooksBll();
            pageIndex = pageIndex < 1 ? 1 : pageIndex;

            int pageCount = bll.GetPageCountByCategoryId(categoryId, pageSize);
            this.CurrentPageCount = pageCount;

            pageIndex = pageIndex > pageCount ? pageCount : pageIndex;
            this.CurrentPageIndex = pageIndex;

            List<Model.Books> list = bll.GetModelListByPage(pageIndex, pageSize, categoryId);
            Repeater1.DataSource = list;
            
            Repeater1.DataBind();

            //加载页面跳转按钮
            this.PageBarString = Common.CommonTools.GetPageBarString(pageIndex, pageCount);
        }
        //生成商品html静态页
        public void GenerateHtml()
        {
            List<Model.Books> list = new BLL.BooksBll().GetModelList("");
            string textHtml = Common.CommonTools.ReadFileGetAllText("/Master/BookShowTemplate.html");

            foreach (Model.Books book in list)
            {
                string bookHtml = textHtml.Replace("$title", book.Title)
                     .Replace("$author", book.Author)
                     .Replace("$descriptionAuthor", book.AurhorDescription)
                     .Replace("$ISBN", book.ISBN)
                     .Replace("$unitPrice", book.UnitPrice.ToString())
                     .Replace("$content", book.ContentDescription)
                     .Replace("$BookId", book.Id.ToString());
                string dir = "/" + book.PublishDate.Year + "/" + book.PublishDate.Month + "/";
                Directory.CreateDirectory(Request.MapPath(dir));
                File.WriteAllText(Request.MapPath(dir + book.ISBN + ".html"), bookHtml, Encoding.UTF8);
            }
            Response.Write("success");
            Response.End();
        }
Beispiel #3
0
 //加载购物车中所有的信息
 private void LoadAllCartInfo(List<Model.Cart> listCart)
 {
     if (Session["userInfo"] != null)
     {
         Model.Users user = Session["userInfo"] as Model.Users;
         //BLL.CartBll cartBll = new BLL.CartBll();
         listCart.AddRange(cartBll.GetModelList2("UserId = " + user.Id));
     }
     else
     {
         HttpCookie cookie = Request.Cookies["ShoppingCart"];
         if (cookie != null)
         {
             BLL.BooksBll bookBll = new BooksBll();
             foreach (string item in cookie.Values)
             {
                 string itemValue = cookie.Values[item];
                 string[] cartInfo = itemValue.Split(new char[] { '|' },
                     StringSplitOptions.RemoveEmptyEntries);
                 listCart.Add(new Model.Cart()
                 {
                     Book = bookBll.GetModel(Convert.ToInt32(cartInfo[0])),
                     Count = Convert.ToInt32(cartInfo[1])
                 });
             }
         }
     }
 }