Package Controller
Class OrderController
java.lang.Object
Controller.OrderController
.Controller for the Order Screen
- Since:
- 2023-03-07
-
Field Summary
Modifier and TypeFieldDescriptionprivate javafx.scene.control.TextField
Text field to input the customer's nameprivate DatabaseConnect
Connection to the databaseprivate javafx.scene.control.Button
Button
Button to navigate data trends sceneprivate javafx.scene.control.Button
Button
Button to navigate edit menu sceneprivate final long
ID number of the employee completing the orderprivate javafx.scene.control.Button
Button
Button to navigate employees sceneprivate javafx.scene.control.Button
Button
Button to navigate inventory sceneprivate javafx.scene.control.Button
Button
Button to logoutMap
of the menu items Elements: <id, <name, price>>private javafx.scene.layout.FlowPane
FlowPane
FlowPane that holds the menu itemsprivate Order
Order
being completedprivate javafx.scene.layout.VBox
Holds the order item buttonsprivate javafx.scene.control.Button
Button
Button to navigate order sceneprivate javafx.scene.control.Button
Button
Button to navigate order history sceneprivate javafx.scene.control.ScrollPane
ScrollPane
ScrollPane that holds the orderBoxprivate SceneSwitch
Switches between scenes or tabsprivate SessionData
Current session dataprivate javafx.scene.control.Button
Button to submit the orderprivate javafx.scene.control.Label
Shows total cost of the order -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
getMenuItemCost
(long id) Returns the COST of a menu item given its IDlong
getMenuItemId
(String name) Returns the ID of a menu item given its NAMEgetMenuItemName
(long id) Returns the NAME of a menu item given its IDvoid
Set up page.void
insertOrderItem
(Order order) Inserts an order into the databasevoid
insertSoldItem
(Order order) Inserts each individual menu item in an order into thesolditem
databasevoid
menuItemButtonOnClick
(javafx.event.ActionEvent event) Handles the button click event for the menu itemsvoid
navButtonClicked
(javafx.event.ActionEvent event) Handle loading a new window when a navigation buttonprivate void
Refreshes the front-endvoid
removeItemButtonOnClick
(javafx.event.ActionEvent event) Remove an item from theOrder
when the dynamically createdButton
is pressedvoid
Handles the buttom click event for the submit order button.void
updateInventory
(Order order) Update the inventory count based on anOrder
void
updateMenuItem
(Order order) Updates themenuitem
database based on anOrder
-
Field Details
-
session
Current session data- See Also:
-
database
Connection to the database- See Also:
-
sceneSwitch
Switches between scenes or tabs- See Also:
-
employeeId
private final long employeeIdID number of the employee completing the order -
order
Order
being completed -
orderButton
private javafx.scene.control.Button orderButtonButton
Button to navigate order scene -
orderHistoryButton
private javafx.scene.control.Button orderHistoryButtonButton
Button to navigate order history scene -
inventoryButton
private javafx.scene.control.Button inventoryButtonButton
Button to navigate inventory scene -
employeesButton
private javafx.scene.control.Button employeesButtonButton
Button to navigate employees scene -
editMenuButton
private javafx.scene.control.Button editMenuButtonButton
Button to navigate edit menu scene -
dataTrendsButton
private javafx.scene.control.Button dataTrendsButtonButton
Button to navigate data trends scene -
logoutButton
private javafx.scene.control.Button logoutButtonButton
Button to logout -
orderScrollPane
private javafx.scene.control.ScrollPane orderScrollPaneScrollPane
ScrollPane that holds the orderBox -
orderBox
private javafx.scene.layout.VBox orderBoxHolds the order item buttons -
customerNameField
private javafx.scene.control.TextField customerNameFieldText field to input the customer's name -
totalCostLabel
private javafx.scene.control.Label totalCostLabelShows total cost of the order -
submitOrderButton
private javafx.scene.control.Button submitOrderButtonButton to submit the order
-
-
Constructor Details
-
OrderController
Constructor- Parameters:
session
- Session's Information
-
-
Method Details
-
initialize
public void initialize()Set up page. Load menu table into hash map, load buttons from hash map, set navbar visibility, and refresh page -
refreshPage
private void refreshPage()Refreshes the front-end -
removeItemButtonOnClick
public void removeItemButtonOnClick(javafx.event.ActionEvent event) Remove an item from theOrder
when the dynamically createdButton
is pressed- Parameters:
event
-ActionEvent
of the button
-
submitOrderOnClick
public void submitOrderOnClick()Handles the buttom click event for the submit order button. Inserts the order into both the orderitem and solditem tables. -
getMenuItemName
Returns the NAME of a menu item given its ID- Parameters:
id
- Identification number as aString
- Returns:
- the name of the menu item
-
getMenuItemCost
public double getMenuItemCost(long id) Returns the COST of a menu item given its ID- Parameters:
id
- Identification number as aString
- Returns:
- the cost of the menu item
-
insertOrderItem
Inserts an order into the database- Parameters:
order
-Order
to insert
-
insertSoldItem
Inserts each individual menu item in an order into thesolditem
database- Parameters:
order
-Order
to insert into the database
-
updateMenuItem
Updates themenuitem
database based on anOrder
- Parameters:
order
-Order
to insert into the database
-
getMenuItemId
Returns the ID of a menu item given its NAME- Parameters:
name
- of the menu item as aString
- Returns:
- the Identification number, -1 when not found
-
updateInventory
Update the inventory count based on anOrder
- Parameters:
order
-Order
that will update inventory
-