Beispiel #1
0
 public static void SetMesaNueva(int Codigo_Area, int Codigo_Orden, int Codigo_Mesa)
 {
     using (var DB = new TPVDBEntities())
     {
         /*var codigo_Orden = new System.Data.Entity.Core.Objects.ObjectParameter("Codigo_Orden", typeof(Int32));
          * codigo_Orden.Value = Codigo_Orden;
          * DB.SPC_SET_ORDEN(codigo_Orden, Codigo_Mesa, null, null, null, null);*/
         var orden = DB.Ordenes.Where(w => w.Codigo_Orden == Codigo_Orden).First();
         orden.Codigo_Mesa = Codigo_Mesa;
         DB.SaveChanges();
     }
 }
Beispiel #2
0
 public static void CobrarCuenta(int Codigo_Orden, int Codigo_Metodo_Pago)
 {
     using (var DB = new TPVDBEntities())
     {
         var orden = DB.Ordenes.Where(w => w.Codigo_Orden == Codigo_Orden).FirstOrDefault();
         if (orden != null)
         {
             orden.Codigo_Estado_Orden = C_ESTADO_ORDEN_PAGADA;
             orden.Codigo_Metodo_Pago  = Codigo_Metodo_Pago;
             orden.Hora_Pago           = DateTime.Now;
             DB.SaveChanges();
         }
     }
 }
Beispiel #3
0
 public static object MarcarPrimeros(int[] lstCodigoOrdenDetalle)
 {
     using (var DB = new TPVDBEntities())
     {
         var Usuario         = HttpContext.Current.Session[C_SV_USUARIO] as Usuarios;
         var ordenesDetalles = DB.OrdenesDetalles.Where(w => lstCodigoOrdenDetalle.Contains(w.Codigo_Orden_Detalle));
         foreach (var ordenDetalle in ordenesDetalles)
         {
             ordenDetalle.Primero = true;
         }
         DB.SaveChanges();
     }
     return(true);
 }
 public static object Agregar_MetodoPago(Metodos_Pago record)
 {
     try
     {
         using (var DB = new TPVDBEntities())
         {
             record.Activo = true;
             DB.Metodos_Pago.Add(record);
             DB.SaveChanges();
         }
         return(new { Result = "OK", Record = record });
     }
     catch
     {
         return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de agregar el area." });
     }
 }
 public static object Eliminar_Productos_Orden(int Codigo_Orden_Detalle)
 {
     try
     {
         using (var DB = new TPVDBEntities())
         {
             var ordenDetalle = DB.OrdenesDetalles.Where(w => w.Codigo_Orden_Detalle == Codigo_Orden_Detalle).First();
             ordenDetalle.Activo = false;
             DB.SaveChanges();
         }
         return(new { Result = "OK" });
     }
     catch
     {
         return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de actualizar el producto." });
     }
 }
 public static object Modificar_MetodoPago(Metodos_Pago record)
 {
     try
     {
         using (var DB = new TPVDBEntities())
         {
             DB.Metodos_Pago.Attach(record);
             var entry = DB.Entry(record);
             entry.Property(p => p.Metodo_Pago).IsModified = true;
             DB.SaveChanges();
         }
         return(new { Result = "OK", Record = record });
     }
     catch
     {
         return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de actualizar el area." });
     }
 }
 public static object Modificar_Ventas(Ordenes record)
 {
     try
     {
         using (var DB = new TPVDBEntities())
         {
             var orden = DB.Ordenes.Where(w => w.Codigo_Orden == record.Codigo_Orden).First();
             if (orden != null)
             {
                 orden.Codigo_Metodo_Pago = record.Codigo_Metodo_Pago;
                 DB.SaveChanges();
             }
         }
         return(new { Result = "OK", Record = record });
     }
     catch
     {
         return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de actualizar el perfil." });
     }
 }
