Subo cambios 457
This commit is contained in:
+26
-56
@@ -23,7 +23,7 @@ namespace compabetov2
|
||||
|
||||
|
||||
{
|
||||
|
||||
private int numeroPagina = 1; // Variable para rastrear el número de página actual
|
||||
private Point lastPoint;
|
||||
private List<Producto> productos;
|
||||
public decimal total = 0;
|
||||
@@ -475,7 +475,7 @@ namespace compabetov2
|
||||
}
|
||||
}
|
||||
|
||||
private void flowLayoutPanel2_Paint(object sender, PaintEventArgs e)
|
||||
public void flowLayoutPanel2_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -485,6 +485,7 @@ namespace compabetov2
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void bntImprimir_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult resultado = MessageBox.Show("¿Quieres hacer esa venta?", "Confirmación de Venta", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
@@ -529,74 +530,25 @@ namespace compabetov2
|
||||
using (PrintDocument documentoImpresion = new PrintDocument())
|
||||
{
|
||||
documentoImpresion.PrintPage += (sender, e) => ImprimirContenido(e);
|
||||
documentoImpresion.PrintController = new StandardPrintController(); // Evita que el documento se imprima automáticamente
|
||||
|
||||
using (PrintDialog printDialog = new PrintDialog())
|
||||
{
|
||||
printDialog.Document = documentoImpresion;
|
||||
|
||||
if (printDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
// Imprime el documento
|
||||
documentoImpresion.Print();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ImprimirTicketEnvio()
|
||||
{
|
||||
using (PrintDocument documentoImpresion = new PrintDocument())
|
||||
{
|
||||
documentoImpresion.PrintPage += (sender, e) => ImprimirContenidoEnvio(e);
|
||||
using (PrintDialog printDialog = new PrintDialog())
|
||||
{
|
||||
printDialog.Document = documentoImpresion;
|
||||
|
||||
if (printDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
documentoImpresion.Print();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ImprimirContenidoEnvio(PrintPageEventArgs e)
|
||||
{
|
||||
|
||||
string responsable = responsablecb.SelectedItem.ToString();
|
||||
// Contenido que deseas imprimir
|
||||
string contenido = " Mini Súper\n" +
|
||||
" Compa BETO\n" +
|
||||
" Saturnino Peña #44\n" +
|
||||
" Lomas de la Laguna\n" +
|
||||
" 311 169 2829\n" +
|
||||
$" Fecha: {DateTime.Now.ToString("dd/MM/yyyy")}\n" +
|
||||
$" Hora: {DateTime.Now.ToString("hh:mm:ss")}\n" +
|
||||
$" Atendió:\n " +
|
||||
$" {responsable}\n" +
|
||||
$" ENVIO:\n " +
|
||||
$" EN CAMINO:\n " +
|
||||
|
||||
"Producto | Precio | Cantidad\n" +
|
||||
"------------------------------------\n";
|
||||
|
||||
contenido += crearContenidoImprimir();
|
||||
|
||||
contenido += $"------------------------------------\n" +
|
||||
$" Total: ${total}\n" +
|
||||
"------------------------------------\n" +
|
||||
" Mini Súper\n" +
|
||||
" Compa BETO\n" +
|
||||
" ¡Gracias por su compra!";
|
||||
|
||||
|
||||
// Configuración de la fuente y del área de impresión
|
||||
Font fuente = new Font("Arial", 10); // Ajustar el tamaño de fuente según sea necesario
|
||||
PointF posicion = new PointF(0, e.MarginBounds.Top);
|
||||
|
||||
// Imprimir el contenido
|
||||
e.Graphics.DrawString(contenido, fuente, Brushes.Black, posicion);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ImprimirContenido(PrintPageEventArgs e)
|
||||
{
|
||||
@@ -631,6 +583,24 @@ namespace compabetov2
|
||||
|
||||
// Imprimir el contenido
|
||||
e.Graphics.DrawString(contenido, fuente, Brushes.Black, posicion);
|
||||
|
||||
// Incrementa el número de página
|
||||
// Tu lógica de impresión actual aquí
|
||||
|
||||
// Incrementa el número de página
|
||||
numeroPagina++;
|
||||
|
||||
// Imprime solo dos páginas
|
||||
if (numeroPagina <= 2)
|
||||
{
|
||||
e.HasMorePages = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
e.HasMorePages = false;
|
||||
numeroPagina = 1; // Reinicia el número de página para futuras impresiones
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user