Example #1
0
 private void btnSearchActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnSearchActionPerformed
   String id = txtSearch.getText(); // Get the ID from the text field.
   if (id.isEmpty()) {
     productModel.updateItems(dao.getAll());
   } else {
     productModel.updateItems(
         dao.getById(id)); // Update the model with the product that is retrieved from getById.
   }
 } // GEN-LAST:event_btnSearchActionPerformed
Example #2
0
  private void cbCategoryFilterActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_cbCategoryFilterActionPerformed
    String category = (String) cbCategoryFilter.getSelectedItem();
    productModel.updateItems(dao.getByCategory(category));

    // String filter = cbCategoryFilter.getToolTipText();

    // productModel.updateItems(dao.

  } // GEN-LAST:event_cbCategoryFilterActionPerformed
Example #3
0
 private void btnDeleteActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
   Product product = (Product) lstProducts.getSelectedValue();
   int result =
       JOptionPane.showConfirmDialog(
           this,
           "Are you sure you want to delete Product ID:"
               + product.getProductID()
               + ", Name: "
               + product.getName());
   if (result == JOptionPane.YES_OPTION) {
     dao.delete(product);
   }
   productModel.updateItems(dao.getAll());
 } // GEN-LAST:event_btnDeleteActionPerformed
Example #4
0
  private void btnEditActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnEditActionPerformed
    Product product = (Product) lstProducts.getSelectedValue();
    if (product == null) {
      JOptionPane.showMessageDialog(
          this,
          "You have not selected a product to edit.",
          "Inane error",
          JOptionPane.ERROR_MESSAGE);

    } else {
      ProductEditorDialog peDialog = new ProductEditorDialog(this, true, product, dao);
      peDialog.setVisible(true);
      productModel.updateItems(dao.getAll());
    } // GEN-LAST:event_btnEditActionPerformed
  }