Exemplo n.º 1
0
    protected void gvCarritoC_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string resultado = "";

        try
        {
            resultado = objDatos.BajaDetCar(Application["cnn"].ToString(), int.Parse(gvCarrito.Rows[e.RowIndex].Cells[1].Text.ToString()));
            if (resultado == "0")
            {
                Response.Write("<script language='javascript'>alert('Se ha eliminado " + gvCarrito.Rows[e.RowIndex].Cells[2].Text.ToString() + " del carrito');</script>");
                datosCarrito();
            }
            else if (resultado == "1")
            {
                Response.Write("<script language='javascript'>alert('El producto " + gvCarrito.Rows[e.RowIndex].Cells[2].Text.ToString() + " ya estaba fuera del carrito');</script>");
            }
            else if (resultado == "2")
            {
                Response.Write("<script language='javascript'>alert('El producto " + gvCarrito.Rows[e.RowIndex].Cells[2].Text.ToString() + " no estaba en el carrito');</script>");
            }
        }
        catch
        {
            Response.Write("<script language='javascript'>alert('Ha ocurrido un error al obtener el indice de la tabla');</script>");
        }
    }
Exemplo n.º 2
0
 protected void imgbAddCart_Click(object sender, ImageClickEventArgs e)
 {
     try
     {
         if (lblIdet.Text != "0")
         {
             objDatos.BajaDetCar(Application["cnn"].ToString(), int.Parse(lblIdet.Text));
             objDatos.AgregarDetCar(Application["cnn"].ToString(), '1', int.Parse(Session["cveUsu"].ToString()), int.Parse(Session["prodId"].ToString()), int.Parse(dwlCant.SelectedValue.ToString()));
             Response.Write("<script language='javascript'>alert('Se ha confirmado la nueva cantidad');document.location.href='dflCarritoE.aspx'</script>");
             return;
         }
         else
         {
             objDatos.AgregarDetCar(Application["cnn"].ToString(), '1', int.Parse(Session["cveUsu"].ToString()), int.Parse(Session["prodId"].ToString()), int.Parse(dwlCant.SelectedValue.ToString()));
             Response.Write("<script language='javascript'>alert('El producto " + lblArticulo.Text + " ha sido agregado al carrito')</script>");
             int ex = int.Parse(lblExistencias.Text);
             ex = ex - int.Parse(dwlCant.SelectedValue.ToString());
             lblExistencias.Text = ex.ToString();
             llenarDrop(ex);
         }
     }
     catch
     {
         Response.Write("<script language='javascript'>alert('Ocurrió un error al leer la base de datos')</script>");
     }
 }