#7: (WIP) calculateDeleteDate
Some checks failed
Quality Check / Linting Check (push) Failing after 12s
Quality Check / Javadoc Check (push) Successful in 21s

This commit is contained in:
arminribic 2024-05-17 10:26:41 +02:00
parent 331c5697f1
commit 5d92bb9b45
3 changed files with 26 additions and 18 deletions

Binary file not shown.

View file

@ -20,6 +20,7 @@ import javafx.stage.Stage;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
@ -109,6 +110,7 @@ public class AllTreatmentController {
); );
this.createComboBoxData(); 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 @FXML
public void handleNewTreatment() { public void handleNewTreatment() {
String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem(); String selectedPatient = this.comboBoxPatientSelection.getSelectionModel().getSelectedItem();
@ -333,4 +323,5 @@ public class AllTreatmentController {
readAllAndShowInTableView(); readAllAndShowInTableView();
} }
} }

View file

@ -51,6 +51,7 @@ public class LockedTreatmentController {
* that is called after the binding of all the fields. * that is called after the binding of all the fields.
*/ */
public void initialize() { public void initialize() {
handleDelete();
this.readAllAndShowInTableView(); this.readAllAndShowInTableView();
this.columnId.setCellValueFactory(new PropertyValueFactory<>("id")); this.columnId.setCellValueFactory(new PropertyValueFactory<>("id"));
@ -101,11 +102,27 @@ public class LockedTreatmentController {
readAllAndShowInTableView(); 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)
*/