Esempio n. 1
0
    protected void gvCart_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        /* Get the cart */
        /*ArrayList cart = (ArrayList)Session["Crat"];*/
        eStore.cart myCart = new eStore.cart();

        // get the current item to use it later
        eStore.cartItem currentItem = myCart.GetCartItem(e.RowIndex);

        /* make sure the cart exists in memory */
        //if (cart == null)
        //    cart = new ArrayList();

        /* check that the current index is available to be removed */
        //if (cart[e.RowIndex] != null)
        //    cart.RemoveAt(e.RowIndex);
        myCart.Remove(e.RowIndex);

        /* refresh the gridview so that it shows the changes */
        //gvCart.DataSource = myCart.cartItems;
        //gvCart.DataBind();
        myCart.BindToGrid(ref gvCart);

        /* save the cart */
        //Session["Crat"] = cart;
        myCart.Save();

        /* indicate success */
        lblOutput.Text = String.Format("The item {0} has been removed.", currentItem.product.name);
    }
Esempio n. 2
0
    protected void gvCart_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        /* Only process when we are working with a datarow.
         * This will make he header row ignored */
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // get the data for this row and cast it to a product
            eStore.cartItem ci = (eStore.cartItem)e.Row.DataItem;

            // format the currency
            e.Row.Cells[2].Text = string.Format("{0:C}", ci.product.amount);
            e.Row.Cells[3].Text = string.Format("{0:C}", ci.total);
        }
        else if (e.Row.RowType == DataControlRowType.Footer)
        {
            eStore.cart cart = new eStore.cart();

            Label lblSubTotal = (Label)e.Row.FindControl("lblSubTotal");
            Label lblTaxl     = (Label)e.Row.FindControl("lblTax");
            Label lblTotal    = (Label)e.Row.FindControl("lblTotal");

            lblSubTotal.Text = string.Format("{0:C}", cart.subTotal);
            lblTaxl.Text     = string.Format("{0:C}", cart.tax);
            lblTotal.Text    = string.Format("{0:C}", cart.total);
        }
    }
Esempio n. 3
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        ArrayList cart = (ArrayList)Session["Cart"];

        if (cart == null)
        {
            cart = new ArrayList();
        }

        eStore.cartItem ci = new eStore.cartItem();
        ci.quantity = 1;
        ci.product  = new product(Convert.ToInt64(Request.QueryString["prodID"]), Server.MapPath("data/products.xml"));

        cart.Add(ci);

        Session["Cart"] = cart;

        lblOutput.Text = String.Format("{0} {1} prints have been added to your cart.", ci.quantity, ci.product.name);
    }
Esempio n. 4
0
 /* behaviours of our cart object */
 public void Add(cartItem pCartItem)
 {
     _cartItems.Add(pCartItem);
 }