<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package telas;

import javax.swing.JOptionPane;
import br.com.biblisis.controller.*;
import java.sql.SQLException;


/**
 *
 * @author romeu
 */
public class TelaLogin extends javax.swing.JFrame {

    /**
     * Creates new form TelaLogin
     */
    private String tipoDoUsuario;
    private String login;
    
    
    public TelaLogin() {
        initComponents();
        this.tipoDoUsuario = "Aluno/Professor";
    }
    
    public void setTipoDoUsuario(String tipoDoUsuario){
        this.tipoDoUsuario = tipoDoUsuario;
    }
    private void verificaLoginAdministradorFuncionario(){
        if(this.tipoDoUsuario.equals("Administrador") || this.tipoDoUsuario.equals("Funcionário") ){
           btnNovoCadastro.setVisible(false);
        }
    }
    
    private void chamaMenu(){
        if (this.tipoDoUsuario.equals("Administrador")){
            TelaAdministrador telaAdministrador = new TelaAdministrador();
            telaAdministrador.setLogin(this.login);
            telaAdministrador.setVisible(true);
            telaAdministrador.setExtendedState(MAXIMIZED_BOTH);
            dispose();
        }else if(this.tipoDoUsuario.equals("Aluno/Professor")){
            TelaAlunoProfessor telaAlunoProfessor = new TelaAlunoProfessor();
            telaAlunoProfessor.setLogin(this.login);
            telaAlunoProfessor.setVisible(true);
            telaAlunoProfessor.setExtendedState(MAXIMIZED_BOTH);
            dispose();
        }else{
            TelaFuncionario telaFuncionario = new TelaFuncionario();
            telaFuncionario.setLogin(this.login);
            telaFuncionario.setVisible(true);
            telaFuncionario.setExtendedState(MAXIMIZED_BOTH);
            dispose();
           ;
        }
    }
    
    private void chamaTelaDeNovoCadastro (String tipo){
        TelaCadastroUsuario novaTelaDeCadastro = new TelaCadastroUsuario ();
        novaTelaDeCadastro.setTipoDoUsuario(tipo);
        novaTelaDeCadastro.setVisible(true);
    }
    
    private boolean validaLogin (String loginId, String senha){
        boolean resposta = false;
        if (this.tipoDoUsuario.equals("Funcionário")){
            try {
               resposta = CFuncionario.login(loginId, senha, 0);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
        } else if (this.tipoDoUsuario.equals("Administrador")){
            try {
                resposta = CFuncionario.login(loginId, senha, 1);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
        }else{
            try {
               resposta =  CAlunoProfessor.login(loginId, senha);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
        }
        return resposta;
    }
    
    
    private boolean validaCaseLogin (String loginId, String senha){
        boolean resposta = false;
        String [] usuario = null;
        if (this.tipoDoUsuario.equals("Funcionário")){
            try {
               resposta = CFuncionario.login(loginId, senha, 0);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
            
            try {
               usuario = CFuncionario.search(loginId);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
            if ( usuario == null || !usuario[0].equals(loginId)){
                resposta = false;
            }
            
            
        } else if (this.tipoDoUsuario.equals("Administrador")){
            try {
                resposta = CFuncionario.login(loginId, senha, 1);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
            
            try {
               usuario = CFuncionario.search(loginId);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
            if ( usuario == null || !usuario[0].equals(loginId)){
                resposta = false;
            }
        }else{
            try {
               resposta =  CAlunoProfessor.login(loginId, senha);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
            try {
               usuario = CAlunoProfessor.search(loginId);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
            }
            if ( usuario == null || !usuario[0].equals(loginId)){
                resposta = false;
            }
        }
        return resposta;
     
    }
    

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        btnEntrar = new javax.swing.JButton();
        btnNovoCadastro = new javax.swing.JButton();
        campoPassSenha = new javax.swing.JPasswordField();
        btnRetornar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        lblAviso = new javax.swing.JLabel();
        lblTipo = new javax.swing.JLabel();
        campoTextoId = new javax.swing.JFormattedTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Autenticação");
        setBounds(new java.awt.Rectangle(0, 0, 0, 0));
        setFocusCycleRoot(false);
        setFocusTraversalPolicyProvider(true);
        setUndecorated(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                formKeyTyped(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N
        jLabel1.setText("LOGIN");
        jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel2.setText("ID");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel3.setText("SENHA");

        btnEntrar.setText("Entrar");
        btnEntrar.setToolTipText("prosseguir com login");
        btnEntrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEntrarActionPerformed(evt);
            }
        });

        btnNovoCadastro.setText("Novo Cadastro");
        btnNovoCadastro.setToolTipText("ainda não é cadastrado?");
        btnNovoCadastro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNovoCadastroActionPerformed(evt);
            }
        });

        campoPassSenha.setToolTipText("digite sua senha");
        campoPassSenha.setPreferredSize(new java.awt.Dimension(40, 23));
        campoPassSenha.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoPassSenhaKeyPressed(evt);
            }
        });

        btnRetornar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/icons8-left-32.png"))); // NOI18N
        btnRetornar.setToolTipText("retornar ao menu principal");
        btnRetornar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRetornarActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/icons8-reading-filled-100.png"))); // NOI18N

        lblAviso.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblAviso.setForeground(new java.awt.Color(255, 0, 0));
        lblAviso.setText("Senha incorreta ou usuário inexistente!");
        lblAviso.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblTipo.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        lblTipo.setText("Tipo do Usuário");
        lblTipo.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        campoTextoId.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoTextoIdActionPerformed(evt);
            }
        });
        campoTextoId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoTextoIdKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                campoTextoIdKeyReleased(evt);
            }
            public void keyTyped(java.awt.event.KeyEvent evt) {
                campoTextoIdKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblAviso)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addComponent(campoPassSenha, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(campoTextoId, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addGap(18, 18, 18)
                        .addComponent(jLabel4))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(btnEntrar, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(btnNovoCadastro)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(btnRetornar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblTipo))
            .addGroup(layout.createSequentialGroup()
                .addGap(127, 127, 127)
                .addComponent(jLabel1)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(105, 105, 105)
                .addComponent(jLabel5)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(0, 300, Short.MAX_VALUE)
                        .addComponent(jLabel4))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel5)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(campoTextoId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(campoPassSenha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblAviso)
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnEntrar)
                            .addComponent(btnNovoCadastro))))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnRetornar, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblTipo)))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void btnNovoCadastroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNovoCadastroActionPerformed
       
      Object[] itens = { "Aluno", "Professor"};
      Object tipoEscolhido = JOptionPane.showInputDialog(null, "Qual o tipo do usuário?", "Novo usuário",
              JOptionPane.INFORMATION_MESSAGE, null,
                  itens, itens [0]); //
      if (tipoEscolhido != null){
          chamaTelaDeNovoCadastro (tipoEscolhido.toString());
      }
    }//GEN-LAST:event_btnNovoCadastroActionPerformed

    private void btnEntrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEntrarActionPerformed
        boolean respostaDaValidacao;
        respostaDaValidacao = validaCaseLogin(campoTextoId.getText(),campoPassSenha.getText());
        
        if (respostaDaValidacao){
            dispose ();
            this.login = campoTextoId.getText();
            chamaMenu();
        }
        lblAviso.setVisible(true); 
    }//GEN-LAST:event_btnEntrarActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        verificaLoginAdministradorFuncionario();
        lblAviso.setVisible(false);
        lblTipo.setText(tipoDoUsuario);
    }//GEN-LAST:event_formWindowOpened

    private void btnRetornarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRetornarActionPerformed
        this.dispose();
        TelaPrincipal novaTelaPrincipal = new TelaPrincipal();
        novaTelaPrincipal.setVisible(true);
    }//GEN-LAST:event_btnRetornarActionPerformed

    private void campoTextoIdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoTextoIdActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_campoTextoIdActionPerformed

    private void campoTextoIdKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoTextoIdKeyTyped
        
    }//GEN-LAST:event_campoTextoIdKeyTyped

    private void formKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyTyped
        campoTextoId.setText(campoTextoId.getText().toUpperCase());
    }//GEN-LAST:event_formKeyTyped

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
        campoTextoId.setText(campoTextoId.getText().toUpperCase());
        
    }//GEN-LAST:event_formKeyPressed

    private void campoTextoIdKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoTextoIdKeyReleased
        //campoTextoId.setText(campoTextoId.getText().toUpperCase());
    }//GEN-LAST:event_campoTextoIdKeyReleased

    private void campoPassSenhaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoPassSenhaKeyPressed
        if(evt.getKeyCode() == evt.VK_ENTER){
            boolean respostaDaValidacao;
        respostaDaValidacao = validaCaseLogin(campoTextoId.getText(),campoPassSenha.getText());
        
        if (respostaDaValidacao){
            this.login = campoTextoId.getText();
            chamaMenu();
        }
        lblAviso.setVisible(true); 
        }
    }//GEN-LAST:event_campoPassSenhaKeyPressed

    private void campoTextoIdKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoTextoIdKeyPressed
        if(evt.getKeyCode() == evt.VK_ENTER){
            boolean respostaDaValidacao;
        respostaDaValidacao = validaCaseLogin(campoTextoId.getText(),campoPassSenha.getText());
        
        if (respostaDaValidacao){
            this.login = campoTextoId.getText();
            chamaMenu();
        }
        lblAviso.setVisible(true); 
        }
    }//GEN-LAST:event_campoTextoIdKeyPressed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaLogin().setVisible(true);
                
            }
        });
        
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnEntrar;
    private javax.swing.JButton btnNovoCadastro;
    private javax.swing.JButton btnRetornar;
    private javax.swing.JPasswordField campoPassSenha;
    private javax.swing.JFormattedTextField campoTextoId;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel lblAviso;
    private javax.swing.JLabel lblTipo;
    // End of variables declaration//GEN-END:variables
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package telas;

import javax.swing.JOptionPane;

/**
 *
 * @author romeu
 */
public class TelaAlunoProfessor extends javax.swing.JFrame {

