コード例 #1
0
 /** Creates new form ViewProductsDialog */
 public ViewProductsDialog(java.awt.Frame parent, boolean modal, ProductDao dao) {
   super(parent, modal);
   this.dao = dao;
   productModel = new ProductListModel(dao.getAll());
   categoryModel = new ProductListModel(dao.getCategories());
   initComponents();
   lstProducts.setModel(productModel);
 }
コード例 #2
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
コード例 #3
0
  /* (non-Javadoc)
   * @see service.ProductService#updateProduct(VO.ProductVo)
   */
  @Override
  public void updateProduct(ProductVo productVo) {

    logger.info("start...");

    Product product = productDao.get(Product.class, productVo.getId());

    product.setName(productVo.getName());
    product.setDescription(productVo.getDescription());
    product.setImgURL(productVo.getImgURL());

    productDao.update(product);

    logger.info("end...");
  }
コード例 #4
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
コード例 #5
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
コード例 #6
0
  /* (non-Javadoc)
   * @see service.ProductService#findAllKindsProducts()
   */
  @Override
  public List<Product> findAllKindsProducts() {

    logger.info("start...");

    List<Product> products = productDao.findAll(Product.class);

    logger.info("end...");

    return products;
  }
コード例 #7
0
  /* (non-Javadoc)
   * @see service.ProductService#findProductsByType(VO.ProductVo)
   */
  @Override
  public List<Product> findProductsByType(ProductVo productVo) {

    logger.info("start...");

    List<Product> products = productDao.findProductsByType(productVo.getType());

    logger.info("end...");

    return products;
  }
コード例 #8
0
  /* (non-Javadoc)
   * @see service.ProductService#saveProduct(VO.ProductVo)
   */
  @Override
  public void saveProduct(ProductVo productVo) {

    logger.info("start...");

    Product product = new Product();

    product.setName(productVo.getName());
    product.setDescription(productVo.getDescription());
    product.setImgURL(productVo.getImgURL());

    productDao.save(product);

    logger.info("end...");
  }
コード例 #9
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
  }
コード例 #10
0
  /* (non-Javadoc)
   * @see service.ProductService#getProduct(VO.ProductVo)
   */
  @Override
  public JSONObject getProduct(ProductVo productVo) {

    logger.info("start...");

    Product product = productDao.get(Product.class, productVo.getId());

    JSONObject object = new JSONObject();

    object.put("productId", product.getId());
    object.put("name", product.getName());
    object.put("description", product.getDescription());
    object.put("imgURL", product.getImgURL());

    logger.info("end...");

    return object;
  }
コード例 #11
0
  /* (non-Javadoc)
   * @see service.ProductService#deleteProduct(VO.ProductVo)
   */
  @Override
  public void deleteProduct(ProductVo productVo) {

    Product product = productDao.get(Product.class, productVo.getId());
    productDao.delete(product);
  }
コード例 #12
0
 public boolean updateProduct(Product product) {
   productDao.updateProduct(product);
   return true;
 }
コード例 #13
0
 public boolean addProduct(ShoppingCart product) {
   productDao.addProduct(product);
   return true;
 }