@FXML private void lvListenerGetEmployeeInfo(MouseEvent event) { try { tabPayCheck.setDisable(true); clearTextFields(); String[] a = lvEmployees.getSelectionModel().getSelectedItem().split("-"); tfInfoId.setText(a[1].trim()); final int ID = Integer.parseInt(tfInfoId.getText()); tfInfoName.setText(Environment.getEmployeeStrInfo(ID, "name")); tfInfoPos.setText(Environment.getEmployeeStrInfo(ID, "position")); tfInfoStreet.setText(Environment.getEmployeeStrInfo(ID, "street")); tfInfoCSZ.setText(Environment.getCityStateZip(ID)); tfInfoPayRate.setText( String.format("%.2f", Double.parseDouble(Environment.getEmployeeStrInfo(ID, "payRate")))); } catch (Exception e) { Alert alert; alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Error Message"); alert.setHeaderText("Whoops you did not select an Employee."); alert.setContentText("Try again."); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { // ... user chose OK } else { // ... user chose CANCEL or closed the dialog } } }
@FXML private void buttonListenerCreatePaycheck(ActionEvent event) { tabPayCheck.setDisable(false); try { LocalDate d = dpPayDate.getValue(); lblCheckDate.setText(d.toString()); lblPayStubName.setText("Pay Stub for " + tfInfoName.getText()); double netPay = 0; if (rbHourly.isSelected()) { HourlyEmployee emp = new HourlyEmployee(); emp.setId(Integer.parseInt(tfInfoId.getText())); emp.setName(tfInfoName.getText()); emp.setPosition(tfInfoPos.getText()); emp.setStreet(tfInfoStreet.getText()); emp.setCity(Environment.getEmployeeStrInfo(emp.getId(), "city")); emp.setState(Environment.getEmployeeStrInfo(emp.getId(), "state")); emp.setZip(Environment.getEmployeeStrInfo(emp.getId(), "zip")); emp.setPayRate(Double.parseDouble(tfInfoPayRate.getText())); emp.setHours(Double.parseDouble(tfHours.getText())); if (emp.getHours() > 70) { lbOvtHrs.setText(String.format("%.2f", emp.getHours() - 70)); } lbHours.setText(emp.getHours() + ""); lbPayRate.setText(String.format("%.2f", emp.getPayRate())); lbgrsPay.setText(String.format("%.2f", emp.getGrossPay())); lblNetPayPayStub.setText(String.format("%.2f", emp.getNetPay())); lbTaxes.setText(String.format("%.2f", emp.getTaxes())); lblCheckDatePayStub.setText(d.toString()); lblPosition.setText(tfInfoPos.getText()); netPay = emp.getNetPay(); } else if (rbSalary.isSelected()) { SalaryEmployee emp = new SalaryEmployee(); emp.setId(Integer.parseInt(tfInfoId.getText())); emp.setName(tfInfoName.getText()); emp.setPosition(tfInfoPos.getText()); emp.setStreet(tfInfoStreet.getText()); emp.setCity(Environment.getEmployeeStrInfo(emp.getId(), "city")); emp.setState(Environment.getEmployeeStrInfo(emp.getId(), "state")); emp.setZip(Environment.getEmployeeStrInfo(emp.getId(), "zip")); emp.setPayRate(Double.parseDouble(tfInfoPayRate.getText())); emp.setHours(Double.parseDouble(tfHours.getText())); if (emp.getHours() > 100) { lbOvtHrs.setText(String.format("%.2f", emp.getHours() - 100)); } lbHours.setText(emp.getHours() + ""); lbPayRate.setText(String.format("%.2f", emp.getPayRate())); lbgrsPay.setText(String.format("%.2f", emp.getGrossPay())); lblNetPayPayStub.setText(String.format("%.2f", emp.getNetPay())); lbTaxes.setText(String.format("%.2f", emp.getTaxes())); lblCheckDatePayStub.setText(d.toString()); lblPosition.setText(tfInfoPos.getText()); netPay = emp.getNetPay(); } lblName.setText(tfInfoName.getText()); lblStreet.setText(tfInfoStreet.getText()); lblCSZ.setText(tfInfoCSZ.getText()); lblNetPay.setText(String.format("%.2f", netPay)); lblCheckAmountString.setText(CheckWriter.main(String.format("%.2f", netPay))); } catch (Exception e) { } }