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 8e670a6..b7edf8f 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 f178e35..647fc73 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 332d002..10a1a65 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..ed74861 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.CoreCompileInputs.cache b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache index 8f1bb2d..7ea0549 100644 --- a/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache +++ b/obj/Debug/compabetov2.csproj.CoreCompileInputs.cache @@ -1 +1 @@ -424f6d4f8bcbc47e89c98d2fa689cb77dffd9f6b5116717e9e8dca5ece3777d7 +c1cf5d87017027705d6c2ec0d3ad2a8c7ff08f19 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.csproj.GenerateResource.cache b/obj/Debug/compabetov2.csproj.GenerateResource.cache index 02cf15a..c58add2 100644 Binary files a/obj/Debug/compabetov2.csproj.GenerateResource.cache and b/obj/Debug/compabetov2.csproj.GenerateResource.cache differ diff --git a/obj/Debug/compabetov2.exe b/obj/Debug/compabetov2.exe index 8e670a6..b7edf8f 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 f178e35..647fc73 100644 Binary files a/obj/Debug/compabetov2.pdb and b/obj/Debug/compabetov2.pdb differ diff --git a/vender.cs b/vender.cs index 36f753c..b22e923 100644 --- a/vender.cs +++ b/vender.cs @@ -120,11 +120,18 @@ namespace compabetov2 { contador.Text = (numeroContador - 1).ToString(); total -= producto.precion; + + // 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); } }); @@ -190,6 +197,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;