From 5d92bb9b45fdf29806742653afe065a1a2f5bf78 Mon Sep 17 00:00:00 2001 From: arminribic Date: Fri, 17 May 2024 10:26:41 +0200 Subject: [PATCH] #7: (WIP) calculateDeleteDate --- db/nursingHome.db | Bin 28672 -> 28672 bytes .../treatment/AllTreatmentController.java | 15 ++------- .../treatment/LockedTreatmentController.java | 29 ++++++++++++++---- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/db/nursingHome.db b/db/nursingHome.db index beb720ff76add8a8682f00c90be513d5bbf8dbf8..8ef2588a1444fcf6109b2c9b050f1719628d572d 100644 GIT binary patch delta 351 zcmZp8z}WDBae}m9IRgU&I}pRb+KD>GlI09~MGJZP{xYy}R59?a=97<`kz+{>a(S=(D(yi;=l8IAHP&ZZk&q$>+J}G5Sx= z<56H_+uYBi&&cSzc|WfulNy^J8`w5pAj!?Oj)7l*Plb0AZxGKho;2>y+=sc%xUO@p z+bk#0%Vnv>&85!G#lXp^C@wB4%E@G8U|^tYV5)0qZfIa-WC|pV4HAn}(m*(ti<^Ow z6R1$Ik(qPz6Ddm;MvlpH@=y3yF|hE@7UO@#f1iIg|BlUq3f=sHyjINej3q^>i6yzI zc_rNZXBqeyb5m0?lM_oa^ZBfq6%o8VHtsy2Akej3oOz{1#X$9$`FU&toSc@-;*4Ms VW^RkkZ}cS;HnSxB;a?OW001sATD<@O delta 359 zcmZp8z}WDBae}m<2?GNII}pRb;)y!Ok|qp#MGJYk8yVO*(ir$wbJg+g;Yj1j=AOFQ zP=J$tawGfC&3zn2jI3^sKEbY&S-JWd-4{>gVif25%OE0dZqC@`T9TNQlbV~Fl9}8X z>^*q~w;3bb*OXJqu)yr0*SY4U$gHU%zCUZ4xOxUMts3-GD% zZsHB%ImVO5{h9kPw;9)Uu6>*31bVqFO?3@Sbqy^IO{`1|3{9;J44s@5xj7ja85PCF z`T5ydj0}uSz)H*vEMvL285lW%5`vA)9Gjm=S+X#4PL`8@!grQ|g@2U*|119c{JZ#9 zZ5CAM;-476<-x1REYDcNXU?q12zGa3NoIZ?8?PBiv?w*PBsVp$gewmy2y`buCz28Y gPEJ#1amKvTqT*C$Zj;S#^d%HFvn2fCUlbq!0B8$a3;+NC diff --git a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java index df8b368..fb88dcd 100644 --- a/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java +++ b/src/main/java/de/hitec/nhplus/treatment/AllTreatmentController.java @@ -20,6 +20,7 @@ import javafx.stage.Stage; import java.io.IOException; import java.sql.SQLException; +import java.time.LocalDate; import java.util.ArrayList; /** @@ -109,6 +110,7 @@ public class AllTreatmentController { ); this.createComboBoxData(); + } /** @@ -258,18 +260,6 @@ public class AllTreatmentController { } } - @FXML - public void handleDelete() { - int index = this.tableView.getSelectionModel().getSelectedIndex(); - Treatment t = this.treatments.remove(index); - TreatmentDao dao = DaoFactory.getInstance().createTreatmentDao(); - try { - dao.delete(t.getId()); - } catch (SQLException exception) { - exception.printStackTrace(); - } - } - @FXML public void handleNewTreatment() { String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem(); @@ -333,4 +323,5 @@ public class AllTreatmentController { readAllAndShowInTableView(); } + } diff --git a/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java b/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java index 3594afd..cec5a76 100644 --- a/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java +++ b/src/main/java/de/hitec/nhplus/treatment/LockedTreatmentController.java @@ -51,6 +51,7 @@ public class LockedTreatmentController { * that is called after the binding of all the fields. */ public void initialize() { + handleDelete(); this.readAllAndShowInTableView(); this.columnId.setCellValueFactory(new PropertyValueFactory<>("id")); @@ -101,11 +102,27 @@ public class LockedTreatmentController { readAllAndShowInTableView(); } + @FXML + public void handleDelete() { + Treatment selecteditem; + LocalDate today = LocalDate.now();//Ändern!!!!! + LocalDate deleteDate; + + for (int i = 0; i < treatments.size(); i++) { + selecteditem = treatments.get(i); + deleteDate = selecteditem.calculateDeleteDate(); + if (today.isEqual(deleteDate) || today.isBefore(deleteDate)) { + try { + treatmentDao.delete(selecteditem.getId()); + System.out.println("Wird gelöscht"); + } catch (SQLException exception) { + exception.printStackTrace(); + } + } + + } + + } + } - - -/* -Button zum entsperren -Column fürs Datum, wann es gesperrt wird, ID(zum später löschen) - */ \ No newline at end of file