Ejemplo n.º 1
0
        public bool ActualizaImpresora(TBL_IMPRESORAS model)
        {
            bool Respuesta = false;

            using (DBLaColina contex = new DBLaColina())
            {
                try
                {
                    TBL_IMPRESORAS actualiza = new TBL_IMPRESORAS();
                    actualiza = contex.TBL_IMPRESORAS.Where(a => a.ID == model.ID).FirstOrDefault();
                    if (actualiza != null)
                    {
                        actualiza.NOMBRE_IMPRESORA = model.NOMBRE_IMPRESORA;
                        actualiza.DESCRIPCION      = model.DESCRIPCION;
                        contex.SaveChanges();
                        Respuesta = true;
                    }
                }
                catch (Exception e)
                {
                    Respuesta = false;
                }
            }
            return(Respuesta);
        }
Ejemplo n.º 2
0
        public bool InsertaImpresora(TBL_IMPRESORAS model)
        {
            bool Respuesta = false;

            using (DBLaColina contex = new DBLaColina())
            {
                try
                {
                    contex.TBL_IMPRESORAS.Add(model);
                    contex.SaveChanges();
                    Respuesta = true;
                }
                catch (Exception e)
                {
                    Respuesta = false;
                }
            }
            return(Respuesta);
        }
        public bool ImprimirPedido(string cantidad, string idproducto, string descripcion, string idMesa)
        {
            bool            respuesta;
            PrintDocument   printDocument1 = new PrintDocument();
            PrinterSettings ps             = new PrinterSettings();
            TBL_PRODUCTOS   producto       = new TBL_PRODUCTOS();
            TBL_IMPRESORAS  impresora      = new TBL_IMPRESORAS();

            //CONSULTA PRODUCTO
            using (DBLaColina contex = new DBLaColina())
            {
                try
                {
                    var idprod = Convert.ToDecimal(idproducto);
                    producto = contex.TBL_PRODUCTOS.Where(x => x.ID == idprod).FirstOrDefault();
                    if (producto != null)
                    {
                        impresora = contex.TBL_IMPRESORAS.Where(x => x.ID == producto.ID_IMPRESORA).FirstOrDefault();
                    }
                }
                catch (Exception ex)
                {
                }
            }
            printDocument1.PrinterSettings             = ps;
            printDocument1.PrinterSettings.PrinterName = impresora.NOMBRE_IMPRESORA;
            printDocument1.PrintPage += (object sender, PrintPageEventArgs e) =>
            {
                //CONSULTA SOLICITUD
                var solicitud = ConsultaSolicitudMesa(Convert.ToDecimal(idMesa));

                //FORMATO FACTURA
                Font body        = new Font("MS Mincho", 12);
                Font bodyNegrita = new Font("MS Mincho", 14, FontStyle.Bold);
                int  ancho       = 280;

                e.Graphics.DrawString("#" + solicitud[0].NumeroMesa + " - MESA => " + solicitud[0].NombreMesa, body, Brushes.Black, new RectangleF(0, 15, ancho, 20));
                e.Graphics.DrawString("MESERO => " + solicitud[0].NombreMesero, body, Brushes.Black, new RectangleF(0, 35, ancho, 20));
                e.Graphics.DrawString("HORA: " + DateTime.Now.ToString("HH:mm:ss"), bodyNegrita, Brushes.Black, new RectangleF(0, 55, ancho, 20));
                e.Graphics.DrawString("" + cantidad, body, Brushes.Black, new RectangleF(0, 95, ancho, 20));
                e.Graphics.DrawString("" + producto.NOMBRE_PRODUCTO, body, Brushes.Black, new RectangleF(30, 95, ancho, 20));

                //DAR FORMATO A DESCRIPCION
                int tamañoDes      = 0;
                var descripcionAux = "";
                int Ymargen        = 0;
                descripcion = descripcion.Replace("\n", " ");
                while (descripcion.Length > 21)
                {
                    tamañoDes     += 21;
                    Ymargen       += 20;
                    descripcionAux = descripcion.Substring(0, 21);
                    descripcion    = descripcion.Substring(21, descripcion.Length - 21);
                    e.Graphics.DrawString("" + descripcionAux, body, Brushes.Black, new RectangleF(30, 95 + Ymargen, ancho, 20));
                }
                e.Graphics.DrawString("" + descripcion, body, Brushes.Black, new RectangleF(30, 115 + Ymargen, ancho, 20));

                e.Graphics.DrawString("_", body, Brushes.Black, new RectangleF(135, 160 + Ymargen, ancho, 20));
            };
            printDocument1.Print();
            respuesta = true;
            return(respuesta);
        }