Package Models.Pojo

Examples of Models.Pojo.Author


    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
      Book book = (Book) list.get(rowIndex);
     
       Author author = book.getAuthor();
     
        switch(columnIndex){
            case 0 : return book.getId();
            case 1 : return book.getName();
            //case 2 : return book.getAuthor_id();
            case 2 : return author.getFull_name();
            case 3 : return book.getPrice();
            case 4 : return book.getTotal_pages();
               
        }
        return new String();
View Full Code Here


        return col_names[col];
    }
   
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Author author = (Author) list.get(rowIndex);
       
        switch(columnIndex){
            case 0 : return author.getId();
            case 1 : return author.getFull_name();
            case 2 : return author.getLocation();
            case 3 : return author.getAge();
            case 4 : return author.getDetails();
               
        }
        return new String();
    }
View Full Code Here

            JOptionPane.showMessageDialog(this, "Select a row");
           
        }
        else{
        AuthorTableModel tableModel = (AuthorTableModel) jTable1.getModel();
        Author author = tableModel.getRowObject(row);
        txtAuthorAge.setText(String.valueOf(author.getAge()));
        txtAuthorFullName.setText(author.getFull_name());
        txtAuthorDetails.setText(author.getDetails());
        txtAuthorLocation.setText(author.getLocation());
                  
        jDialog1.setVisible(true);
        }
    }//GEN-LAST:event_btnShowSelectedActionPerformed
View Full Code Here

    private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
        //We need author object. Lets again fetch it from tablemodel
        AuthorTableModel tableModel = (AuthorTableModel) jTable1.getModel();
        int row = jTable1.getSelectedRow();
        int age = 0;
        Author author = tableModel.getRowObject(row);
        author.setFull_name(txtAuthorFullName.getText());
       
        try{
        age = Integer.parseInt(txtAuthorAge.getText());
        }catch(NumberFormatException e){
            System.err.println("number not given, taken as 0");
            //e.printStackTrace();
        }
        author.setAge(age);
      
        author.setLocation(txtAuthorLocation.getText());
        author.setDetails(txtAuthorDetails.getText());
       
        AuthorModel authorModel = new AuthorModel();
        int update_flag = authorModel.update(author);
        if(update_flag == 1){
            //tableModel.fireTableRowsUpdated(row-1, row+1);
            tableModel.fireTableDataChanged();
            jDialog1.dispose();
            JOptionPane.showMessageDialog(this, "Author "+author.getFull_name()+" updated!", "Success!", JOptionPane.INFORMATION_MESSAGE);
        }
       
    }//GEN-LAST:event_btnUpdateActionPerformed
View Full Code Here

        );
    }// </editor-fold>//GEN-END:initComponents

    private void cmboxAuthorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmboxAuthorActionPerformed
        // TODO add your handling code here:
        Author author = (Author)cmboxAuthor.getSelectedItem();
        System.out.println("Selected --"+author.getFull_name());
    }//GEN-LAST:event_cmboxAuthorActionPerformed
View Full Code Here

        String bookName = txtBookName.getText();
        float price = Float.parseFloat(txtBookPrice.getText());
        int total_pages = Integer.parseInt(txtBookTotalPages.getText());
       
        //set author id from combobox 
        Author author = (Author)cmboxAuthor.getSelectedItem();
        int author_id = author.getId();
       
        Book book = new Book();
        book.setName(bookName);
        book.setAuthor_id(author_id);
        book.setPrice(price);
View Full Code Here

        String full_name    = txtAuthorFullName.getText();
        String location     = txtAuthorLocation.getText();
        int age             = Integer.parseInt(txtAuthorAge.getText());
        String details      = txtAuthorDetails.getText();

        Author author = new Author();
        AuthorModel authorModel = new AuthorModel();

        author.setFull_name(full_name);
        author.setLocation(location);
        author.setAge(age);
        author.setDetails(details);
       
        int flag = authorModel.save(author);
        if(flag == 1)
        {
            JOptionPane.showMessageDialog(null, "Author added !", "Message", JOptionPane.INFORMATION_MESSAGE);
View Full Code Here

        book.setAuthor_id(rs.getInt("author_id"));
        book.setPrice(rs.getFloat("price"));
        book.setTotal_pages(rs.getInt("total_pages"));
        //Set the author object for book.
        AuthorModel authorModel = new AuthorModel();
        Author author = authorModel.whereId(book.getAuthor_id());
        book.setAuthor(author);
        return book;
    }
View Full Code Here

            stmt = conn.createStatement();
            String query = "SELECT * FROM "+table_name;
            rs = stmt.executeQuery(query);
           
            while (rs.next()) {
                Author author = setterForAuthor(rs); // call to private function
          
                authors.add(author);
            }

        } catch (SQLException ex) {
View Full Code Here

            String authorName_query = authorName+"%";
            prepStmt.setString(1, authorName_query);
            rs = prepStmt.executeQuery();
           
            while (rs.next()) {
                Author author = setterForAuthor(rs);    //call to private function
          
                authors.add(author);
            }

        } catch (SQLException ex) {
View Full Code Here

TOP

Related Classes of Models.Pojo.Author

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.