From d75cb0a32fd28a9630b9bdf7e5f8e2011e17965d Mon Sep 17 00:00:00 2001 From: Jens Date: Wed, 28 Apr 2021 23:19:51 +0200 Subject: [PATCH] Amount/Unit progress --- .../rhasspy/shoppinglist/ShoppingListEntry.java | 14 +++++++------- .../src/com/jens/rhasspy/shoppinglist/Start.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ShoppingList/src/com/jens/rhasspy/shoppinglist/ShoppingListEntry.java b/ShoppingList/src/com/jens/rhasspy/shoppinglist/ShoppingListEntry.java index 7591fa6..895706f 100644 --- a/ShoppingList/src/com/jens/rhasspy/shoppinglist/ShoppingListEntry.java +++ b/ShoppingList/src/com/jens/rhasspy/shoppinglist/ShoppingListEntry.java @@ -85,7 +85,7 @@ public class ShoppingListEntry } else { - updateAmount(); + return updateAmount(); } } catch(Exception e) @@ -182,11 +182,11 @@ public class ShoppingListEntry if(currentAmount + this.getAmount() > 0) { // Update the amount - String updateQuery = "UPDATE listEntries set=? WHERE listId=? AND productId=? AND unit=?"; + String updateQuery = "UPDATE listEntries set amount=? WHERE listId=? AND productId=? AND unit=?"; preparedStmt = conn.prepareStatement(updateQuery); preparedStmt.setFloat(1, currentAmount + this.getAmount()); - preparedStmt.setLong(2, this.getProduct().getId()); + preparedStmt.setLong(2, this.getParentList().getId()); preparedStmt.setLong(3, this.getProduct().getId()); preparedStmt.setLong(4, this.getUnit().getId()); @@ -194,11 +194,11 @@ public class ShoppingListEntry long numAffectedRows = preparedStmt.executeUpdate(); Miscellaneous.logEvent("AMOUNT OF UPDATED ROWS: " + numAffectedRows, 5); - ResultSet rs = preparedStmt.getGeneratedKeys(); +// ResultSet rs = preparedStmt.getGeneratedKeys(); if (numAffectedRows > 0) { Miscellaneous.logEvent("Amount added to existing entry.", 2); - rs.close(); +// rs.close(); preparedStmt.close(); return true; } @@ -217,11 +217,11 @@ public class ShoppingListEntry long numAffectedRows = preparedStmt.executeUpdate(); Miscellaneous.logEvent("AMOUNT OF UPDATED ROWS: " + numAffectedRows, 5); - ResultSet rs = preparedStmt.getGeneratedKeys(); +// ResultSet rs = preparedStmt.getGeneratedKeys(); if (numAffectedRows > 0) { Miscellaneous.logEvent("Resulting amount < 0, entry deleted.", 2); - rs.close(); +// rs.close(); preparedStmt.close(); return true; } diff --git a/ShoppingList/src/com/jens/rhasspy/shoppinglist/Start.java b/ShoppingList/src/com/jens/rhasspy/shoppinglist/Start.java index 49ec03f..a9d52be 100644 --- a/ShoppingList/src/com/jens/rhasspy/shoppinglist/Start.java +++ b/ShoppingList/src/com/jens/rhasspy/shoppinglist/Start.java @@ -111,7 +111,7 @@ public class Start exitWithError(Settings.languageBlock.get("productNotFound") + " " + productName); for(ShoppingListEntry entry : list.getEntries()) - { + {bestehende reduzieren if(entry.getProduct().equals(p)) { if(entry.delete())