bajar cambios

This commit is contained in:
carlos
2024-02-03 06:35:06 -06:00
12 changed files with 215 additions and 106 deletions
+1 -1
View File
@@ -294,7 +294,7 @@
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255)))));
this.BackgroundImage = global::compabetov2.Properties.Resources.Form;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(1147, 758);
this.ClientSize = new System.Drawing.Size(1273, 867);
this.ControlBox = false;
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.lbVendedorMes);
-24
View File
@@ -129,30 +129,6 @@
<metadata name="Total.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Producto.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Precio.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Cantidad.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Total.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
+43 -22
View File
@@ -41,63 +41,76 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(22, 25);
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.ForeColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(113, 129);
this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 20);
this.label1.Size = new System.Drawing.Size(88, 36);
this.label1.TabIndex = 0;
this.label1.Text = "Cliente:";
//
// txtCliente
//
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(25, 61);
this.txtCliente.Location = new System.Drawing.Point(117, 173);
this.txtCliente.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtCliente.Name = "txtCliente";
this.txtCliente.Size = new System.Drawing.Size(337, 26);
this.txtCliente.Size = new System.Drawing.Size(448, 30);
this.txtCliente.TabIndex = 1;
//
// txtDireccion
//
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(25, 149);
this.txtDireccion.Location = new System.Drawing.Point(117, 281);
this.txtDireccion.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtDireccion.Name = "txtDireccion";
this.txtDireccion.Size = new System.Drawing.Size(337, 26);
this.txtDireccion.Size = new System.Drawing.Size(448, 30);
this.txtDireccion.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(22, 110);
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.ForeColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(113, 233);
this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(79, 20);
this.label2.Size = new System.Drawing.Size(112, 36);
this.label2.TabIndex = 2;
this.label2.Text = "Direccion:";
//
// txtTelefono
//
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(24, 227);
this.txtTelefono.Location = new System.Drawing.Point(116, 377);
this.txtTelefono.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtTelefono.Name = "txtTelefono";
this.txtTelefono.Size = new System.Drawing.Size(338, 26);
this.txtTelefono.Size = new System.Drawing.Size(449, 30);
this.txtTelefono.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(21, 191);
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.ForeColor = System.Drawing.Color.Transparent;
this.label3.Location = new System.Drawing.Point(112, 333);
this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(75, 20);
this.label3.Size = new System.Drawing.Size(105, 36);
this.label3.TabIndex = 4;
this.label3.Text = "Telefono:";
//
// btnAceptar
//
this.btnAceptar.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnAceptar.Location = new System.Drawing.Point(103, 277);
this.btnAceptar.Location = new System.Drawing.Point(221, 439);
this.btnAceptar.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnAceptar.Name = "btnAceptar";
this.btnAceptar.Size = new System.Drawing.Size(77, 31);
this.btnAceptar.Size = new System.Drawing.Size(103, 38);
this.btnAceptar.TabIndex = 6;
this.btnAceptar.Text = "Aceptar";
this.btnAceptar.UseVisualStyleBackColor = true;
@@ -106,9 +119,10 @@
// btnCancelar
//
this.btnCancelar.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnCancelar.Location = new System.Drawing.Point(203, 277);
this.btnCancelar.Location = new System.Drawing.Point(355, 439);
this.btnCancelar.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnCancelar.Name = "btnCancelar";
this.btnCancelar.Size = new System.Drawing.Size(83, 31);
this.btnCancelar.Size = new System.Drawing.Size(111, 38);
this.btnCancelar.TabIndex = 8;
this.btnCancelar.Text = "Cancelar";
this.btnCancelar.UseVisualStyleBackColor = true;
@@ -116,9 +130,13 @@
//
// datosEnvio
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(374, 341);
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(27)))), ((int)(((byte)(104)))), ((int)(((byte)(255)))));
this.BackgroundImage = global::compabetov2.Properties.Resources.Form;
this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
this.ClientSize = new System.Drawing.Size(736, 561);
this.ControlBox = false;
this.Controls.Add(this.btnCancelar);
this.Controls.Add(this.btnAceptar);
this.Controls.Add(this.txtTelefono);
@@ -127,8 +145,11 @@
this.Controls.Add(this.label2);
this.Controls.Add(this.txtCliente);
this.Controls.Add(this.label1);
this.DoubleBuffered = true;
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "datosEnvio";
this.Text = "Datos del envio";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Load += new System.EventHandler(this.datosEnvio_Load);
this.ResumeLayout(false);
this.PerformLayout();
+143 -1
View File
@@ -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.Text;
using System.Threading.Tasks;
@@ -14,6 +15,10 @@ namespace compabetov2.Ventas
{
public partial class datosEnvio : Form
{
public string Cliente => txtCliente.Text;
public string Direccion => txtDireccion.Text;
public string Telefono => txtTelefono.Text;
private Envio envio;
List<DetalleEnvioModel> detallesEnvio;
vender ventanaPadre;
@@ -25,6 +30,8 @@ namespace compabetov2.Ventas
this.ventanaPadre = ventanaPadre;
}
private void btnAceptar_Click(object sender, EventArgs e)
{
envio.cliente = txtCliente.Text;
@@ -33,10 +40,140 @@ namespace compabetov2.Ventas
if (service.crearEnvio(envio, detallesEnvio))
{
MessageBox.Show("Envio hecho");
ventanaPadre.ImprimirTicketEnvio();
ImprimirTicketEnvio();
ventanaPadre.eliminarProductosTocket();
ventanaPadre.llenarLayout();
ventanaPadre.total = 0;
this.Close();
}
}
private string crearContenidoImprimir()
{
int contador_saltar_2_vueltas = 1;
string resultado = "";
foreach (var item in ventanaPadre.flowLayoutPanel2.Controls)
{
if (contador_saltar_2_vueltas <= 3)
{
contador_saltar_2_vueltas++;
continue;
}
TableLayoutPanel panelProducto = item as TableLayoutPanel;
TableLayoutPanel panelInfo = panelProducto.Controls[1] as TableLayoutPanel;
Label lbnombre = panelInfo.Controls[0] as Label;
Label lbPrecio = panelInfo.Controls[1] as Label;
Label Lbcantidad = panelInfo.Controls[2] as Label;
Label Lbtotal = panelInfo.Controls[3] as Label;
//nombre producto
string textoLbnombre = lbnombre.Text;
string[] cadenas = textoLbnombre.Split(':');
string productoNombre = cadenas[1].Remove(0, 1);
//precio
string textoLbPrecio = lbPrecio.Text;
cadenas = textoLbPrecio.Split('$');
string precioProducto = cadenas[1];
//cantidad
string textoLbCantidad = Lbcantidad.Text;
cadenas = textoLbCantidad.Split(':');
string cantidadProducto = cadenas[1].Remove(0, 1);
//total
string textoLbTotal = Lbtotal.Text;
cadenas = textoLbTotal.Split('$');
string totalProducto = cadenas[1];
resultado += $"{(productoNombre.Length > 10 ? $"{productoNombre}\n" : $"{productoNombre}")} | ${precioProducto} | {cantidadProducto}\n";
}
return resultado;
}
private void ImprimirContenidoEnvio(PrintPageEventArgs e)
{
string responsable = envio.responsable;
// 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: ${envio.total + 10}\n" +
"------------------------------------\n" +
" Mini Súper\n" +
" Compa BETO\n" +
" ¡Gracias por su compra!\n" +
"------------------------------------\n" +
" Detalle envío:\n" +
$" Cliente: {txtCliente.Text}\n" +
$" Dirección: {AjustarDireccion(txtDireccion.Text)}\n" +//tengo duda aquí
$" Teléfono: {txtTelefono.Text}";
// 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 string AjustarDireccion(string direccion)
{
const int maxCaracteresPorLinea = 8;
// Verifica la longitud de la dirección
if (direccion.Length > maxCaracteresPorLinea)
{
// Inserta un salto de línea después de 8 caracteres
int segmentos = direccion.Length / maxCaracteresPorLinea;
string direccionFormateada = "";
for (int i = 0; i < segmentos; i++)
{
int inicio = i * maxCaracteresPorLinea;
direccionFormateada += direccion.Substring(inicio, maxCaracteresPorLinea) + "\n";
}
return direccionFormateada;
}
// Devuelve la dirección sin cambios si no se necesita ajustar
return direccion;
}
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();
}
}
}
}
@@ -44,5 +181,10 @@ namespace compabetov2.Ventas
{
Close();
}
private void datosEnvio_Load(object sender, EventArgs e)
{
}
}
}
+1 -1
View File
@@ -376,7 +376,7 @@
private System.Windows.Forms.Button button5;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.ComponentModel.BackgroundWorker backgroundWorker1;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
public System.Windows.Forms.FlowLayoutPanel flowLayoutPanel2;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.Timer horafecha;
+27 -57
View File
@@ -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
}
}
@@ -884,7 +854,7 @@ namespace compabetov2
{
List<DetalleEnvioModel> detallesEnvio = listaProductosEnvio();
string responsable = responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text;
Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable,"","",total+10);
Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable,"","",total);
if(detallesEnvio.Count > 0){
datosEnvio datosEnvio = new datosEnvio(envio, detallesEnvio,this);
datosEnvio.Show();
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.