Skip to content

Commit 5b21efe

Browse files
committed
Fixed off by 1 error and table column naming mistake; Exit alert confirmation
1 parent e2044e7 commit 5b21efe

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/main/java/sealey/javafxinventorysystem/AddProduct.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void populateTable1(ObservableList<Part> parts){
302302
table1IDCol.setCellValueFactory(new PropertyValueFactory<>("id"));
303303
table1NameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
304304
table1InvCol.setCellValueFactory(new PropertyValueFactory<>("stock"));
305-
table1InvCol.setCellValueFactory(new PropertyValueFactory<>("price"));
305+
table1PriceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
306306
}
307307

308308
void populateTable2(ObservableList<Part> parts){
@@ -312,7 +312,7 @@ void populateTable2(ObservableList<Part> parts){
312312
table2IDCol.setCellValueFactory(new PropertyValueFactory<>("id"));
313313
table2NameCol.setCellValueFactory(new PropertyValueFactory<>("name"));
314314
table2InvCol.setCellValueFactory(new PropertyValueFactory<>("stock"));
315-
table2InvCol.setCellValueFactory(new PropertyValueFactory<>("price"));
315+
table2PriceCol.setCellValueFactory(new PropertyValueFactory<>("price"));
316316
}
317317

318318
@Override

src/main/java/sealey/javafxinventorysystem/MainWindow.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,15 @@ void onActionDeleteProduct(ActionEvent event) {
287287
@FXML
288288
void onActionExit(ActionEvent event) {
289289

290-
System.exit(0);
290+
Alert alert = new Alert(Alert.AlertType.WARNING);
291+
alert.setHeaderText("Are you sure you want to exit?");
292+
alert.setContentText("Your data will not be saved.");
293+
294+
Optional<ButtonType> result = alert.showAndWait();
295+
296+
if (result.get() == ButtonType.OK) {
297+
System.exit(0);
298+
}
291299
}
292300

293301
/*

src/main/java/sealey/javafxinventorysystem/ModifyPart.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ void onActionSave(ActionEvent event) throws IOException {
134134
throw new NumberFormatException();
135135
} else {
136136
if(inhouseRadio.isSelected()){
137-
InHouse newPart = new InHouse(id,name,price,inv,max,min);
137+
InHouse newPart = new InHouse(id,name,price,inv,min,max);
138138
newPart.setMachineId(Integer.parseInt(machineIDText.getText()));
139-
Inventory.updatePart(id,newPart);
139+
Inventory.updatePart(id - 1,newPart);
140140
} else {
141-
OutSourced newPart = new OutSourced(id,name,price,inv,max,min);
141+
OutSourced newPart = new OutSourced(id,name,price,inv,min,max);
142142
newPart.setCompanyName(machineIDText.getText());
143-
Inventory.updatePart(id,newPart);
143+
Inventory.updatePart(id - 1,newPart);
144144
}
145145
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
146146
scene = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("MainWindow.fxml")));

src/main/java/sealey/javafxinventorysystem/ModifyProduct.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void onActionSave(ActionEvent event) throws IOException {
251251
} else {
252252
Product temp = new Product(id,name,price,inv,min,max);
253253
temp.getAllAssociatedParts().setAll(bottomTable);
254-
Inventory.updateProduct(id-1,temp);
254+
Inventory.updateProduct(id - 1,temp);
255255

256256
stage = (Stage)((Button)event.getSource()).getScene().getWindow();
257257
scene = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("MainWindow.fxml")));

0 commit comments

Comments
 (0)