agrea productos en venta despues de buscar un producto
This commit is contained in:
+39
-2
@@ -117,7 +117,8 @@ namespace compabetov2
|
|||||||
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
|
||||||
if (numeroContador > 0)
|
|
||||||
|
if (existeTocket(producto.nombre))
|
||||||
{
|
{
|
||||||
contador.Text = (numeroContador - 1).ToString();
|
contador.Text = (numeroContador - 1).ToString();
|
||||||
total -= producto.precion;
|
total -= producto.precion;
|
||||||
@@ -132,7 +133,6 @@ namespace compabetov2
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Mostrar mensaje de advertencia
|
|
||||||
MessageBox.Show("No puedes vender menos de 0 cosas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
MessageBox.Show("No puedes vender menos de 0 cosas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -152,6 +152,9 @@ namespace compabetov2
|
|||||||
btnMas.FlatAppearance.BorderSize = 0;
|
btnMas.FlatAppearance.BorderSize = 0;
|
||||||
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
|
btnMas.Click += new EventHandler(delegate (object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if(int.Parse(contador.Text.ToString()) < 0 && !existeTocket(producto.nombre)) {
|
||||||
|
contador.Text = "0";
|
||||||
|
}
|
||||||
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;
|
||||||
@@ -179,6 +182,7 @@ namespace compabetov2
|
|||||||
{
|
{
|
||||||
foreach (var item in flowLayoutPanel2.Controls)
|
foreach (var item in flowLayoutPanel2.Controls)
|
||||||
{
|
{
|
||||||
|
|
||||||
TableLayoutPanel panelProducto = item as TableLayoutPanel;
|
TableLayoutPanel panelProducto = item as TableLayoutPanel;
|
||||||
if (panelProducto != null && panelProducto.Controls.Count > 1)
|
if (panelProducto != null && panelProducto.Controls.Count > 1)
|
||||||
{
|
{
|
||||||
@@ -201,6 +205,8 @@ namespace compabetov2
|
|||||||
{
|
{
|
||||||
string textcantidad = Lbcantidad.Text;
|
string textcantidad = Lbcantidad.Text;
|
||||||
string[] cantidadCadenas = textcantidad.Split(' ');
|
string[] cantidadCadenas = textcantidad.Split(' ');
|
||||||
|
if(int.Parse(cantidadCadenas[1]) > 0)
|
||||||
|
{
|
||||||
int NuevaCantiad = int.Parse(cantidadCadenas[1]) - cantidad;
|
int NuevaCantiad = int.Parse(cantidadCadenas[1]) - cantidad;
|
||||||
|
|
||||||
int NuevoTotal = (int)(NuevaCantiad * precio);
|
int NuevoTotal = (int)(NuevaCantiad * precio);
|
||||||
@@ -216,6 +222,12 @@ namespace compabetov2
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Mostrar mensaje de advertencia
|
||||||
|
MessageBox.Show("No puedes vender menos de 0 cosas", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,6 +235,31 @@ namespace compabetov2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool existeTocket(string nombreProducto)
|
||||||
|
{
|
||||||
|
int contador_saltar_2_vueltas = 1;
|
||||||
|
foreach (var item in flowLayoutPanel2.Controls)
|
||||||
|
{
|
||||||
|
if (contador_saltar_2_vueltas <= 3)
|
||||||
|
{
|
||||||
|
contador_saltar_2_vueltas++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
TableLayoutPanel panelProducto = item as TableLayoutPanel;
|
||||||
|
TableLayoutPanel panelInfo = panelProducto.Controls[1] as TableLayoutPanel;
|
||||||
|
Label lbnombre = panelInfo.Controls[0] as Label;
|
||||||
|
string textoLb = lbnombre.Text;
|
||||||
|
string[] cadenas = textoLb.Split(':');
|
||||||
|
string cadena = cadenas[1].Remove(0, 1);
|
||||||
|
|
||||||
|
if (cadena.Equals(nombreProducto))
|
||||||
|
{
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user