Beispiel #1
0
        public static object listado_Areas_Combo()
        {
            try
            {
                //var DefaultItem = new { DisplayText = "[-Sin Categoría Padre-]", Value = 0 };
                using (var DB = new TPVDBEntities())
                {
                    var Resultado = DB.SPC_GET_AREA(null, null, null, true).ToList()
                                    .Select(c => new
                    {
                        DisplayText = c.Area,
                        Value       = c.Codigo_Area
                    }).OrderBy(o => o.DisplayText).ToList();

                    //--
                    //Resultado.Insert(0, DefaultItem);
                    return(new { Result = "OK", Options = Resultado });
                }
            }
            catch
            {
                return(new { Result = "ERROR", Message = "Ha ocurrido un error al cargar el listado de areas. Contacte su administrador." });
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                (LogManager.GetCurrentClassLogger()).Info("Ordenes.PageLoad");
                string CodigoArea = Request["CodigoArea"];
                string CodigoMesa = Request["CodigoMesa"];
                string NombreMesa = Request["NombreMesa"];
                (LogManager.GetCurrentClassLogger()).Info(string.Format("Area: {0}, CodMesa: {1}, Mesa: {2}", CodigoArea, CodigoMesa, NombreMesa));
                if (CodigoArea != null)
                {
                    Session["CodigoAreaActual"] = CodigoArea;
                }
                if (CodigoMesa != null)
                {
                    using (var DB = new TPVDBEntities())
                    {
                        ///-- Nombre de la mesa
                        lblMesa.InnerText = NombreMesa;
                        ///-- Agregar referencia al codigo de mesa
                        Comanda.Attributes.Add("Data-CodigoMesa", CodigoMesa);
                        Comanda.Attributes.Add("Data-CodigoArea", CodigoArea);

                        var Ordenes = DB.SPC_GET_ORDENDETALLE(null, int.Parse(CodigoMesa), null, null, null, null, null, null, true);
                        (LogManager.GetCurrentClassLogger()).Info("SPC_GET_ORDENDETALLE", Ordenes);
                        foreach (var Orden in Ordenes)
                        {
                            lblPAX.InnerText = Orden.Comensales.ToString();

                            var a          = new HtmlGenericControl("a");
                            var h4Cantidad = new HtmlGenericControl("h4");
                            var h4Producto = new HtmlGenericControl("h4");
                            var h4Precio   = new HtmlGenericControl("h4");
                            var h6Nota     = new HtmlGenericControl("h6");

                            a.Attributes.Add("href", "#");
                            a.Attributes.Add("Data-CodigoOrdenDetalle", Orden.Codigo_Orden_Detalle.ToString());
                            a.Attributes.Add("Data-PrecioVenta", CambioDecimal(Orden.PrecioVenta.Value));
                            a.Attributes.Add("Data-ImprimirCocina", Orden.Impresora ? "1" : "0");

                            ///-- Si el estado es "pendiente"
                            if (Orden.Codigo_Estado_Orden_Detalle == 1)
                            {
                                a.Attributes.Add("class", "list-group-item list-group-item-danger");
                            }
                            else
                            {
                                a.Attributes.Add("class", "list-group-item");
                            }

                            h4Cantidad.Attributes.Add("class", "cantidad");
                            h4Cantidad.InnerText = Orden.Cantidad_Producto.ToString();

                            h4Producto.Attributes.Add("class", "producto");
                            h4Producto.InnerText = Orden.NombreProducto;

                            h4Precio.Attributes.Add("class", "precio");
                            h4Precio.InnerText = CambioDecimal(Orden.Sub_Total_Precio_Producto);

                            a.Controls.Add(h4Cantidad);
                            a.Controls.Add(h4Producto);
                            a.Controls.Add(h4Precio);

                            ///-- Agregar Nota si el pedido posee
                            if (Orden.Nota_Producto != null && Orden.Nota_Producto.Length > 0)
                            {
                                h6Nota.Attributes.Add("class", "nota");
                                h6Nota.InnerText = Orden.Nota_Producto;
                                a.Controls.Add(h6Nota);
                            }

                            ///-- Agregar pedido a la comanda
                            Comanda.Controls.Add(a);
                            Comanda.Attributes.Add("Data-CodigoOrden", Orden.Codigo_Orden.ToString());
                        }

                        var Categorias = DB.SPC_GET_CATEGORIA(null, 0, null, true);
                        (LogManager.GetCurrentClassLogger()).Info("SPC_GET_CATEGORIA", Categorias);
                        foreach (var Categoria in Categorias)
                        {
                            var li = new HtmlGenericControl("li");
                            var a  = new HtmlGenericControl("a");

                            a.Attributes.Add("href", "#");
                            a.Attributes.Add("Data-CodigoCategoria", Categoria.Codigo_Categoria_Producto.ToString());
                            if (Categoria.Codigo_Categoria_Padre_Producto != 0)
                            {
                                a.Attributes.Add("Data-CodigoCategoriaPadre", Categoria.Codigo_Categoria_Padre_Producto.ToString());
                            }
                            a.InnerText = Categoria.Categoria_Producto;

                            li.Controls.Add(a);
                            uListaCategorias.Controls.Add(li);
                        }

                        var Productos = DB.SPC_GET_PRODUCTO(null, null, null, null, null, true);
                        (LogManager.GetCurrentClassLogger()).Info("SPC_GET_PRODUCTO", Productos);
                        foreach (var Producto in Productos)
                        {
                            ///-- Si es extra
                            if (Producto.Codigo_Tipo_Producto == 2 || Producto.Codigo_Tipo_Producto == 3)
                            {
                                var Extra    = new HtmlGenericControl("a");
                                var imgExtra = new HtmlGenericControl("img");
                                var pExtra   = new HtmlGenericControl("p");
                                Extra.Attributes.Add("href", "#");
                                Extra.Attributes.Add("Data-CodigoProducto", Producto.Codigo_Producto.ToString());
                                Extra.Attributes.Add("Data-NombreProducto", Producto.NombreProducto);
                                Extra.Attributes.Add("Data-PrecioComoExtra", Producto.PrecioComoExtra.ToString());
                                Extra.Attributes.Add("class", "product");

                                imgExtra.Attributes.Add("class", "img-product");
                                imgExtra.Attributes.Add("src", string.Format("/utils/VisorImagenProducto.aspx?codigoproducto={0}", Producto.Codigo_Producto));
                                pExtra.InnerText = Producto.NombreProducto;

                                Extra.Controls.Add(imgExtra);
                                Extra.Controls.Add(pExtra);

                                dExtras.Controls.Add(Extra);
                            }
                        }

                        var Areas = DB.SPC_GET_AREA(null, null, null, true);
                        (LogManager.GetCurrentClassLogger()).Info("SPC_GET_AREA", Areas);
                        foreach (var Area in Areas)
                        {
                            (LogManager.GetCurrentClassLogger()).Info("Area" + Area.Area);
                            (LogManager.GetCurrentClassLogger()).Info("Codigo" + Area.Codigo_Area);
                            (LogManager.GetCurrentClassLogger()).Info("Color" + Area.Color_Area);
                            var li = new HtmlGenericControl("li");
                            var a  = new HtmlGenericControl("a");

                            if (int.Parse(CodigoArea) == Area.Codigo_Area)
                            {
                                dArea.Style.Add(HtmlTextWriterStyle.BackgroundColor, Area.Color_Area);
                                li.Attributes.Add("class", "active");
                            }

                            a.Attributes.Add("href", "#");
                            a.Attributes.Add("Data-CodigoArea", Area.Codigo_Area.ToString());
                            a.Attributes.Add("Data-ColorArea", Area.Color_Area);
                            a.InnerText = Area.Area;

                            li.Controls.Add(a);
                            uListaAreas.Controls.Add(li);
                        }
                        (LogManager.GetCurrentClassLogger()).Info("Fin Loop");
                    }
                }
                (LogManager.GetCurrentClassLogger()).Info("Fin PageLoad");
            }
            catch (Exception ex)
            {
                (LogManager.GetCurrentClassLogger()).Error(ex, "ha ocurrido un error al intentar Imprimir Cuenta");
                throw new Exception(ex.Message);
            }
        }