Beispiel #1
0
        protected void btnCarrito_Click(object sender, EventArgs e)
        {
            ///buscar en db segun prod y plat
            ///encontrar img url
            GestionCompra gc = new GestionCompra();

            if (this.Session["carrito"] == null)
            {
                this.Session["carrito"] = GestionCompra.CrearCarrito();
            }

            Image   imgbtn = this.grdProd.Items[0].FindControl("ImgProd") as Image;
            Label   lbl2   = this.grdDatos.Items[0].FindControl("Nombre_Producto_PRLabel") as Label;
            Label   lbl3   = this.grdDatos.Items[0].FindControl("PrecioUnitario_Producto_PxPLabel") as Label;
            Label   lbl4   = this.grdDatos.Items[0].FindControl("Nombre_Plataforma_PLabel") as Label;
            TextBox txt    = this.grdDatos.Items[0].FindControl("txtCant") as TextBox;


            string imgUrl, name, plat;
            int    cant;
            float  precio, preciototal;

            imgUrl      = imgbtn.ImageUrl;
            name        = lbl2.Text;
            plat        = lbl4.Text;
            cant        = Convert.ToInt32(txt.Text);
            precio      = (float)Convert.ToDouble(lbl3.Text.Trim());
            preciototal = precio * cant;



            gc.AgregarCarrito((DataTable)this.Session["carrito"], imgUrl, name, plat, cant, preciototal);

            Response.Redirect("Carrito.aspx");
        }
Beispiel #2
0
    protected void grdCarrito_SelectedIndexChanged(object sender, EventArgs e)
    {
        int           f  = grdCarrito.SelectedIndex;
        GestionCompra gc = new GestionCompra();

        gc.EliminaCarrito((DataTable)this.Session["carrito"], f);
        CarritoDeCompras.cont--;
        ActualizaCarrito();
    }