Beispiel #1
0
        private void cargarDetalleComanda()
        {
            List <ComandaDetalle> arrayDetalle = new List <ComandaDetalle>();

            Comanda comanda = new Comanda();

            comanda = (Comanda)Session["comanda_actual"];

            if (comanda.obtenerDetalle() != null && comanda.obtenerDetalle().Count > 0)
            {
                grvComandaDetalle.DataSource = comanda.obtenerDetalle();
                grvComandaDetalle.DataBind();


                cargarTotalComanda(comanda);
            }
            else
            {
                arrayDetalle = ComandaDetalleLN.ObtenerTodos(comanda.comanda_id);

                foreach (ComandaDetalle item in arrayDetalle)
                {
                    comanda.agregarPedido(item.producto, item.cantidad, item.notas);
                }

                grvComandaDetalle.DataSource = comanda.obtenerDetalle();
                grvComandaDetalle.DataBind();

                cargarTotalComanda(comanda);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Agrega los pedidos de productos a la comanda.
        /// </summary>
        /// <param name="producto_id"></param>
        /// <param name="notas"></param>
        /// <param name="cant"></param>
        private void agregarProductosAComanda(string producto_id, string notas, int cant)
        {
            Producto producto = new Producto();

            producto = ProductoLN.SeleccionarProducto(producto_id);

            if (producto != null)
            {
                comanda.agregarPedido(producto, cant, notas);

                foreach (ComandaDetalle detalle in comanda.obtenerDetalle())
                {
                    try
                    {
                        //Solo agrega nuevos productos, para los existentes, no realiza ninguna acción.
                        ComandaDetalleLN.Nuevo(comanda.comanda_id, detalle);

                        //Refrescar los productos en pantalla
                        cargarProductosPorCategoria(cboCategorias.SelectedItem.Text);
                    }
                    catch (Exception ex)
                    {
                        lblErrorMessage.Text = "Ha ocurrido un error al guardar el pedido " + comanda.comanda_id + "-" + detalle.producto.producto_id + "\n" +
                                               "Código de error: " + ex.Message;
                        lblErrorMessage.CssClass = "alert alert-danger";
                    }
                }
            }
        }