Ejemplo n.º 1
0
  private void printBarcode() throws AppException, UserException {
    Session session = HibernateUtils.openSession();
    try {
      int selectedRow = table.getSelectedRow();
      if (selectedRow < 0) {
        return;
      }
      int itemId =
          (int)
              table
                  .getModel()
                  .getValueAt(selectedRow, tableParameters.get(ColumnEnum.ID).getColumnIndex());

      ItemFacade facade = ItemFacade.getInstance();
      Item item = facade.getDetail(itemId, session);

      String barcode = item.getBarcode();
      if (barcode == null || barcode.trim().equals("")) {
        throw new UserException(
            "Barcode untuk barang ["
                + item.getCode()
                + "] "
                + item.getName()
                + " belum diregistrasi");
      }

      File file = BarcodeUtils.generatePdfFile(item.getBarcode());
      BarcodeUtils.print(file);

    } finally {
      session.close();
    }
  }
Ejemplo n.º 2
0
  private void showDetail() {
    Session session = HibernateUtils.openSession();
    try {
      int selectedRow = table.getSelectedRow();
      if (selectedRow < 0) {
        return;
      }
      int itemId =
          (int)
              table
                  .getModel()
                  .getValueAt(selectedRow, tableParameters.get(ColumnEnum.ID).getColumnIndex());

      ItemFacade facade = ItemFacade.getInstance();
      Item item = facade.getDetail(itemId, session);

      StockForm stockForm = new StockForm(this, ActionType.UPDATE);
      stockForm.setFormDetailValue(item);
      stockForm.setVisible(true);

      btnRefresh.doClick();
    } finally {
      session.close();
    }
  }
Ejemplo n.º 3
0
  @Override
  public void loadData() throws AppException {
    Session session = HibernateUtils.openSession();
    try {
      String code = txtKode.getText();
      String barcode = txtBarcode.getText();
      String name = txtNama.getText();
      boolean disabled = rdBarangTidakAktif.isSelected();

      ItemFacade facade = ItemFacade.getInstance();
      List<Item> items = facade.search(code, barcode, name, disabled, session);

      XTableModel tableModel = (XTableModel) table.getModel();
      tableModel.setRowCount(items.size());

      for (int i = 0; i < items.size(); ++i) {
        Item item = items.get(i);

        tableModel.setValueAt(
            item.getCode(), i, tableParameters.get(ColumnEnum.CODE).getColumnIndex());

        tableModel.setValueAt(
            item.getName(), i, tableParameters.get(ColumnEnum.NAME).getColumnIndex());

        tableModel.setValueAt(
            Formatter.formatNumberToString(facade.calculateStock(item)),
            i,
            tableParameters.get(ColumnEnum.STOCK).getColumnIndex());

        tableModel.setValueAt(
            item.getUnit(), i, tableParameters.get(ColumnEnum.UNIT).getColumnIndex());
        tableModel.setValueAt(
            Formatter.formatNumberToString(facade.getLastBuyPrice(item)),
            i,
            tableParameters.get(ColumnEnum.BUY_PRICE).getColumnIndex());

        tableModel.setValueAt(
            Formatter.formatNumberToString(item.getSellPrice()),
            i,
            tableParameters.get(ColumnEnum.SELL_PRICE).getColumnIndex());

        tableModel.setValueAt(item.getId(), i, tableParameters.get(ColumnEnum.ID).getColumnIndex());
      }
    } finally {
      session.close();
    }
  }