    /**
     * Creates new form TelaAlunoProfessor
     */
    private String login = "Usuário";
    public TelaAlunoProfessor() {
        initComponents();
    }

    public void setLogin(String login) {
        this.login = login;
    }


    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuUsuario = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuItemVisualizarHistorico = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenuItem5 = new javax.swing.JMenuItem();
        menuAcervo = new javax.swing.JMenu();
        menuItemConsultarAcervo = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        menuItemEncerrarSessao = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Menu do Usuário");
        setUndecorated(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/backgroundPadrao.jpg"))); // NOI18N

        menuUsuario.setText("Usuário");

        jMenuItem1.setText("Editar dados cadastrais");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuUsuario.add(jMenuItem1);

        menuItemVisualizarHistorico.setText("Visualizar histórico");
        menuItemVisualizarHistorico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemVisualizarHistoricoActionPerformed(evt);
            }
        });
        menuUsuario.add(menuItemVisualizarHistorico);

        jMenuBar1.add(menuUsuario);

        jMenu2.setText("Reserva");

        jMenuItem3.setText("Fazer reserva");
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem3);

        jMenuItem4.setText("Consultar reserva");
        jMenuItem4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem4ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem4);

        jMenuItem5.setText("Cancelar reserva");
        jMenu2.add(jMenuItem5);

        jMenuBar1.add(jMenu2);

        menuAcervo.setText("Acervo");

        menuItemConsultarAcervo.setText("Consultar acervo");
        menuItemConsultarAcervo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemConsultarAcervoActionPerformed(evt);
            }
        });
        menuAcervo.add(menuItemConsultarAcervo);

        jMenuBar1.add(menuAcervo);

        jMenu5.setText("Logout");

        menuItemEncerrarSessao.setText("Encerrar sessão");
        menuItemEncerrarSessao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemEncerrarSessaoActionPerformed(evt);
            }
        });
        jMenu5.add(menuItemEncerrarSessao);

        jMenuBar1.add(jMenu5);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel1))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1189, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem4ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem4ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    private void menuItemConsultarAcervoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemConsultarAcervoActionPerformed
        TelaConsultaAcervo novaTelaDeConsulta = new TelaConsultaAcervo();
        novaTelaDeConsulta.setVisible(true);
    }//GEN-LAST:event_menuItemConsultarAcervoActionPerformed

    private void menuItemEncerrarSessaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemEncerrarSessaoActionPerformed
        int resposta = JOptionPane.showConfirmDialog(null, "Deseja encerrar sua sessão?");
        if (resposta == 0){
           TelaPrincipal novaTela = new TelaPrincipal ();
            novaTela.setVisible(true);
            this.dispose(); 
        }
    }//GEN-LAST:event_menuItemEncerrarSessaoActionPerformed

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        menuUsuario.setText("Olá, " + login+"!");
    }//GEN-LAST:event_formWindowOpened

    private void menuItemVisualizarHistoricoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemVisualizarHistoricoActionPerformed
        
        TelaConsultaEmprestimo novaTelaDeConsulta = new TelaConsultaEmprestimo();
        novaTelaDeConsulta.setVisible(true);
        novaTelaDeConsulta.setLoginAlunoProfessor(login);
    }//GEN-LAST:event_menuItemVisualizarHistoricoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaAlunoProfessor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaAlunoProfessor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaAlunoProfessor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaAlunoProfessor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaAlunoProfessor().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem3;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenu menuAcervo;
    private javax.swing.JMenuItem menuItemConsultarAcervo;
    private javax.swing.JMenuItem menuItemEncerrarSessao;
    private javax.swing.JMenuItem menuItemVisualizarHistorico;
    private javax.swing.JMenu menuUsuario;
    // End of variables declaration//GEN-END:variables
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.model.bean;

/**
 *
 * @author romeu
 */
public class Editora {
    private int codEdit;
    private String nomeEdit;
    
    public Editora(int codEdit, String nomeEdit){
        this.codEdit    = codEdit;
        this.nomeEdit   = nomeEdit;
    }
    
    public Editora(String nomeEdit) {
        this.nomeEdit = nomeEdit;
    }
    
    public Editora(int codEdit) {
        this.codEdit    = codEdit;
        this.nomeEdit   = null;
    }

    public void setNomeEdit(String nomeEdit) {
        this.nomeEdit = nomeEdit;
    }

    public int getCodEdit() {
        return codEdit;
    }

    public String getNomeEdit() {
        return nomeEdit;
    }

    @Override
    public String toString() {
        return "Editora{" + "codEdit=" + codEdit + ", nomeEdit=" + nomeEdit + '}';
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        
        if (!(obj instanceof Editora)) {
            return false;
        }
        
        Editora other  = (Editora) obj;
        return other.codEdit == this.codEdit;
    }
}<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.model.bean;
import java.util.Calendar;
import java.util.Date;


public class Funcionario extends Usuario {
    private int codCargo;
    
    public Funcionario(String login, String senha, String nome, int codCargo) {
        super(login, senha, nome);
        this.codCargo = codCargo;
    }
    
    public Funcionario(String login) {
        super(login);
    }
    
    public int getCargo() {
        return this.codCargo;
    }
    
    public void setCargo(int codCargo) {
        this.codCargo = codCargo;
    }
    
    @Override
    public String toString() {
        return "Funcionario{" + " funcionario = " + super.getNome() + " login = " + super.getLogin() + " senha = " + super.getSenha() + " codigo = " + this.codCargo + '}';
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Funcionario)) {
            return false;
        }
        
        Funcionario other = (Funcionario) obj;
        return other.getLogin().equals(this.getLogin());
    }
    
    /*
    public Emprestimo fazEmprestimo (Usuario usuario, Exemplar exemplar, Obra obra){
        Data dtEmprestimo, dtDevolucao; 
        dtEmprestimo = dtDevolucao = new Data("yyyy-MM-dd HH:mm:ss");
        dtDevolucao.adicionarAnos(7);
        return  (new Emprestimo(this, usuario, exemplar, obra, dtEmprestimo, dtDevolucao));
    }*/
    
    /*
    public Emprestimo fazEmprestimo (Usuario usuario, Exemplar exemplar){
        Date dataAtual = new Date ();
        Date dataLimite = geraDataLimite();
        Emprestimo novoEmprestimo = new Emprestimo (this, usuario, exemplar, dataAtual, dataLimite );
        
        return novoEmprestimo;
    }
    
    private Date geraDataLimite (){
        Date dataLimite;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.DATE, +3); 
        dataLimite = calendar.getTime(); 
        
        return dataLimite;
    }
    
    public boolean verificaAtrasoDeEmprestimo (Emprestimo emprestimo){
        return emprestimo.isAtraso();
    }
    
    public Devolucao devolveEmprestimo (Emprestimo emprestimo, int codigoDaDevolucao){//EXPLICAR
        Date dataAtual = new Date ();
        Devolucao novaDevolucao = new Devolucao (codigoDaDevolucao, this, emprestimo.getExemplar(),dataAtual);
        return novaDevolucao;
    }
    */
    
            
 
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */


/*Trocar o tipo DATE por Data*/

package br.com.biblisis.model.bean;
import java.util.Date;


public class Emprestimo {
    private Funcionario funcionario;
    private Usuario usuario;
    private Exemplar exemplar;
    private Obra obra;
    private Data dataEmprestimo;
    private Data dataDevolucao;

    public Emprestimo(Funcionario funcionario, Usuario usuario, Exemplar exemplar, Obra obra, Data dataEmprestimo, Data dataDevolucao) {
        this.funcionario = funcionario;
        this.usuario = usuario;
        this.exemplar = exemplar;
        this.obra = obra;
        this.dataEmprestimo = dataEmprestimo;
        this.dataDevolucao = dataDevolucao;
    }

