public void populateProdFreqValues() {
    try {

      Connection con = Main.dbConnection;
      if (!con.isValid(0)) {
        con = Main.reconnect();
      }
      freqValues.clear();
      PreparedStatement stmt =
          con.prepareStatement(
              "select value, code, seq, lov_lookup_id from lov_lookup where code='PRODUCT_FREQ' order by seq");
      ResultSet rs = stmt.executeQuery();
      while (rs.next()) {
        freqValues.add(rs.getString(1));
      }
      prodFreq.getItems().addAll(freqValues);
    } catch (SQLException e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    } catch (Exception e) {

      Main._logger.debug("Error :", e);
      e.printStackTrace();
    }
  }
 private void checkItems() {
   String[] freqItems = productRow.getSupportingFreq().split(",");
   for (int i = 0; i < freqItems.length; i++) {
     String freq = freqItems[i].trim();
     prodFreq.getCheckModel().check(freq);
   }
 }
 public boolean isValid() {
   boolean valid = true;
   if (nameTF.getText().isEmpty() || nameTF.getText() == null) {
     valid = false;
     Notifications.create()
         .text("Invalid Product Name")
         .text("Product name cannot be left empty.")
         .hideAfter(Duration.seconds(5))
         .showError();
   }
   if (codeTF.getText().isEmpty() || codeTF.getText() == null) {
     valid = false;
     Notifications.create()
         .text("Invalid Product Code")
         .text("Product code cannot be left empty.")
         .hideAfter(Duration.seconds(5))
         .showError();
   }
   if (typeTF.getSelectionModel().getSelectedItem() == null) {
     valid = false;
     Notifications.create()
         .text("Invalid Product Type Selection")
         .text("Type selection cannot be left empty and must be selected")
         .hideAfter(Duration.seconds(5))
         .showError();
   }
   if (prodFreq.getCheckModel().isEmpty()) {
     valid = false;
     Notifications.create()
         .text("Invalid Frequency")
         .text("Product Frequency selection cannot be left empty and must be selected")
         .hideAfter(Duration.seconds(5))
         .showError();
   }
   if (productExistsInCategory(
       nameTF.getText(), billCategoryTF.getSelectionModel().getSelectedItem())) {
     valid = false;
     Notifications.create()
         .text("Duplicate Product in Bill Category")
         .text("Product Name already exists in this bill category.")
         .hideAfter(Duration.seconds(5))
         .showError();
   }
   return valid;
 }
  public Product returnUpdatedProduct() {
    if (isValid()) {
      try {
        productRow.setName(nameTF.getText());
        productRow.setType(typeTF.getSelectionModel().getSelectedItem());
        productRow.setSupportingFreq(supportedFreq(prodFreq.getCheckModel().getCheckedItems()));
        productRow.setPrice(
            Double.parseDouble(priceTF.getText().isEmpty() ? "0.0" : priceTF.getText()));
        productRow.setMonday(
            Double.parseDouble(mondayTF.getText().isEmpty() ? "0.0" : mondayTF.getText()));
        productRow.setTuesday(
            Double.parseDouble(tuesdayTF.getText().isEmpty() ? "0.0" : tuesdayTF.getText()));
        productRow.setWednesday(
            Double.parseDouble(wednesdayTF.getText().isEmpty() ? "0.0" : wednesdayTF.getText()));
        productRow.setThursday(
            Double.parseDouble(thursdayTF.getText().isEmpty() ? "0.0" : thursdayTF.getText()));
        productRow.setFriday(
            Double.parseDouble(fridayTF.getText().isEmpty() ? "0.0" : fridayTF.getText()));
        productRow.setSaturday(
            Double.parseDouble(saturdayTF.getText().isEmpty() ? "0.0" : saturdayTF.getText()));
        productRow.setSunday(
            Double.parseDouble(sundayTF.getText().isEmpty() ? "0.0" : sundayTF.getText()));
        productRow.setCode(codeTF.getText());
        productRow.setDow(dowTF.getSelectionModel().getSelectedItem());
        productRow.setFirstDeliveryDate(firstDeliveryDate.getValue());
        productRow.setIssueDate(issueDate.getValue());
        productRow.setBillCategory(billCategoryTF.getSelectionModel().getSelectedItem());
        productRow.updateProductRecord();
      } catch (NumberFormatException e) {
        Notifications.create()
            .title("Invalid value")
            .text("Please enter numbers for Price and Monday - Sunday fields")
            .hideAfter(Duration.seconds(5))
            .showError();
        Main._logger.debug("Error :", e);
        e.printStackTrace();
      } catch (Exception e) {

        Main._logger.debug("Error :", e);
        e.printStackTrace();
      }
    }
    return productRow;
  }