formulario datos envio

This commit is contained in:
carlos
2024-02-03 04:59:42 -06:00
30 changed files with 903 additions and 240 deletions
+139 -16
View File
@@ -1,5 +1,6 @@
using compabetov2.database;
using compabetov2.database.modelos;
using compabetov2.Ventas;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -22,8 +23,10 @@ namespace compabetov2
{
private Point lastPoint;
private List<Producto> productos;
private decimal total = 0;
public decimal total = 0;
private LoginModel loginPrincipal;
@@ -37,6 +40,44 @@ namespace compabetov2
this.loginPrincipal = loginPrincipal;
}
private void InitializeFlowLayout()
{
// Inicializar el flowLayoutPanel3 (asegúrate de que ya está creado en tu formulario)
// Habilitar eventos táctiles simulados
flowLayoutPanel3.MouseDown += FlowLayoutPanel3_MouseDown;
flowLayoutPanel3.MouseMove += FlowLayoutPanel3_MouseMove;
flowLayoutPanel3.MouseUp += FlowLayoutPanel3_MouseUp;
}
private void FlowLayoutPanel3_MouseDown(object sender, MouseEventArgs e)
{
lastPoint = new Point(e.X, e.Y);
flowLayoutPanel3.Capture = true;
}
private void FlowLayoutPanel3_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int deltaX = lastPoint.X - e.X;
int deltaY = lastPoint.Y - e.Y;
// Ajustar la dirección del desplazamiento
flowLayoutPanel3.AutoScrollPosition = new Point(flowLayoutPanel3.AutoScrollPosition.X + deltaX, flowLayoutPanel3.AutoScrollPosition.Y - deltaY);
lastPoint = new Point(e.X, e.Y);
}
}
private void FlowLayoutPanel3_MouseUp(object sender, MouseEventArgs e)
{
flowLayoutPanel3.Capture = false;
}
private void llenarComBox()
{
List<Empleado> empleados = service.conseguirEmpleados();
@@ -46,7 +87,7 @@ namespace compabetov2
}
}
private void llenarLayout()
public void llenarLayout()
{
flowLayoutPanel3.Controls.Clear();
foreach (Producto producto in productos)
@@ -406,6 +447,8 @@ namespace compabetov2
}
private void button1_Click(object sender, EventArgs e)
{
// Cerrar el formulario de ventas
@@ -463,6 +506,8 @@ namespace compabetov2
MessageBox.Show("Venta hecha");
eliminarProductosTocket();
llenarLayout();
total= 0;
}
}
@@ -496,6 +541,63 @@ namespace compabetov2
}
}
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)
{
@@ -569,8 +671,9 @@ namespace compabetov2
cadenas = textoLbTotal.Split('$');
string totalProducto = cadenas[1];
resultado += $"{productoNombre} | ${precioProducto} | {cantidadProducto}\n";
resultado += $"{(productoNombre.Length > 10 ? $"{productoNombre}\n" : $"{productoNombre}")} | ${precioProducto} | {cantidadProducto}\n";
}
return resultado;
}
@@ -702,7 +805,23 @@ namespace compabetov2
private void responsablecb_SelectedIndexChanged(object sender, EventArgs e)
{
bntImprimir.Enabled = responsablecb.SelectedIndex != -1;
// Verificar si hay un elemento seleccionado en el ComboBox
if (responsablecb.SelectedItem != null)
{
// Habilitar los botones
bntImprimir.Enabled = true;
btnFiar.Enabled = true;
btnEnviar.Enabled = true;
}
else {
bntImprimir.Enabled = false;
btnFiar.Enabled = false;
btnEnviar.Enabled = false;
}
}
@@ -767,20 +886,16 @@ namespace compabetov2
string responsable = responsablecb.Text.Equals("") ? loginPrincipal.usuario : responsablecb.Text;
Envio envio = new Envio(-1, DateTime.Now.ToString(), "", "", responsable,"","",total+10);
if(detallesEnvio.Count > 0){
if (service.crearEnvio(envio, detallesEnvio))
{
MessageBox.Show("Envio hecho");
eliminarProductosTocket();
llenarLayout();
}
else
{
MessageBox.Show("No hay ningun producto agregado");
}
datosEnvio datosEnvio = new datosEnvio(envio, detallesEnvio,this);
datosEnvio.Show();
}
else
{
MessageBox.Show("No hay ningun producto agregado");
}
}
private void eliminarProductosTocket()
public void eliminarProductosTocket()
{
for (int i = flowLayoutPanel2.Controls.Count -1; i > 2; i--)
{
@@ -789,7 +904,15 @@ namespace compabetov2
flowLayoutPanel1.Controls.Remove(c);
}
label1.Text = "Total: 0";
txtbusqueda.Text = "";
}
private void button2_Click(object sender, EventArgs e)
{
Estadiscticas estadiscticas = new Estadiscticas();
estadiscticas.Owner = this;
estadiscticas.Show();
}
}
}