    public Funcionario getFuncionario() {
        return funcionario;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public Exemplar getExemplar() {
        return exemplar;
    }

    public Data getDataEmprestimo() {
        return dataEmprestimo;
    }

    public Data getDataDevolucao() {
        return dataDevolucao;
    }

    public void setFuncionario(Funcionario funcionario) {
        this.funcionario = funcionario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public void setExemplar(Exemplar exemplar) {
        this.exemplar = exemplar;
    }

    public void setDataEmprestimo(Data dataEmprestimo) {
        this.dataEmprestimo = dataEmprestimo;
    }

    public void setDataDevolucao(Data dataDevolucao) {
        this.dataDevolucao = dataDevolucao;
    }

    public Obra getObra() {
        return obra;
    }

    public void setObra(Obra obra) {
        this.obra = obra;
    }


    public boolean isAtraso (){
        return !dataDevolucao.depoisDaDataAtual();
    }
    

    public void calculaDataDevolucao(int dias) {
        this.dataDevolucao.adicionarDias(dias);
    }
    
    @Override
    public String toString() {
        return "Emprestimo{" + "funcionario=" + funcionario.getLogin() + ", usuario=" + usuario.getLogin() + ", exemplar=" + exemplar.getCodExemplar() + ", obra=" + obra.getTitulo() + ", dataEmprestimo=" + dataEmprestimo + ", dataDevolucao=" + dataDevolucao + '}';
    }
    
    
}
<file_sep>create database dbbiblisis;

use dbbiblisis;

show tables;


create table tbeditora(
		codEdit int primary key auto_increment,
		nomeEdit varchar(60) not null			
);


create table tbobra(
		codObra int primary key auto_increment,
		tituloObra varchar(100) not null,   
        categoriaObra varchar(60) not null, 
        autorObra varchar(60),			
        dataPublicao date,
        codEdit int not null,
        foreign key (codEdit) references tbeditora(codEdit)
);


create table tblivro(
		isbn varchar(20) not null,
		codObra int not null,
        foreign key(codObra) references tbobra(codObra),
        primary key(isbn, codObra)
);


create table tbperiodico(
		issn varchar(20) not null,
		codObra int not null,
        foreign key(codObra) references tbobra(codObra),
        primary key(issn, codObra)
);


create table tbexemplar(
		codEx int auto_increment,
		codObra int not null,
        isEmprestado bool,							
        foreign key(codObra) references tbobra(codObra),
        primary key(codEx, codObra)
);


create table tbcargo(
		codCargo int primary key,
		nomeCargo varchar(80) not null				
);


create table tbfuncionario(
		loginFun varchar(15) not null unique primary key,
		senhaFun varchar(15) not null,
		nomeFun varchar(60) not null,	
        codCargo int not null references tbcargo(codCargo) /*Ele não adicionou o relacionamento a cargo*/
);



create table tbusuario(
		loginUser varchar(15) not null unique primary key,
        senhaUser varchar(15) not null,
		nomeUser varchar(60) not null,
        statusUser bool
);


create table tbreserva(
		loginUser varchar(15) not null,
		codObra int not null,
		codEx int not null,
		dataReserva timestamp default current_timestamp, /*dataTime*/
		dataRetirada dateTime, /*YYYY-MM-DD HH:MM:SS*/
		foreign key(loginUser) references tbusuario(loginUser),
		foreign key(codObra) references tbobra(codObra),
		foreign key(codEx) references tbexemplar(codEx),
		primary key(loginUser, codObra, codEx)
);


create table tbemprestimo(
		loginFun varchar(15) not null,
        loginUser varchar(15) not null,
        codEx int not null,
        codObra int not null,
        dataEmprestimo timestamp default current_timestamp,
        dataDevolucao dateTime not null,
        foreign key(loginFun) references tbfuncionario(LoginFun),
        foreign key(loginUser) references tbusuario(loginUser),
        foreign key(codEx) references tbexemplar(codEx),
        foreign key(codObra) references tbobra(codObra),
        primary key(loginFun, loginUser, codEx, codObra)
);


create table tbdevolucao (
		codDevolucao int auto_increment primary key,
		loginFun varchar(15) not null,
        codEx int not null,
        codObra int not null,
        dataDevolucao dateTime not null,
        foreign key(loginFun) references tbfuncionario(loginFun),
        foreign key(codEx) references tbexemplar(codEx),
        foreign key(codObra) references tbobra(codObra)
);


create table tbrenovacao (
		codRenovacao int auto_increment primary key,
		loginFun varchar(15) not null,
        codEx int not null,
        codObra int not null,
        dataRenovacao dateTime not null,
        foreign key(loginFun) references tbfuncionario(loginFun),
        foreign key(codEx) references tbexemplar(codEx),
        foreign key(codObra) references tbobra(codObra)
);



/*Inserindo Cargos, por hora somente 2*/
insert into tbcargo values(1, 'ATENDENTE'), (2, 'ADM');

/*Inserindo Funcionarios*/
insert into tbfuncionario values ('admin', 'admin', 'jock', 1);
insert into tbfuncionario values ('carllosveiga', '12456', 'carlos', 2), ('pedriHG', '9999', 'Pedro', 2);
insert into tbfuncionario values ('root', 'admin', 'administrador', 1);


/*Inserindo Usuarios*/
insert into tbusuario values ('jockfss', '343536', 'Jock', false);
insert into tbusuario values ('luquete', '8745', 'lucas', false);
insert into tbusuario values ('joao978', '4861556', '<NAME>', false);
insert into tbusuario values ('pedrinho@10', 'ped789', 'Pedro', false);  
insert into tbusuario values ('ivavia#14', 'iva123', 'Ivan', false);
insert into tbusuario values ('ters@15', '89712', 'Terezina', false);


/*Inserindo as Principais Editoras*/
insert into tbeditora values (null, 'Veja'), (null, 'Escute'), (null, 'Ande');
insert into tbeditora values (null, 'PC&CIA');


/*Inserindo Obra*/
insert into tbobra values (null, 'As Aventuras de Pedro', 'Aventura', 'Jorge', '2018-03-02', 1);	
insert into tbobra values (null, 'Algebra Linear - XXXX', 'Matemáica', 'Carlos', '2018-03-02', 2);
insert into tbobra values (null, 'Zip - ED de compactacao', 'Informatica', '<NAME>', '2018-02-01', 3);
insert into tbobra values (null, 'Raspeberry Pi', 'Informatica', 'PC&Cia', '2018-02-01', 4);


/*Inserindo Livros*/
insert into tblivro values ('ISBN388053101-3', 1);
insert into tblivro values ('ISBN012345689-0', 2);
insert into tblivro values ('ISBN095530100-9', 4);

/*Inserindo um Periodo*/
insert into tbperiodico values ('ISSN1511-3707', 5);


/*Inserindo Exemplares*/

-- exemplares das As Aventuras de Pedro
insert into tbexemplar values (1, 1, 0);
insert into tbexemplar values (2, 1, 0);
insert into tbexemplar values (3, 1, 0);
insert into tbexemplar values (4, 1, 0);
insert into tbexemplar values (5, 1, 0);

-- exemplares de Algebra Linear
insert into tbexemplar values (1, 2, 0);
insert into tbexemplar values (2, 2, 0);
insert into tbexemplar values (3, 2, 0);
insert into tbexemplar values (4, 2, 0);

-- exemplares de Zip - ED de compactacao
insert into tbexemplar values (1, 4, 0);
insert into tbexemplar values (2, 4, 0);
insert into tbexemplar values (3, 4, 0);
insert into tbexemplar values (4, 4, 0);

-- exemplares de Raspeberry - PI*/
insert into tbexemplar values (1, 5, 0);
insert into tbexemplar values (2, 5, 0);
insert into tbexemplar values (3, 5, 0);
insert into tbexemplar values (4, 5, 0);



/*************** Funções do Programa ***************************/


/******************* Reserva ***********************************/
/*Usuario solicita Reserva  CREATE */
insert into tbreserva values ('jockfss', 1, 1, null, null);
insert into tbreserva values ('joao978', 1, 2, null, null);
insert into tbreserva values ('ivavia#14', 1, 3, null, null);
insert into tbreserva values ('ivavia#14', 1, 4, null, null);

/*Usuario Cancela uma Reseva - Delete*/
 -- delete from tbreserva where loginUser = 'jockfss' and codObra = 1 and codEx = 1;

/*Consulta Reserva - Search*/
select * from tbreserva where loginUser = 'jockfss' and codObra = 1 and codEx = 1;

/*Atualiza uma Reserva - UPDATE (Quem Faz Isso e o Funcionario)*/
update tbreserva set dataRetirada = '2018-02-2 14:39:15' where loginUser = 'jockfss' and codObra = 1 and codEx = 1; 

/*Visualisa Hitorico de Reserva*/
select * from tbreserva where loginUser = 'ivavia#14';

/*Reserva em Aberto?*/
select * from tbreserva where dataRetirada is null;




/*******Realizar um emprestimo************/
update tbexemplar set isEmprestado = true where codObra = 1 and codEx = 1;
update tbreserva set dataRetirada = '2018-02-2 14:39:15' where loginUser = 'jockfss' and codObra = 1 and codEx = 1; 
insert into tbemprestimo values ('carllosveiga', 'jockfss', 1, 1, null, '2018-02-27 14:39:15'); /*Gera uma data de 7 dias pra devolucao*/

update tbexemplar set isEmprestado = true where codObra = 1 and codEx = 4;
update tbreserva set dataRetirada = '2018-02-27 14:39:15' where loginUser = 'ivavia#14' and codObra = 1 and codEx = 4;
insert into tbemprestimo values ('carllosveiga', 'ivavia#14', 1, 4, null, '2018-02-27 14:39:15'); /*Gera uma data de 7 dias pra devolucao*/

/*Visualisa Hitorico de Emprestimo*/
select * from tbemprestimo where loginUser = 'ivavia#14';


/*Consulta Acervo de Obras*/
select * from tbobra;

/*Consultar Situacao do Aluno/Professor*/
select * from tbusuario where loginUser = 'jockfss';



/***************/
select * from tbemprestimo;
select * from tbusuario;
select * from tbreserva;
select * from tbexemplar order by codObra, codEx;


select * from tbexemplar order by codObra, codEx;
select * from tbusuario;
/***************/

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package telas;

import br.com.biblisis.controller.CAlunoProfessor;
import br.com.biblisis.controller.CEmprestimo;
import br.com.biblisis.controller.CExemplar;
import br.com.biblisis.controller.CObra;
import java.awt.Color;
import java.awt.event.KeyEvent;
import java.text.SimpleDateFormat;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;

/**
 *
 * @author romeu
 */
public class TelaNovoEmprestimo extends javax.swing.JFrame {

    /**
     * Creates new form TelaNovoEmprestimo
     */
    ArrayList <String[]> acervo;
    ArrayList <String[]> acervoDeExemplares;
    ArrayList <String[]> emprestimos;
    
    
    
    private DefaultListModel modeloLista = new DefaultListModel();
    private String loginFuncionario;
    private String loginUsuario;
    private int codigoDoExemplar;
    private int codigoDaObra;
    private int diasParaADevolucao;
    
    
    public TelaNovoEmprestimo() {
        initComponents();
        this.acervo = new ArrayList<String[]>();
        this.acervoDeExemplares = new ArrayList<String[]>();
        this.emprestimos = new ArrayList<String[]>();
    }
    
    private void constroiListaDeEmprestimos() throws ParseException{
        if (!this.emprestimos.isEmpty()){
            this.emprestimos.clear();
        }
        try {
            this.emprestimos = (ArrayList<String[]>) CEmprestimo.readAll();
         }catch (SQLException e)  {
                System.out.println("Erro!" + e);
        }  
    }

    public void setLoginFuncionario(String loginFuncionario) {
        this.loginFuncionario = loginFuncionario;
    }

    private void adicionaExemplaroNaLista (String codigoDoExemplar){
        listaExemplares.setModel(modeloLista);
        modeloLista.addElement(codigoDoExemplar);
    }
    
    private String[] buscaAlunoProfessor(String login){
        String[] resposta = null;
        try {
            resposta = CAlunoProfessor.search(login);
        }catch (SQLException e) {
            System.out.println("Erro!" + e);
        }
        return resposta;
    }
    
    private void constroiAcervo(){
        try {
            this.acervo = (ArrayList<String[]>) CObra.read();
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
        }   
    }
    
    private void constroiAcervoDeExemplares(){
        try {
            this.acervoDeExemplares = (ArrayList<String[]>) CExemplar.read();
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
        }   
    }
    
    private String [] buscaExemplar(int codigoDoExemplar, int codigoDaObra){
        String [] resposta = null;
        try {
            resposta = CExemplar.search(codigoDoExemplar, codigoDaObra);
        }catch (SQLException e) {
            System.out.println("Erro!" + e);
            return resposta;
        }
        return resposta;
    }
    
    private String [] buscaObra (int codigoDaObra){
        
        Iterator it = this.acervo.iterator();
        String [] obra;
        while (it.hasNext()){
            obra = (String [])it.next();
            if (Integer.parseInt(obra[0]) == codigoDaObra ){
                return obra;
            }
        }
        return null;
    }
    
    private ArrayList<String> buscaExemplares(int codigoDaObra){
        
        Iterator it = this.acervoDeExemplares.iterator();
        String [] exemplar;
        String [] obra;
        ArrayList<String> exemplaresDesejados = new ArrayList();
        while (it.hasNext()){
            exemplar = (String [])it.next();
            obra = exemplar[1].split(",");
            obra = obra[0].split("=");
            if (codigoDaObra == Integer.parseInt(obra[1]) ){
                exemplaresDesejados.add(exemplar[0]);
            } 
        }
        return exemplaresDesejados;
    }
    
    private boolean disponibilidadeDoExemplar (int codigoDoExemplar, int codigoDaObra){
        String [] exemplarProcurado = buscaExemplar(codigoDoExemplar, codigoDaObra);
        //System.out.println(exemplarProcurado[2]);
        if (Boolean.parseBoolean(exemplarProcurado[2]) == true){
            return false;
        }else{
            return true;
        }
    }
    
    private void registraNovoEmprestimo (String loginFunc, String loginUsu, int codEx, int codOb, int dias){
        try {
            CEmprestimo.create(loginFunc, loginUsu, codEx, codOb, dias);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
        }  
        try {
            CExemplar.update(codEx, codOb, true);
            }catch (SQLException e) {
                System.out.println("Erro!" + e);
        } 
    }
    
     private Date geraDataLimite (int diasEmprestados , Date dataAtual){
        Date dataLimite;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(dataAtual);
        calendar.add(Calendar.DATE, + diasEmprestados); 
        dataLimite = calendar.getTime(); 
        
        return dataLimite;
    }
     /*
    private int buscaCodigoDoEmprestimo (String [] emprestimoProcurado){
        int indiceProcurado;
        int codigoDoEmprestimo;
        if (this.emprestimos.contains(emprestimoProcurado)){
           indiceProcurado = this.emprestimos.indexOf(emprestimoProcurado);
        }else{
           return -1;   
        } 
        codigoDoEmprestimo = this.emprestimos.size() - indiceProcurado;
        return codigoDoEmprestimo;
    }
    
     
     
     private int buscaCodigoDoEmprestimo (String logFunc, String logUsu, String dataEmp  ){
        Iterator it = this.emprestimos.iterator();
        String [] emprestimoDaLista;
       
        while (it.hasNext()){
            emprestimoDaLista = (String[]) it.next();
            String dataDoEmprestimoDaLista = emprestimoDaLista[4];
            String [] dataDividida = dataDoEmprestimoDaLista.split(" ");
            String hora = dataDividida[1];
            dataDividida = dataDividida[0].split("-");
            String dataFormatada = dataDividida[2]+"/"+dataDividida[1] + "/" + dataDividida[0] +" "+ hora;
            
            System.out.println(this.emprestimos.size() - this.emprestimos.indexOf(emprestimoDaLista));
            System.out.println(emprestimoDaLista[0] +  " - " + logFunc + emprestimoDaLista[1] +  " - " + logUsu + dataFormatada + " - " + dataEmp );
            System.out.println(emprestimoDaLista[0].equals(logFunc) + " " + emprestimoDaLista[1].equals(logUsu) + " " + dataEmp.equals(dataFormatada) );
            
            if ( (emprestimoDaLista[0].equals(logFunc)) && (emprestimoDaLista[1].equals(logUsu)) && (dataEmp.equals(dataFormatada)) ){
                return this.emprestimos.size() - this.emprestimos.indexOf(emprestimoDaLista);
            }
        }
        return -1;
    */
    
    private String geraCodigoDeEmprestimo (String data){
       String [] dataDividida = data.split(" ");
       String hora = dataDividida[1];
       dataDividida = dataDividida[0].split("/");
       String [] horaDividida = hora.split(":");
       String codigoDoEmprestimo = "E" + dataDividida[0] + dataDividida[1] + dataDividida[2] + "-" + horaDividida[0] + horaDividida[1] + horaDividida[2];
       return codigoDoEmprestimo;
    }
     
    private String [] buscaReferenciaDoEmprestimo (String logFunc, String logUsu, int codEx, int codObra, String dataEmp  ){ //OK
        Iterator it = this.emprestimos.iterator();
        String [] emprestimoDaLista;
       
        while (it.hasNext()){
            emprestimoDaLista = (String[]) it.next();
            
            System.out.println(dataEmp);
            System.out.println(emprestimoDaLista[4]);
            System.out.println(dataEmp.equals(emprestimoDaLista[4]));
            
            if ( (emprestimoDaLista[0].equals(logFunc)) && (emprestimoDaLista[1].equals(logUsu)) && (emprestimoDaLista[2].equals(Integer.toString(codEx))) && (emprestimoDaLista[3].equals(Integer.toString(codObra))) && (dataEmp.equals(emprestimoDaLista[4])) ){
                
                return emprestimoDaLista;
            }
        }
        return null;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        txtLoginId = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        btnVerificarSituacao = new javax.swing.JButton();
        lblSituacaoDoUsuario = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        lblNome = new javax.swing.JLabel();
        lblSituacaoDaObra = new javax.swing.JLabel();
        btnVerificarDisponibilidade = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        txtCodigoDaObra = new javax.swing.JTextField();
        lblTitulo = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        listaExemplares = new javax.swing.JList<>();
        btnConfirmarEmprestimo = new javax.swing.JButton();
        lblCodigoDoExemplar = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        btnFechar3 = new javax.swing.JButton();
        lblConsultarAcervo = new javax.swing.JButton();
        btnColarCodigoCopiado = new javax.swing.JButton();
        lblDisponibilidadeDoExemplar = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        txtDiasParaDevolucao = new javax.swing.JLabel();
        txtDiasParaADevolucao = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Novo Empréstimo");
        setUndecorated(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N
        jLabel1.setText("NOVO EMPRÉSTIMO");
        jLabel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        txtLoginId.setToolTipText("seu ID pode conter letras ou números");
        txtLoginId.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtLoginIdKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtLoginIdKeyReleased(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel3.setText("LOGIN/ID");

        btnVerificarSituacao.setText("Verificar Situação");
        btnVerificarSituacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVerificarSituacaoActionPerformed(evt);
            }
        });

        lblSituacaoDoUsuario.setText("Situação");
        lblSituacaoDoUsuario.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel4.setText("NOME");

        lblNome.setText("Digite o ID do usuário");
        lblNome.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        lblSituacaoDaObra.setText("Situação");
        lblSituacaoDaObra.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        btnVerificarDisponibilidade.setText("Verificar Disponibildade");
        btnVerificarDisponibilidade.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVerificarDisponibilidadeActionPerformed(evt);
            }
        });

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel7.setText("CÓDIGO DA OBRA");

        txtCodigoDaObra.setToolTipText("seu ID pode conter letras ou números");
        txtCodigoDaObra.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtCodigoDaObraKeyPressed(evt);
            }
        });

        lblTitulo.setText("Digite o código da obra");
        lblTitulo.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel9.setText("TÍTULO");

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel10.setText("EXEMPLARES DISPONÍVEIS");

        listaExemplares.setModel(new javax.swing.AbstractListModel<String>() {
            String[] strings = { "Exemplares" };
            public int getSize() { return strings.length; }
            public String getElementAt(int i) { return strings[i]; }
        });
        listaExemplares.setToolTipText("clique sobre o exemplar desejado para mais detalhes");
        listaExemplares.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                listaExemplaresMouseClicked(evt);
            }
        });
        listaExemplares.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                listaExemplaresKeyPressed(evt);
            }
        });
        listaExemplares.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                listaExemplaresValueChanged(evt);
            }
        });
        jScrollPane2.setViewportView(listaExemplares);

        btnConfirmarEmprestimo.setText("Confirmar Empréstimo");
        btnConfirmarEmprestimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfirmarEmprestimoActionPerformed(evt);
            }
        });

        lblCodigoDoExemplar.setText("Digite o código da obra");
        lblCodigoDoExemplar.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel11.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel11.setText("EXEMPLAR SELECIONADO");

        btnFechar3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icones/icons8-close-window-24.png"))); // NOI18N
        btnFechar3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFechar3ActionPerformed(evt);
            }
        });

        lblConsultarAcervo.setText("Consultar Acervo");
        lblConsultarAcervo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                lblConsultarAcervoActionPerformed(evt);
            }
        });

        btnColarCodigoCopiado.setText("Colar Código Copiado");
        btnColarCodigoCopiado.setToolTipText("acesse o acervo e copie um código para colar");
        btnColarCodigoCopiado.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnColarCodigoCopiadoActionPerformed(evt);
            }
        });

        lblDisponibilidadeDoExemplar.setText("Digite o código da obra");
        lblDisponibilidadeDoExemplar.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel12.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel12.setText("DISPONIBILIDADE DO EXEMPLAR");

        txtDiasParaDevolucao.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        txtDiasParaDevolucao.setText("DIAS PARA A DEVOLUÇÃO");

        txtDiasParaADevolucao.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtDiasParaADevolucaoFocusLost(evt);
            }
        });
        txtDiasParaADevolucao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                txtDiasParaADevolucaoKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNome, javax.swing.GroupLayout.PREFERRED_SIZE, 213, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(txtLoginId)
                                .addGap(18, 18, 18)
                                .addComponent(btnVerificarSituacao)
                                .addGap(18, 18, 18)
                                .addComponent(lblSituacaoDoUsuario, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(34, 34, 34))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(13, 13, 13)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(lblCodigoDoExemplar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(jLabel11)
                                                .addGap(165, 165, 165)))
                                        .addGap(0, 200, Short.MAX_VALUE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jLabel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(lblDisponibilidadeDoExemplar, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtDiasParaDevolucao)
                                            .addComponent(txtDiasParaADevolucao, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(89, 89, 89))))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(btnConfirmarEmprestimo)
                                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(81, 81, 81))))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel9)
                                .addGap(18, 18, 18)
                                .addComponent(lblTitulo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lblConsultarAcervo, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(txtCodigoDaObra, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(btnVerificarDisponibilidade)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(lblSituacaoDaObra, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(35, 35, 35)))
                        .addComponent(btnColarCodigoCopiado)
                        .addGap(18, 18, 18))))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel1)
                .addGap(216, 216, 216)
                .addComponent(btnFechar3, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1))
                    .addComponent(btnFechar3, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(txtLoginId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnVerificarSituacao)
                        .addComponent(lblSituacaoDoUsuario)))
                .addGap(13, 13, 13)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(lblNome))
                .addGap(18, 18, 18)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtCodigoDaObra, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnVerificarDisponibilidade)
                    .addComponent(lblSituacaoDaObra))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(lblTitulo)
                    .addComponent(btnColarCodigoCopiado)
                    .addComponent(lblConsultarAcervo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnConfirmarEmprestimo))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel11)
                        .addGap(11, 11, 11)
                        .addComponent(lblCodigoDoExemplar)
                        .addGap(14, 14, 14)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(txtDiasParaDevolucao))
                        .addGap(5, 5, 5)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblDisponibilidadeDoExemplar)
                            .addComponent(txtDiasParaADevolucao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(37, Short.MAX_VALUE))
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        constroiAcervo();
        constroiAcervoDeExemplares();
        try {
            constroiListaDeEmprestimos();
        } catch (ParseException ex) {
            Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(Level.SEVERE, null, ex);
        }  
        
    }//GEN-LAST:event_formWindowOpened
   
   
    private void btnConfirmarEmprestimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfirmarEmprestimoActionPerformed
        try {
            constroiListaDeEmprestimos ();
        } catch (ParseException ex) {
            Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        if (!txtLoginId.getText().equals("") && lblSituacaoDoUsuario.getText().equals("Liberado")){
            if (!txtCodigoDaObra.getText().equals("") && lblSituacaoDaObra.getText().equals("Disponível")){
                if (lblDisponibilidadeDoExemplar.getText().equals("Disponível")){
                   if(!txtDiasParaADevolucao.getText().equals("")  && !txtDiasParaADevolucao.getText().matches("[A-Za-z]{1,}")){
                       int resposta = JOptionPane.showConfirmDialog(null, "Deseja realizar o empréstimo?");
                       if (resposta == 0){
                           this.diasParaADevolucao = Integer.parseInt(txtDiasParaADevolucao.getText());
                           registraNovoEmprestimo(this.loginFuncionario, this.loginUsuario, this.codigoDoExemplar, this.codigoDaObra, this.diasParaADevolucao);
                           Date dataDoEmprestimo = new Date ();
                           Date dataLimite = geraDataLimite(this.diasParaADevolucao, dataDoEmprestimo);
                           SimpleDateFormat formato = new SimpleDateFormat ("dd/MM/yyyy");
                           
                           try {//recarrega do banco para ArrayList de emprestimos
                               constroiListaDeEmprestimos();
                           } catch (ParseException ex) {
                               Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(Level.SEVERE, null, ex);
                           }
                           
                           SimpleDateFormat formatoParaGerarCodigo = new SimpleDateFormat ("dd/MM/yyyy HH:mm:ss");
                           
                           String codigoDoNovoEmprestimo = geraCodigoDeEmprestimo(formatoParaGerarCodigo.format(dataDoEmprestimo) );
                           System.out.println(codigoDoNovoEmprestimo);
                           
                           JOptionPane.showMessageDialog(null,"Código do Empréstimo: " + codigoDoNovoEmprestimo + "  Data de devolução: "  + formato.format(dataLimite));
                       }
                   }else{
                      JOptionPane.showMessageDialog(null, "Digite os dias para a devolução!");  
                   }
                }else{
                   JOptionPane.showMessageDialog(null, "Exemplar indisponível!"); 
                }
                
            }else{
                JOptionPane.showMessageDialog(null, "Obra indisponível ou código não digitado!");
            }
        }else{
            JOptionPane.showMessageDialog(null, "Usuário bloqueado ou nome não digitado!");
        }
        
    }//GEN-LAST:event_btnConfirmarEmprestimoActionPerformed

    private void listaExemplaresMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_listaExemplaresMouseClicked
        if (!modeloLista.isEmpty()){
           String codigoDoExemplar = listaExemplares.getSelectedValue();
            lblCodigoDoExemplar.setText(codigoDoExemplar);
            boolean isExemplarDisponivel = disponibilidadeDoExemplar(Integer.parseInt(codigoDoExemplar), this.codigoDaObra);
            if (isExemplarDisponivel){
                lblDisponibilidadeDoExemplar.setText("Disponível");
                lblDisponibilidadeDoExemplar.setForeground(Color.blue);
                this.codigoDoExemplar = Integer.parseInt(codigoDoExemplar);//ATRIBUTO
            }else{
                lblDisponibilidadeDoExemplar.setText("Não disponível");
                lblDisponibilidadeDoExemplar.setForeground(Color.red);
            } 
        }
    }//GEN-LAST:event_listaExemplaresMouseClicked

    private void btnFechar3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFechar3ActionPerformed
        dispose();
    }//GEN-LAST:event_btnFechar3ActionPerformed

    private void btnVerificarSituacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerificarSituacaoActionPerformed
        String loginDoUsuario = txtLoginId.getText();
        String [] alunoProfessor;
        if (!loginDoUsuario.equals("") ){
           alunoProfessor = buscaAlunoProfessor(loginDoUsuario);
           if (alunoProfessor != null){
               lblNome.setText(alunoProfessor[1]);
               lblNome.setForeground(Color.black);
                if (Boolean.parseBoolean(alunoProfessor[2])){
                    lblSituacaoDoUsuario.setText("Bloqueado"); 
                    lblSituacaoDoUsuario.setForeground(Color.red);
                }else{
                    lblSituacaoDoUsuario.setText("Liberado"); 
                    lblSituacaoDoUsuario.setForeground(Color.blue);
                    this.loginUsuario = txtLoginId.getText(); //ATRIBUTO
                }
           }else{
                lblNome.setText("Usuário não encontrado!");
           }
           
        }else{
            lblNome.setText("Digite um ID!");
            lblNome.setForeground(Color.red);
        }
    }//GEN-LAST:event_btnVerificarSituacaoActionPerformed

    private void lblConsultarAcervoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_lblConsultarAcervoActionPerformed
        TelaConsultaAcervo novaTela = new TelaConsultaAcervo ();
        novaTela.setVisible(true);
        
    }//GEN-LAST:event_lblConsultarAcervoActionPerformed

    private void btnColarCodigoCopiadoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnColarCodigoCopiadoActionPerformed
       TextTransfer clipboard = new TextTransfer();
       txtCodigoDaObra.setText(clipboard.getClipboardContents());
    }//GEN-LAST:event_btnColarCodigoCopiadoActionPerformed

    private void btnVerificarDisponibilidadeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerificarDisponibilidadeActionPerformed
         
            if (!txtCodigoDaObra.getText().matches("[A-Za-z]{1,}")){
                if (txtCodigoDaObra.getText().equals("")){
            lblSituacaoDaObra.setText("Digite um código!");
            lblSituacaoDaObra.setForeground(Color.red);
        }
        if (!txtCodigoDaObra.getText().equals("")){
            modeloLista.clear();
        String codigoDigitado = txtCodigoDaObra.getText();
        String [] obraDesejada = null;
        if (!codigoDigitado.equals("")){
            obraDesejada = buscaObra(Integer.parseInt(codigoDigitado));
            if (obraDesejada != null){
                lblTitulo.setText(obraDesejada[1]);
                lblTitulo.setForeground(Color.black);
            }else{
                lblTitulo.setText("Obra não encontrada!");
                lblTitulo.setForeground(Color.red);
            }
        }else{
            lblTitulo.setText("Digite um código para prosseguir!");
            lblTitulo.setForeground(Color.red);
        }
        
        ArrayList<String > exemplaresEncontrados;
        boolean isObraDisponivel = false;
        if (obraDesejada != null){
            exemplaresEncontrados = buscaExemplares(Integer.parseInt(codigoDigitado));
            if (!exemplaresEncontrados.isEmpty()){
                Iterator it = exemplaresEncontrados.iterator();
                String exemplar;
                while (it.hasNext()){
                    exemplar = (String)it.next();
                    if (isObraDisponivel == false){
                        isObraDisponivel = disponibilidadeDoExemplar(Integer.parseInt(exemplar), Integer.parseInt(codigoDigitado));//ARRUMAR ERRO!!!!!!!
                    }
                    listaExemplares.setModel(modeloLista);
                    modeloLista.addElement(exemplar);
                }
            }else{
                lblCodigoDoExemplar.setText("Sem exemplares para a obra! Contate o administrador.");
            }
        }
        if (isObraDisponivel){
            lblSituacaoDaObra.setText("Disponível");
            lblSituacaoDaObra.setForeground(Color.blue);
            this.codigoDaObra = Integer.parseInt(codigoDigitado);//ATRIBUTO
        }else{
            this.codigoDaObra = Integer.parseInt(codigoDigitado);
            lblSituacaoDaObra.setText("Não disponível");
            lblSituacaoDaObra.setForeground(Color.red);
        }
            }
        
        }
     
        
        
        
    }//GEN-LAST:event_btnVerificarDisponibilidadeActionPerformed

    private void listaExemplaresValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_listaExemplaresValueChanged
        
    }//GEN-LAST:event_listaExemplaresValueChanged

    private void txtLoginIdKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtLoginIdKeyReleased
       //txtLoginId.setText(txtLoginId.getText().toUpperCase());
    }//GEN-LAST:event_txtLoginIdKeyReleased

    private void txtDiasParaADevolucaoFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtDiasParaADevolucaoFocusLost
