コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            d = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
            if (d != null && d.Items.Count != 0)
            {
                if (!IsPostBack)
                {
                    DataList1.DataSource = d.CreateDataSource();
                    DataList1.DataBind();
                    Label1.Text = d.ShoppingCartTotal.ToString("c");
                }
                else
                {
                    foreach (DataListItem cartItems in DataList1.Items)
                    {
                        Label PriceLabel = (Label)cartItems.FindControl("lblPrice");
                        Label ProductIdLabel = (Label)cartItems.FindControl("lblProductId");
                        Label NameLabel = (Label)cartItems.FindControl("lblName");
                        Label RatingLabel = (Label)cartItems.FindControl("lblRating");
                        Label totalPrice = (Label)cartItems.FindControl("lblAmtVoted");
                        Label DetailsLabel = (Label)cartItems.FindControl("lblDetails");
                        TextBox Quantity = (TextBox)cartItems.FindControl("txtQuantity");

                        int c = int.Parse(ProductIdLabel.Text);
                        d = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
                        d.AddItem(new OrderItem { Name = NameLabel.Text, ProductNum = c, Price = decimal.Parse(PriceLabel.Text.Substring(1)), ProductQty = int.Parse(Quantity.Text) });

                    }
                    DataList1.DataSource = d.CreateDataSource();
                    DataList1.DataBind();
                    ShoppingCart ds = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
                    Label1.Text = ds.ShoppingCartTotal.ToString("c");
                }
            }
            else
                Label1.Text = "Their are no items in the cart.";
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ConfirmOrder.SetActiveView(ConfirmCart);
            d = (ShoppingCart)HttpContext.Current.Session["ShoppingCart"];
            if (d != null)
            {
                ShoppingCartDataList.DataSource = d.CreateDataSource();
                ShoppingCartDataList0.DataSource = d.CreateDataSource();
                ShoppingCartDataList.DataBind();
                ShoppingCartDataList0.DataBind();
                lblOrderTotPrice.Text = string.Format("{0} you are a {1} member", d.ShoppingCartTotal.ToString("C"), d.getShoppingCartType());
            }
            else
            {
                lblOrderTotPrice.Text = "Thier are no products in your Cart.";
                btnAcceptShoppingCart.Visible = false;
            }

            if (!IsPostBack)
            {
                ViewState["PreviousPage"] = Request.UrlReferrer.ToString();
            }
        }
コード例 #3
0
        private ShoppingCart ReplaceShoppingCart(ShoppingCart shoppingCart, MemberPrivilege memberPrivilege)
        {
            ShoppingCart newCart = ShoppingCart.getShoppingCart(memberPrivilege);

            foreach (OrderItem item in shoppingCart.Items)
                newCart.AddItem(item);

            return newCart;
        }