Exemple #1
0
    protected void addtoCart_Click(object sender, EventArgs e)
    {
        //add certain number of selected product to cart
        List <Product> p         = (List <Product>)Session["Products"];
        Customer       aCustomer = (Customer)Session["Customer"];

        int qty    = Convert.ToInt16(txtQuantity.Text);
        int prodId = Convert.ToInt16(Request.QueryString["id"]);

        aCustomer = CartFunctions.addItemtoCart(p, aCustomer, prodId, qty);

        lblQty.Text         = txtQuantity.Text + " ";
        lblProduct.Text     = "x " + lblProdTitle.Text + " added to your cart";
        Session["Customer"] = aCustomer;

        //displays products bought with
        ClientScript.RegisterStartupScript(GetType(), "hwa", "confirmOrder();", true);

        Label lblCost = (Label)this.Master.FindControl("lblCost");

        lblCost.Text = CartFunctions.getSubTotal(aCustomer).ToString("C");

        Label lblItem = (Label)this.Master.FindControl("lblItems");

        lblItem.Text = CartFunctions.getNumItem(aCustomer).ToString() + " items";
    }