if(!txtDiasParaADevolucao.getText().equals("")  && !txtDiasParaADevolucao.getText().matches("[A-Za-z]{1,}")){
    int diasDigitados = Integer.parseInt(txtDiasParaADevolucao.getText());
        if(diasDigitados > 10){
            JOptionPane.showMessageDialog(null, "Não é permitido um prazo maior que 10 dias!");
            txtDiasParaADevolucao.setText("10");
        }
}        
        
    }//GEN-LAST:event_txtDiasParaADevolucaoFocusLost

    private void listaExemplaresKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_listaExemplaresKeyPressed
        if (!modeloLista.isEmpty()){
           String codigoDoExemplar = listaExemplares.getSelectedValue();
            lblCodigoDoExemplar.setText(codigoDoExemplar);
            boolean isExemplarDisponivel = disponibilidadeDoExemplar(Integer.parseInt(codigoDoExemplar), this.codigoDaObra);
            if (isExemplarDisponivel){
                lblDisponibilidadeDoExemplar.setText("Disponível");
                lblDisponibilidadeDoExemplar.setForeground(Color.blue);
                this.codigoDoExemplar = Integer.parseInt(codigoDoExemplar);//ATRIBUTO
            }else{
                lblDisponibilidadeDoExemplar.setText("Não disponível");
                lblDisponibilidadeDoExemplar.setForeground(Color.red);
            } 
        }
    }//GEN-LAST:event_listaExemplaresKeyPressed

    private void txtLoginIdKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtLoginIdKeyPressed
        if(evt.getKeyCode() == KeyEvent.VK_ENTER){
             String loginDoUsuario = txtLoginId.getText();
        String [] alunoProfessor;
        if (!loginDoUsuario.equals("") ){
           alunoProfessor = buscaAlunoProfessor(loginDoUsuario);
           if (alunoProfessor != null){
               lblNome.setText(alunoProfessor[1]);
               lblNome.setForeground(Color.black);
                if (Boolean.parseBoolean(alunoProfessor[2])){
                    lblSituacaoDoUsuario.setText("Bloqueado"); 
                    lblSituacaoDoUsuario.setForeground(Color.red);
                }else{
                    lblSituacaoDoUsuario.setText("Liberado"); 
                    lblSituacaoDoUsuario.setForeground(Color.blue);
                    this.loginUsuario = txtLoginId.getText(); //ATRIBUTO
                }
           }else{
                lblNome.setText("Usuário não encontrado!");
           }
           
        }else{
            lblNome.setText("Digite um ID!");
            lblNome.setForeground(Color.red);
        }
        }
    }//GEN-LAST:event_txtLoginIdKeyPressed

    private void txtCodigoDaObraKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodigoDaObraKeyPressed
        //tirar selecao
        if(evt.getKeyCode() == KeyEvent.VK_ENTER){
            if (!txtCodigoDaObra.getText().matches("[A-Za-z]{1,}")){
                if (txtCodigoDaObra.getText().equals("")){
            lblSituacaoDaObra.setText("Digite um código!");
            lblSituacaoDaObra.setForeground(Color.red);
        }
        if (!txtCodigoDaObra.getText().equals("")){
            modeloLista.clear();
        String codigoDigitado = txtCodigoDaObra.getText();
        String [] obraDesejada = null;
        if (!codigoDigitado.equals("")){
            obraDesejada = buscaObra(Integer.parseInt(codigoDigitado));
            if (obraDesejada != null){
                lblTitulo.setText(obraDesejada[1]);
                lblTitulo.setForeground(Color.black);
            }else{
                lblTitulo.setText("Obra não encontrada!");
                lblTitulo.setForeground(Color.red);
            }
        }else{
            lblTitulo.setText("Digite um código para prosseguir!");
            lblTitulo.setForeground(Color.red);
        }
        
        ArrayList<String > exemplaresEncontrados;
        boolean isObraDisponivel = false;
        if (obraDesejada != null){
            exemplaresEncontrados = buscaExemplares(Integer.parseInt(codigoDigitado));
            if (!exemplaresEncontrados.isEmpty()){
                Iterator it = exemplaresEncontrados.iterator();
                String exemplar;
                while (it.hasNext()){
                    exemplar = (String)it.next();
                    if (isObraDisponivel == false){
                        isObraDisponivel = disponibilidadeDoExemplar(Integer.parseInt(exemplar), Integer.parseInt(codigoDigitado));//ARRUMAR ERRO!!!!!!!
                    }
                    listaExemplares.setModel(modeloLista);
                    modeloLista.addElement(exemplar);
                }
            }else{
                lblCodigoDoExemplar.setText("Sem exemplares para a obra! Contate o administrador.");
            }
        }
        if (isObraDisponivel){
            lblSituacaoDaObra.setText("Disponível");
            lblSituacaoDaObra.setForeground(Color.blue);
            this.codigoDaObra = Integer.parseInt(codigoDigitado);//ATRIBUTO
        }else{
            this.codigoDaObra = Integer.parseInt(codigoDigitado);
            lblSituacaoDaObra.setText("Não disponível");
            lblSituacaoDaObra.setForeground(Color.red);
        }
            }
        
        }
        }
        
        
        
        
        
        
        
        
    }//GEN-LAST:event_txtCodigoDaObraKeyPressed

    private void txtDiasParaADevolucaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtDiasParaADevolucaoKeyPressed
        if(evt.getKeyCode() == KeyEvent.VK_ENTER){
            try {
            constroiListaDeEmprestimos ();
        } catch (ParseException ex) {
            Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        
        if (!txtLoginId.getText().equals("") && lblSituacaoDoUsuario.getText().equals("Liberado")){
            if (!txtCodigoDaObra.getText().equals("") && lblSituacaoDaObra.getText().equals("Disponível")){
                if (lblDisponibilidadeDoExemplar.getText().equals("Disponível")){
                   if(!txtDiasParaADevolucao.getText().equals("")  && !txtDiasParaADevolucao.getText().matches("[A-Za-z]{1,}")){
                       int resposta = JOptionPane.showConfirmDialog(null, "Deseja realizar o empréstimo?");
                       if (resposta == 0){
                           this.diasParaADevolucao = Integer.parseInt(txtDiasParaADevolucao.getText());
                           registraNovoEmprestimo(this.loginFuncionario, this.loginUsuario, this.codigoDoExemplar, this.codigoDaObra, this.diasParaADevolucao);
                           Date dataDoEmprestimo = new Date ();
                           Date dataLimite = geraDataLimite(this.diasParaADevolucao, dataDoEmprestimo);
                           SimpleDateFormat formato = new SimpleDateFormat ("dd/MM/yyyy");
                           
                           try {//recarrega do banco para ArrayList de emprestimos
                               constroiListaDeEmprestimos();
                           } catch (ParseException ex) {
                               Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(Level.SEVERE, null, ex);
                           }
                           
                           SimpleDateFormat formatoParaGerarCodigo = new SimpleDateFormat ("dd/MM/yyyy HH:mm:ss");
                           
                           String codigoDoNovoEmprestimo = geraCodigoDeEmprestimo(formatoParaGerarCodigo.format(dataDoEmprestimo) );
                           System.out.println(codigoDoNovoEmprestimo);
                           
                           JOptionPane.showMessageDialog(null,"Código do Empréstimo: " + codigoDoNovoEmprestimo + "  Data de devolução: "  + formato.format(dataLimite));
                       }
                   }else{
                      JOptionPane.showMessageDialog(null, "Digite os dias para a devolução!");  
                   }
                }else{
                   JOptionPane.showMessageDialog(null, "Exemplar indisponível!"); 
                }
                
            }else{
                JOptionPane.showMessageDialog(null, "Obra indisponível ou código não digitado!");
            }
        }else{
            JOptionPane.showMessageDialog(null, "Usuário bloqueado ou nome não digitado!");
        }
        }
    }//GEN-LAST:event_txtDiasParaADevolucaoKeyPressed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaNovoEmprestimo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new TelaNovoEmprestimo().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnColarCodigoCopiado;
    private javax.swing.JButton btnConfirmarEmprestimo;
    private javax.swing.JButton btnFechar3;
    private javax.swing.JButton btnVerificarDisponibilidade;
    private javax.swing.JButton btnVerificarSituacao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel lblCodigoDoExemplar;
    private javax.swing.JButton lblConsultarAcervo;
    private javax.swing.JLabel lblDisponibilidadeDoExemplar;
    private javax.swing.JLabel lblNome;
    private javax.swing.JLabel lblSituacaoDaObra;
    private javax.swing.JLabel lblSituacaoDoUsuario;
    private javax.swing.JLabel lblTitulo;
    private javax.swing.JList<String> listaExemplares;
    private javax.swing.JTextField txtCodigoDaObra;
    private javax.swing.JTextField txtDiasParaADevolucao;
    private javax.swing.JLabel txtDiasParaDevolucao;
    private javax.swing.JTextField txtLoginId;
    // End of variables declaration//GEN-END:variables
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.controller;

