Skip to content
Snippets Groups Projects
Commit 5ef8f769 authored by Harry Linrui XU's avatar Harry Linrui XU
Browse files

Added alert box if budget amount is exceeded

parent 483fc8ce
No related branches found
No related tags found
10 merge requests!43Merging frontend-testing into master,!38"Made progressbar dynamic in accordance to spending. Added balance field....,!37Made the sub progress bars respond to changes in expense,!32Added input validation to add dialog boxes.,!30Redesigned scenes,!29Redesigned scenes,!28Redesigned scenes,!26Redesigned Main menu and expense/income windows,!24Merging frontend-testing with master,!23Merging frontend-testing and master
......@@ -7,6 +7,7 @@ import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Modality;
import javafx.stage.Stage;
......@@ -106,7 +107,11 @@ public class BudgetController {
item = budgetController.getNewBudgetItem();
if(item != null && dialogMode == DialogMode.ADD){
listOfBudgetItems.add(item);
try {
general.addToBudget(item.getBudgetAmount(), item.getBudgetDescription(), item.getBudgetCategory());
} catch(IllegalArgumentException e) {
showIllegalBudgetItemDialog();
}
}
refreshObservableList();
}
......@@ -140,6 +145,15 @@ public class BudgetController {
return alert.showAndWait();
}
private Optional<ButtonType> showIllegalBudgetItemDialog() {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Budget amount exceeded");
alert.setHeaderText("Your budget exceeds the max limit");
alert.setContentText("The total budget sum must be bl" );
return alert.showAndWait();
}
protected void refreshObservableList(){
budgetTableView.setItems(budgetList);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment