Subo cambios 534
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
@@ -156,6 +157,9 @@ namespace compabetov2
|
||||
if (service.concluirEnvio(envio, detalles))
|
||||
{
|
||||
llenarPanel();
|
||||
ImprimirTicketConcluido(envio);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -308,6 +312,53 @@ namespace compabetov2
|
||||
}
|
||||
|
||||
}
|
||||
public static class ImpresionHelper
|
||||
{
|
||||
public static void ImprimirContenido(string contenido)
|
||||
{
|
||||
PrintDocument pd = new PrintDocument();
|
||||
pd.PrintPage += (sender, e) =>
|
||||
{
|
||||
Font fuente = new Font("Arial", 10);
|
||||
PointF posicion = new PointF(0, e.MarginBounds.Top);
|
||||
e.Graphics.DrawString(contenido, fuente, Brushes.Black, posicion);
|
||||
};
|
||||
|
||||
PrintDialog printDialog = new PrintDialog();
|
||||
printDialog.Document = pd;
|
||||
|
||||
if (printDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
pd.Print();
|
||||
}
|
||||
}
|
||||
}
|
||||
private string CrearContenidoImprimir(Envio envio)
|
||||
{
|
||||
// Aquí deberías construir el contenido del ticket según tus necesidades
|
||||
// Puedes usar StringBuilder para construir el contenido eficientemente
|
||||
StringBuilder contenido = new StringBuilder();
|
||||
contenido.AppendLine($"Fecha: {envio.fecha}");
|
||||
contenido.AppendLine($"Responsable: {envio.responsable}");
|
||||
contenido.AppendLine($"Cliente: {envio.cliente}");
|
||||
contenido.AppendLine($"Direccion: {envio.direccion}");
|
||||
contenido.AppendLine($"Telefono: {envio.telefono}");
|
||||
// ... Agrega más información según sea necesario
|
||||
|
||||
return contenido.ToString();
|
||||
}
|
||||
|
||||
private void ImprimirTicketConcluido(Envio envio)
|
||||
{
|
||||
string contenido = CrearContenidoImprimir(envio);
|
||||
contenido += "Estado: CONCLUIDO\n"; // Añade el estado concluido al final del ticket
|
||||
ImpresionHelper.ImprimirContenido(contenido);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user