public static int findCategorierID(String name) { for (Categorier cat : CategorierList) { if (cat.getNomCategorier() == name) { return cat.getIdcat(); } } return 0; }
// ************************************************************************* public String findUniterNameCat(int id) { for (Categorier cat : CategorierList) { if (cat.getIdcat() == id) { return findUniterName(cat.getIduniter()); } } return null; }
public String findCategorierName(int id) { for (Categorier cat : CategorierList) { if (cat.getIdcat() == id) { return cat.getNomCategorier(); } } return null; }
public void categorier() { String sql = "SELECT * FROM categorier"; try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql); ) { // System.out.println("uniter Table:"); while (rs.next()) { Categorier categorier = new Categorier(); categorier.setIdcat(rs.getInt("idcat")); categorier.setNomCategorier(rs.getString("nomcat")); categorier.setIduniter(rs.getInt("iduniter")); CategorierList.add(categorier); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }