コード例 #1
0
ファイル: Buyer.java プロジェクト: MrHappyyy/Laboratory
  private void updateTable() {
    dataExchange.transferString("updateTable");
    listProduct = new ArrayList<ProductEntity>();
    int size = dataExchange.acceptInt();

    for (int i = 0; i < size; i++) {
      listProduct.add(dataExchange.acceptProductEntity());
    }

    listGroup = new ArrayList<GroupEntity>();
    size = dataExchange.acceptInt();

    for (int i = 0; i < size; i++) {
      listGroup.add(dataExchange.acceptGroupEntity());
    }

    listSubGroup = new ArrayList<SubGroupEntity>();
    size = dataExchange.acceptInt();

    for (int i = 0; i < size; i++) {
      listSubGroup.add(dataExchange.acceptSubGroupEntity());
    }

    listProductTable = new ArrayList<ProductTableEntity>();

    for (int i = 0; i < listProduct.size(); i++) {
      ProductTableEntity entity = new ProductTableEntity();

      for (int j = 0; j < listGroup.size(); j++) {

        if (listProduct.get(i).getGroupId() == listGroup.get(j).getGroupId()) {
          entity.setGroupName(listGroup.get(j).getGroupName());
          break;
        }
      }

      for (int j = 0; j < listSubGroup.size(); j++) {

        if (listProduct.get(i).getSubGroupId() == listSubGroup.get(j).getSubGroupId()) {
          entity.setSubGroupName(listSubGroup.get(j).getSubGroupName());
          break;
        }
      }
      entity.setProductId(i + 1);
      entity.setProductName(listProduct.get(i).getProductName());
      entity.setAmount(listProduct.get(i).getAmount());
      entity.setPrice(listProduct.get(i).getPrice());
      listProductTable.add(entity);
    }
    productTableModel.removeIsAll();

    for (int i = 0; i < listProductTable.size(); i++) {
      String[] table = {
        String.valueOf(listProductTable.get(i).getProductId()),
        listProductTable.get(i).getProductName(),
        listProductTable.get(i).getGroupName(),
        listProductTable.get(i).getSubGroupName(),
        String.valueOf(listProductTable.get(i).getAmount()),
        String.valueOf(listProductTable.get(i).getPrice())
      };
      productTableModel.addDate(table);
    }
    table.setVisible(false);
    table.setVisible(true);
  }
コード例 #2
0
 public void deleteButtonClick() {
   productTableModel.deleteSelectedProduct();
 }