From 76d41599d9aba498bbb5a59d3ee5b615d5a1a5f5 Mon Sep 17 00:00:00 2001 From: dengrenjie Date: Sun, 12 May 2019 20:16:55 +0800 Subject: [PATCH 1/2] Fix double conversion bug --- src/model/RecipeForm.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/model/RecipeForm.java b/src/model/RecipeForm.java index 838a15e..b4c964e 100644 --- a/src/model/RecipeForm.java +++ b/src/model/RecipeForm.java @@ -35,12 +35,6 @@ public boolean save() { private boolean insert() { recipe.setIngredients(recipeIngredients); - try { - recipe.amountConversion(batchSize, 1000); - } catch (InvalidInputException e) { - e.printStackTrace(); - return false; - } return recipe.insert(); } From bd863e256a2fb887e333ea655e4e481adbb24e95 Mon Sep 17 00:00:00 2001 From: dengrenjie Date: Sun, 12 May 2019 20:17:23 +0800 Subject: [PATCH 2/2] Fix could not delete recipe ingredient problem --- src/model/Recipe.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/model/Recipe.java b/src/model/Recipe.java index d34bd0e..1fbfb70 100644 --- a/src/model/Recipe.java +++ b/src/model/Recipe.java @@ -215,7 +215,7 @@ public boolean insert() { @Override public boolean delete() { DatabaseHelper dbHelper = new DatabaseHelper(); - boolean status; + boolean status = true; String query = String.format("DELETE FROM Recipe WHERE Recipe_ID=%d", this.getID()); try { @@ -225,13 +225,9 @@ public boolean delete() { e.printStackTrace(); return false; } - for (RecipeIngredient ingredient : ingredients) { - status = ingredient.delete(); - if (!status) - return false; - } + status = RecipeIngredient.deleteAll(this.getID()); notifyListener(); - return true; + return status; } @Override