Beispiel #8
0
        public static bool CambiarPAX(int Codigo_Orden, int Comensales)
        {
            using (var DB = new TPVDBEntities())
            {
                bool resultado    = true;
                var  codigo_Orden = new System.Data.Entity.Core.Objects.ObjectParameter("Codigo_Orden", typeof(Nullable <int>));
                codigo_Orden.Value = Codigo_Orden;

                if (Comensales >= 0)
                {
                    DB.Ordenes.First(f => f.Codigo_Orden == Codigo_Orden).Comensales = Comensales;
                    DB.SaveChanges();
                }
                else
                {
                    resultado = false;
                }

                return(resultado);
            }
        }
        public static object Modificar_Productos_Orden(SPC_GET_ORDENDETALLE_Result record)
        {
            try
            {
                using (var DB = new TPVDBEntities())
                {
                    var ordenDetalle = DB.OrdenesDetalles.Where(w => w.Codigo_Orden_Detalle == record.Codigo_Orden_Detalle).First();
                    ordenDetalle.Cantidad_Producto         = record.Cantidad_Producto;
                    ordenDetalle.Nota_Producto             = record.Nota_Producto;
                    ordenDetalle.Sub_Total_Precio_Producto = record.Sub_Total_Precio_Producto;

                    if (ordenDetalle.Sub_Total_Precio_Producto == 0)
                    {
                        ordenDetalle.Nota_Producto += " INVITADO";
                    }
                    DB.SaveChanges();
                }
                return(new { Result = "OK", Record = record });
            }
            catch
            {
                return(new { Result = "ERROR", Message = "Ocurrió un inconveniente al momento de actualizar el producto." });
            }
        }
