Class AddProductController
java.lang.Object
com.xavierloeraflores.inventorymanagement.AddProductController
- All Implemented Interfaces:
javafx.fxml.Initializable
Controller class for the AddProduct.fmxl form.
Implements Initializable
- Author:
- xavierloeraflores
-
Field Summary
Modifier and TypeFieldDescriptionThe [columnAssociatedId] which displays Associated Parts' Id.The [columnAssociatedName] which displays Associated Parts' Name.The [columnAssociatedPrice] which displays Associated Parts' Price.The [columnAssociatedStock] which displays Associated Parts' Stock.The [columnInventoryId] which displays Inventory Parts' Id.The [columnInventoryName] which displays Inventory Parts' Name.The [columnInventoryPrice] which displays Inventory Parts' Price.The [columnInventoryStock] which displays Inventory Parts' Stock.private String
The [errorMessage] which will be displayed in case of an error when validating.private javafx.scene.control.TextField
The [fieldID] which displays the id for the Part .private javafx.scene.control.TextField
The [fieldMax] takes in input from the user for the partMax.private javafx.scene.control.TextField
The [fieldMin] takes in input from the user for the partMin.private javafx.scene.control.TextField
The [fieldName] takes in input from the user for the partName.private javafx.scene.control.TextField
The [fieldPrice] takes in input from the user for the partPrice.private javafx.scene.control.TextField
The [fieldSearch] takes in input from the user for searching for parts.private javafx.scene.control.TextField
The [fieldStock] takes in input from the user for the Part inventory or partStock.private Product
The [newProduct] to be added to the inventory.private int
The autogenerated [productId] of the Product to be added.private javafx.scene.control.TableView<Part>
The [TableAssociated] which displays Associated Parts.private javafx.scene.control.TableView<Part>
The [tableInventoryPart] which displays Inventory Parts. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
handleAdd
(javafx.event.ActionEvent actionEvent) Handles the add associated part functionality when a user presses the add button.private void
handleCancel
(javafx.event.ActionEvent actionEvent) Handles the canceling functionality when a user presses the cancel button.private void
handleRemove
(javafx.event.ActionEvent actionEvent) Handles the remove associated part functionality when a user presses the remove button.private void
handleSave
(javafx.event.ActionEvent actionEvent) Handles the saving functionality when a user presses the save button.private void
handleSearch
(javafx.event.ActionEvent actionEvent) Handles the search part functionality when the user enters a search query.void
initialize
(URL url, ResourceBundle rb) Initializes the FXML Screen, creates a newProduct object, & generates a productId.private void
mainScreen
(javafx.event.ActionEvent actionEvent) Returns the user back to the main screen.void
Handles setting up all the tables and populates them with the data.private boolean
Validates whether the inputs the user has provided are valid for creating a new product.
-
Field Details
-
fieldId
private javafx.scene.control.TextField fieldIdThe [fieldID] which displays the id for the Part . -
fieldName
private javafx.scene.control.TextField fieldNameThe [fieldName] takes in input from the user for the partName. -
fieldStock
private javafx.scene.control.TextField fieldStockThe [fieldStock] takes in input from the user for the Part inventory or partStock. -
fieldPrice
private javafx.scene.control.TextField fieldPriceThe [fieldPrice] takes in input from the user for the partPrice. -
fieldMin
private javafx.scene.control.TextField fieldMinThe [fieldMin] takes in input from the user for the partMin. -
fieldMax
private javafx.scene.control.TextField fieldMaxThe [fieldMax] takes in input from the user for the partMax. -
fieldSearch
private javafx.scene.control.TextField fieldSearchThe [fieldSearch] takes in input from the user for searching for parts. -
tableInventoryPart
The [tableInventoryPart] which displays Inventory Parts. -
columnInventoryPartId
The [columnInventoryId] which displays Inventory Parts' Id. -
columnInventoryPartName
The [columnInventoryName] which displays Inventory Parts' Name. -
columnInventoryPartStock
The [columnInventoryStock] which displays Inventory Parts' Stock. -
columnInventoryPartPrice
The [columnInventoryPrice] which displays Inventory Parts' Price. -
tableAssociatedPart
The [TableAssociated] which displays Associated Parts. -
columnAssociatedPartId
The [columnAssociatedId] which displays Associated Parts' Id. -
columnAssociatedPartName
The [columnAssociatedName] which displays Associated Parts' Name. -
columnAssociatedPartStock
The [columnAssociatedStock] which displays Associated Parts' Stock. -
columnAssociatedPartPrice
The [columnAssociatedPrice] which displays Associated Parts' Price. -
errorMessage
The [errorMessage] which will be displayed in case of an error when validating. -
productId
private int productIdThe autogenerated [productId] of the Product to be added. -
newProduct
The [newProduct] to be added to the inventory.
-
-
Constructor Details
-
AddProductController
public AddProductController()
-
-
Method Details
-
mainScreen
Returns the user back to the main screen.- Parameters:
actionEvent
- JavaFX action event- Throws:
IOException
-
validate
private boolean validate(String name, String priceString, String stockString, String minString, String maxString) Validates whether the inputs the user has provided are valid for creating a new product. RUNTIME ERROR: errorMessage was not updating with the concat function.- Parameters:
name
- [String] name value from the name fieldpriceString
- [String] price value from the price fieldstockString
- [String] stock value from the inventory/stock fieldminString
- [String] min value from the min fieldmaxString
- [String] max value from the max field- Returns:
- [Boolean] true if the inputs are valid, false if any of the inputs are not valid
-
handleSave
Handles the saving functionality when a user presses the save button. If the inputs are valid, the Part is added to the Inventory.- Parameters:
actionEvent
- JavaFX action event- Throws:
IOException
-
handleCancel
Handles the canceling functionality when a user presses the cancel button. It will return the user the Main screen if the user confirms cancellation- Parameters:
actionEvent
- JavaFX action event- Throws:
IOException
-
handleRemove
Handles the remove associated part functionality when a user presses the remove button. It will remove the associated part if the user confirms removal- Parameters:
actionEvent
- JavaFX action event- Throws:
IOException
-
handleSearch
Handles the search part functionality when the user enters a search query. It will populate the table with the search results or bring up a dialog box if no searches found- Parameters:
actionEvent
- JavaFX action event- Throws:
IOException
-
handleAdd
Handles the add associated part functionality when a user presses the add button. It will add the associated part if the user has selected a part- Parameters:
actionEvent
- JavaFX action event- Throws:
IOException
-
mapTables
public void mapTables()Handles setting up all the tables and populates them with the data. This function also maps all the columns with properties from the Part class. -
initialize
Initializes the FXML Screen, creates a newProduct object, & generates a productId.- Specified by:
initialize
in interfacejavafx.fxml.Initializable
- Parameters:
url
- parameter for the FXML Screenrb
- parameter for the FXML Screen
-