Descargo Cambios de CARLOS0102243
This commit is contained in:
@@ -79,8 +79,6 @@ namespace compabetov2
|
|||||||
inventario inventario = new inventario(loginPrincipal);
|
inventario inventario = new inventario(loginPrincipal);
|
||||||
inventario.Show();
|
inventario.Show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lblfecha_Click(object sender, EventArgs e)
|
private void lblfecha_Click(object sender, EventArgs e)
|
||||||
@@ -99,19 +97,35 @@ namespace compabetov2
|
|||||||
|
|
||||||
// Mostrar el formulario de ventas
|
// Mostrar el formulario de ventas
|
||||||
|
|
||||||
|
if (loginPrincipal.tipo.Equals("empleado"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Usted no tiene permisos de acceder a este apartado");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
personal personal = new personal(loginPrincipal);
|
personal personal = new personal(loginPrincipal);
|
||||||
|
|
||||||
personal.Show();
|
personal.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBox3_Click(object sender, EventArgs e)
|
private void pictureBox3_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (loginPrincipal.tipo.Equals("empleado"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Usted no tiene permisos de acceder a este apartado");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
envios envios = new envios(loginPrincipal);
|
envios envios = new envios(loginPrincipal);
|
||||||
|
|
||||||
envios.Show();
|
envios.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -120,7 +134,6 @@ namespace compabetov2
|
|||||||
{
|
{
|
||||||
cuentas cuentas = new cuentas(loginPrincipal);
|
cuentas cuentas = new cuentas(loginPrincipal);
|
||||||
cuentas.Show();
|
cuentas.Show();
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pictureBox6_Click(object sender, EventArgs e)
|
private void pictureBox6_Click(object sender, EventArgs e)
|
||||||
@@ -170,11 +183,20 @@ namespace compabetov2
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void button2_Click(object sender, EventArgs e)
|
private void button2_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (loginPrincipal.tipo.Equals("empleado"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Usted no tiene permisos de acceder a este apartado");
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Estadiscticas estadiscticas = new Estadiscticas();
|
Estadiscticas estadiscticas = new Estadiscticas();
|
||||||
estadiscticas.Show();
|
estadiscticas.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+51
-10
@@ -22,10 +22,7 @@ namespace compabetov2
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
private bool masBtnPresionado = false;
|
|
||||||
private bool menosBtnPresionado = false;
|
|
||||||
private List<Producto> productos;
|
private List<Producto> productos;
|
||||||
private List<TableLayoutPanel> cartas = new List<TableLayoutPanel>();
|
|
||||||
private decimal total = 0;
|
private decimal total = 0;
|
||||||
private LoginModel loginPrincipal;
|
private LoginModel loginPrincipal;
|
||||||
|
|
||||||
@@ -120,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;
|
||||||
@@ -135,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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -155,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;
|
||||||
@@ -173,10 +173,7 @@ namespace compabetov2
|
|||||||
|
|
||||||
carta.Controls.Add(pic, 0, 0);
|
carta.Controls.Add(pic, 0, 0);
|
||||||
carta.Controls.Add(HUD, 0, 1);
|
carta.Controls.Add(HUD, 0, 1);
|
||||||
cartas.Add(carta);
|
|
||||||
flowLayoutPanel3.Controls.Add(carta);
|
flowLayoutPanel3.Controls.Add(carta);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -185,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)
|
||||||
{
|
{
|
||||||
@@ -207,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);
|
||||||
@@ -222,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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,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)
|
||||||
{
|
{
|
||||||
@@ -432,6 +463,7 @@ namespace compabetov2
|
|||||||
MessageBox.Show("Venta hecha");
|
MessageBox.Show("Venta hecha");
|
||||||
eliminarProductosTocket();
|
eliminarProductosTocket();
|
||||||
llenarLayout();
|
llenarLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -677,8 +709,16 @@ namespace compabetov2
|
|||||||
|
|
||||||
private void txtbusqueda_TextChanged(object sender, EventArgs e)
|
private void txtbusqueda_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
if (!txtbusqueda.Text.Equals(""))
|
||||||
|
{
|
||||||
|
productos = service.conseguirProductosFiltrados(txtbusqueda.Text);
|
||||||
|
llenarLayout();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
getData();
|
||||||
|
llenarLayout();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DetalleEnvioModel> listaProductosEnvio()
|
private List<DetalleEnvioModel> listaProductosEnvio()
|
||||||
@@ -749,6 +789,7 @@ namespace compabetov2
|
|||||||
flowLayoutPanel1.Controls.Remove(c);
|
flowLayoutPanel1.Controls.Remove(c);
|
||||||
}
|
}
|
||||||
label1.Text = "Total: 0";
|
label1.Text = "Total: 0";
|
||||||
|
txtbusqueda.Text = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1483,6 +1483,31 @@ namespace compabetov2.database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SQLiteDataReader conseguirProductosFiltradosDAO(string nombreProducto)
|
||||||
|
{
|
||||||
|
SQLiteDataReader reader = null;
|
||||||
|
var db_conexion = new Conexion();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SQLiteConnection conexion = db_conexion.get_connection();
|
||||||
|
|
||||||
|
conexion.Open();
|
||||||
|
|
||||||
|
string sql = "SELECT * FROM Producto WHERE nombre LIKE @nombre";
|
||||||
|
SQLiteCommand command = new SQLiteCommand(sql, conexion);
|
||||||
|
command.Parameters.AddWithValue("@nombre", $"%{nombreProducto}%");
|
||||||
|
reader = command.ExecuteReader();
|
||||||
|
|
||||||
|
return reader;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLiteException ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message);
|
||||||
|
return reader;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void crearDB()
|
private static void crearDB()
|
||||||
{
|
{
|
||||||
var db_conexion = new Conexion();
|
var db_conexion = new Conexion();
|
||||||
|
|||||||
@@ -439,5 +439,26 @@ namespace compabetov2.database
|
|||||||
|
|
||||||
return resumen;
|
return resumen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Producto> conseguirProductosFiltrados(string nombreProducto) {
|
||||||
|
List<Producto> productos = new List<Producto>();
|
||||||
|
SQLiteDataReader reader = DAO.conseguirProductosFiltradosDAO(nombreProducto);
|
||||||
|
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
Producto producto = new Producto(
|
||||||
|
int.Parse(reader["idproducto"].ToString()),
|
||||||
|
reader["nombre"].ToString(),
|
||||||
|
reader["descripcion"].ToString(),
|
||||||
|
decimal.Parse(reader["precio"].ToString()),
|
||||||
|
reader["img"].ToString(),
|
||||||
|
int.Parse(reader["stock"].ToString())
|
||||||
|
);
|
||||||
|
|
||||||
|
productos.Add(producto);
|
||||||
|
}
|
||||||
|
|
||||||
|
return productos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user