Beispiel #10
0
        public static void ImprimirCuenta(int CodigoOrden)
        {
            try
            {
                int LINE_MAX_LENGHT = Properties.Settings.Default.MaximoCaracteresBarra;
                var center          = new StringFormat()
                {
                    Alignment = StringAlignment.Center
                };

                Usuarios            usuario     = null;
                string              AtendidoPor = string.Empty;
                InformacionEmpresa  info        = null;
                System.Drawing.Font Normal      = null;
                System.Drawing.Font Bold        = null;
                List <SPC_GET_ORDENDETALLE_Result> OrdenDetalle = null;
                var     Mesa         = string.Empty;
                decimal TotalFactura = 0;
                int     comensales   = 0;

                using (var DB = new TPVDBEntities())
                {
                    info   = DB.InformacionEmpresa.First();
                    Normal = new System.Drawing.Font(info.TipoLetraBarra, (int)info.TamanoLetraBarra, System.Drawing.FontStyle.Regular);
                    Bold   = new System.Drawing.Font(info.TipoLetraBarra, (int)info.TamanoLetraBarra, System.Drawing.FontStyle.Bold);

                    if (!string.IsNullOrEmpty(info.TipoLetraBarra))
                    {
                        Normal = new System.Drawing.Font(new System.Drawing.FontFamily(info.TipoLetraBarra), (float)info.TamanoLetraBarra.Value, System.Drawing.FontStyle.Regular);
                        Bold   = new System.Drawing.Font(new System.Drawing.FontFamily(info.TipoLetraBarra), (float)info.TamanoLetraBarra, System.Drawing.FontStyle.Bold);
                    }

                    var orden = DB.Ordenes.Where(w => w.Codigo_Orden == CodigoOrden).First();
                    usuario     = orden.OrdenesDetalles.First().Usuarios;
                    AtendidoPor = usuario.Nombre_Usuario + " " + usuario.Apellido_Usuario;
                    comensales  = orden.Comensales;

                    if (orden.Codigo_Estado_Orden == 1)
                    {
                        orden.Codigo_Estado_Orden = 2;
                        orden.Hora_Pago           = DateTime.Now;

                        DB.SaveChanges();
                    }
                    OrdenDetalle = DB.SPC_GET_ORDENDETALLE(CodigoOrden, null, null, null, null, null, null, null, true)
                                   .OrderBy(o => o.OrdenFactura).ToList();
                }

                ///-- Mesa y Nº factura
                var ordenDetalle = OrdenDetalle.First();
                Mesa = ordenDetalle.Mesa;
                var NumeroFactura = string.Format("{0}-{1}", ordenDetalle.Hora_Pago.Value.Year, ordenDetalle.NumeroFactura.Value.ToString().PadLeft(6, '0'));

                int Index           = 0;
                var LineasImpresion = new List <LineaPedido>();
                LineasImpresion.Add(new LineaPedido(Index++, info.NombreEmpresa.ToUpper(), Bold, center));
                LineasImpresion.Add(new LineaPedido(Index++, info.Direccion, Normal, center));
                LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} {1}, {2}",
                                                                           info.CodigoPostal, info.Ciudad, info.Provincia), Normal, center));

                if (!string.IsNullOrEmpty(info.Telefono))
                {
                    LineasImpresion.Add(new LineaPedido(Index++, "Tel. " + info.Telefono, Normal, center));
                }
                if (!string.IsNullOrEmpty(info.Movil) && info.Telefono != info.Movil)
                {
                    LineasImpresion.Add(new LineaPedido(Index++, "Móvil " + info.Movil, Normal, center));
                }
                if (!string.IsNullOrEmpty(info.NIF))
                {
                    LineasImpresion.Add(new LineaPedido(Index++, "N.I.F: " + info.NIF, Normal, center));
                }
                if (!string.IsNullOrEmpty(info.CIF))
                {
                    LineasImpresion.Add(new LineaPedido(Index++, "C.I.F: " + info.CIF, Normal, center));
                }

                Index++;
                LineasImpresion.Add(new LineaPedido(Index++, string.Format("Factura Simplificada: {0}",
                                                                           NumeroFactura.PadLeft(LINE_MAX_LENGHT - 22, ' ')), Normal));
                LineasImpresion.Add(new LineaPedido(Index++, new string('-', LINE_MAX_LENGHT), Normal));
                var grpProductos = OrdenDetalle.GroupBy(g => new { g.NombreProducto }).ToList();
                foreach (var Producto in grpProductos)
                {
                    var grpUnidadMedida = Producto.GroupBy(g => g.Codigo_Producto_Unidad_Medida);
                    foreach (var UnidadMedida in grpUnidadMedida)
                    {
                        var grpNota = UnidadMedida.GroupBy(g => g.Nota_Producto).ToList();
                        foreach (var Pedidos in grpNota)
                        {
                            var Linea = new SPC_GET_ORDENDETALLE_Result();
                            foreach (var Pedido in Pedidos)
                            {
                                Linea.Cantidad_Producto         += Pedido.Cantidad_Producto;
                                Linea.NombreProducto             = Pedido.NombreProducto;
                                Linea.Nota_Producto              = Pedido.Nota_Producto;
                                Linea.Sub_Total_Precio_Producto += Pedido.Sub_Total_Precio_Producto;
                            }

                            string cantidad     = string.Format("{0}x{1:F}", Linea.Cantidad_Producto.ToString().PadLeft(2, ' '), Linea.Sub_Total_Precio_Producto / Linea.Cantidad_Producto);
                            string Descripcion  = string.Empty;
                            string total        = Linea.Sub_Total_Precio_Producto.ToString("F");
                            int    EspacioTotal = 0;
                            int    intFiller    = 0;

                            EspacioTotal = (LINE_MAX_LENGHT - 3) - cantidad.Length - total.Length;
                            if (!string.IsNullOrEmpty(Linea.Nota_Producto))
                            {
                                EspacioTotal -= Linea.Nota_Producto.Length + 2;
                                if (EspacioTotal < 0)
                                {
                                    EspacioTotal = 0;
                                }
                                Descripcion  = Linea.NombreProducto.Truncate(EspacioTotal);
                                Descripcion += " " + Linea.Nota_Producto;
                            }
                            else
                            {
                                Descripcion = Linea.NombreProducto.Truncate(EspacioTotal);
                            }

                            intFiller = (LINE_MAX_LENGHT - 2) - (cantidad.Length + Descripcion.Length + total.Length);
                            if (intFiller == 0)
                            {
                                LineasImpresion.Add(new LineaPedido(Index++,
                                                                    string.Format("{0} {1} {2}", cantidad, Descripcion, total), Normal));
                            }
                            else if (intFiller > 0)
                            {
                                LineasImpresion.Add(new LineaPedido(Index++,
                                                                    string.Format("{0} {1}{2} {3}", cantidad, Descripcion, new string('.', intFiller), total), Normal));
                            }

                            TotalFactura += Linea.Sub_Total_Precio_Producto;
                        }
                    }
                }
                LineasImpresion.Add(new LineaPedido(Index++, new string('-', LINE_MAX_LENGHT), Normal));
                LineasImpresion.Add(new LineaPedido(Index++, string.Format("TOTAL: {0}",
                                                                           TotalFactura.ToString("F").PadLeft(LINE_MAX_LENGHT - 7, '.')), Bold));
                if (comensales > 1)
                {
                    Index++;
                    LineasImpresion.Add(new LineaPedido(Index++, string.Format("{0} por persona",
                                                                               (TotalFactura / comensales).ToString("F")), Normal, center));
                    Index++;
                }
                Index++;
                LineasImpresion.Add(new LineaPedido(Index++, "TIPO    BASE    IVA     TOTAL", Normal));

                var Impuestos = TotalFactura / (1 + info.PorcientoIVA.Value);

                LineasImpresion.Add(new LineaPedido(Index++,
                                                    string.Format("{0} {1} {2} {3}",
                                                                  info.PorcientoIVA.Value.ToString("F").PadRight(7, ' '),
                                                                  (TotalFactura - Impuestos).ToString("F").PadRight(7, ' '),
                                                                  Impuestos.ToString("F").PadRight(7, ' '),
                                                                  TotalFactura.ToString("F")),
                                                    Normal));

                Index++;
                LineasImpresion.Add(new LineaPedido(Index++, "PRECIOS CON IVA INCLUIDO", Normal));
                LineasImpresion.Add(new LineaPedido(Index++, "ATENDIDO POR: " + AtendidoPor, Normal));
                LineasImpresion.Add(new LineaPedido(Index++, "MESA: " + Mesa.ToUpper(), Bold));
                LineasImpresion.Add(new LineaPedido(Index++, "FECHA: " + DateTime.Now.ToString("dd MMM HH:mm:ss"), Normal));

                Index++;
                if (!string.IsNullOrEmpty(info.Facebook))
                {
                    LineasImpresion.Add(new LineaPedido(Index++, "Síguenos en FB", Bold, center));
                    LineasImpresion.Add(new LineaPedido(Index++, info.Facebook, Normal, center));
                }
                LineasImpresion.Add(new LineaPedido(Index++, "Gracias por su visita", Normal, center));

                HttpContext.Current.Session.Add(C_SV_IMPRESION, LineasImpresion);

                var pd = new System.Drawing.Printing.PrintDocument();
                pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage);
                pd.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("3 1/8 inc x 220 mm", 313, (Index + 2) * Normal.Height);
                pd.DefaultPageSettings.Margins   = new System.Drawing.Printing.Margins(0, 0, 0, 0);

                if (!string.IsNullOrEmpty(info.NombreImpresoraBarra))
                {
                    pd.PrinterSettings.PrinterName = info.NombreImpresoraBarra;
                }

                pd.Print();
            }
            catch (Exception ex)
            {
                (LogManager.GetCurrentClassLogger()).Error(ex, "ha ocurrido un error al intentar Imprimir Cuenta");
                throw new Exception(ex.Message);
            }
        }