java.lang.Object
com.xavierloeraflores.inventorymanagement.AddPartController
All Implemented Interfaces:
javafx.fxml.Initializable

public class AddPartController extends Object implements javafx.fxml.Initializable
Controller class for the AddPart.fmxl form. Implements Initializable
Author:
xavierloeraflores
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    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 [fieldSpecial] takes in input from the user for both machineId and companyName.
    private javafx.scene.control.TextField
    The [fieldStock] takes in input from the user for the Part inventory or partStock.
    private boolean
    The [isOutsourced] boolean which indicates if the Part is Outsourced or In House.
    private javafx.scene.control.Label
    The [labelSpecial] which displays whether the user should enter a machineId or companyName.
    private int
    The autogenerated [partId] of the Part to be added.
    private javafx.scene.control.RadioButton
    The [radioInHouse] which allows the user to select an In House Part.
    private javafx.scene.control.RadioButton
    The [radioOutsourced] which allows the user to select an Outsourced Part.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    handleCancel(javafx.event.ActionEvent actionEvent)
    Handles the canceling functionality when a user presses the cancel button.
    private void
    handleSave(javafx.event.ActionEvent actionEvent)
    Handles the saving functionality when a user presses the save button.
    void
    Initializes the FXML Screen, sets the part to InHouse, & generates a partId.
    private void
    mainScreen(javafx.event.ActionEvent actionEvent)
    Returns the user back to the main screen.
    private void
    setRadioInHouse(javafx.event.ActionEvent actionEvent)
    When the user presses the In House radio button, the Part will convert to an InHouse Part type
    private void
    setRadioOutsourced(javafx.event.ActionEvent actionEvent)
    When the user presses the Outsourced radio button, the Part will convert to an Outsourced Part type
    private boolean
    validate(String name, String priceString, String stockString, String minString, String maxString, String special, boolean isOutsourced)
    Validates whether the inputs the user has provided are valid for creating a new part.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • radioInHouse

      private javafx.scene.control.RadioButton radioInHouse
      The [radioInHouse] which allows the user to select an In House Part.
    • radioOutsourced

      private javafx.scene.control.RadioButton radioOutsourced
      The [radioOutsourced] which allows the user to select an Outsourced Part.
    • fieldId

      private javafx.scene.control.TextField fieldId
      The [fieldID] which displays the id for the Part .
    • fieldName

      private javafx.scene.control.TextField fieldName
      The [fieldName] takes in input from the user for the partName.
    • fieldStock

      private javafx.scene.control.TextField fieldStock
      The [fieldStock] takes in input from the user for the Part inventory or partStock.
    • fieldPrice

      private javafx.scene.control.TextField fieldPrice
      The [fieldPrice] takes in input from the user for the partPrice.
    • fieldMin

      private javafx.scene.control.TextField fieldMin
      The [fieldMin] takes in input from the user for the partMin.
    • fieldMax

      private javafx.scene.control.TextField fieldMax
      The [fieldMax] takes in input from the user for the partMax.
    • labelSpecial

      private javafx.scene.control.Label labelSpecial
      The [labelSpecial] which displays whether the user should enter a machineId or companyName.
    • fieldSpecial

      private javafx.scene.control.TextField fieldSpecial
      The [fieldSpecial] takes in input from the user for both machineId and companyName.
    • isOutsourced

      private boolean isOutsourced
      The [isOutsourced] boolean which indicates if the Part is Outsourced or In House.
    • errorMessage

      private String errorMessage
      The [errorMessage] which will be displayed in case of an error when validating.
    • partId

      private int partId
      The autogenerated [partId] of the Part to be added.
  • Constructor Details

    • AddPartController

      public AddPartController()
  • Method Details

    • setRadioInHouse

      private void setRadioInHouse(javafx.event.ActionEvent actionEvent)
      When the user presses the In House radio button, the Part will convert to an InHouse Part type
      Parameters:
      actionEvent - JavaFX action event
    • setRadioOutsourced

      private void setRadioOutsourced(javafx.event.ActionEvent actionEvent)
      When the user presses the Outsourced radio button, the Part will convert to an Outsourced Part type
      Parameters:
      actionEvent - JavaFX action event
    • mainScreen

      private void mainScreen(javafx.event.ActionEvent actionEvent) throws IOException
      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, String special, boolean isOutsourced)
      Validates whether the inputs the user has provided are valid for creating a new part. RUNTIME ERROR: errorMessage was not updating with the concat function.
      Parameters:
      name - [String] name value from the name field
      priceString - [String] price value from the price field
      stockString - [String] stock value from the inventory/stock field
      minString - [String] min value from the min field
      maxString - [String] max value from the max field
      special - [String] special value from the special field
      isOutsourced - [Boolean] values as a result of the radio buttons
      Returns:
      [Boolean] true if the inputs are valid, false if any of the inputs are not valid
    • handleSave

      private void handleSave(javafx.event.ActionEvent actionEvent) throws IOException
      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

      private void handleCancel(javafx.event.ActionEvent actionEvent) throws IOException
      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
    • initialize

      public void initialize(URL url, ResourceBundle rb)
      Initializes the FXML Screen, sets the part to InHouse, & generates a partId.
      Specified by:
      initialize in interface javafx.fxml.Initializable
      Parameters:
      url - parameter for the FXML Screen
      rb - parameter for the FXML Screen