etiqueta total en ticket

This commit is contained in:
carlos
2024-01-09 00:49:07 -06:00
12 changed files with 92 additions and 11 deletions
+1 -3
View File
@@ -1,8 +1,6 @@
{ {
"ExpandedNodes": [ "ExpandedNodes": [
"", ""
"\\database",
"\\database\\modelos"
], ],
"SelectedNode": "\\.sln", "SelectedNode": "\\.sln",
"PreviewInSolutionExplorer": false "PreviewInSolutionExplorer": false
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -58,3 +58,33 @@ C:\Users\carsu\Source\Repos\compabetoOG\bin\Debug\compabetov2.application
C:\Users\carsu\Source\Repos\compabetoOG\obj\Debug\compabetov2.exe.manifest C:\Users\carsu\Source\Repos\compabetoOG\obj\Debug\compabetov2.exe.manifest
C:\Users\carsu\Source\Repos\compabetoOG\obj\Debug\compabetov2.application C:\Users\carsu\Source\Repos\compabetoOG\obj\Debug\compabetov2.application
C:\Users\Googl\Documents\compabetov2\obj\Debug\compabetov2.envios.resources C:\Users\Googl\Documents\compabetov2\obj\Debug\compabetov2.envios.resources
C:\Users\Googl\Documents\compabetoOG\bin\Debug\compabetov2.exe.config
C:\Users\Googl\Documents\compabetoOG\bin\Debug\compabetov2.exe.manifest
C:\Users\Googl\Documents\compabetoOG\bin\Debug\compabetov2.application
C:\Users\Googl\Documents\compabetoOG\bin\Debug\compabetov2.exe
C:\Users\Googl\Documents\compabetoOG\bin\Debug\compabetov2.pdb
C:\Users\Googl\Documents\compabetoOG\bin\Debug\EntityFramework.dll
C:\Users\Googl\Documents\compabetoOG\bin\Debug\EntityFramework.SqlServer.dll
C:\Users\Googl\Documents\compabetoOG\bin\Debug\System.Data.SQLite.dll
C:\Users\Googl\Documents\compabetoOG\bin\Debug\System.Data.SQLite.EF6.dll
C:\Users\Googl\Documents\compabetoOG\bin\Debug\System.Data.SQLite.Linq.dll
C:\Users\Googl\Documents\compabetoOG\bin\Debug\EntityFramework.xml
C:\Users\Googl\Documents\compabetoOG\bin\Debug\EntityFramework.SqlServer.xml
C:\Users\Googl\Documents\compabetoOG\bin\Debug\System.Data.SQLite.xml
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.csproj.AssemblyReference.cache
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.cuentas.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.envios.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.inventario.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.login.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.MenuPrincipal.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.mermas.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.personal.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.Properties.Resources.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.vender.resources
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.csproj.GenerateResource.cache
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.csproj.CoreCompileInputs.cache
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.exe.manifest
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.application
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.csproj.CopyComplete
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.exe
C:\Users\Googl\Documents\compabetoOG\obj\Debug\compabetov2.pdb
Binary file not shown.
Binary file not shown.
+1 -2
View File
@@ -92,9 +92,8 @@ namespace compabetov2
private void button8_Click(object sender, EventArgs e) private void button8_Click(object sender, EventArgs e)
{ {
int idEmpelado;
int fila = dataGridView1.CurrentCell.RowIndex; int fila = dataGridView1.CurrentCell.RowIndex;
MessageBox.Show(fila + ""); int idEmpleado = int.Parse(dataGridView1.Rows[fila].Cells[0].Value.ToString());
Empleado empleado = new Empleado(); Empleado empleado = new Empleado();
} }
+60 -6
View File
@@ -27,9 +27,7 @@ namespace compabetov2
private bool menosBtnPresionado = false; private bool menosBtnPresionado = false;
private List<Producto> productos; private List<Producto> productos;
private List<TableLayoutPanel> cartas = new List<TableLayoutPanel>(); private List<TableLayoutPanel> cartas = new List<TableLayoutPanel>();
// private List<Producto>
private decimal total = 0; private decimal total = 0;
private Label ticketLabel;
@@ -113,6 +111,7 @@ namespace compabetov2
btnMenos.BackColor = Color.FromArgb(33, 90, 255); btnMenos.BackColor = Color.FromArgb(33, 90, 255);
btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e) btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e)
{ {
int numeroContador = int.Parse(contador.Text.ToString()); int numeroContador = int.Parse(contador.Text.ToString());
// Validar que el contador no sea 0 antes de restar // Validar que el contador no sea 0 antes de restar
@@ -120,11 +119,19 @@ namespace compabetov2
{ {
contador.Text = (numeroContador - 1).ToString(); contador.Text = (numeroContador - 1).ToString();
total -= producto.precion; total -= producto.precion;
label1.Text = $"Total: ${total}";
// Obtener información del Label id y precio
int idProducto = int.Parse(id.Text);
decimal precioProducto = producto.precion;
// Restar al ticket existente si ya se agregó
RestarDelTicket(idProducto, producto.nombre, precioProducto, 1);
} }
else else
{ {
// Mostrar mensaje de advertencia // Mostrar mensaje de advertencia
MessageBox.Show("No puedes vender cosas negativas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBox.Show("No puedes vender menos de 0 cosas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
} }
}); });
@@ -146,9 +153,7 @@ namespace compabetov2
int numeroContador = int.Parse(contador.Text.ToString()); int numeroContador = int.Parse(contador.Text.ToString());
contador.Text = (numeroContador + 1).ToString(); contador.Text = (numeroContador + 1).ToString();
total += producto.precion; total += producto.precion;
label1.Text = $"Total: ${total}";
// Obtener información del Label id y precio // Obtener información del Label id y precio
int idProducto = int.Parse(id.Text); int idProducto = int.Parse(id.Text);
@@ -190,6 +195,55 @@ namespace compabetov2
} }
private void RestarDelTicket(int idProducto, string nombreProducto, decimal precio, int cantidad)
{
foreach (var item in flowLayoutPanel2.Controls)
{
TableLayoutPanel panelProducto = item as TableLayoutPanel;
if (panelProducto != null && panelProducto.Controls.Count > 1)
{
TableLayoutPanel panelInfo = panelProducto.Controls[1] as TableLayoutPanel;
if (panelInfo != null && panelInfo.Controls.Count > 2)
{
Label lbnombre = panelInfo.Controls[0] as Label;
if (lbnombre != null)
{
string textoLb = lbnombre.Text;
string[] cadenas = textoLb.Split(':');
string cadena = cadenas[1].Remove(0, 1);
if (cadena.Equals(nombreProducto))
{
Label Lbcantidad = panelInfo.Controls[2] as Label;
Label Lbtotal = panelInfo.Controls[3] as Label;
if (Lbcantidad != null && Lbtotal != null)
{
string textcantidad = Lbcantidad.Text;
string[] cantidadCadenas = textcantidad.Split(' ');
int NuevaCantiad = int.Parse(cantidadCadenas[1]) - cantidad;
int NuevoTotal = (int)(NuevaCantiad * precio);
// Actualizar el ticket existente
Lbcantidad.Text = $"Cantidad: {NuevaCantiad}";
Lbtotal.Text = $"Total: ${NuevoTotal}";
// Si la cantidad llega a 0, eliminar el ticket del flowLayoutPanel2
if (NuevaCantiad == 0)
{
flowLayoutPanel2.Controls.Remove(panelProducto);
}
break;
}
}
}
}
}
}
}
private void GenerarTicket(int idProducto, string nombreProducto, decimal precio, int cantidad, decimal total, string rutaImg) private void GenerarTicket(int idProducto, string nombreProducto, decimal precio, int cantidad, decimal total, string rutaImg)
{ {
bool existeProducto = false; bool existeProducto = false;