Skip to content

Instantly share code, notes, and snippets.

@Kijimu7
Created June 29, 2020 19:09
Show Gist options
  • Save Kijimu7/2c76a2ca8caf65f33aeb048d97340aa2 to your computer and use it in GitHub Desktop.
Save Kijimu7/2c76a2ca8caf65f33aeb048d97340aa2 to your computer and use it in GitHub Desktop.
//Create auto Ids
Random random = new Random();
int id = random.nextInt(50);
if (!isOutsourced) {
InHouse newInHouse = new InHouse(0, "", 0, 0, 0, 0, 0);
if (isValid(addPartNameTxt.getText(), addPartPriceTxt.getText(), addPartInvTxt.getText(), addPartMinTxt.getText(),
addPartMaxTxt.getText(), addPartDynamicTxt.getText())) {
newInHouse.setId(id);
if (!addPartNameTxt.getText().isEmpty()) {
newInHouse.setName(addPartNameTxt.getText());
}
if (!addPartPriceTxt.getText().isEmpty()) {
newInHouse.setPrice(Double.parseDouble(addPartPriceTxt.getText()));
}
if (!addPartInvTxt.getText().isEmpty()) {
newInHouse.setInv(Integer.parseInt(addPartInvTxt.getText()));
}
if (!addPartMinTxt.getText().isEmpty()) {
newInHouse.setMin(Integer.parseInt(addPartMinTxt.getText()));
}
if (!addPartMaxTxt.getText().isEmpty()) {
newInHouse.setMax(Integer.parseInt(addPartMaxTxt.getText()));
}
if (!addPartDynamicTxt.getText().isEmpty()) {
newInHouse.setMachineId(Integer.parseInt(addPartDynamicTxt.getText()));
}
Inventory.addPart(newInHouse);
System.out.println("Part Added");
// Stage stage;
// Parent root;
// stage = (Stage) addPartsaveBtn.getScene().getWindow();
// FXMLLoader loader = new FXMLLoader(getClass().getResource("/ViewController/MainScreen.fxml"));
// root = loader.load();
// Scene scene = new Scene(root);
// stage.setScene(scene);
// stage.show();
}
}else {
Outsourced newOutsourced = new Outsourced(0, "", 0, 0, 0, 0, "");
if (isValid(addPartNameTxt.getText(), addPartPriceTxt.getText(), addPartInvTxt.getText(), addPartMinTxt.getText(), addPartMaxTxt.getText(), addPartDynamicTxt.getText())) {
newOutsourced.setId(id);
if (!addPartNameTxt.getText().isEmpty()) {
newOutsourced.setName(addPartNameTxt.getText());
}
if (!addPartPriceTxt.getText().isEmpty()) {
newOutsourced.setPrice(Double.parseDouble(addPartPriceTxt.getText()));
}
if (!addPartInvTxt.getText().isEmpty()) {
newOutsourced.setInv(Integer.parseInt(addPartInvTxt.getText()));
}
if (!addPartMinTxt.getText().isEmpty()) {
newOutsourced.setMin(Integer.parseInt(addPartMinTxt.getText()));
}
if (!addPartMaxTxt.getText().isEmpty()) {
newOutsourced.setMax(Integer.parseInt(addPartMaxTxt.getText()));
}
if (!addPartDynamicTxt.getText().isEmpty()) {
newOutsourced.setCompanyName(addPartDynamicTxt.getText());
}
Inventory.addPart(newOutsourced);
System.out.println("Part Added");
}
// Stage stage;
// Parent root;
// stage = (Stage) addPartsaveBtn.getScene().getWindow();
// FXMLLoader loader = new FXMLLoader(getClass().getResource("/ViewController/MainScreen.fxml"));
// root = loader.load();
// Scene scene = new Scene(root);
// stage.setScene(scene);
// stage.show();
} ReturnToMainScreen(event);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment