예제 #1
0
 private void ImprimirVenta(object idVenta)
 {
     using (var dt = ObtenerDetalles())
     {
         if (dt.Rows.Count > 0)
         {
             string documento     = Documento.ToString();
             string tipoDocumento = TipoDocumento.ToString();
             string comprobante   = "Venta";
             string número        = idVenta.ToString();
             string fecha         = Fecha.Date.ToString("dd/MM/yyyy");
             string subTotal      = Subtotal.ToString();
             string descuento     = Descuento.ToString();
             string total         = ImporteTotal.ToString();
             MostrarReporte(dt, DireccionCliente, RazónSocialCliente, documento,
                            tipoDocumento, comprobante, número, fecha,
                            subTotal, descuento, total);
         }
         else
         {
             ShowError("No pudo imprimir el documento.");
         }
     }
 }
예제 #2
0
        void pdoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            Graphics graphics      = e.Graphics;
            Font     fontEmpresa   = new Font("Courier New", 12, FontStyle.Bold);
            Font     fontCabecera  = new Font("Courier New", 8);
            Font     fontProductos = new Font("Courier New", 7);

            int cantLineaTotales   = 39;
            int cantiLineaCabecera = 40;
            int cantColumnaTotales = 8;

            int startX = 10;
            int startY = 0;
            int Offset = 0;

            graphics.DrawString(CentrarTexto(Tienda, 27), fontEmpresa, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 20;
            graphics.DrawString(CentrarTexto(Direccion, cantiLineaCabecera), fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 30;
            graphics.DrawString("Folio:" + NumeroTicket, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
            graphics.DrawString("Fecha:" + this.FechaVenta, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
            graphics.DrawString("Atendió: " + Cajero, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
            string underLine = "------------------------------------------";

            graphics.DrawString(underLine, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            foreach (ArticuloVenta articulo in Articulos)
            {
                Offset = Offset + 10;
                graphics.DrawString(RegistarElementoTicket(articulo.Cantidad.ToString(), articulo.NombreArticulo, "", AlinearTexto(articulo.Monto.ToString("0.00"), true, 11)), fontProductos, new SolidBrush(Color.Black), startX, startY + Offset);
            }

            Offset = Offset + 20;
            string subtotal = AlinearTexto(("Subtotal = " + AlinearTexto((Articulos.Sum(a => a.Monto) - decimal.Parse(IVA)).ToString("0.00"), true, cantColumnaTotales)), true, cantLineaTotales);

            graphics.DrawString(subtotal, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
            string iva = AlinearTexto("IVA = " + AlinearTexto(IVA, true, cantColumnaTotales), true, cantLineaTotales);

            graphics.DrawString(iva, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
            string descuento = AlinearTexto("Descuento = " + AlinearTexto(Descuento.ToString("0.00"), true, cantColumnaTotales), true, cantLineaTotales);

            graphics.DrawString(descuento, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;

            string montoTotal = AlinearTexto((Articulos.Sum(a => a.Monto) - Descuento).ToString("0.00"), true, cantColumnaTotales);
            string total      = AlinearTexto("Total = " + montoTotal, true, cantLineaTotales);

            graphics.DrawString(total, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 20;
            string totalLetra = CentrarTexto(string.Format("({0})", Enletras(montoTotal)), cantiLineaCabecera);

            graphics.DrawString(totalLetra, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 30;
            string pagos = "Efectivo: " + Efectivo.ToString("0.00") + "   Cambio: " + Cambio.ToString();

            graphics.DrawString(pagos, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset    = Offset + 10;
            underLine = "------------------------------------------";
            graphics.DrawString(underLine, fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
            graphics.DrawString(CentrarTexto("GRACIAS POR SU COMPRA", cantiLineaCabecera), fontCabecera, new SolidBrush(Color.Black), startX, startY + Offset);
            Offset = Offset + 10;
        }