import br.com.biblisis.model.bean.Data;
import br.com.biblisis.model.bean.Editora;
import br.com.biblisis.model.bean.Obra;
import br.com.biblisis.model.dao.DAOEditora;
import br.com.biblisis.model.dao.DAOObra;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
/**
 *
 * @author Jock
 */
public abstract class CObra {
    private static Obra obra;
    private static DAOObra daoObra;
    private static DAOEditora daoEditora;

     /** 
      * Rotina apenas o Administrador realiza - codCargo = 1
      *  Porem o Funcionario pode realizar um seu cadastro (Caso não exista!)
      *  Ao executar o cadastro faça sempre uma busca na base antes
      */
    public static void create(int codObra, String titulo, String categoria, String autor, String dataDePublicacao, int codEdit) throws SQLException { //data no formato --> yyyy/MM/DD <--- ler cada campo como string e juntar '+'
        daoObra = new DAOObra();
        obra    = new Obra(codObra, titulo, categoria, autor, new Data(dataDePublicacao), (new DAOEditora()).search(new Editora(codEdit)));
        daoObra.create(obra);
    }
    
    /*Rotina apenas o Administrador realiza - codCargo = 1*/
    public static List<String[]> read() throws SQLException {
        daoObra = new DAOObra();
        ArrayList<String[]> obras    = new ArrayList<String[]>();
        
        for (Obra obraEncontrada : daoObra.read()) {
            String[] busca = new String[6];
            busca[0]       = String.valueOf(obraEncontrada.getCodigoObra());
            busca[1]       = obraEncontrada.getTitulo();
            busca[2]       = obraEncontrada.getCategoria();
            busca[3]       = obraEncontrada.getAutor();
            busca[4]       = obraEncontrada.getDataPublicacao().toString();
            busca[5]       = String.valueOf(obraEncontrada.getEditora().getCodEdit());
            obras.add(busca);
        }
        
        return obras;
    }
    
