示例#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);
  }
 public boolean updateProduct(Product product) {
   productDao.updateProduct(product);
   return true;
 }
 public boolean addProduct(ShoppingCart product) {
   productDao.addProduct(product);
   return true;
 }