Example #1
0
 private void deleteBorrowerPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_deleteBorrowerPerformed
   if (borrowersTable.getSelectedRowCount() > 0) {
     try {
       Borrower b =
           reader.getBorrower((Integer) model.getValueAt(borrowersTable.getSelectedRow(), 0));
       int result =
           JOptionPane.showConfirmDialog(
               this,
               java.util.ResourceBundle.getBundle("de/web/feitsch/fabian/loft/bundles/bundle")
                       .getString("gui.delete_question")
                   + b.getName()
                   + " "
                   + b.getSurname()
                   + "'?",
               java.util.ResourceBundle.getBundle("de/web/feitsch/fabian/loft/bundles/bundle")
                   .getString("gui.msgtitles.warning"),
               JOptionPane.YES_NO_OPTION);
       if (result == JOptionPane.YES_OPTION) {
         BorrowerBookQuest relationQuest = new BorrowerBookQuest();
         relationQuest.addNumericCondition(
             "borrower_id", b.getID(), DigitOperator.EQUAL, SQLOperator.AND);
         ArrayList<BorrowerBookRelation> relations =
             reader.getBorrowerBookRelations(relationQuest);
         for (BorrowerBookRelation relation : relations) {
           writer.deleteEntry(relation);
         }
         writer.deleteEntry(b);
         repaint();
       }
     } catch (SQLException ex) {
       Logger.getLogger(BorrowerPanel.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 } // GEN-LAST:event_deleteBorrowerPerformed
Example #2
0
 /** Creates new form BorrowerPanel */
 public BorrowerPanel(DataBaseReader reader, DataBaseWriter writer) {
   this.writer = writer;
   this.reader = reader;
   initComponents();
   quest = new BorrowerQuest();
   model = (BorrowerDataModel) borrowersTable.getModel();
   model.showBorrowers(quest);
 }
Example #3
0
 @Override
 public void repaint() {
   if (model != null) {
     model.showBorrowers(quest);
     counterLabel.setText(String.valueOf(borrowersTable.getRowCount()));
     borrowersTable.repaint();
   }
   super.repaint();
 }
Example #4
0
 private void editBorrowerPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_editBorrowerPerformed
   if (borrowersTable.getSelectedRowCount() > 0) {
     try {
       Borrower b =
           reader.getBorrower((Integer) model.getValueAt(borrowersTable.getSelectedRow(), 0));
       BorrowerInputDialog inputDialog =
           new BorrowerInputDialog(
               java.util.ResourceBundle.getBundle("de/web/feitsch/fabian/loft/bundles/bundle")
                   .getString("gui.borrower.edit_a_borrower"),
               writer,
               b);
       inputDialog.setLocationRelativeTo(this);
       inputDialog.setVisible(true);
       repaint();
     } catch (SQLException ex) {
       Logger.getLogger(BorrowerPanel.class.getName()).log(Level.SEVERE, null, ex);
     }
   }
 } // GEN-LAST:event_editBorrowerPerformed