    public static void update(int codObra, String titulo, String categoria, String autor, String dataDePublicao, int codEdit) throws SQLException {
        daoObra = new DAOObra();
        obra    = new Obra(codObra, titulo, categoria, autor, new Data(dataDePublicao), (new DAOEditora()).search(new Editora(codEdit)));
        daoObra.update(obra);
    }
    
     /** Rotina apenas o Administrador realiza - codCargo = 1
      *   Porem um funcionario pode excluir sua conta
      */
    public static void delete(int codEdit) throws SQLException {
        daoObra = new DAOObra();
        obra    = new Obra(codEdit);
        daoObra.delete(obra);
    }
    
    
    public static String[] search(int codObra) throws SQLException {
        daoObra = new DAOObra();
        obra    = daoObra.search(new Obra(codObra));
        String[] retorno = new String[6];
        if (obra != null){
            retorno[0] = String.valueOf(obra.getCodigoObra());
            retorno[1] = obra.getTitulo();
            retorno[2] = obra.getCategoria();
            retorno[3] = obra.getAutor();
            retorno[4] = obra.getDataPublicacao().toString();
            retorno[5] = String.valueOf(obra.getEditora().getCodEdit());
        }else{
            retorno = null;
        }
        return retorno;
    }    
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.model.bean;


public class AlunoProfessor extends Usuario {
    private boolean status;
    
