#7 Sperren/Entsperren
This commit is contained in:
parent
b5f4e1ad0d
commit
d2e41c06f2
5 changed files with 36 additions and 7 deletions
Binary file not shown.
|
@ -61,7 +61,7 @@ public class AllTreatmentController {
|
||||||
public ComboBox<String> comboBoxNurseSelection;
|
public ComboBox<String> comboBoxNurseSelection;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private Button buttonDelete;
|
private Button buttonLock;
|
||||||
|
|
||||||
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
||||||
private TreatmentDao dao;
|
private TreatmentDao dao;
|
||||||
|
@ -100,12 +100,12 @@ public class AllTreatmentController {
|
||||||
this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
|
this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
|
||||||
this.tableView.setItems(this.treatments);
|
this.tableView.setItems(this.treatments);
|
||||||
|
|
||||||
this.buttonDelete.setDisable(true);
|
this.buttonLock.setDisable(true);
|
||||||
this.tableView
|
this.tableView
|
||||||
.getSelectionModel()
|
.getSelectionModel()
|
||||||
.selectedItemProperty()
|
.selectedItemProperty()
|
||||||
.addListener((observableValue, oldTreatment, newTreatment) ->
|
.addListener((observableValue, oldTreatment, newTreatment) ->
|
||||||
AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null)
|
AllTreatmentController.this.buttonLock.setDisable(newTreatment == null)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.createComboBoxData();
|
this.createComboBoxData();
|
||||||
|
@ -316,4 +316,21 @@ public class AllTreatmentController {
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void handleLock(){
|
||||||
|
Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
selectedItem.setLocked(true);
|
||||||
|
this.dao.update(selectedItem);
|
||||||
|
}catch (SQLException exception){
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
readAllAndShowInTableView();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,9 +87,21 @@ public class LockedTreatmentController {
|
||||||
@FXML
|
@FXML
|
||||||
private void unlockTreatment()
|
private void unlockTreatment()
|
||||||
{
|
{
|
||||||
|
Treatment selectedItem = this.tableView.getSelectionModel().getSelectedItem();
|
||||||
|
if (selectedItem == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
selectedItem.setLocked(false);
|
||||||
|
this.treatmentDao.update(selectedItem);
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
readAllAndShowInTableView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class TreatmentDao extends DaoImp<Treatment> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PreparedStatement getReadAllStatement() throws SQLException {
|
protected PreparedStatement getReadAllStatement() throws SQLException {
|
||||||
final String SQL = "SELECT * FROM treatment";
|
final String SQL = "SELECT * FROM treatment where isLocked = false";
|
||||||
return this.connection.prepareStatement(SQL);
|
return this.connection.prepareStatement(SQL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,11 +88,11 @@
|
||||||
</center>
|
</center>
|
||||||
<right>
|
<right>
|
||||||
<Button
|
<Button
|
||||||
fx:id="buttonDelete"
|
fx:id="buttonLock"
|
||||||
mnemonicParsing="false"
|
mnemonicParsing="false"
|
||||||
onAction="#handleDelete"
|
onAction="#handleLock"
|
||||||
prefWidth="200.0"
|
prefWidth="200.0"
|
||||||
text="Löschen"
|
text="Sperren"
|
||||||
GridPane.columnIndex="2"
|
GridPane.columnIndex="2"
|
||||||
/>
|
/>
|
||||||
</right>
|
</right>
|
||||||
|
|
Loading…
Reference in a new issue