busqueda de productos
This commit is contained in:
+10
-8
@@ -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;
|
||||||
|
|
||||||
@@ -173,10 +170,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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -677,8 +671,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()
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user