Exemplo n.º 1
0
        private void BindBookList()
        {
            Model.BaseParameter para = new Model.BaseParameter();
            int pageIndex            = 1;

            if (!string.IsNullOrEmpty(Request.QueryString["pi"]))
            {
                pageIndex = Convert.ToInt32(Request.QueryString["pi"]);
            }
            para.PageIndex = pageIndex;
            para.PageSize  = 10;
            para.OrderKey  = "UnitPrice";


            #region 参数
            if (!string.IsNullOrEmpty(Request.QueryString["cid"]))
            {
                para.KeyValues.Add("CategoryId", Request.QueryString["cid"]);
            }
            #endregion

            BLL.Books bll   = new BLL.Books();
            int       total = 0;
            rptBook.DataSource = bll.GetDataSetByPara(para, out total).Tables[0];
            double pageCount = Math.Ceiling(total / (double)para.PageSize);
            this.PageBar1.CurrentPageIndex = pageIndex;
            this.PageBar1.CurrentPageCount = (int)pageCount;
            rptBook.DataBind();
        }
Exemplo n.º 2
0
        protected string GetDir(object id)
        {
            BLL.Books   bll  = new BLL.Books();
            Model.Books book = bll.GetModel(Convert.ToInt32(id));
            string      str  = book.PublishDate.Year + "/" + book.PublishDate.Month + "/" + book.PublishDate.Day + "/"
                               + book.Id + ".html";

            return(str);
        }
Exemplo n.º 3
0
        private void BindBookData()
        {
            this.PageIndex = int.Parse(Request["pageIndex"] ?? "1");
            int pageSize = 10;

            BLL.Books bookServer = new BLL.Books();
            this.ProductList = bookServer.GetListByPage(PageIndex, pageSize);
            int total = bookServer.GetRecordCount("");

            this.PageCount = Math.Max((total + pageSize - 1) / pageSize, 1);
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (IsPostBack)
     {
         BLL.Books          bll  = new BLL.Books();
         List <Model.Books> list = bll.GetModelList("");
         foreach (Model.Books model in list)
         {
             bll.CreateHtmlPage(model.Id);
         }
     }
 }
Exemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");
            //1.判断用户是否登陆
            Model.Users userModel = new BLL.Users().GetModel(context.Request.Cookies["cp1"].Value);
            if (Common.WebHelper.CheckCookie(userModel) == false)
            {
                context.Response.Write("no");
                return;
            }

            //2.检查该商品数据库中是否存在
            int bookId = int.Parse(context.Request["bookId"] ?? "0");

            Model.Books book = new BLL.Books().GetModel(bookId);
            if (book == null)
            {
                context.Response.Write("no");
                return;
            }

            //3.将商品添加到购物车
            Model.Users user       = (Model.Users)context.Session["userInfo"];
            BLL.Cart    cartServer = new BLL.Cart();
            Model.Cart  cart       = cartServer.GetCart(user.Id, bookId);
            if (cart != null)
            {
                cart.Count++;
                cartServer.Update(cart);
            }
            else
            {
                cart       = new Model.Cart();
                cart.Count = 1;
                cart.Book  = book;
                cart.User  = user;
                cartServer.Add(cart);
            }
            context.Response.Write("OK");
        }