Subo cambios 534

This commit is contained in:
Michael Robles
2024-02-03 05:34:05 -07:00
parent 1754d797b4
commit 6c4ced08b3
9 changed files with 120 additions and 43 deletions
+51
View File
@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
using System.Drawing; using System.Drawing;
using System.Drawing.Printing;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Text; using System.Text;
@@ -156,6 +157,9 @@ namespace compabetov2
if (service.concluirEnvio(envio, detalles)) if (service.concluirEnvio(envio, detalles))
{ {
llenarPanel(); 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) private void button1_Click(object sender, EventArgs e)
{ {
+39 -34
View File
@@ -34,8 +34,10 @@
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
this.txtTelefono = new System.Windows.Forms.TextBox(); this.txtTelefono = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.btnAceptar = new System.Windows.Forms.Button(); this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.btnCancelar = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// label1 // label1
@@ -44,7 +46,7 @@
this.label1.BackColor = System.Drawing.Color.Transparent; this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("Poppins", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Font = new System.Drawing.Font("Poppins", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.ForeColor = System.Drawing.Color.Transparent; this.label1.ForeColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(113, 129); this.label1.Location = new System.Drawing.Point(156, 109);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1"; this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(88, 36); this.label1.Size = new System.Drawing.Size(88, 36);
@@ -54,7 +56,7 @@
// txtCliente // txtCliente
// //
this.txtCliente.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txtCliente.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtCliente.Location = new System.Drawing.Point(117, 173); this.txtCliente.Location = new System.Drawing.Point(160, 153);
this.txtCliente.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.txtCliente.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtCliente.Name = "txtCliente"; this.txtCliente.Name = "txtCliente";
this.txtCliente.Size = new System.Drawing.Size(448, 30); this.txtCliente.Size = new System.Drawing.Size(448, 30);
@@ -63,10 +65,11 @@
// txtDireccion // txtDireccion
// //
this.txtDireccion.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txtDireccion.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtDireccion.Location = new System.Drawing.Point(117, 281); this.txtDireccion.Location = new System.Drawing.Point(160, 261);
this.txtDireccion.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.txtDireccion.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtDireccion.Multiline = true;
this.txtDireccion.Name = "txtDireccion"; this.txtDireccion.Name = "txtDireccion";
this.txtDireccion.Size = new System.Drawing.Size(448, 30); this.txtDireccion.Size = new System.Drawing.Size(448, 34);
this.txtDireccion.TabIndex = 3; this.txtDireccion.TabIndex = 3;
// //
// label2 // label2
@@ -75,7 +78,7 @@
this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("Poppins", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Font = new System.Drawing.Font("Poppins", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.ForeColor = System.Drawing.Color.Transparent; this.label2.ForeColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(113, 233); this.label2.Location = new System.Drawing.Point(156, 213);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2"; this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(112, 36); this.label2.Size = new System.Drawing.Size(112, 36);
@@ -85,7 +88,7 @@
// txtTelefono // txtTelefono
// //
this.txtTelefono.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.txtTelefono.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.txtTelefono.Location = new System.Drawing.Point(116, 377); this.txtTelefono.Location = new System.Drawing.Point(159, 357);
this.txtTelefono.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.txtTelefono.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtTelefono.Name = "txtTelefono"; this.txtTelefono.Name = "txtTelefono";
this.txtTelefono.Size = new System.Drawing.Size(449, 30); this.txtTelefono.Size = new System.Drawing.Size(449, 30);
@@ -97,36 +100,36 @@
this.label3.BackColor = System.Drawing.Color.Transparent; this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Font = new System.Drawing.Font("Poppins", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.Font = new System.Drawing.Font("Poppins", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.ForeColor = System.Drawing.Color.Transparent; this.label3.ForeColor = System.Drawing.Color.Transparent;
this.label3.Location = new System.Drawing.Point(112, 333); this.label3.Location = new System.Drawing.Point(155, 313);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3"; this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(105, 36); this.label3.Size = new System.Drawing.Size(105, 36);
this.label3.TabIndex = 4; this.label3.TabIndex = 4;
this.label3.Text = "Telefono:"; this.label3.Text = "Telefono:";
// //
// btnAceptar // pictureBox2
// //
this.btnAceptar.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.pictureBox2.BackColor = System.Drawing.Color.Transparent;
this.btnAceptar.Location = new System.Drawing.Point(221, 439); this.pictureBox2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.btnAceptar.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.pictureBox2.Image = global::compabetov2.Properties.Resources.check1;
this.btnAceptar.Name = "btnAceptar"; this.pictureBox2.Location = new System.Drawing.Point(282, 414);
this.btnAceptar.Size = new System.Drawing.Size(103, 38); this.pictureBox2.Name = "pictureBox2";
this.btnAceptar.TabIndex = 6; this.pictureBox2.Size = new System.Drawing.Size(100, 69);
this.btnAceptar.Text = "Aceptar"; this.pictureBox2.TabIndex = 22;
this.btnAceptar.UseVisualStyleBackColor = true; this.pictureBox2.TabStop = false;
this.btnAceptar.Click += new System.EventHandler(this.btnAceptar_Click); this.pictureBox2.Click += new System.EventHandler(this.pictureBox2_Click);
// //
// btnCancelar // pictureBox1
// //
this.btnCancelar.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.btnCancelar.Location = new System.Drawing.Point(355, 439); this.pictureBox1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
this.btnCancelar.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.pictureBox1.Image = global::compabetov2.Properties.Resources.cancel1;
this.btnCancelar.Name = "btnCancelar"; this.pictureBox1.Location = new System.Drawing.Point(388, 414);
this.btnCancelar.Size = new System.Drawing.Size(111, 38); this.pictureBox1.Name = "pictureBox1";
this.btnCancelar.TabIndex = 8; this.pictureBox1.Size = new System.Drawing.Size(100, 69);
this.btnCancelar.Text = "Cancelar"; this.pictureBox1.TabIndex = 21;
this.btnCancelar.UseVisualStyleBackColor = true; this.pictureBox1.TabStop = false;
this.btnCancelar.Click += new System.EventHandler(this.btnCancelar_Click); this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
// //
// datosEnvio // datosEnvio
// //
@@ -135,10 +138,10 @@
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255))))); this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255)))));
this.BackgroundImage = global::compabetov2.Properties.Resources.Form; this.BackgroundImage = global::compabetov2.Properties.Resources.Form;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(736, 561); this.ClientSize = new System.Drawing.Size(789, 568);
this.ControlBox = false; this.ControlBox = false;
this.Controls.Add(this.btnCancelar); this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.btnAceptar); this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.txtTelefono); this.Controls.Add(this.txtTelefono);
this.Controls.Add(this.label3); this.Controls.Add(this.label3);
this.Controls.Add(this.txtDireccion); this.Controls.Add(this.txtDireccion);
@@ -150,6 +153,8 @@
this.Name = "datosEnvio"; this.Name = "datosEnvio";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Load += new System.EventHandler(this.datosEnvio_Load); this.Load += new System.EventHandler(this.datosEnvio_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -163,7 +168,7 @@
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtTelefono; private System.Windows.Forms.TextBox txtTelefono;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button btnAceptar; private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.Button btnCancelar; private System.Windows.Forms.PictureBox pictureBox1;
} }
} }
+30 -9
View File
@@ -143,21 +143,20 @@ namespace compabetov2.Ventas
// Verifica la longitud de la dirección // Verifica la longitud de la dirección
if (direccion.Length > maxCaracteresPorLinea) if (direccion.Length > maxCaracteresPorLinea)
{ {
// Inserta un salto de línea después de 8 caracteres StringBuilder direccionFormateada = new StringBuilder();
int segmentos = direccion.Length / maxCaracteresPorLinea;
string direccionFormateada = "";
for (int i = 0; i < segmentos; i++) for (int i = 0; i < direccion.Length; i += maxCaracteresPorLinea)
{ {
int inicio = i * maxCaracteresPorLinea; int caracteresRestantes = direccion.Length - i;
direccionFormateada += direccion.Substring(inicio, maxCaracteresPorLinea) + "\n"; int caracteresEnEstaLinea = Math.Min(caracteresRestantes, maxCaracteresPorLinea);
direccionFormateada.AppendLine(direccion.Substring(i, caracteresEnEstaLinea));
} }
return direccionFormateada; return direccionFormateada.ToString();
} }
// Devuelve la dirección sin cambios si no se necesita ajustar return direccion; // Devuelve la dirección sin cambios si no es necesario ajustarla
return direccion;
} }
public void ImprimirTicketEnvio() public void ImprimirTicketEnvio()
@@ -186,5 +185,27 @@ namespace compabetov2.Ventas
{ {
} }
private void pictureBox1_Click(object sender, EventArgs e)
{
Close();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
envio.cliente = txtCliente.Text;
envio.direccion = txtDireccion.Text;
envio.telefono = txtTelefono.Text;
if (service.crearEnvio(envio, detallesEnvio))
{
MessageBox.Show("Envio hecho");
ImprimirTicketEnvio();
ventanaPadre.eliminarProductosTocket();
ventanaPadre.llenarLayout();
ventanaPadre.total = 0;
this.Close();
}
}
} }
} }
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.