    public AlunoProfessor(String login, String senha, String nome, boolean status) {
        super(login, senha, nome);
        this.status = status;
    }
    
    public AlunoProfessor(String login) {
        super(login);
    }

    public void setStaus(boolean status) {
        this.status = status;
    }
    
    public boolean getStatus() {
        return this.status;
    }
    
    public String toString() {
        return super.toString() + " - " + status;
    }
    
    /*
    public Emprestimo fazEmprestimo (Usuario usuario, Exemplar exemplar){
        Date dataAtual = new Date ();
        Date dataLimite = geraDataLimite();
        Emprestimo novoEmprestimo = new Emprestimo (this, usuario, exemplar, exemplar.getObra(), dataAtual, dataLimite );
        
        return novoEmprestimo;
    }
    
    private Date geraDataLimite (){
        Date dataLimite;
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(Calendar.DATE, +3); 
        dataLimite = calendar.getTime(); 
        
        return dataLimite;
    }
    
    public boolean verificaAtrasoDeEmprestimo (Emprestimo emprestimo){
        return emprestimo.isAtraso();
    }
    */
    
}
<file_sep>1 - Instale mysql e xampp
2 - Copie e cole o script no mysql e execute o raio sem barrinha.
    (Crie o BD e todas as tabelas - dbbiblisis)

OBS: Software desenvolvido no NETBEANS <file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.model.bean;



public class Livro extends Obra {
    private String isbn;
    
    public Livro (int codObra, String titulo, String categoria, String autor, Data dataPublicacao, Editora editora, String isbn){
        super(codObra, titulo, categoria, autor, dataPublicacao, editora);
        this.isbn = isbn;
    }
    
    public String getIsbn() {
        return this.isbn;
    }
    
    public void setIsbn(String isbn) {
        this.isbn = isbn;
    }
    
        @Override
    public String toString() {
        return "Livro{" + "codObra=" + super.getCodigoObra() + ", titulo=" + super.getTitulo() + ", categoria=" + super.getCategoria() + ", autor=" + super.getAutor() + ", dataPublicacao=" + super.getDataPublicacao() + ", ISBN=" + this.isbn + '}';
    }

    
    
}



<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.controller;


import br.com.biblisis.model.bean.AlunoProfessor;
import br.com.biblisis.model.bean.Data;
import br.com.biblisis.model.bean.Emprestimo;
import br.com.biblisis.model.bean.Exemplar;
import br.com.biblisis.model.bean.Funcionario;
import br.com.biblisis.model.bean.Obra;
import br.com.biblisis.model.dao.DAOAlunoProfessor;
import br.com.biblisis.model.dao.DAOEmprestimo;
import br.com.biblisis.model.dao.DAOExemplar;
import br.com.biblisis.model.dao.DAOFuncionario;
import br.com.biblisis.model.dao.DAOObra;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Jock
 */
public abstract class CEmprestimo {
    private static Emprestimo emprestimo;
    private static Exemplar exemplar;
    private static Obra obra;
    private static AlunoProfessor alunoProfessor;
    private static Funcionario funcionario;
    private static Data dtDevolucao, dtEmprestimo;
    private static DAOEmprestimo daoEmprestimo;
    private static DAOExemplar daoExemplar;
    private static DAOObra daoObra;
    private static DAOAlunoProfessor daoAlunoProfessor;
    private static DAOFuncionario daoFuncionario;
   
    private static Emprestimo cud(String loginFun, String loginUser, int codExemplar, int codObra) throws SQLException {
        //Instancias de daos
        daoExemplar = new DAOExemplar();
        daoObra = new DAOObra();
        daoAlunoProfessor = new DAOAlunoProfessor();
        daoFuncionario = new DAOFuncionario();

        //instancias do model
        exemplar = daoExemplar.search(new Exemplar(codExemplar, new Obra(codObra))); // cuida com null pointerException
        obra = daoObra.search(new Obra(codObra));
        alunoProfessor = daoAlunoProfessor.search(new AlunoProfessor(loginUser));
        funcionario = daoFuncionario.search(new Funcionario(loginFun));
        dtDevolucao = dtEmprestimo = new Data("yyyy-MM-dd HH:mm:ss");

        return (new Emprestimo(funcionario, alunoProfessor, exemplar, obra, dtEmprestimo, dtDevolucao) );
    }
    
    public static Data create(String loginFun, String loginUser, int codExemplar, int codObra, int diasParaDevolucao) throws SQLException {
        try {
            daoEmprestimo = new DAOEmprestimo();
            emprestimo = cud(loginFun, loginUser, codExemplar, codObra);
            emprestimo.getDataDevolucao().adicionarDias(diasParaDevolucao);
            daoEmprestimo.create(emprestimo);
        } catch (NullPointerException e) {
            throw new IllegalArgumentException("ERRO ::: login(funcionario ou usuario), codExmplar ou codObra incorretos.\n" + e);
        }
        return emprestimo.getDataEmprestimo();
    }
    
    public static void update(String loginFun, String loginUser, int codExemplar, int codObra, int diasParaDevolucao) throws SQLException {
         try {
            daoEmprestimo = new DAOEmprestimo();
            emprestimo = cud(loginFun, loginUser, codExemplar, codObra);
            emprestimo.getDataDevolucao().adicionarDias(diasParaDevolucao);
            daoEmprestimo.update(emprestimo);
        } catch (NullPointerException e) {
            throw new IllegalArgumentException("ERRO ::: login(funcionario ou usuario), codExmplar ou codObra incorretos.\n" + e);
        }       
    }

    /*Rotina apenas o Administrador realiza - codCargo = 1*/
    public static void delete(String loginFun, String loginUser, int codExemplar, int codObra) throws SQLException {
        try {
            daoEmprestimo = new DAOEmprestimo();
            emprestimo = cud(loginFun, loginUser, codExemplar, codObra);
            daoEmprestimo.delete(emprestimo);
        } catch (NullPointerException e) {
            throw new IllegalArgumentException("ERRO ::: login(funcionario ou usuario), codExmplar ou codObra incorretos.\n" + e);
        }         
    }        
    
     /*Rotina apenas o Administrador realiza - codCargo = 1*/
    private static List<String[]> read(List<Emprestimo> read) throws SQLException, ParseException {
        daoEmprestimo       = new DAOEmprestimo();
        ArrayList<String[]> emprestimos   = new ArrayList<>();
        
        for (Emprestimo emprestimo : read) {
            String[] busca = new String[6];
            busca[0]       = emprestimo.getFuncionario().getLogin();
            busca[1]       = emprestimo.getUsuario().getLogin();
            busca[2]       = String.valueOf(emprestimo.getExemplar().getCodExemplar());
            busca[3]       = String.valueOf(emprestimo.getObra().getCodigoObra());
            busca[4]       = emprestimo.getDataEmprestimo().toString();
            busca[5]       = emprestimo.getDataDevolucao().toString();
            emprestimos.add(busca);
        }
        
        return emprestimos;
    }
    
    public static List<String[]> readAll() throws SQLException, ParseException {
        daoEmprestimo                      = new DAOEmprestimo();
        ArrayList<String[]> emprestimos    = new ArrayList<>();
        
        for (Emprestimo emprestimo : daoEmprestimo.readAll()) {
            String[] busca = new String[6];
            busca[0]       = emprestimo.getFuncionario().getLogin();
            busca[1]       = emprestimo.getUsuario().getLogin();
            busca[2]       = String.valueOf(emprestimo.getExemplar().getCodExemplar());
            busca[3]       = String.valueOf(emprestimo.getObra().getCodigoObra());
            busca[4]       = emprestimo.getDataEmprestimo().toString();
            busca[5]       = emprestimo.getDataDevolucao().toString();
            emprestimos.add(busca);
        }
        
        return emprestimos;
    }
    
