示例#1
0
 private void CopyObjectToModel() {
   _buku.setId(txtId.getText());
   _buku.setJudul(txtJudul.getText());
   _buku.setPenerbit(txtPenerbit.getText());
   _buku.setPengarang(txtPengarang.getText());
   _buku.setTahunTerbit(Integer.parseInt(txtTahunTerbit.getText()));
   _buku.setJmlHalaman(Integer.parseInt(txtTebal.getText()));
   _buku.setNilaiSewa(Integer.parseInt(txtHrgSewa.getText()));
   _buku.setIsbn(txtIsbn.getText());
   _buku.setStatus(mBuku.EnumBukuStatus.ada);
 }
示例#2
0
  private void btnDeleteActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnDeleteActionPerformed
    int result =
        JOptionPane.showConfirmDialog(
            null, "Anda yakin ingin menghapus data ini?", "Konfirmasi", JOptionPane.YES_NO_OPTION);

    if (result == JOptionPane.YES_OPTION) {
      this.CopyObjectToModel();
      _buku.EraseRow();
      DefaultTableModel tblModel = (DefaultTableModel) jTabBuku.getModel();
      tblModel.removeRow(jTabBuku.convertColumnIndexToModel(jTabBuku.getSelectedRow()));
    }
  } // GEN-LAST:event_btnDeleteActionPerformed
示例#3
0
 private void LoadRows() {
   mBuku buku = new mBuku();
   List CollectionOfBuku = buku.FetchRows();
   ListIterator lst = CollectionOfBuku.listIterator();
   DefaultTableModel tblModel = (DefaultTableModel) jTabBuku.getModel();
   while (lst.hasNext()) {
     mBuku item = (mBuku) lst.next();
     tblModel.addRow(
         new Object[] {
           item.getId(),
           item.getJudul(),
           item.getPenerbit(),
           item.getPengarang(),
           item.getTahunTerbit(),
           item.getJmlHalaman(),
           item.getIsbn(),
           item.getNilaiSewa(),
           item.getStatus()
         });
   }
 }
示例#4
0
  private boolean SaveRow() {
    boolean result = false;

    this.CopyObjectToModel();
    if (_buku.MergeRow()) {
      DefaultTableModel tblModel = (DefaultTableModel) jTabBuku.getModel();
      if (_isNew) {
        tblModel.addRow(
            new Object[] {
              _buku.getId(),
              _buku.getJudul(),
              _buku.getPenerbit(),
              _buku.getPengarang(),
              _buku.getTahunTerbit(),
              _buku.getJmlHalaman(),
              _buku.getIsbn(),
              _buku.getNilaiSewa(),
              _buku.getStatus()
            });
        cUtils.ClearObjInput(
            new Object[] {
              txtId,
              txtJudul,
              txtIsbn,
              txtPenerbit,
              txtPengarang,
              txtTahunTerbit,
              txtTebal,
              txtHrgSewa
            });
      } else {
        int rowPosition = jTabBuku.convertRowIndexToModel(jTabBuku.getSelectedRow());
        tblModel.setValueAt(_buku.getId(), rowPosition, 0);
        tblModel.setValueAt(_buku.getJudul(), rowPosition, 1);
        tblModel.setValueAt(_buku.getPenerbit(), rowPosition, 2);
        tblModel.setValueAt(_buku.getPengarang(), rowPosition, 3);
        tblModel.setValueAt(_buku.getTahunTerbit(), rowPosition, 4);
        tblModel.setValueAt(_buku.getJmlHalaman(), rowPosition, 5);
        tblModel.setValueAt(_buku.getIsbn(), rowPosition, 6);
        tblModel.setValueAt(_buku.getNilaiSewa(), rowPosition, 6);
        tblModel.setValueAt(_buku.getStatus(), rowPosition, 8);
      }
      result = true;
    }
    return result;
  }