diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json index dc00168..249c658 100644 --- a/.vs/VSWorkspaceState.json +++ b/.vs/VSWorkspaceState.json @@ -1,8 +1,6 @@ { "ExpandedNodes": [ - "", - "\\database", - "\\database\\modelos" + "" ], "SelectedNode": "\\.sln", "PreviewInSolutionExplorer": false diff --git a/.vs/compabetoOG/v17/.wsuo b/.vs/compabetoOG/v17/.wsuo index 89c25f0..473814e 100644 Binary files a/.vs/compabetoOG/v17/.wsuo and b/.vs/compabetoOG/v17/.wsuo differ diff --git a/bin/Debug/compabetov2.exe b/bin/Debug/compabetov2.exe index 1bb74c7..9c47dd5 100644 Binary files a/bin/Debug/compabetov2.exe and b/bin/Debug/compabetov2.exe differ diff --git a/bin/Debug/compabetov2.pdb b/bin/Debug/compabetov2.pdb index 3943f8d..d2f5e52 100644 Binary files a/bin/Debug/compabetov2.pdb and b/bin/Debug/compabetov2.pdb differ diff --git a/obj/Debug/DesignTimeResolveAssemblyReferences.cache b/obj/Debug/DesignTimeResolveAssemblyReferences.cache index 30c6059..562d4b7 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferences.cache and b/obj/Debug/DesignTimeResolveAssemblyReferences.cache differ diff --git a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache index eaa118c..331e5bd 100644 Binary files a/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache and b/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/obj/Debug/compabetov2.csproj.AssemblyReference.cache b/obj/Debug/compabetov2.csproj.AssemblyReference.cache index 46c7c97..6e284d8 100644 Binary files a/obj/Debug/compabetov2.csproj.AssemblyReference.cache and b/obj/Debug/compabetov2.csproj.AssemblyReference.cache differ diff --git a/obj/Debug/compabetov2.csproj.FileListAbsolute.txt b/obj/Debug/compabetov2.csproj.FileListAbsolute.txt index b96bd7a..08b0e48 100644 --- a/obj/Debug/compabetov2.csproj.FileListAbsolute.txt +++ b/obj/Debug/compabetov2.csproj.FileListAbsolute.txt @@ -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.application 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 diff --git a/obj/Debug/compabetov2.exe b/obj/Debug/compabetov2.exe index 1bb74c7..9c47dd5 100644 Binary files a/obj/Debug/compabetov2.exe and b/obj/Debug/compabetov2.exe differ diff --git a/obj/Debug/compabetov2.pdb b/obj/Debug/compabetov2.pdb index 3943f8d..d2f5e52 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ diff --git a/personal.cs b/personal.cs index 9a2353b..dbc8493 100644 --- a/personal.cs +++ b/personal.cs @@ -92,9 +92,8 @@ namespace compabetov2 private void button8_Click(object sender, EventArgs e) { - int idEmpelado; int fila = dataGridView1.CurrentCell.RowIndex; - MessageBox.Show(fila + ""); + int idEmpleado = int.Parse(dataGridView1.Rows[fila].Cells[0].Value.ToString()); Empleado empleado = new Empleado(); } diff --git a/vender.cs b/vender.cs index 36f753c..31bf404 100644 --- a/vender.cs +++ b/vender.cs @@ -27,9 +27,7 @@ namespace compabetov2 private bool menosBtnPresionado = false; private List productos; private List cartas = new List(); - // private List private decimal total = 0; - private Label ticketLabel; @@ -113,6 +111,7 @@ namespace compabetov2 btnMenos.BackColor = Color.FromArgb(33, 90, 255); btnMenos.Click += new EventHandler(delegate (object sender, EventArgs e) { + int numeroContador = int.Parse(contador.Text.ToString()); // Validar que el contador no sea 0 antes de restar @@ -120,11 +119,19 @@ namespace compabetov2 { contador.Text = (numeroContador - 1).ToString(); 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 { // 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()); contador.Text = (numeroContador + 1).ToString(); total += producto.precion; - - - + label1.Text = $"Total: ${total}"; // Obtener información del Label id y precio 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) { bool existeProducto = false;