    public static List<String[]> allRead() throws SQLException, ParseException {
        return read( (new DAOEmprestimo() ).allRead() );
    }
    
    public static List<String[]> userRead(String loginUser) throws SQLException, ParseException {
        return read( (new DAOEmprestimo().userRead(loginUser)) ); 
    }
    
    public static List<String[]> funcionarioRead(String loginFun) throws SQLException, ParseException {
        return read( (new DAOEmprestimo()).funcionarioRead(loginFun) ); 
    }
    
    
      /** 
      * Rotina apenas o Administrador realiza - codCargo = 1
      *  Porem o Funcionario pode realizar um seu cadastro (Caso não exista!)
      *  Ao executar o cadastro faça sempre uma busca na base antes
      */
    /*public static void create(String loginFun, String loginUser, int codExemplar, int codObra, int diasParaDevolucao) {
        //Instancias de daos
        daoEmprestimo       = new DAOEmprestimo();
        daoExemplar         = new DAOExemplar();
        daoObra             = new DAOObra();
        daoAlunoProfessor   = new DAOAlunoProfessor();
        daoFuncionario      = new DAOFuncionario();
        
        try {
            //instancias do model
            exemplar            = daoExemplar.search(new Exemplar(codExemplar, new Obra(codObra))); // cuida com null pointerException
            obra                = daoObra.search(new Obra(codObra));
            alunoProfessor      = daoAlunoProfessor.search(new AlunoProfessor(loginUser));
            funcionario         = daoFuncionario.search(new Funcionario(loginFun));
            dtDevolucao         = dtEmprestimo = new Data("yyyy-MM-dd HH:mm:ss");
            
            //Altera o status do exemplar e atualiza no banco
            //exemplar.setIsEmprestado(true); //quem deve fazer isso é o controler de fun (faz emprestimo)
            //daoExemplar.update(exemplar);   //quem deve fazer isso é o controler de fun (faz emprestimo)
            
            //Altera a data de devolucao e guarda o emprestimo no banco
            dtDevolucao.adicionarDias(diasParaDevolucao);
            daoEmprestimo.create(new Emprestimo(funcionario, alunoProfessor, exemplar, obra, dtEmprestimo, dtDevolucao));
            
        } catch (NullPointerException | SQLException e) {
            System.err.println("ERRO, exemplar ou obra ou alunoProfessor ou funionario inexistente ou ERRO ao salvar no Banco de Dados ::: \n" + e);
        }
    }*/
    
        
    /*public static void update(String loginFun, String loginUser, int codExemplar, int codObra, int diasParaDevolucao) throws SQLException {
        try {
            //Instancias de daos
            daoEmprestimo       = new DAOEmprestimo();
            daoExemplar         = new DAOExemplar();
            daoObra             = new DAOObra();
            daoAlunoProfessor   = new DAOAlunoProfessor();
            daoFuncionario      = new DAOFuncionario();
   
            //instancias do model
            exemplar            = daoExemplar.search(new Exemplar(codExemplar, new Obra(codObra))); // cuida com null pointerException
            obra                = daoObra.search(new Obra(codObra));
            alunoProfessor      = daoAlunoProfessor.search(new AlunoProfessor(loginUser));
            funcionario         = daoFuncionario.search(new Funcionario(loginFun));
            dtDevolucao         = new Data("yyyy-MM-dd HH:mm:ss");
            
            //Altera o status do exemplar e atualiza no banco
            //exemplar.setIsEmprestado(true); //quem deve fazer isso é o controler de fun (faz emprestimo)
            //daoExemplar.update(exemplar);   //quem deve fazer isso é o controler de fun (faz emprestimo)
            
            //Altera a data de devolucao e guarda o emprestimo no banco
            dtDevolucao.adicionarDias(diasParaDevolucao);
            daoEmprestimo.update(new Emprestimo(funcionario, alunoProfessor, exemplar, obra, dtEmprestimo, dtDevolucao));
            
        } catch (NullPointerException | SQLException e) {
            System.err.println("ERRO, exemplar ou obra ou alunoProfessor ou funionario inexistente ou ERRO ao salvar no Banco de Dados ::: \n" + e);
        }
    }*/
    
    /** Rotina apenas o Administrador realiza - codCargo = 1
     *   Porem um funcionario pode excluir sua conta
     */
    /*public static void delete(String loginFun, String loginUser, int codExemplar, int codObra) throws SQLException {
        try {
            //Instancias de daos
            daoEmprestimo       = new DAOEmprestimo();
            daoExemplar         = new DAOExemplar();
            daoObra             = new DAOObra();
            daoAlunoProfessor   = new DAOAlunoProfessor();
            daoFuncionario      = new DAOFuncionario();
   
            //instancias do model
            exemplar            = daoExemplar.search(new Exemplar(codExemplar, new Obra(codObra))); // cuida com null pointerException
            obra                = daoObra.search(new Obra(codObra));
            alunoProfessor      = daoAlunoProfessor.search(new AlunoProfessor(loginUser));
            funcionario         = daoFuncionario.search(new Funcionario(loginFun));

            
            //Altera o status do exemplar e atualiza no banco
            //exemplar.setIsEmprestado(true); //quem deve fazer isso é o controler de fun (faz emprestimo)
            //daoExemplar.update(exemplar);   //quem deve fazer isso é o controler de fun (faz emprestimo)
            
            //Altera a data de devolucao e guarda o emprestimo no banco
            daoEmprestimo.delete(new Emprestimo(funcionario, alunoProfessor, exemplar, obra, null, null));
            
        } catch (NullPointerException | SQLException e) {
            System.err.println("ERRO, exemplar ou obra ou alunoProfessor ou funionario inexistente ou ERRO ao salvar no Banco de Dados ::: \n" + e);
        }
    }*/
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.controller;

import br.com.biblisis.model.bean.Editora;
import br.com.biblisis.model.dao.DAOEditora;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Jock
 */
public abstract class CEditora {
    private static Editora editora;
    private static DAOEditora daoEditora;

     /** 
      * Rotina apenas o Administrador realiza - codCargo = 1
      *  Porem o Funcionario pode realizar um seu cadastro (Caso não exista!)
      *  Ao executar o cadastro faça sempre uma busca na base antes
      */
    public static void create(String nomeEdit) throws SQLException {
        daoEditora      = new DAOEditora();
        editora         = new Editora(nomeEdit);
        daoEditora.create(editora);
    }
    
    /*Rotina apenas o Administrador realiza - codCargo = 1*/
    public static List<String[]> read() throws SQLException {
       daoEditora      = new DAOEditora();
       ArrayList<String[]> editoras   = new ArrayList<>();
        
        for (Editora editora : daoEditora.read()) {
            String[] busca = new String[2];
            busca[0]       = String.valueOf(editora.getCodEdit());
            busca[1]       = editora.getNomeEdit();
            editoras.add(busca);
        }
        
        return editoras;
    }
    
    public static void update(int codEdit, String nomeEdit) throws SQLException {
        daoEditora      = new DAOEditora();
        editora         = new Editora(codEdit, nomeEdit);
        daoEditora.update(editora);
    }
    
    /** Rotina apenas o Administrador realiza - codCargo = 1
      * Porem um funcionario pode excluir sua conta
      */
    public static void delete(int codEdit) throws SQLException {
        daoEditora      = new DAOEditora();
        editora         = new Editora(codEdit);
        daoEditora.delete(editora);
    }
    
    public static String[] search(int codEdit) throws SQLException {
        daoEditora          = new DAOEditora();
        editora             = daoEditora.search(new Editora(codEdit));
        String[] retorno    = new String[2];
        
        if (editora!= null){
        retorno[0] = String.valueOf(editora.getCodEdit());
        retorno[1] = editora.getNomeEdit();
        }else{
            retorno = null;
        }
        return retorno;
    }      
}
<file_sep>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.biblisis.model.dao;

import br.com.biblisis.model.bean.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

/**
 *
 * @author Jock
 */
public class DAOReserva {
    
    
    public void create(Reserva reserva) throws SQLException {
        Connection con          = ConnectionFactory.getConnection();
        PreparedStatement stmt  = null;
        
        try {
            stmt = con.prepareStatement("INSERT INTO tbreserva VALUES (?, ?, ?, ?, ?)");
        } catch (SQLException e) {
            System.err.println("ERRO ::: " + e);
        } finally {
            ConnectionFactory.closeConnection(con, stmt);
        }
        
    }
    
    public List<Reserva> read() throws SQLException {
        Connection con          = ConnectionFactory.getConnection();
        PreparedStatement stmt  = null;
        
        try {
            stmt = con.prepareStatement("");
        } catch (SQLException e) {
            System.err.println("ERRO ::: " + e);
        } finally {
            ConnectionFactory.closeConnection(con, stmt);
        }
        
        return null;
        
    }
    
    public void update(Reserva reserva) throws SQLException {
        Connection con          = ConnectionFactory.getConnection();
        PreparedStatement stmt  = null;
        
        try {
            stmt = con.prepareStatement("");
        } catch (SQLException e) {
            System.err.println("ERRO ::: " + e);
        } finally {
            ConnectionFactory.closeConnection(con, stmt);
        }
        
    }
    
    public void delete(Reserva reserva) throws SQLException {
        Connection con          = ConnectionFactory.getConnection();
        PreparedStatement stmt  = null;
        
        try {
            stmt = con.prepareStatement("");
        } catch (SQLException e) {
            System.err.println("ERRO ::: " + e);
        } finally {
            ConnectionFactory.closeConnection(con, stmt);
        }
        
    }
    
    public Reserva search(Reserva reserva) throws SQLException {
        Connection con          = ConnectionFactory.getConnection();
        PreparedStatement stmt  = null;
        ResultSet rs            = null;
        
        try {
            stmt = con.prepareStatement("");
        } catch (SQLException e) {
            System.err.println("ERRO ::: " + e);
        } finally {
            ConnectionFactory.closeConnection(con, stmt);
        }
        
        return null;
    }
    
}
