示例#1
0
    public string GuardarCarro()
    {
        int            id_producto;
        int            existencia;
        int            cantidad_comprada;
        decimal        precio;
        MyShoppingCart shc = (MyShoppingCart)Session["shopping_cart"];
        LinkButton     lb;

        for (int i = 0; i < GVProductos.Rows.Count; i++)
        {
            lb          = (LinkButton)GVProductos.Rows[i].FindControl("LBNombre");
            id_producto = int.Parse(lb.CommandName);
            existencia  = int.Parse(lb.CommandArgument);
            try
            {
                cantidad_comprada = int.Parse(((TextBox)GVProductos.Rows[i].FindControl("TBCantidad")).Text);
            }
            catch (Exception)
            {
                return("Debe cersiorarse de que la cantidad del producto" + lb.Text + " introducida tenga un formato numérico");
            }
            if (existencia < cantidad_comprada)//Se controla que no se pidan mas productos que su existencia en el almacen
            {
                return("La cantidad de " + lb.Text + " comprada es mayor que la existencia del producto en el almacén");
            }
            precio = decimal.Parse(((Label)GVProductos.Rows[i].FindControl("LPrecio")).Text);
            shc.Modifica_cant(id_producto, cantidad_comprada, precio);
            ((Label)GVProductos.Rows[i].FindControl("LSubtotal")).Text = UsefullProc.FormatoPrecio(cantidad_comprada * precio);
        }

        this.LabelTotal.Text = "Total a pagar: $ " + UsefullProc.FormatoPrecio(shc.Precio_total);
        this.LError.Text     = "";
        return("");
    }
示例#2
0
 private void CargarProducto(int id_prod)
 {
     BLLayer.Producto p = new BLLayer.Producto();
     p.LoadByPrimaryKey(id_prod);
     if (p.RowCount > 0)
     {
         this.LBNombre.Text     = p.Nombre_producto;
         this.LMarca.Text       = p.Marca;
         this.LPrecio.Text      = "$ " + UsefullProc.FormatoPrecio(p.Precio);
         this.LExistencia.Text  = p.Existencia.ToString();
         this.LDescripcion.Text = p.Descripcion;
         this.IFoto2.ImageUrl   = "~/Handlers/ImageHandler.ashx?id=" + id_prod.ToString();
     }
 }
示例#3
0
 protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         DataRowView dataRow = (DataRowView)e.Row.DataItem;
         LinkButton  lb      = (LinkButton)e.Row.FindControl("LBNombre");
         lb.Text            = dataRow["Nombre_producto"].ToString();
         lb.CommandName     = dataRow["Id_producto"].ToString();
         lb.CommandArgument = dataRow["Existencia"].ToString();
         ((Label)e.Row.FindControl("LMarca")).Text       = dataRow["Marca"].ToString();
         ((Label)e.Row.FindControl("LPrecio")).Text      = UsefullProc.FormatoPrecio((decimal)dataRow["Precio"]);
         ((TextBox)e.Row.FindControl("TBCantidad")).Text = dataRow["Cantidad_comprada"].ToString();
         ((Label)e.Row.FindControl("LSubtotal")).Text    = UsefullProc.FormatoPrecio((decimal)dataRow["Monto_por_producto"]);
     }
 }
示例#4
0
 protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         DataRowView dataRow = (DataRowView)e.Row.DataItem;
         Label       lb      = (Label)e.Row.FindControl("LNombre");
         lb.Text = dataRow["Nombre_producto"].ToString();
         ((Label)e.Row.FindControl("LMarca")).Text    = dataRow["Marca"].ToString();
         ((Label)e.Row.FindControl("LPrecio")).Text   = UsefullProc.FormatoPrecio((decimal)dataRow["Precio"]);
         ((Label)e.Row.FindControl("LCantidad")).Text = dataRow["Cantidad"].ToString();
         ((Label)e.Row.FindControl("LSubtotal")).Text = UsefullProc.FormatoPrecio(((decimal)dataRow["Precio"]) * ((int)dataRow["Cantidad"]));
         Label   l     = (Label)e.Row.FindControl("L");
         decimal total = decimal.Parse(this.LabelTotal.Text);
         total += ((decimal)dataRow["Precio"]) * ((int)dataRow["Cantidad"]);
         this.LabelTotal.Text = UsefullProc.FormatoPrecio(total);
     }
 }
    private void Cargar_Producto(int id_prod)
    {
        Producto p = new Producto();

        p.LoadByPrimaryKey(id_prod);
        this.TBNombre.Text      = p.Nombre_producto;
        this.TBPrecio.Text      = UsefullProc.FormatoPrecio(p.Precio);
        this.TBMarca.Text       = p.Marca;
        this.TBCantidad.Text    = p.Existencia + "";
        this.TBDescripcion.Text = p.Descripcion;
        this.TBCodigo.Text      = p.Codigo;
        int id_cat = p.Id_categoria;

        this.DDLCategoria.SelectedValue = id_cat.ToString();
        if (p.Foto != null)
        {
            this.IFoto.ImageUrl = "~/Handlers/ImageHandler.ashx?id=" + id_prod;
        }
        this.IBAceptar.ImageUrl = "~/App_Themes/Store/Img/032.gif";
    }
示例#6
0
    protected void Eiminar_onClick(object sender, EventArgs e)
    {
        int            id_producto;
        decimal        precio;
        CheckBox       chb;
        MyShoppingCart shc = (MyShoppingCart)Session["shopping_cart"];
        DataView       dv  = (DataView)GVProductos.DataSource;

        for (int i = 0; i < GVProductos.Rows.Count; i++)
        {
            chb = (CheckBox)GVProductos.Rows[i].FindControl("ChBEliminar");
            if (chb.Checked)
            {
                id_producto = int.Parse(((LinkButton)GVProductos.Rows[i].FindControl("LBNombre")).CommandName);
                precio      = decimal.Parse(((Label)GVProductos.Rows[i].FindControl("LPrecio")).Text);
                shc.Elimina_prod(id_producto, precio);
            }
        }
        this.LabelTotal.Text = "Total a pagar: $ " + UsefullProc.FormatoPrecio(shc.Precio_total);
        Response.Redirect("ShoppingCart.aspx");
    }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["error_message"] != "")
        {
            this.LError.Text = Request.QueryString["error_message"];
        }
        MyShoppingCart sc = (MyShoppingCart)Session["shopping_cart"];
        bool           m  = (sc != null && sc.Total_productos > 0);

        this.LBEliminar.Visible = m;
        this.LBSeguir.Visible   = m;
        this.LAnuncio.Visible   = !m;
        this.IBComprar.Visible  = m;
        this.IBSalvar.Visible   = m;
        if (!IsPostBack)
        {
            if (m)
            {
                GVProductos.DataSource = sc.DefaultView;
                GVProductos.DataBind();
                this.LabelTotal.Text = "Total a pagar: $ " + UsefullProc.FormatoPrecio(sc.Precio_total);
            }
        }
    }