carta para productos
This commit is contained in:
@@ -1,25 +1,178 @@
|
||||
using System;
|
||||
using compabetov2.database;
|
||||
using compabetov2.database.modelos;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace compabetov2
|
||||
{
|
||||
public partial class vender : Form
|
||||
|
||||
|
||||
{
|
||||
|
||||
private int cantidad = 0;
|
||||
private bool masBtnPresionado = false;
|
||||
private bool menosBtnPresionado = false;
|
||||
private List<Producto> productos;
|
||||
private List<TableLayoutPanel> cartas = new List<TableLayoutPanel>();
|
||||
private decimal total = 0;
|
||||
|
||||
|
||||
|
||||
public vender()
|
||||
{
|
||||
InitializeComponent();
|
||||
getData();
|
||||
llenarLayout();
|
||||
}
|
||||
|
||||
private void llenarLayout()
|
||||
{
|
||||
foreach (Producto producto in productos)
|
||||
{
|
||||
|
||||
TableLayoutPanel carta = new TableLayoutPanel();
|
||||
carta.ColumnCount = 1;
|
||||
carta.RowCount = 2;
|
||||
|
||||
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 80F));
|
||||
carta.RowStyles.Add(new RowStyle(SizeType.Percent, 20F));
|
||||
|
||||
carta.Width = 200;
|
||||
carta.Height = 300;
|
||||
|
||||
PictureBox pic = new PictureBox();
|
||||
pic.Dock = DockStyle.Fill;
|
||||
pic.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
pic.Image = Properties.Resources.Modelo;
|
||||
pic.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
pic.Tag = producto.idProducto;
|
||||
|
||||
Label id = new Label();
|
||||
id.Text = producto.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);
|
||||
|
||||
Label precio = new Label();
|
||||
precio.Text = "$5";// + producto.precion.ToString();
|
||||
precio.BackColor = Color.FromArgb(82, 82, 82);
|
||||
precio.ForeColor = Color.White;
|
||||
precio.Width = 40;
|
||||
precio.Font = new Font(id.Font, FontStyle.Bold);
|
||||
precio.Dock = DockStyle.Bottom;
|
||||
pic.Controls.Add(precio);
|
||||
|
||||
TableLayoutPanel HUD = new TableLayoutPanel();
|
||||
HUD.ColumnCount = 3;
|
||||
HUD.RowCount = 1;
|
||||
HUD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
HUD.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 33F));
|
||||
|
||||
Label contador = new Label();
|
||||
contador.Text = "0";
|
||||
contador.Dock = DockStyle.Fill;
|
||||
contador.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
contador.Font = new Font(contador.Font.FontFamily, 30);
|
||||
|
||||
Button btnMenos = new Button();
|
||||
btnMenos.Text = "-";
|
||||
btnMenos.Width = 25;
|
||||
btnMenos.Height = 25;
|
||||
btnMenos.Font = new Font(btnMenos.Font.FontFamily, 30);
|
||||
btnMenos.ForeColor = Color.White;
|
||||
btnMenos.Dock = DockStyle.Fill;
|
||||
btnMenos.FlatStyle = FlatStyle.Flat;
|
||||
btnMenos.FlatAppearance.BorderSize = 0;
|
||||
btnMenos.BackColor = Color.FromArgb(33, 90, 255);
|
||||
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
int numeroContador = int.Parse(contador.Text.ToString());
|
||||
contador.Text = (numeroContador - 1).ToString();
|
||||
total -= producto.precion;
|
||||
});
|
||||
|
||||
|
||||
|
||||
Button btnMas = new Button();
|
||||
btnMas.Text = "+";
|
||||
btnMas.Width = 25;
|
||||
btnMas.Height = 25;
|
||||
btnMas.Dock = DockStyle.Fill;
|
||||
btnMas.Font = new Font(btnMas.Font.FontFamily, 30);
|
||||
btnMas.ForeColor = Color.White;
|
||||
btnMas.BackColor = Color.FromArgb(33, 90, 255);
|
||||
btnMas.FlatStyle = FlatStyle.Flat;
|
||||
btnMas.FlatAppearance.BorderSize = 0;
|
||||
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||
{
|
||||
int numeroContador = int.Parse(contador.Text.ToString());
|
||||
contador.Text = (numeroContador + 1).ToString();
|
||||
total += producto.precion;
|
||||
});
|
||||
|
||||
HUD.Controls.Add(btnMenos);
|
||||
HUD.Controls.Add(contador);
|
||||
HUD.Controls.Add(btnMas);
|
||||
|
||||
carta.Controls.Add(pic, 0, 0);
|
||||
carta.Controls.Add(HUD, 0, 1);
|
||||
cartas.Add(carta);
|
||||
flowLayoutPanel3.Controls.Add(carta);
|
||||
}
|
||||
}
|
||||
|
||||
private void getData()
|
||||
{
|
||||
this.productos = service.conseguirProductos();
|
||||
}
|
||||
|
||||
private void vender_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void lblhora_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void lblfecha_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void horafecha_Tick(object sender, EventArgs e)
|
||||
{
|
||||
lblhora.Text = DateTime.Now.ToString("h:mm:ss");
|
||||
lblfecha.Text = DateTime.Now.ToLongDateString();
|
||||
}
|
||||
|
||||
private void cervezasgb_Enter(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void flowLayoutPanel3_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user