Cada vez más cercas del final2

This commit is contained in:
Michael Robles
2024-01-08 15:36:26 -07:00
parent 9303edc799
commit c31ca97e7a
8 changed files with 55 additions and 7 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2 -1
View File
@@ -96,6 +96,7 @@
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
this.flowLayoutPanel2.Size = new System.Drawing.Size(324, 1191);
this.flowLayoutPanel2.TabIndex = 11;
this.flowLayoutPanel2.Paint += new System.Windows.Forms.PaintEventHandler(this.flowLayoutPanel2_Paint);
//
// panel1
//
@@ -278,7 +279,7 @@
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoScroll = true;
this.ClientSize = new System.Drawing.Size(1371, 750);
this.ClientSize = new System.Drawing.Size(1924, 750);
this.Controls.Add(this.textBox2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.flowLayoutPanel3);
+53 -6
View File
@@ -6,6 +6,7 @@ using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -98,12 +99,6 @@ namespace compabetov2
btnMenos.FlatStyle = FlatStyle.Flat;
btnMenos.FlatAppearance.BorderSize = 0;
btnMenos.BackColor = Color.FromArgb(33, 90, 255);
// Agregar esquinas redondeadas al botón
System.Drawing.Drawing2D.GraphicsPath gp = new System.Drawing.Drawing2D.GraphicsPath();
gp.AddEllipse(0, 0, btnMenos.Width, btnMenos.Height);
btnMenos.Region = new Region(gp);
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
{
int numeroContador = int.Parse(contador.Text.ToString());
@@ -139,6 +134,28 @@ namespace compabetov2
int numeroContador = int.Parse(contador.Text.ToString());
contador.Text = (numeroContador + 1).ToString();
total += producto.precion;
// Obtener información del Label id y precio
int idProducto = int.Parse(id.Text);
decimal precioProducto;
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, precioProducto, int.Parse(contador.Text), total);
// ... (código existente)
});
HUD.Controls.Add(btnMenos);
@@ -150,8 +167,33 @@ namespace compabetov2
cartas.Add(carta);
flowLayoutPanel3.Controls.Add(carta);
}
}
private void GenerarTicket(int idProducto, string nombreProducto, decimal precio, int cantidad, decimal total)
{
// Crear un nuevo control (puede ser un Label, Panel, etc.) para representar el ticket
Label ticketLabel = new Label();
ticketLabel.Text = $"ID: {idProducto} | Producto: {nombreProducto} | Precio: ${precio} | Cantidad: {cantidad} | Total: ${total}";
ticketLabel.BackColor = Color.LightGray; // Puedes ajustar el color de fondo según tu diseño
ticketLabel.AutoSize = true;
// Agregar el ticket al flowLayoutPanel2
flowLayoutPanel2.Controls.Add(ticketLabel);
}
private void getData()
{
this.productos = service.conseguirProductos();
@@ -194,6 +236,11 @@ namespace compabetov2
menuPrincipal.Show();
this.Dispose(true);
}
private void flowLayoutPanel2_Paint(object sender, PaintEventArgs e)
{
}
}
}