busqueda de productos lista

This commit is contained in:
carlos
2024-02-15 01:39:16 -06:00
parent ea999a41e8
commit dfbb52c78a
7 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -787,7 +787,7 @@ namespace compabetov2
{ {
if (!txtbusqueda.Text.Equals("")) if (!txtbusqueda.Text.Equals(""))
{ {
//productos = service.conseguirProductosFiltrados(txtbusqueda.Text); productos = service.conseguirProductosFiltrados(txtbusqueda.Text);
llenarLayout(); llenarLayout();
} }
else else
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -1566,7 +1566,7 @@ namespace compabetov2.database
conexion.Open(); conexion.Open();
string sql = "SELECT * FROM Producto WHERE nombre LIKE @nombre"; string sql = "SELECT * FROM variantes WHERE nombre LIKE @nombre";
SQLiteCommand command = new SQLiteCommand(sql, conexion); SQLiteCommand command = new SQLiteCommand(sql, conexion);
command.Parameters.AddWithValue("@nombre", $"%{nombreProducto}%"); command.Parameters.AddWithValue("@nombre", $"%{nombreProducto}%");
reader = command.ExecuteReader(); reader = command.ExecuteReader();
+8 -8
View File
@@ -438,28 +438,28 @@ namespace compabetov2.database
return resumen; return resumen;
} }
public static List<Producto> conseguirProductosFiltrados(string nombreProducto) public static List<Variante> conseguirProductosFiltrados(string nombreProducto)
{ {
List<Producto> productos = new List<Producto>(); List<Variante> productos = new List<Variante>();
SQLiteDataReader reader = DAO.conseguirProductosFiltradosDAO(nombreProducto); SQLiteDataReader reader = DAO.conseguirProductosFiltradosDAO(nombreProducto);
int idIndex = reader.GetOrdinal("idproducto"); int idIndex = reader.GetOrdinal("idVariante");
int nombreIndex = reader.GetOrdinal("nombre"); int nombreIndex = reader.GetOrdinal("nombre");
int descripcionIndex = reader.GetOrdinal("descripcion");
int precioIndex = reader.GetOrdinal("precio"); int precioIndex = reader.GetOrdinal("precio");
int cantidadIndex = reader.GetOrdinal("cantidad");
int imgIndex = reader.GetOrdinal("img"); int imgIndex = reader.GetOrdinal("img");
int stockIndex = reader.GetOrdinal("stock"); int fkProductoIndex = reader.GetOrdinal("fk_producto");
while (reader.Read()) while (reader.Read())
{ {
Producto producto = new Producto( Variante producto = new Variante(
reader.GetInt32(idIndex), reader.GetInt32(idIndex),
reader.GetString(nombreIndex), reader.GetString(nombreIndex),
reader.GetString(descripcionIndex),
reader.GetDecimal(precioIndex), reader.GetDecimal(precioIndex),
reader.GetInt32(cantidadIndex),
reader.GetString(imgIndex), reader.GetString(imgIndex),
reader.GetInt32(stockIndex) reader.GetInt32(fkProductoIndex)
); );
productos.Add(producto); productos.Add(producto);
Binary file not shown.
Binary file not shown.