示例#1
0
  @Override
  public void selectCategory(int indexCategory, JTable proTable) {
    products.clear();
    proIndexes.clear();
    String category_id = catIndexes.get(indexCategory);
    products = (new Products()).getList(0, category_id, "NULL", "NULL");

    if (!products.isEmpty()) {
      DefaultTableModel model = (DefaultTableModel) proTable.getModel();
      head(model);

      for (Products product : products) {
        model.addRow(
            new Object[] {
              product.getProduct_id(),
              product.getParent_product_id(),
              product.getProduct_name(),
              product.getProduct_price(),
              product.getProduct_color(),
              product.getProduct_size(),
              product.getRegister_state()
            });
      }

    } else
      JOptionPane.showMessageDialog(
          null, "There is not any product to show.", "Products", JOptionPane.INFORMATION_MESSAGE);
  }
示例#2
0
  @Override
  public void searchProduct(JTextField product, JTable proTable) {
    products.clear();
    proIndexes.clear();
    products = (new Products()).getList(1, "NULL", product.getText(), "NULL");

    if (!products.isEmpty()) {
      DefaultTableModel model = (DefaultTableModel) proTable.getModel();
      head(model);

      for (Products proSearch : products) {
        model.addRow(
            new Object[] {
              proSearch.getProduct_id(),
              proSearch.getParent_product_id(),
              proSearch.getProduct_name(),
              proSearch.getProduct_price(),
              proSearch.getProduct_color(),
              proSearch.getProduct_size(),
              proSearch.getRegister_state()
            });
      }

    } else
      JOptionPane.showMessageDialog(
          null, "There is not any product to show.", "Products", JOptionPane.INFORMATION_MESSAGE);
  }