From bf7a102bb2f636b33a086d095f773d0b3c3f0c0d Mon Sep 17 00:00:00 2001 From: laurimaaninka Date: Sun, 12 Apr 2026 16:44:02 +0300 Subject: [PATCH 1/2] Haara luotu Signed-off-by: laurimaaninka --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90697d0..0ca2c3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 2.0.0-pre +- Asiakkaalle laskutusosoite? + # 1.1.0 - Kuljetuslistaa luodessa kuljetusrivin nollaaminen/palauttaminen oletusmääriin. - Kuljetuslistojen ja raporttien tulostamismekanismin läpikäynti From 8d1a0ccf3d1d6ced5f74ae5cfcc571b6d88c6810 Mon Sep 17 00:00:00 2001 From: laurimaaninka Date: Sun, 12 Apr 2026 17:19:11 +0300 Subject: [PATCH 2/2] =?UTF-8?q?Lis=C3=A4tty=20laskutustieto=20tietokantaan?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: laurimaaninka --- .idea/sqldialects.xml | 1 + .../java/fi/lpam/dataluokat/Tietokanta.java | 37 +++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/.idea/sqldialects.xml b/.idea/sqldialects.xml index c0e01ca..2d4858e 100644 --- a/.idea/sqldialects.xml +++ b/.idea/sqldialects.xml @@ -1,6 +1,7 @@ + \ No newline at end of file diff --git a/src/main/java/fi/lpam/dataluokat/Tietokanta.java b/src/main/java/fi/lpam/dataluokat/Tietokanta.java index 1e86632..ed47c54 100644 --- a/src/main/java/fi/lpam/dataluokat/Tietokanta.java +++ b/src/main/java/fi/lpam/dataluokat/Tietokanta.java @@ -1,10 +1,8 @@ package fi.lpam.dataluokat; import fi.lpam.gui.virheDialogit.SiirtoVirhe; -import fi.lpam.gui.virheDialogit.YhteysVirhe; import fi.lpam.Main; -import javafx.scene.control.Alert; import org.apache.commons.lang3.SystemUtils; import java.io.*; @@ -15,16 +13,14 @@ public class Tietokanta { private static String osoite; private static String dbPath = SystemUtils.getUserHome().getAbsolutePath() + "\\OneDrive\\Kuljetusruokasovellus\\tietokanta.db"; - public Tietokanta(boolean dev) throws IOException { + public Tietokanta(boolean dev) { if (dev) dbPath = "testikanta.db"; File file = new File(dbPath); try { - //noinspection ResultOfMethodCallIgnored - file.getParentFile().mkdirs(); + boolean _ = file.getParentFile().mkdirs(); + boolean _ = file.createNewFile(); } catch (Exception _) {} - //noinspection ResultOfMethodCallIgnored - file.createNewFile(); osoite = "jdbc:sqlite:" + file.getAbsolutePath(); @@ -37,24 +33,35 @@ public class Tietokanta { for (String query : sql.split(";")) { conn.createStatement().execute(query); } - } - catch (Exception e) { - SiirtoVirhe virhe = new SiirtoVirhe(e); - virhe.showAndWait(); + catch (SQLException | IOException e) { + handleException(e); } + //Lisää laskutustietokenttä Asiakkaat tauluun + try (Connection conn = haeYhteys()) { + Statement stmt = conn.createStatement(); + stmt.execute("alter table asiakkaat add column laskutustieto TEXT"); + } + catch (SQLException e) { + if (!e.getMessage().contains("duplicate column name: laskutustieto")) { + handleException(e); + } + } } public static Connection haeYhteys() { - Connection connection = null; try { connection = DriverManager.getConnection(osoite); - } catch (Exception e) { - Alert virhe = new YhteysVirhe(e); - virhe.showAndWait(); + } catch (SQLException e) { + handleException(e); } return connection; } + + private static void handleException(Exception e) { + SiirtoVirhe virhe = new SiirtoVirhe(e); + virhe.showAndWait(); + } } \ No newline at end of file