Example #1
0
    public void cargarDatosProductos()
    {
        Producto theData = null;

        try
        {
            theData = ProductoBLL.GetProductoById(Convert.ToInt32(ProductoIdHiddenField.Value));

            if (theData == null)
            {
                Response.Redirect("~/Administracion/inventario/Producto/ListaProducto.aspx");
            }

            if (theData.ProductoId != 0)
            {
                NombreTextBox.Text                 = theData.Nombre;
                DescripcionTextBox.Text            = theData.Descripcion;
                UnidadMedidaComboBox.SelectedValue = theData.UnidadMedidaId;
                PrecioTextBox.Text                 = Convert.ToString(theData.Precio);
                stockTextBox.Text             = Convert.ToString(theData.Stock);
                FamiliaComboBox.SelectedValue = Convert.ToString(theData.FamiliaId);
                SaveProducto.Visible          = false;
                UpdateProductoButton.Visible  = true;
            }
        }
        catch
        {
            log.Error("Error al obtener la informaciĆ³n del producto");
        }
    }
    private void CargarDatos(int productoID)
    {
        Producto obj = ProductoBLL.GetProductoById(productoID);

        if (obj == null)
        {
            Response.Redirect("ListaProducto.aspx");
        }

        DescripcionTextBox.Text  = obj.Descripcion;
        PrecioCompraTextBox.Text = obj.PrecioCompra.ToString();
        PrecioVentaTextBox.Text  = obj.PrecioVenta.ToString();
    }
Example #3
0
    protected void ProductosList_SelectedIndexChanged(object sender, EventArgs e)
    {
        int productoId = Convert.ToInt32(ProductosList.SelectedValue);

        if (productoId <= 0)
        {
            PrecioTextBox.Text = "0";
            return;
        }

        Producto obj = ProductoBLL.GetProductoById(productoId);

        PrecioTextBox.Text = obj.PrecioCompra.ToString();
        ProductoIdHD.Value = productoId.ToString();
        AlmacenList.DataBind();
    }
Example #4
0
    protected void GridProducto_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int productoId = 0;

        try
        {
            productoId = Convert.ToInt32(e.CommandArgument);
        }
        catch (Exception ex)
        {
        }
        if (productoId <= 0)
        {
            return;
        }

        Producto obj = ProductoBLL.GetProductoById(productoId);

        if (obj == null)
        {
            return;
        }

        if (e.CommandName == "Eliminar")
        {
            try
            {
                ProductoBLL.DeleteProducto(productoId);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('success', 'EliminaciĆ³n Exitosa.')", true);

                GridProducto.DataBind();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                throw new Exception("Error al eliminar");
            }
        }
        if (e.CommandName == "Editar")
        {
            Session["PRODUCTO_ID"] = productoId.ToString();
            Response.Redirect("FormProducto.aspx");
        }
    }
    private void CargarProducto()
    {
        if (string.IsNullOrEmpty(ProductoIdHiddenField.Value))
        {
            Response.Redirect("~/Administracion/Inventario/ImagenProducto/ListaImagenProducto.aspx");
            return;
        }
        try
        {
            Producto objProducto = ProductoBLL.GetProductoById(Convert.ToInt32(ProductoIdHiddenField.Value));
            CodigoLiteral.Text = objProducto.ProductoId.ToString();
            NombreLiteral.Text = objProducto.Nombre;

            cargarListaImagenesDelProducto(ProductoIdHiddenField.Value);
        }
        catch (Exception ex)
        {
            log.Error("Error al cargar caracteristica del articulo ", ex);
        }
    }
Example #6
0
    public static string agregarItemCarrito(string itemId)
    {
        try
        {
            string cookieName   = "FoodGoodCartId";
            bool   cookieExists = HttpContext.Current.Request.Cookies[cookieName] != null;
            if (!cookieExists)
            {
                PedidoUtilities.SetupShoppingCart();
            }
            //bool carritoEnCuota = PedidoUtilities.GetCarritoEnCuotas();
            Dictionary <string, DatorProductoCarrito> carrito = PedidoUtilities.GetCarrito();
            //string carritoEnCuota = PedidoUtilities.GetCarritoEnCuotas();

            //if (itemEnCuota == carritoEnCuota)
            //    carrito = PedidoUtilities.GetCarrito();
            //else
            //    carritoEnCuota = itemEnCuota;

            int cantidad = 1;
            DatorProductoCarrito item = null;

            int articuloId = Convert.ToInt32(itemId);
            if (carrito.ContainsKey(itemId))
            {
                item = carrito[itemId];
            }
            else
            {
                //List<ImageFile> MyimageId = ArticuloBLL.GetImagenesIdsArticulo(articuloId);

                Producto objArticulo = ProductoBLL.GetProductoById(articuloId);
                item = new DatorProductoCarrito()
                {
                    ProductoId     = articuloId,
                    Nombre         = objArticulo.Nombre,
                    Descripcion    = objArticulo.Descripcion,
                    UnidadMedidaId = objArticulo.UnidadMedidaId,
                    Cantidad       = 0,
                    Precio         = Convert.ToDecimal(objArticulo.Precio),
                    SubTotal       = 0,
                    Stock          = objArticulo.Stock,
                    FamiliaId      = objArticulo.FamiliaId,
                    ImagenId       = objArticulo.ImagenId
                };

                carrito.Add(itemId, item);
            }


            item.Cantidad = item.Cantidad + cantidad;

            item.SubTotal = item.Cantidad * item.Precio;
            PedidoUtilities.UpdateCarrito(carrito);
            //PedidoUtilities.UpdateCarritoCuotas(carritoEnCuota);

            JavaScriptSerializer js = new JavaScriptSerializer();
            return(js.Serialize(carrito));
        }

        catch (Exception ex)
        {
            //throw ex;
            log.Error("Error adding article to shopping cart", ex);
            return("error");
        }
    }