diff --git a/db/nursingHome.db b/db/nursingHome.db index fbd0833..4febd50 100644 Binary files a/db/nursingHome.db and b/db/nursingHome.db differ diff --git a/src/main/java/de/hitec/nhplus/controller/AllNurseController.java b/src/main/java/de/hitec/nhplus/controller/AllNurseController.java new file mode 100644 index 0000000..3bd75bb --- /dev/null +++ b/src/main/java/de/hitec/nhplus/controller/AllNurseController.java @@ -0,0 +1,59 @@ +package de.hitec.nhplus.controller; + +import de.hitec.nhplus.datastorage.DaoFactory; +import de.hitec.nhplus.datastorage.NurseDao; +import de.hitec.nhplus.model.Nurse; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.cell.TextFieldTableCell; + +import java.sql.SQLException; + +public class AllNurseController { + + @FXML + private TableView tableView; + @FXML + private TableColumn columnId; + @FXML + private TableColumn columnFirstName; + @FXML + private TableColumn columnSurname; + @FXML + private TableColumn columnPhoneNumber; + + private final ObservableList nurses = FXCollections.observableArrayList(); + private NurseDao dao; + + public void initialize() { + this.readAllAndSHowInTableView(); + + this.columnId.setCellValueFactory(new PropertyValueFactory<>("nid")); + + this.columnFirstName.setCellValueFactory(new PropertyValueFactory<>("firstName")); + this.columnFirstName.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.columnSurname.setCellValueFactory(new PropertyValueFactory<>("surname")); + this.columnSurname.setCellFactory(TextFieldTableCell.forTableColumn()); + + + this.columnPhoneNumber.setCellValueFactory(new PropertyValueFactory<>("phoneNumber")); + this.columnPhoneNumber.setCellFactory(TextFieldTableCell.forTableColumn()); + + this.tableView.setItems(this.nurses); + } + + private void readAllAndSHowInTableView(){ + this.nurses.clear(); + this.dao = DaoFactory.getDaoFactory().createNurseDAO(); + try { + this.nurses.addAll(this.dao.readAll()); + }catch (SQLException exception){ + exception.printStackTrace(); + } + } +} diff --git a/src/main/java/de/hitec/nhplus/controller/MainWindowController.java b/src/main/java/de/hitec/nhplus/controller/MainWindowController.java index 862380d..85b9f36 100644 --- a/src/main/java/de/hitec/nhplus/controller/MainWindowController.java +++ b/src/main/java/de/hitec/nhplus/controller/MainWindowController.java @@ -36,4 +36,14 @@ public class MainWindowController { exception.printStackTrace(); } } + + @FXML + private void handleShowAllNurses(ActionEvent event){ + FXMLLoader loader = new FXMLLoader(Main.class.getResource("/de/hitec/nhplus/AllNurseView.fxml")); + try { + mainBorderPane.setCenter(loader.load()); + }catch (IOException exception){ + exception.printStackTrace(); + } + } } diff --git a/src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml b/src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml deleted file mode 100644 index 8e82ca1..0000000 --- a/src/main/resources/de/hitec/nhplus/AllCaregiverView.fxml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + +