public List<Plato> GetPlato(string filtro, int id) { List<Plato> listPlato = new List<Plato>(); con.Ejecutar(query: $"SELECT * FROM tbl_menu WHERE nombre LIKE %{filtro}% OR id = {id}"); Plato m; if (con.rs.Read()) { m = new Plato { Id = con.rs.GetInt32(0), Nombre = con.rs.GetString(1), Precio = con.rs.GetInt32(2) }; listPlato.Add(m); } return listPlato; }
public List<Plato> GetPlatos() { List<Plato> listPlato = new List<Plato>(); con.Ejecutar(query: "SELECT * FROM tbl_menu"); Plato m; while (con.rs.Read()) { m = new Plato { Id = con.rs.GetInt32(0), Nombre = con.rs.GetString(1), Precio = con.rs.GetInt32(2) }; listPlato.Add(m); } return listPlato; }
public void AgregarPlato(Plato m) { string query = $"INSERT INTO tbl_menu VALUES('{m.Nombre}',{m.Precio});"; con.Ejecutar(query); }