#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;
|
||||
|
||||
@FXML
|
||||
private Button buttonDelete;
|
||||
private Button buttonLock;
|
||||
|
||||
private final ObservableList<Treatment> treatments = FXCollections.observableArrayList();
|
||||
private TreatmentDao dao;
|
||||
|
@ -100,12 +100,12 @@ public class AllTreatmentController {
|
|||
this.columnDescription.setCellValueFactory(new PropertyValueFactory<>("description"));
|
||||
this.tableView.setItems(this.treatments);
|
||||
|
||||
this.buttonDelete.setDisable(true);
|
||||
this.buttonLock.setDisable(true);
|
||||
this.tableView
|
||||
.getSelectionModel()
|
||||
.selectedItemProperty()
|
||||
.addListener((observableValue, oldTreatment, newTreatment) ->
|
||||
AllTreatmentController.this.buttonDelete.setDisable(newTreatment == null)
|
||||
AllTreatmentController.this.buttonLock.setDisable(newTreatment == null)
|
||||
);
|
||||
|
||||
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
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -88,11 +88,11 @@
|
|||
</center>
|
||||
<right>
|
||||
<Button
|
||||
fx:id="buttonDelete"
|
||||
fx:id="buttonLock"
|
||||
mnemonicParsing="false"
|
||||
onAction="#handleDelete"
|
||||
onAction="#handleLock"
|
||||
prefWidth="200.0"
|
||||
text="Löschen"
|
||||
text="Sperren"
|
||||
GridPane.columnIndex="2"
|
||||
/>
|
||||
</right>
|
||||
|
|
Loading…
Reference in a new issue