示例#1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int bookId = Convert.ToInt32(context.Request["bookId"]);
            int userId = ((Users)context.Session["user"]).Id;
            int count  = Convert.ToInt32(context.Request["count"]);
            //创建订单
            Orders o = new Orders();

            o.UserId      = userId;
            o.OrderDate   = DateTime.Now;
            o.OrderId     = UniqueData.Gener("");
            o.PostAddress = "";
            o.state       = 0;
            //赋值总价
            o.TotalPrice = bbll.GetModel(bookId).UnitPrice *count;

            ob.Add(o);

            //创建详细订单信息
            OrderBook obk = new OrderBook()
            {
                OrderID   = o.OrderId,
                BookID    = bookId,
                Quantity  = count,
                UnitPrice = bbll.GetModel(bookId).UnitPrice *count
            };

            obbll.Add(obk);

            context.Response.Write(o.OrderId);
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string cartId = context.Request["cartIds"];

            string[] cartIds = cartId.Split(',');
            int      userId  = ((Users)context.Session["user"]).Id;

            //创建订单
            Orders o = new Orders();

            o.UserId      = userId;
            o.OrderDate   = DateTime.Now;
            o.OrderId     = UniqueData.Gener("");
            o.PostAddress = "";
            o.state       = 0;
            o.TotalPrice  = 0;

            //将购物车中用户要购买的商品添加到集合中
            List <Cart> cartList = new List <Cart>();

            for (int i = 1; i < cartIds.Length; i++)
            {
                cartList.Add(cb.GetModel(Convert.ToInt32(cartIds[i])));
            }
            //赋值总价
            foreach (var item in cartList)
            {
                o.TotalPrice += bbll.GetModel(item.BookId).UnitPrice *item.Count;
            }
            ob.Add(o);

            //创建详细订单信息
            foreach (var item in cartList)
            {
                OrderBook obk = new OrderBook()
                {
                    OrderID   = o.OrderId,
                    BookID    = item.BookId,
                    Quantity  = item.Count,
                    UnitPrice = bbll.GetModel(item.BookId).UnitPrice *item.Count
                };
                obbll.Add(obk);

                //删除购物车中的信息
                cb.Delete(item.Id);
            }

            context.Response.Write(o.OrderId);
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int      bookId = Convert.ToInt32(Request["bookId"]);
            BooksBll BBll   = new BooksBll();

            model = BBll.GetModel(bookId);
            CategoriesBll CBll = new CategoriesBll();

            list   = CBll.GetModelList("");
            listPB = PBll.GetModelList("");
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request["bookid"]);
            //图书详情
            BooksBll bbl = new BooksBll();

            books = bbl.GetModel(id);

            //随机显示图书
            DataSet ds = bbl.GetBooksByRandom(4);

            booksList = bbl.DataTableToList(ds.Tables[0]);

            //猜你喜欢
            DataSet ds1 = bbl.GetBooksByRandom(12);

            guestLike = bbl.DataTableToList(ds1.Tables[0]);

            count = new BookCommentBll().GetRecordCount("BookId=" + id);
        }