bajo cambios 21012024
This commit is contained in:
@@ -22,8 +22,6 @@ namespace compabetov2
|
||||
|
||||
|
||||
{
|
||||
|
||||
private int cantidad = 0;
|
||||
private bool masBtnPresionado = false;
|
||||
private bool menosBtnPresionado = false;
|
||||
private List<Producto> productos;
|
||||
@@ -64,13 +62,6 @@ namespace compabetov2
|
||||
pic.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
pic.Tag = producto.idProducto;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Label id = new Label();
|
||||
id.Text = producto.idProducto.ToString();
|
||||
id.BackColor = Color.FromArgb(82, 82, 82);
|
||||
@@ -161,23 +152,8 @@ namespace compabetov2
|
||||
// Obtener información del Label id y precio
|
||||
int idProducto = int.Parse(id.Text);
|
||||
decimal precioProducto = producto.precion;
|
||||
if (decimal.TryParse(precio.Text, NumberStyles.Currency, CultureInfo.CurrentCulture, out precioProducto))
|
||||
{
|
||||
// Generar ticket y agregarlo al flowLayoutPanel2
|
||||
//GenerarTicket(idProducto, producto.nombre, precioProducto, int.Parse(contador.Text), total);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Manejar el caso en el que la conversión no sea exitosa
|
||||
//MessageBox.Show("Formato de precio no válido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
// Generar ticket y agregarlo al flowLayoutPanel2
|
||||
GenerarTicket(idProducto, producto.nombre, producto.precion, int.Parse(contador.Text), total, rutaImg);
|
||||
|
||||
MessageBox.Show(crearContenidoImprimir());
|
||||
|
||||
|
||||
});
|
||||
|
||||
HUD.Controls.Add(btnMenos);
|
||||
@@ -293,6 +269,15 @@ namespace compabetov2
|
||||
pic.Image = Image.FromFile(rutaImg);//hay error aquí
|
||||
pic.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
|
||||
Label id = new Label();
|
||||
id.Text = idProducto.ToString();
|
||||
id.BackColor = Color.FromArgb(82, 82, 82);
|
||||
id.ForeColor = Color.White;
|
||||
id.Width = 20;
|
||||
id.Font = new Font(id.Font, FontStyle.Bold);
|
||||
id.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
pic.Controls.Add(id);
|
||||
|
||||
TableLayoutPanel infoTicket = new TableLayoutPanel();
|
||||
infoTicket.ColumnCount = 1;
|
||||
infoTicket.RowCount = 4;
|
||||
@@ -378,7 +363,7 @@ namespace compabetov2
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
MenuPrincipal menuPrincipal = new MenuPrincipal(loginPrincipal);
|
||||
menuPrincipal.Show();
|
||||
menuPrincipal.ShowDialog();
|
||||
this.Dispose(true);
|
||||
}
|
||||
|
||||
@@ -491,6 +476,62 @@ namespace compabetov2
|
||||
return resultado;
|
||||
}
|
||||
|
||||
private void button7_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<DetalleVentaModel> detalleVentas = listaProductosVenta();
|
||||
if(detalleVentas.Count > 0)
|
||||
{
|
||||
VentaModel ventaModel = new VentaModel(total);
|
||||
|
||||
if(service.crearVentaDAO(ventaModel, detalleVentas))
|
||||
{
|
||||
MessageBox.Show("Venta hecha");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("No hay ningun producto agregado");
|
||||
}
|
||||
}
|
||||
|
||||
private List<DetalleVentaModel> listaProductosVenta()
|
||||
{
|
||||
List<DetalleVentaModel> detalleVentas = new List<DetalleVentaModel>();
|
||||
int contador_saltar_2_vueltas = 1;
|
||||
foreach (var item in 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;
|
||||
PictureBox pic = panelProducto.Controls[0] as PictureBox;
|
||||
Label idLabel = null;
|
||||
foreach (Control control in pic.Controls)
|
||||
{
|
||||
if (control is Label)
|
||||
{
|
||||
idLabel = (Label)control;
|
||||
break;
|
||||
}
|
||||
}
|
||||
int idProducto = int.Parse(idLabel.Text);
|
||||
Producto producto = new Producto(idProducto);
|
||||
|
||||
Label Lbcantidad = panelInfo.Controls[2] as Label;
|
||||
string textcantidad = Lbcantidad.Text;
|
||||
string[] cantidadCadenas = textcantidad.Split(' ');
|
||||
int cantidad = int.Parse(cantidadCadenas[1]);
|
||||
|
||||
DetalleVentaModel detalleVenta = new DetalleVentaModel(cantidad, producto);
|
||||
|
||||
|
||||
detalleVentas.Add(detalleVenta);
|
||||
}
|
||||
|
||||
return detalleVentas;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user