Sei sulla pagina 1di 237

UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

INTRODUCCION

El manual técnico presenta la manera en la que se trabajo lógicamente el


proyecto de la Biblioteca para la Universidad Nacional Amazonica de
Madre de Dios,donde se explica detalladamente todo los aspectos,en las
codificaciones están por funciones las cuales facilitara el entendimiento
para las que trabajaran en este o con este proyecto para mejorarlo.

Sabemos que los sistemas de información son innovables y pueden estar


en constante cambio según la tecnología va avanzando.

Este manual técnico será de vital importancia para robustecer dicho


sistema con mas funciones o se puede realizar sistemas expertos.
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

CLASE CONEXIÓN

*//Esta es la clase conexión en el cual se utiliza el conector mySQL –java-


5.1.5jar para utilizar los datos desde la base de datos en el sistema .
package clases;

import java.sql.*;

import javax.swing.JOptionPane;

/**

*// esta es la clase conexion .. se utiliza un conector mysql para jalar los datos de la
base de datos

* @author Zombyes Informaticos

*/public class conexion {

Connection conect = null;

public Connection conexion() {

try { *//El try – catch nos sirve para controlar errores que detecta al momento
cuando se ingresa cualquier dato

Class.forName("org.gjt.mm.mysql.Driver");

conect = DriverManager.getConnection("jdbc:mysql://localhost/biblioteca_unamad", "root", "");

} catch (Exception e) {

JOptionPane.showMessageDialog(null, "error" + e);

return conect;

public PreparedStatement prepareStatement(String sqlpersona) {

throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods,
choose Tools | Templates.

package clases; *//Este es el paquete clase que hemos creado

import java.awt.Color;

import java.awt.Component;

import javax.swing.DefaultCellEditor;

import javax.swing.JCheckBox;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
import javax.swing.JComponent;

import javax.swing.JTable;

import javax.swing.table.TableCellRenderer;

/**

*/

public class Celda_CheckBox extends DefaultCellEditor implements TableCellRenderer {

private JComponent component = new JCheckBox();

private boolean value = false; // valor de la celda

/** Creamos Constructor de clase */

public Celda_CheckBox() {

super( new JCheckBox() );

/** retorna valor de celda */

@Override

public Object getCellEditorValue() {

return ((JCheckBox)component).isSelected();

/** Segun el valor de la celda selecciona/deseleciona el JCheckBox */

@Override

public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int
column) {

//Color de fondo en modo edicion

( (JCheckBox) component).setBackground( new Color(200,200,0) );

//obtiene valor de celda y coloca en el JCheckBox

boolean b = ((Boolean) value).booleanValue();

( (JCheckBox) component).setSelected( b );

return ( (JCheckBox) component);

/** cuando termina la manipulacion de la celda */

@Override
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
public boolean stopCellEditing() {

value = ((Boolean)getCellEditorValue()).booleanValue() ;

((JCheckBox)component).setSelected( value );

return super.stopCellEditing();

} /** retorna componente */

public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean


hasFocus, int row, int column) {

if (value == null)

return null;

return ( (JCheckBox) component );

VENTANANILLA DE LOGIN(ACCESO AL
SISTEMA)

En esta codificación podemos observar el ingreso a nuestro sistema teniendo los


datos correctos,en caso de que no sean correctos no se podrá ingresar en los cuales
actúan el try- catch

package presentacion;// trabajamos en el paquete Presentacion que hemos creado

import clases.conexion;

import javax.swing.JOptionPane;

import java.sql.*;

/**

* @author sombyes informaticos

*/

public class login extends javax.swing.JFrame {

private String detalle;

private String codigo_empleado;

private String cargo;

private String nombre;

private String apellido;

/**
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
* Creates new form login

*/

public login() {

initComponents();// Este sirve para mostrar la ventanilla login con todo los
componentes

setLocationRelativeTo(null);

setResizable(false);

setTitle("ACCESO AL SISTEMA");

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jLabel1 = new javax.swing.JLabel();// Se reconoce a los jlabel para poder ingresar


datos

jPanel1 = new javax.swing.JPanel();

jLabel3 = new javax.swing.JLabel();

txtusername = new javax.swing.JTextField();//utilizaremos el username y el password para


ingresar al sistema

txtpassword = new javax.swing.JPasswordField();

jLabel2 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jLabel1.setText("jLabel1");// E// Aquí se muestran los valores

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS LOGIN"));

jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

jPanel1.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(738, 99, -1, -1));

txtusername.setBackground(new java.awt.Color(233, 233, 233));// En este caso solo estamos


insertando colores

txtusername.setFont(new java.awt.Font("Tahoma", 2, 36)); // NOI18N

txtusername.setForeground(new java.awt.Color(101, 31, 113));

jPanel1.add(txtusername, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 100, 220, 40));


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
txtpassword.setBackground(new java.awt.Color(233, 233, 233));

txtpassword.setFont(new java.awt.Font("Tahoma", 2, 36)); // NOI18N

txtpassword.setForeground(new java.awt.Color(101, 31, 113));

jPanel1.add(txtpassword, new org.netbeans.lib.awtextra.AbsoluteConstraints(500, 160, 220, 40));

jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/login.png"))); // NOI18N

jPanel1.add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 750, 330));

jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

jLabel4MouseClicked(evt);

});

jPanel1.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(430, 210, 310, 70));

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

);

pack();

}// </editor-fold>

private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

iniciar();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

/**

* @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(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(login.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 login().setVisible(true);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
});

// Variables declaration - do not modify

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JPanel jPanel1;

private javax.swing.JPasswordField txtpassword;

private javax.swing.JTextField txtusername; // Fin de la declaración de variables

private void iniciar() {

conexion cc= new conexion();

Connection cn=cc.conexion();

ResultSet rs =null; //Este es para los valores de username y password

ResultSet rs1 =null;

String user = txtusername.getText();

//String jerarquia = (String) cnbusuario.getItemAt(cnbusuario.getSelectedIndex());//Estamos indicando


que nuestro sistema será por jerarquia

//String sqlidempleado="select usuario.Login='"+login+"',usuario.Password='"+pass+"',usuario.IdEmpleado


from usuario,empleado where usuario.IdEmpleado=empleado.IdEmpleado and empleado.Cargo like
'"+jerarquia+"'";

// consulta de suario existente

String sql="select * from usuario where nombre='"+user+"' and password='"+txtpassword.getText()+"'";

try{

// preparando consulta

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

// bota resultado

if(rs.next()){

codigo_empleado=rs.getString("id_persona");

Statement st1=cn.createStatement();

rs1=st1.executeQuery("select *from persona where id_persona='"+codigo_empleado+"'");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
if(rs1.next()){

cargo=rs1.getString("tipo");

nombre=rs1.getString("nombre");

apellido=rs1.getString("apaterno");

menu_principal.codigo_empleado=codigo_empleado;

menu_principal.cargo_empleado=cargo;

menu_principal fr2=new menu_principal();

fr2.setLocationRelativeTo(fr2);

fr2.setResizable(true);

fr2.setVisible(true);

login.this.setVisible(false);

}//finde if seguro true

} else JOptionPane.showMessageDialog(this, "Datos Incorrectos");

}catch(Exception ex){

JOptionPane.showMessageDialog(this, "error..."+ex);

}}

VENTANILLA PRINCIPAL DEL SISTEMA

(Este código tiene la función de hacer reconocer y mantener la visibilidad de los datos
del menubar, panel cuando el sistema cargue,además nos muestra la funciones
restringidas de los usuarios)

package presentacion;

import clases.conexion;// Vamos a importar nuestra clase conexión y nuestras librerias

import java.sql.Connection;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.swing.JOptionPane;

/**

* @author zombyes informaticos

*/

public class menu_principal extends javax.swing.JFrame {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
static String codigo_empleado;

static String cargo_empleado;

/**

Creamos nuevo formulario en el menu

*/

public menu_principal() {

initComponents();// Inicializa los componentes de la ventanilla que creamos

cargar_datos_login();

if(cargo_empleado.equals("ESTUDIANTE") ||cargo_empleado.equals("DOCENTE")){

menuconsultaprestamo.setEnabled(true);

menucategoria.setEnabled(false);

menulibros.setEnabled(false);

menurrhh.setEnabled(false);

menuregprestamo.setEnabled(false);

menusanciones.setEnabled(false);

menuregsolicitud.setEnabled(false);

menuregistroreservas.setEnabled(false);

menureservas.setEnabled(false);

}else if (cargo_empleado.equals("BIBLIOTECARIO")) {

menuconsultaprestamo.setEnabled(false);

menufichapress.setEnabled(false);

menurrhh.setEnabled(false);

}else if (cargo_empleado.equals("ADMINISTRADOR")) {

menuconsultaprestamo.setEnabled(false);

menufichapress.setEnabled(false);

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel4 = new javax.swing.JPanel();

jLabel5 = new javax.swing.JLabel();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel6 = new javax.swing.JLabel();

txtcodigo = new javax.swing.JTextField();

txtnombre = new javax.swing.JTextField();

jLabel7 = new javax.swing.JLabel();

txtcargo = new javax.swing.JTextField();

jPanel1 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jMenuBar1 = new javax.swing.JMenuBar();

jMenu1 = new javax.swing.JMenu();

jMenuItem4 = new javax.swing.JMenuItem();

menuconsultas = new javax.swing.JMenu();

menusanciones = new javax.swing.JMenuItem();

jSeparator2 = new javax.swing.JPopupMenu.Separator();

menuregprestamo = new javax.swing.JMenuItem();

menuregsolicitud = new javax.swing.JMenuItem();

menuregistroreservas = new javax.swing.JMenuItem();

jSeparator4 = new javax.swing.JPopupMenu.Separator();

menuconsultaprestamo = new javax.swing.JMenuItem();

jSeparator3 = new javax.swing.JPopupMenu.Separator();

menubiblioetca = new javax.swing.JMenu();

menucategoria = new javax.swing.JMenuItem();

menulibros = new javax.swing.JMenuItem();

jSeparator1 = new javax.swing.JPopupMenu.Separator();

menufichapress = new javax.swing.JMenuItem();

menureservas = new javax.swing.JMenuItem();

menurrhh = new javax.swing.JMenu();

jMenuItem3 = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel4.setBackground(new java.awt.Color(255, 204, 255));

jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "DATOS LOGIN",


javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 3, 18), new
java.awt.Color(0, 102, 51))); // NOI18N
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

jLabel5.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N

jLabel5.setForeground(new java.awt.Color(153, 153, 0));

jLabel5.setText("Codigo");

jLabel6.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N//Insertamos tipo de letra

jLabel6.setForeground(new java.awt.Color(153, 153, 0));

jLabel6.setText("Nombre");

txtcodigo.setEditable(false);

txtcodigo.setFont(new java.awt.Font("Arial", 3, 16)); // NOI18N

txtcodigo.setForeground(new java.awt.Color(0, 0, 153));

txtnombre.setEditable(false);

txtnombre.setFont(new java.awt.Font("Arial", 3, 16)); // NOI18N

txtnombre.setForeground(new java.awt.Color(0, 0, 153));

jLabel7.setFont(new java.awt.Font("Arial", 1, 16)); // NOI18N

jLabel7.setForeground(new java.awt.Color(0, 102, 51));

jLabel7.setText("Tipo Lector");

txtcargo.setEditable(false);

txtcargo.setFont(new java.awt.Font("Arial", 3, 16)); // NOI18N

txtcargo.setForeground(new java.awt.Color(0, 0, 153));

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);

jPanel4.setLayout(jPanel4Layout);

jPanel4Layout.setHorizontalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel5)

.addGap(18, 18, 18)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 134,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jLabel6)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 411,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jLabel7)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtcargo)

.addContainerGap())

);

jPanel4Layout.setVerticalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel7)

.addComponent(txtcargo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel5)

.addComponent(jLabel6)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/fondo_biblio.png"))); //
NOI18N

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1)

.addGap(0, 0, Short.MAX_VALUE))

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

);

jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/pc.png"))); // NOI18N

jMenu1.setText("SISTEMA");

jMenuItem4.setText("cerrar sesion");

jMenuItem4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem4ActionPerformed(evt);

});

jMenu1.add(jMenuItem4);

jMenuBar1.add(jMenu1);

menuconsultas.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/imagenes/icono_consulta.png"))); // NOI18N

menuconsultas.setText("CONSULTAS");

menuconsultas.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menuconsultasActionPerformed(evt);

});

menusanciones.setText("SANCIONES");

menusanciones.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
menusancionesActionPerformed(evt);

});

menuconsultas.add(menusanciones);

menuconsultas.add(jSeparator2);

menuregprestamo.setText("REGISTRO DE PRESTAMOS");//setTex nos indica que nos


mostrara los valores de registro de préstamo ,funciona lo mismo para los siguientes

menuregprestamo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menuregprestamoActionPerformed(evt);

});

menuconsultas.add(menuregprestamo);

menuregsolicitud.setText("REGISTRO DE SOLICITUDES");

menuregsolicitud.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menuregsolicitudActionPerformed(evt);

});

menuconsultas.add(menuregsolicitud);

menuregistroreservas.setText("REGISTRO DE RESERVAS");

menuregistroreservas.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menuregistroreservasActionPerformed(evt);

});

menuconsultas.add(menuregistroreservas);

menuconsultas.add(jSeparator4);

menuconsultaprestamo.setText("CONSULTA PRESTAMO");

menuconsultaprestamo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menuconsultaprestamoActionPerformed(evt);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

});

menuconsultas.add(menuconsultaprestamo);

menuconsultas.add(jSeparator3);

jMenuBar1.add(menuconsultas);

menubiblioetca.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/imagenes/icono_biblioteca.png"))); // NOI18N

menubiblioetca.setText("BIBLIOTECA");

menucategoria.setText("CATEGORIAS");

menucategoria.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menucategoriaActionPerformed(evt);

});

menubiblioetca.add(menucategoria);

menulibros.setText("LIBROS");

menulibros.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menulibrosActionPerformed(evt);

});

menubiblioetca.add(menulibros);

menubiblioetca.add(jSeparator1);

menufichapress.setText("FICHA PRESTAMO");

menufichapress.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menufichapressActionPerformed(evt);

});

menubiblioetca.add(menufichapress);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
menureservas.setText("RESERVAS");

menureservas.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

menureservasActionPerformed(evt);

});

menubiblioetca.add(menureservas);

jMenuBar1.add(menubiblioetca);

menurrhh.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/icono_rrhh.png"))); //
NOI18N

menurrhh.setText("USUARIOS");

jMenuItem3.setText("ADMIN PERSONAL");

jMenuItem3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jMenuItem3ActionPerformed(evt);

});

menurrhh.add(jMenuItem3);

jMenuBar1.add(menurrhh);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createSequentialGroup()
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap()

.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())

);

pack();

}// </editor-fold>

private void menucategoriaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

categoria cat=new categoria();

cat.setLocationRelativeTo(null);

cat.setVisible(true);

private void menulibrosActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

libros li=new libros();

li.setLocationRelativeTo(null);

li.setVisible(true);

private void jMenuItem4ActionPerformed(java.awt.event.ActionEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
// TODO add your handling code here:

login l=new login();

l.setLocationRelativeTo(null);

l.setVisible(true);

this.setVisible(false);

private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

personas per=new personas();

per.setLocationRelativeTo(null);

per.setVisible(true);

private void menuregprestamoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

registro_prestamos r=new registro_prestamos();

r.setLocationRelativeTo(null);

r.setVisible(true);

private void menufichapressActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

ficha_prestamo fp=new ficha_prestamo();

ficha_prestamo.codigo_persona=codigo_empleado;

ficha_prestamo.cargo=txtcargo.getText();

ficha_prestamo.txtcodigo.setText(txtcodigo.getText());

ficha_prestamo.txtnombre.setText(txtnombre.getText());

ficha_prestamo.txtcargo.setText(txtcargo.getText());

fp.setLocationRelativeTo(null);

fp.setVisible(true);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

private void menuconsultasActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

private void menuregsolicitudActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

confirmar_ficha_prestamo cs=new confirmar_ficha_prestamo();

cs.setLocationRelativeTo(null);

cs.setVisible(true);

private void menuconsultaprestamoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

consulta_prestamo cp=new consulta_prestamo();

consulta_prestamo.txtdato.setText(txtcodigo.getText());

consulta_prestamo.txttipopersona.setText(txtcargo.getText());

cp.setLocationRelativeTo(null);

cp.setVisible(true);

private void menusancionesActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

registro_sancionados rs=new registro_sancionados();

rs.setLocationRelativeTo(null);

rs.setVisible(true);

private void menureservasActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

ficha_prestamo_reserva fr=new ficha_prestamo_reserva();

fr.setLocationRelativeTo(null);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
fr.setVisible(true);

private void menuregistroreservasActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

confirmar_reserva cr=new confirmar_reserva();

cr.setLocationRelativeTo(null);

cr.setVisible(true);

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(menu_principal.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(menu_principal.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(menu_principal.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(menu_principal.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new menu_principal().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JMenu jMenu1;

private javax.swing.JMenuBar jMenuBar1;

private javax.swing.JMenuItem jMenuItem3;

private javax.swing.JMenuItem jMenuItem4;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel4;

private javax.swing.JPopupMenu.Separator jSeparator1;

private javax.swing.JPopupMenu.Separator jSeparator2;

private javax.swing.JPopupMenu.Separator jSeparator3;

private javax.swing.JPopupMenu.Separator jSeparator4;

private javax.swing.JMenu menubiblioetca;

private javax.swing.JMenuItem menucategoria;

private javax.swing.JMenuItem menuconsultaprestamo;

private javax.swing.JMenu menuconsultas;

private javax.swing.JMenuItem menufichapress;

private javax.swing.JMenuItem menulibros;

private javax.swing.JMenuItem menuregistroreservas;

private javax.swing.JMenuItem menuregprestamo;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JMenuItem menuregsolicitud;

private javax.swing.JMenuItem menureservas;

private javax.swing.JMenu menurrhh;

private javax.swing.JMenuItem menusanciones;

private javax.swing.JTextField txtcargo;

private javax.swing.JTextField txtcodigo;

private javax.swing.JTextField txtnombre;

// En esta parte habíamos declarado variables

private void cargar_datos_login() {

conexion cc =new conexion();

Connection cn=cc.conexion();

String sql="";

ResultSet RS1 = null;

if (cargo_empleado.equals("ESTUDIANTE")) {

sql="select

//Realizamos la consulta para saber que tipo de usuario esta ingresando

estudiante.codigo,persona.nombre,persona.apaterno,persona.amaterno,estudiante.carrera_prof from
persona,estudiante where persona.id_persona=estudiante.id_persona and
persona.id_persona='"+codigo_empleado+"'";

}else if (cargo_empleado.equals("DOCENTE")) {//En este caso ve si es docente

sql="select docente.d_codigo,persona.nombre,persona.apaterno,persona.amaterno from


persona,docente where persona.id_persona=docente.id_persona and
persona.id_persona='"+codigo_empleado+"'";

}else if (cargo_empleado.equals("ADMINISTRADOR")) {// si es administrador

sql="select administrador.a_codigo,persona.nombre,persona.apaterno,persona.amaterno from


persona,administrador where persona.id_persona=administrador.id_persona and
persona.id_persona='"+codigo_empleado+"'";

}else if (cargo_empleado.equals("BIBLIOTECARIO")) { // o el usuario que ingreso es


bilbiotecario

sql="select bibliotecario.b_codigo,persona.nombre,persona.apaterno,persona.amaterno from


persona,bibliotecario where persona.id_persona=bibliotecario.id_persona and
persona.id_persona='"+codigo_empleado+"'";

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

try {

//Como anteriormente hemos preparado la consulta ahora ejecutamos la consulta

Statement stmt = cn.createStatement();

RS1 = stmt.executeQuery(sql);

while (RS1.next()) {

txtcodigo.setText(RS1.getString(1));

txtnombre.setText(RS1.getString(2)+" "+RS1.getString(3)+" "+RS1.getString(4));

txtcargo.setText(cargo_empleado);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categorias", 2);

VENTANILLA DE FICHA DE PRESTAMO

En este código se realiza la función de registrar libro a prestarse,y cada acción que
realiza en el código esta explicado por funciones para el fácil entendimiento de los
códigos sobre lo que se esta haciendo.

package presentacion;// Seguimos trabajando en el paquete Presentacion

import clases.*;

import java.sql.*;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.GregorianCalendar;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;//Hemos importado nuestra conexión y las librerías


que estamos utilizando.

/**

*
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
* @author ZOMBYES INFORMATICOS

*/

public class ficha_prestamo extends javax.swing.JFrame {

static String codigo_persona;

static String cargo;

DefaultTableModel model;

public static String[][] list_categoria=new String[9][24];

public static String[] list_subcategoria=new String[200];

/**

* Creates new form ficha_prestamo

*/

public ficha_prestamo() { // Inicializamos nuestro constructor ficha prestamo

initComponents();

rdtitulo.setSelected(true);

cargar_fecha();

cargar_categoria();

cargar_subcategoria();

//cargar_registros();

btnregistrarprestamo.setEnabled(false);

/**

* 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">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jPanel2 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablalibros = new javax.swing.JTable();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel3 = new javax.swing.JPanel();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

btnregistrarprestamo = new javax.swing.JButton();

jPanel4 = new javax.swing.JPanel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

txtcodigo = new javax.swing.JTextField();

txtnombre = new javax.swing.JTextField();

jLabel7 = new javax.swing.JLabel();

txtcargo = new javax.swing.JTextField();

jPanel5 = new javax.swing.JPanel();

rdtitulo = new javax.swing.JRadioButton();

rdautor = new javax.swing.JRadioButton();

rdcodigo = new javax.swing.JRadioButton();

jLabel2 = new javax.swing.JLabel();

jLabel1 = new javax.swing.JLabel();

txtdato = new javax.swing.JTextField();

cnbcategoria = new javax.swing.JComboBox();

jLabel3 = new javax.swing.JLabel();

cnbsubcategoria = new javax.swing.JComboBox();

jPanel6 = new javax.swing.JPanel();

jLabel8 = new javax.swing.JLabel();

txttitulo = new javax.swing.JTextField();

txttitulo1 = new javax.swing.JTextField();

jLabel9 = new javax.swing.JLabel();

jLabel10 = new javax.swing.JLabel();

txtautor = new javax.swing.JTextField();

jLabel13 = new javax.swing.JLabel();

txtcodigolibro = new javax.swing.JTextField();

jLabel12 = new javax.swing.JLabel();

txtid = new javax.swing.JTextField();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel7 = new javax.swing.JPanel();

jScrollPane2 = new javax.swing.JScrollPane();

tabladetalleprestamo = new javax.swing.JTable();

jButton3 = new javax.swing.JButton();

jLabel4 = new javax.swing.JLabel();

txtfechapresstamo = new javax.swing.JTextField();

jLabel11 = new javax.swing.JLabel();

txtfechadevolucion = new javax.swing.JTextField();

//Hemos declarado todo los componentes que vamos a utilizar

jPanel1.setBackground(new java.awt.Color(0, 255, 204));

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "FICHA PRESTAMO",


javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("18thCentury", 0, 14), new
java.awt.Color(0, 102, 102))); // NOI18N

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE LIBROS"));

tablalibros.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

));

tablalibros.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablalibrosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablalibros);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 707, Short.MAX_VALUE)

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 118,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);//Aquí solo estamos colocando para la estética de nuestra ventanilla ficha


prestamo

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/nuevo.png"))); // NOI18N

jButton1.setText("NUEVO");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

btnregistrarprestamo.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnregistrarprestamo.setText("SOLICITAR PRESTAMO");

btnregistrarprestamo.addActionListener(new java.awt.event.ActionListener() {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
public void actionPerformed(java.awt.event.ActionEvent evt) {

btnregistrarprestamoActionPerformed(evt);

});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(29, 29, 29)

.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 141,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(43, 43, 43)

.addComponent(btnregistrarprestamo)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2)

.addContainerGap())

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1)

.addComponent(jButton2))

.addGap(0, 0, Short.MAX_VALUE))

.addComponent(btnregistrarprestamo, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addContainerGap())

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS USUARIO"));

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel5.setForeground(new java.awt.Color(51, 51, 255));

jLabel5.setText("Codigo");

jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel6.setForeground(new java.awt.Color(0, 51, 204));

jLabel6.setText("Nombre");

txtcodigo.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N

txtnombre.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N

jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel7.setForeground(new java.awt.Color(0, 51, 204));

jLabel7.setText("Lector");

txtcargo.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);

jPanel4.setLayout(jPanel4Layout);

jPanel4Layout.setHorizontalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 68,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 136,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel6)

.addGap(18, 18, 18)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 372,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 62, Short.MAX_VALUE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtcargo, javax.swing.GroupLayout.PREFERRED_SIZE, 318,


javax.swing.GroupLayout.PREFERRED_SIZE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap())

);

jPanel4Layout.setVerticalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel5)

.addComponent(jLabel6)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel7)

.addComponent(txtcargo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("BUSAQUEDA DE LIBROS"));

rdtitulo.setText("titulo");

rdtitulo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdtituloActionPerformed(evt);

});

rdautor.setText("Autor");

rdautor.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdautorActionPerformed(evt);

});
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

rdcodigo.setText("codigo");

rdcodigo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdcodigoActionPerformed(evt);

});

jLabel2.setText("Categoria");

jLabel1.setText("Ingrese dato");

txtdato.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

txtdatoKeyReleased(evt);

});

cnbcategoria.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbcategoriaActionPerformed(evt);

});

jLabel3.setText("Sub Categoria");

cnbsubcategoria.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbsubcategoriaActionPerformed(evt);

});

javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);

jPanel5.setLayout(jPanel5Layout);

jPanel5Layout.setHorizontalGroup(

jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel5Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel5Layout.createSequentialGroup()

.addComponent(jLabel3)

.addGap(18, 18, 18)

.addComponent(cnbsubcategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))

.addGroup(jPanel5Layout.createSequentialGroup()

.addComponent(rdtitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 68,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(rdautor, javax.swing.GroupLayout.PREFERRED_SIZE, 67,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(rdcodigo))

.addGroup(jPanel5Layout.createSequentialGroup()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(jLabel1))

.addGap(18, 18, 18)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(cnbcategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE, 205,


javax.swing.GroupLayout.PREFERRED_SIZE))))

.addContainerGap(29, Short.MAX_VALUE))

);

jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1,


jLabel2, jLabel3, rdautor, rdcodigo, rdtitulo});

jPanel5Layout.setVerticalGroup(

jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel5Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(rdtitulo)

.addComponent(rdautor)

.addComponent(rdcodigo))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2)

.addComponent(cnbcategoria, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(2, 2, 2)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(cnbsubcategoria, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel5Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1,


jLabel2, jLabel3, rdautor, rdcodigo, rdtitulo});

jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS DEL LIBRO"));

jLabel8.setText("TITULO");

jLabel9.setText("SUB TITULO");

jLabel10.setText("AUTOR");

jLabel13.setText("CODIGO LIBRO");
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);

jPanel6.setLayout(jPanel6Layout);

jPanel6Layout.setHorizontalGroup(

jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel13)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(txtcodigolibro, javax.swing.GroupLayout.PREFERRED_SIZE, 149,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel9)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18,
Short.MAX_VALUE)

.addComponent(txttitulo1, javax.swing.GroupLayout.PREFERRED_SIZE, 390,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGap(18, 18, 18))

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel10)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(txttitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)

.addComponent(txtautor))

.addContainerGap())

);

jPanel6Layout.setVerticalGroup(
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addGap(8, 8, 8)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel8)

.addComponent(txttitulo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel13)

.addComponent(txtcodigolibro, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel10)

.addComponent(txtautor, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txttitulo1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel9))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jLabel12.setText("CODIGO PRESTAMO");

jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("DETALLE PRESTAMO"));

tabladetalleprestamo.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

"Codigo Libro", "Titulo", "Cantidad"


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

));

jScrollPane2.setViewportView(tabladetalleprestamo);

jButton3.setText("-");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);

jPanel7.setLayout(jPanel7Layout);

jPanel7Layout.setHorizontalGroup(

jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel7Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 1028,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 39,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel7Layout.setVerticalGroup(

jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel7Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel7Layout.createSequentialGroup()

.addComponent(jButton3)

.addGap(0, 76, Short.MAX_VALUE))

.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
Short.MAX_VALUE))

.addContainerGap())
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

jLabel4.setText("Fecha Prestamo");

jLabel11.setText("Fecha Devolucion");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel12)

.addGap(18, 18, 18)

.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, 208,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 134,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtfechapresstamo, javax.swing.GroupLayout.PREFERRED_SIZE, 158,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 134,


javax.swing.GroupLayout.PREFERRED_SIZE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtfechadevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 158,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGap(0, 0, Short.MAX_VALUE)))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)

.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtfechapresstamo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel4))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(txtfechadevolucion, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel11)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel4, 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(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// Agregamos el código de manejo

this.setVisible(false);

private void rdtituloActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdtitulo.setSelected(true);

rdautor.setSelected(false);

rdcodigo.setSelected(false);

private void rdautorActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdtitulo.setSelected(false);

rdautor.setSelected(true);

rdcodigo.setSelected(false);

private void rdcodigoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdtitulo.setSelected(false);

rdautor.setSelected(false);

rdcodigo.setSelected(true);

private void btnregistrarprestamoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

int fila=tablalibros.getSelectedRow();

if (fila>-1) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
if (verificar_sancion()==true) {

if (verificar_estado_usuario()==true) {

registrar_prestamo();

}else JOptionPane.showMessageDialog(this, "PRESTAMO PENDIENTE");

}else JOptionPane.showMessageDialog(this, "ESTAS SANCIONADO");

private void tablalibrosMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

int fila=tablalibros.getSelectedRow();

if (Integer.parseInt(tablalibros.getValueAt(fila, 10).toString())>0) {

btnregistrarprestamo.setEnabled(true);

if (cargo.equals("ESTUDIANTE")) {

txtcodigolibro.setText(tablalibros.getValueAt(fila, 0).toString());

txttitulo.setText(tablalibros.getValueAt(fila, 2).toString());

txttitulo1.setText(tablalibros.getValueAt(fila, 3).toString());

txtautor.setText(tablalibros.getValueAt(fila, 6).toString());

if (cargo.equals("DOCENTE")) {

if (tabladetalleprestamo.getRowCount()<2) {

DefaultTableModel modelo = (DefaultTableModel) tabladetalleprestamo.getModel();

Object[] dato=new Object[5];

dato[0]=tablalibros.getValueAt(fila, 0).toString();

dato[1]=tablalibros.getValueAt(fila, 2).toString();

dato[2]=1;

modelo.addRow(dato);

tabladetalleprestamo.setModel(modelo);

}else{

JOptionPane.showMessageDialog(this,"estock insuficiente");

btnregistrarprestamo.setEnabled(false);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

cargar_fecha();

limpiar();

CARGAR_CODIGO();

btnregistrarprestamo.setEnabled(true);

private void txtdatoKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:

filtrar_registro_libros();

private void cnbcategoriaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

filtrar_registro_libros();

private void cnbsubcategoriaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

filtrar_registro_libros();

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

DefaultTableModel modelo = (DefaultTableModel) tabladetalleprestamo.getModel();

int fila_select = tabladetalleprestamo.getSelectedRow();

if(fila_select<0){

// no se puede eliminar

JOptionPane.showMessageDialog(this,"Tabla vacia o no ha seleccionado una fila.");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}else {

modelo.removeRow(fila_select);

/**

* @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(ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

//</editor-fold>
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new ficha_prestamo().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton btnregistrarprestamo;

private javax.swing.JComboBox cnbcategoria;

private javax.swing.JComboBox cnbsubcategoria;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel11;

private javax.swing.JLabel jLabel12;

private javax.swing.JLabel jLabel13;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JPanel jPanel4;

private javax.swing.JPanel jPanel5;

private javax.swing.JPanel jPanel6;

private javax.swing.JPanel jPanel7;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JScrollPane jScrollPane2;

private javax.swing.JRadioButton rdautor;

private javax.swing.JRadioButton rdcodigo;

private javax.swing.JRadioButton rdtitulo;

private javax.swing.JTable tabladetalleprestamo;

private javax.swing.JTable tablalibros;

private javax.swing.JTextField txtautor;

public static javax.swing.JTextField txtcargo;

public static javax.swing.JTextField txtcodigo;

private javax.swing.JTextField txtcodigolibro;

private javax.swing.JTextField txtdato;

private javax.swing.JTextField txtfechadevolucion;

private javax.swing.JTextField txtfechapresstamo;

private javax.swing.JTextField txtid;

public static javax.swing.JTextField txtnombre;

private javax.swing.JTextField txttitulo;

private javax.swing.JTextField txttitulo1;

// Fin de variables en declaracion

private void cargar_fecha() {

java.util.Date date = new java.util.Date();

java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

String fecha = sdf.format(date);

txtfechapresstamo.setText(fecha);

if (txtcargo.getText().equals("ESTUDIANTE")) {

SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");

String fechadev1="";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
try {

fechadev1 = sumarFechasDias(formatoDelTexto.parse(fecha), 2);

txtfechadevolucion.setText(fechadev1);

} catch (ParseException ex) {

JOptionPane.showMessageDialog(this, ex);

if(txtcargo.getText().equals("DOCENTE")) {

SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");

String fechadev="";

try {

fechadev = sumarFechasDias(formatoDelTexto.parse(fecha), 3);

txtfechadevolucion.setText(fechadev);

} catch (ParseException ex) {

JOptionPane.showMessageDialog(this, ex);

private void cargar_categoria() {

conexion cc =new conexion();

Connection cn=cc.conexion();

ResultSet RS1 = null;

String sql="select *from categoria";

try {

Statement stmt = cn.createStatement();

RS1 = stmt.executeQuery(sql);

int i = 0;

for (int j = cnbcategoria.getItemCount() - 1; j >= 0; j--) {

cnbcategoria.removeItemAt(j);

while (RS1.next()) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
list_categoria[0][i] = (String) RS1.getString(1);

list_categoria[1][i] = (String) RS1.getString(2);

cnbcategoria.addItem(list_categoria[1][i]) ;

i++;

RS1.close();

stmt.close();

cn.close();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categoria", 2);

private void cargar_subcategoria() {

conexion cc =new conexion();

Connection cn=cc.conexion();

ResultSet RS1 = null;

String sql="select distinct p_subcategoria from libros";

try {

Statement stmt = cn.createStatement();

RS1 = stmt.executeQuery(sql);

int i=0;

while (RS1.next()) {

list_subcategoria[i] = (String) RS1.getString(1);

cnbsubcategoria.addItem(list_subcategoria[i]);

i++;

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
RS1.close();

stmt.close();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categorias", 2);

private void cargar_registros() {

String [] titulos ={"Codigo","Nombre","Titulo","Sub Titulo","Categoria","Editorial","Autor","Serie","Sub


Categoria","Fecha","Cantidad"};

String [] registros=new String[11];

String sql="select *from libros";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
registros[7]=rs.getString(8);

registros[8]=rs.getString(9);

registros[9]=rs.getString(10);

registros[10]=rs.getString(11);

model.addRow(registros);

tablalibros.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void limpiar() {

txtautor.setText(null);

txtdato.setText(null);

txttitulo.setText(null);

txttitulo1.setText(null);

txtcodigolibro.setText(null);

SimpleDateFormat formatofecha = new SimpleDateFormat("yyyy-MM-dd");

private String sumarFechasDias(java.util.Date fch, int dias) {

Calendar cal = new GregorianCalendar();

cal.setTime(fch);

cal.add(Calendar.DATE, dias);

return "" + formatofecha.format(cal.getTime());

private void registrar_prestamo() {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
conexion cx=new conexion();

Connection con=cx.conexion();

if (txtcargo.getText().equals("ESTUDIANTE")) {

String sqlestudiante="insert into ficha_Pestudiante values(?,?,?,?,?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, txtid.getText());

pst1.setString(2, txtcodigolibro.getText());

pst1.setString(3, codigo_persona);

pst1.setString(4, "1");

pst1.setString(5, txtfechapresstamo.getText());

pst1.setString(6, txtfechadevolucion.getText());

pst1.setString(7, "SOLICITANDO");

int reg1=pst1.executeUpdate();

if (reg1>0) {

actualizar_stock(txtcodigolibro.getText());

JOptionPane.showMessageDialog(this, "registro con exito");

btnregistrarprestamo.setEnabled(false);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);

if (txtcargo.getText().equals("DOCENTE")) {

int reg2=0;

String sqlestudiante="insert into ficha_PDocente values(?,?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, txtid.getText());

pst1.setString(2, codigo_persona);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
pst1.setString(3, txtfechapresstamo.getText());

pst1.setString(4, txtfechadevolucion.getText());

int reg1=pst1.executeUpdate();

if (reg1>0) {

for (int i = 0; i < tabladetalleprestamo.getRowCount(); i++) {

PreparedStatement pst2=con.prepareStatement("insert into detalle_ficha_PDocente


values(?,?,?,?)");

pst2.setString(1, txtid.getText());

pst2.setString(2, tabladetalleprestamo.getValueAt(i, 0).toString());

pst2.setString(3, "1");

pst2.setString(4, "SOLICITANDO");

reg2=pst2.executeUpdate();

actualizar_stock(tabladetalleprestamo.getValueAt(i, 0).toString());

if (reg2>0) {

JOptionPane.showMessageDialog(this, "Registro con Exito");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);

private void CARGAR_CODIGO() {

String sql="";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
try {

conexion cx=new conexion();

Connection con=cx.conexion();

if (txtcargo.getText().equals("ESTUDIANTE")) {

sql="select max(f_codigo) as 'Codigo' from ficha_Pestudiante";

if (txtcargo.getText().equals("DOCENTE")) {

sql="select max(f_codigo) as 'Codigo' from ficha_PDocente";

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(sql);

if (rs.next()) {

int lastID = rs.getInt(1);

txtid.setText(String.valueOf(lastID + 1));

rs.close();

stmt.close();

} catch (SQLException error) {

System.out.print(error);

private String Buscar_Categoria(int PosicionEntrada, int PosicionSalida, String Texto) {

String texto = "";

try {

for (int i = 0; i < list_categoria[PosicionEntrada].length; i++) {

if (list_categoria[PosicionEntrada][i] == null) {

} else if (list_categoria[PosicionEntrada][i].equals(Texto)) {

texto = list_categoria[PosicionSalida][i];
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
break;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "ERROR AL BUSCAR categoria ", "ERROR", 2, null);

return texto;

private void filtrar_registro_libros() {

String codigo_categoria=Buscar_Categoria(1, 0, (String)


cnbcategoria.getItemAt(cnbcategoria.getSelectedIndex()));

String SubCtegoria=(String) cnbsubcategoria.getSelectedItem();

String tipo_busqueda="";

if (rdtitulo.isSelected() == true) {

tipo_busqueda ="p_titulo";

}else if (rdautor.isSelected() == true) {

tipo_busqueda = "p_autor";

}else if (rdcodigo.isSelected() == true) {

tipo_busqueda = "p_codigo";

//Preparamos la consulta

String [] titulos ={"Codigo","Nombre","Titulo","Sub Titulo","Categoria","Editorial","Autor","Serie","Sub


Categoria","Fecha","Cantidad"};

String [] registros=new String[11];

String sql="SELECT * FROM libros WHERE ca_codigo='"+codigo_categoria+"' and


p_subcategoria='"+SubCtegoria+"' and libros."+tipo_busqueda+" LIKE '%"+txtdato.getText()+"%'";

model=new DefaultTableModel(null,titulos);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

registros[7]=rs.getString(8);

registros[8]=rs.getString(9);

registros[9]=rs.getString(10);

registros[10]=rs.getString(11);

model.addRow(registros);

tablalibros.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void actualizar_stock( String codigo) {

conexion cn=new conexion();

Connection cc=cn.conexion();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String sql1="update libros set p_cantidad=p_cantidad-1 where p_codigo='"+codigo+"'";

try {

PreparedStatement pst1 = cc.prepareStatement(sql1);

pst1.executeUpdate();

cargar_registros();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "error"+ex);

private boolean verificar_estado_usuario() {

boolean bol=false;

try {

conexion cx=new conexion();

Connection con=cx.conexion();

String sql="";

Statement stm=con.createStatement();

if (txtcargo.getText().equals("ESTUDIANTE")) {

sql="select *from ficha_Pestudiante where id_persona='"+codigo_persona+"' and


f_estado='SOLICITANDO' or f_estado='EN PRESTAMO' or f_estado='RESERVADO'";

if (txtcargo.getText().equals("DOCENTE")) {

sql="select detalle_ficha_PDocente.df_estado from ficha_PDocente,detalle_ficha_PDocente where


ficha_PDocente.f_codigo=detalle_ficha_PDocente.f_codigo and
ficha_PDocente.id_persona='"+codigo_persona+"' and detalle_ficha_PDocente.df_estado='SOLICITANDO' or
detalle_ficha_PDocente.df_estado='EN PRESTAMO' or detalle_ficha_PDocente.df_estado='RESERVADO'";

ResultSet rs=stm.executeQuery(sql);

if (rs.next()) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
bol=false;

}else bol=true;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e);

return bol;

private boolean verificar_sancion() {

boolean bol=false;

try {

conexion cx=new conexion();

Connection con=cx.conexion();

String sql="";

Statement stm=con.createStatement();

if (txtcargo.getText().equals("ESTUDIANTE")) {

sql="select *from sancion where s_codigopersona='"+txtcodigo.getText()+"' and


s_usuario='ESTUDIANTE' and s_estado='ACTIVO'";

if (txtcargo.getText().equals("DOCENTE")) {

sql="select *from sancion where s_codigopersona='"+txtcodigo.getText()+"' and s_usuario='DOCENTE'


and s_estado='ACTIVO'";

ResultSet rs=stm.executeQuery(sql);

if (rs.next()) {

bol=false;

}else bol=true;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e);

return bol;

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

VENTANILLA DE LA FICHA DE RESERVA

Esta ventanilla tambien esta explicado por cada acción como funciones de sistema
para el fácil entendimiento,el código se muestra casi similar a la de ficha de
préstamo,la diferencia es que en esta los datos se transfieren direntamente a la
ventanilla reporte de reserva ,mientras que la otra a reporte de préstamo .

En este caso la ficha de reserva será manejada por el bibliotecario mediante la


llamada de un lector.

package presentacion;

import clases.*;

import java.sql.*;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.GregorianCalendar;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

/**

* @author zombyes informaticos

*/

public class ficha_prestamo_reserva extends javax.swing.JFrame {

static String codigo_persona;

static String cargo;

DefaultTableModel model;

public static String[][] list_categoria=new String[9][24];

public static String[] list_subcategoria=new String[200];

/**

* Creates new form ficha_prestamo

*/

public ficha_prestamo_reserva() {

initComponents();

rdtitulo.setSelected(true);

cargar_fecha();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
cargar_categoria();

cargar_subcategoria();

//cargar_registros();

btnregistrarprestamo.setEnabled(false);

rdestudiante.setSelected(true);

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jPanel2 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablalibros = new javax.swing.JTable();

jPanel3 = new javax.swing.JPanel();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

btnregistrarprestamo = new javax.swing.JButton();

jPanel4 = new javax.swing.JPanel();

jLabel5 = new javax.swing.JLabel();

jLabel6 = new javax.swing.JLabel();

txtcodigousuario = new javax.swing.JTextField();

txtnombre = new javax.swing.JTextField();

jLabel7 = new javax.swing.JLabel();

txtcargo = new javax.swing.JTextField();

rdestudiante = new javax.swing.JRadioButton();

rddocente = new javax.swing.JRadioButton();

jLabel14 = new javax.swing.JLabel();

txtidpersona = new javax.swing.JTextField();

jPanel5 = new javax.swing.JPanel();

rdtitulo = new javax.swing.JRadioButton();

rdautor = new javax.swing.JRadioButton();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
rdcodigo = new javax.swing.JRadioButton();

jLabel2 = new javax.swing.JLabel();

jLabel1 = new javax.swing.JLabel();

txtdato = new javax.swing.JTextField();

cnbcategoria = new javax.swing.JComboBox();

jLabel3 = new javax.swing.JLabel();

cnbsubcategoria = new javax.swing.JComboBox();

jPanel6 = new javax.swing.JPanel();

jLabel8 = new javax.swing.JLabel();

txttitulo = new javax.swing.JTextField();

txttitulo1 = new javax.swing.JTextField();

jLabel9 = new javax.swing.JLabel();

jLabel10 = new javax.swing.JLabel();

txtautor = new javax.swing.JTextField();

jLabel13 = new javax.swing.JLabel();

txtcodigolibro = new javax.swing.JTextField();

jLabel12 = new javax.swing.JLabel();

txtid = new javax.swing.JTextField();

jPanel7 = new javax.swing.JPanel();

jScrollPane2 = new javax.swing.JScrollPane();

tabladetalleprestamo = new javax.swing.JTable();

jButton3 = new javax.swing.JButton();

jLabel4 = new javax.swing.JLabel();

txtfechapresstamo = new javax.swing.JTextField();

jLabel11 = new javax.swing.JLabel();

txtfechadevolucion = new javax.swing.JTextField();

jPanel1.setBackground(new java.awt.Color(102, 102, 255));

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "FICHA PRESTAMO",


javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("18thCentury", 0, 14), new
java.awt.Color(0, 102, 102))); // NOI18N
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE LIBROS"));

tablalibros.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

));

tablalibros.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablalibrosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablalibros);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1)

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 118,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/nuevo.png"))); // NOI18N

jButton1.setText("NUEVO");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

btnregistrarprestamo.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnregistrarprestamo.setText("REGISTRAR RESERVA");

btnregistrarprestamo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnregistrarprestamoActionPerformed(evt);

});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton1)

.addGap(330, 330, 330))

.addGroup(jPanel3Layout.createSequentialGroup()

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(btnregistrarprestamo))

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(35, 35, 35)

.addComponent(jButton2)))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(30, 30, 30)

.addComponent(jButton1)

.addGap(40, 40, 40)

.addComponent(btnregistrarprestamo, javax.swing.GroupLayout.PREFERRED_SIZE, 58,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2)

.addGap(62, 62, 62))

);

jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS USUARIO"));

jLabel5.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel5.setForeground(new java.awt.Color(204, 0, 0));

jLabel5.setText("Codigo");
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel6.setForeground(new java.awt.Color(204, 0, 0));

jLabel6.setText("Nombre");

txtcodigousuario.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N

txtcodigousuario.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txtcodigousuarioMouseClicked(evt);

});

txtcodigousuario.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

txtcodigousuarioActionPerformed(evt);

});

txtnombre.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N

jLabel7.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel7.setForeground(new java.awt.Color(204, 0, 0));

jLabel7.setText("Lector");

txtcargo.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N

rdestudiante.setText("ESTUDIATES");

rdestudiante.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdestudianteActionPerformed(evt);

});

rddocente.setText("DOCENTES");
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
rddocente.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rddocenteActionPerformed(evt);

});

jLabel14.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N

jLabel14.setForeground(new java.awt.Color(204, 0, 0));

jLabel14.setText("ID");

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);

jPanel4.setLayout(jPanel4Layout);

jPanel4Layout.setHorizontalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel4Layout.createSequentialGroup()

.addGap(4, 4, 4)

.addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 68,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtcargo))

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 68,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtcodigousuario, javax.swing.GroupLayout.PREFERRED_SIZE, 167,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel4Layout.createSequentialGroup()

.addComponent(rdestudiante, javax.swing.GroupLayout.PREFERRED_SIZE, 120,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(rddocente, javax.swing.GroupLayout.PREFERRED_SIZE, 127,
javax.swing.GroupLayout.PREFERRED_SIZE))))

.addGap(18, 18, 18)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel14, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addGap(18, 18, 18)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 372,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtidpersona, javax.swing.GroupLayout.PREFERRED_SIZE, 187,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(0, 0, Short.MAX_VALUE))

);

jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5,


jLabel7});

jPanel4Layout.setVerticalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addGap(4, 4, 4)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(rdestudiante)

.addComponent(rddocente))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel5)

.addComponent(txtcodigousuario, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel6)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel7)

.addComponent(txtcargo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel14)

.addComponent(txtidpersona, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel5,


jLabel7});

jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("BUSQUEDA DE LIBROS"));

rdtitulo.setText("titulo");

rdtitulo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdtituloActionPerformed(evt);

});

rdautor.setText("Autor");

rdautor.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdautorActionPerformed(evt);

});

rdcodigo.setText("codigo");

rdcodigo.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdcodigoActionPerformed(evt);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
});

jLabel2.setText("Categoria");

jLabel1.setText("Ingrese dato");

txtdato.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

txtdatoKeyReleased(evt);

});

cnbcategoria.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbcategoriaActionPerformed(evt);

});

jLabel3.setText("Sub Categoria");

cnbsubcategoria.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbsubcategoriaActionPerformed(evt);

});

javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);

jPanel5.setLayout(jPanel5Layout);

jPanel5Layout.setHorizontalGroup(

jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel5Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel5Layout.createSequentialGroup()

.addComponent(jLabel3)

.addGap(18, 18, 18)


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(cnbsubcategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))

.addGroup(jPanel5Layout.createSequentialGroup()

.addComponent(rdtitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 68,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(rdautor, javax.swing.GroupLayout.PREFERRED_SIZE, 67,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(rdcodigo))

.addGroup(jPanel5Layout.createSequentialGroup()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(jLabel1))

.addGap(18, 18, 18)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cnbcategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE, 205,


javax.swing.GroupLayout.PREFERRED_SIZE))))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1,


jLabel2, jLabel3, rdautor, rdcodigo, rdtitulo});

jPanel5Layout.setVerticalGroup(

jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel5Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(rdtitulo)

.addComponent(rdautor)

.addComponent(rdcodigo))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2)

.addComponent(cnbcategoria, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(10, 10, 10)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(cnbsubcategoria, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel5Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1,


jLabel2, jLabel3, rdautor, rdcodigo, rdtitulo});

jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS DEL LIBRO"));

jLabel8.setText("TITULO");

jLabel9.setText("SUB TITULO");

jLabel10.setText("AUTOR");

jLabel13.setText("CODIGO LIBRO");//Mostramos valores o los atributos del objeto libro

javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);

jPanel6.setLayout(jPanel6Layout);

jPanel6Layout.setHorizontalGroup(

jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel13)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(txtcodigolibro, javax.swing.GroupLayout.PREFERRED_SIZE, 149,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel9)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18,
Short.MAX_VALUE)

.addComponent(txttitulo1, javax.swing.GroupLayout.PREFERRED_SIZE, 390,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGap(18, 18, 18))

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel10)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(txttitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)

.addComponent(txtautor))

.addContainerGap())

);

jPanel6Layout.setVerticalGroup(

jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addGap(8, 8, 8)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel8)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(txttitulo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel13)

.addComponent(txtcodigolibro, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel10)

.addComponent(txtautor, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txttitulo1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel9))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jLabel12.setText("CODIGO PRESTAMO");

txtid.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

txtidActionPerformed(evt);

});

jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder("DETALLE PRESTAMO"));

tabladetalleprestamo.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

"Codigo Libro", "Titulo", "Cantidad"

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
));

jScrollPane2.setViewportView(tabladetalleprestamo);

jButton3.setText("-");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);

jPanel7.setLayout(jPanel7Layout);

jPanel7Layout.setHorizontalGroup(

jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel7Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 1027,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 39,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel7Layout.setVerticalGroup(

jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel7Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel7Layout.createSequentialGroup()

.addComponent(jButton3)

.addGap(0, 76, Short.MAX_VALUE))

.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0,
Short.MAX_VALUE))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap())

);

jLabel4.setText("Fecha RESERVA");

jLabel11.setText("Fecha DE EXPIRACION");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, 1091, Short.MAX_VALUE)

.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)

.addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
jPanel1Layout.createSequentialGroup()

.addComponent(jLabel12)

.addGap(18, 18, 18)

.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, 208,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()

.addGap(0, 0, Short.MAX_VALUE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 134,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(txtfechapresstamo, javax.swing.GroupLayout.PREFERRED_SIZE, 158,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 131,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(txtfechadevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 158,


javax.swing.GroupLayout.PREFERRED_SIZE)))))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 207,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap(37, Short.MAX_VALUE)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(txtfechadevolucion, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel11)

.addComponent(txtfechapresstamo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel4))

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel12)

.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel1Layout.createSequentialGroup()
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

pack();

}// </editor-fold>

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.setVisible(false);

private void rdtituloActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdtitulo.setSelected(true);

rdautor.setSelected(false);

rdcodigo.setSelected(false);

private void rdautorActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdtitulo.setSelected(false);

rdautor.setSelected(true);

rdcodigo.setSelected(false);

private void rdcodigoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdtitulo.setSelected(false);

rdautor.setSelected(false);

rdcodigo.setSelected(true);

private void btnregistrarprestamoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

int fila=tablalibros.getSelectedRow();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
if (fila>-1) {

if (verificar_sancion()==true) {

if (verificar_estado_usuario()==true) {

registrar_prestamo();

}else JOptionPane.showMessageDialog(this, "PRESTAMO PENDIENTE");

}else JOptionPane.showMessageDialog(this, "ESTAS SANCIONADO");

private void tablalibrosMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

int fila=tablalibros.getSelectedRow();

if (Integer.parseInt(tablalibros.getValueAt(fila, 10).toString())>0) {

if (Integer.parseInt(tablalibros.getValueAt(fila, 10).toString())!=1) {

btnregistrarprestamo.setEnabled(true);

if (txtcargo.getText().equals("ESTUDIANTE")) {

txtcodigolibro.setText(tablalibros.getValueAt(fila, 0).toString());

txttitulo.setText(tablalibros.getValueAt(fila, 2).toString());

txttitulo1.setText(tablalibros.getValueAt(fila, 3).toString());

txtautor.setText(tablalibros.getValueAt(fila, 6).toString());

if (txtcargo.getText().equals("DOCENTE")) {

if (tabladetalleprestamo.getRowCount()<2) {

DefaultTableModel modelo = (DefaultTableModel) tabladetalleprestamo.getModel();

Object[] dato=new Object[5];

dato[0]=tablalibros.getValueAt(fila, 0).toString();

dato[1]=tablalibros.getValueAt(fila, 2).toString();

dato[2]=1;

modelo.addRow(dato);

tabladetalleprestamo.setModel(modelo);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

}else{

JOptionPane.showMessageDialog(this,"LO SENTIMOS SOLO PARA USO EN SALA ");

btnregistrarprestamo.setEnabled(false);

}else{

JOptionPane.showMessageDialog(this,"LIBRO AGOTADO");

btnregistrarprestamo.setEnabled(false);

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

cargar_fecha();

limpiar();

CARGAR_CODIGO();

btnregistrarprestamo.setEnabled(true);

private void txtdatoKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:

filtrar_registro_libros();

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private void cnbcategoriaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

filtrar_registro_libros();

private void cnbsubcategoriaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

filtrar_registro_libros();

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

DefaultTableModel modelo = (DefaultTableModel) tabladetalleprestamo.getModel();

int fila_select = tabladetalleprestamo.getSelectedRow();

if(fila_select<0){

// no se puede eliminar

JOptionPane.showMessageDialog(this,"Tabla vacia o no ha seleccionado una fila.");

}else {

modelo.removeRow(fila_select);

private void txtcodigousuarioActionPerformed(java.awt.event.ActionEvent evt) {

// Agregamos su código de manjo aqui

conexion cx=new conexion();

Connection cn=cx.conexion();

String sql="";

try{

if (rdestudiante.isSelected() == true) {

sql="select persona.id_persona,persona.nombre,persona.apaterno,persona.amaterno,persona.tipo from


estudiante,persona where estudiante.id_persona=persona.id_persona and
estudiante.codigo='"+txtcodigousuario.getText()+"' ";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

}else if (rddocente.isSelected() == true) {

sql="select persona.id_persona,persona.nombre,persona.apaterno,persona.amaterno,persona.tipo from


docente,persona where docente.id_persona=persona.id_persona and
docente.d_codigo='"+txtcodigousuario.getText()+"' ";

Statement st1=cn.createStatement();

ResultSet rs1=st1.executeQuery(sql);

if(rs1.next()){

codigo_persona=rs1.getString(1);

txtidpersona.setText(rs1.getString(1));

txtnombre.setText(rs1.getString(2)+" "+rs1.getString(3)+" "+rs1.getString(4));

txtcargo.setText(rs1.getString(5));

}//fin de if seguro true

}catch(Exception ex){

JOptionPane.showMessageDialog(this, "error..."+ex);

private void rdestudianteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdestudiante.setSelected(true);

rddocente.setSelected(false);

private void rddocenteActionPerformed(java.awt.event.ActionEvent evt) {

rdestudiante.setSelected(false);

rddocente.setSelected(true);

private void txtcodigousuarioMouseClicked(java.awt.event.MouseEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
// TODO add your handling code here:

txtcodigousuario.setText(null);

txtnombre.setText(null);

txtcargo.setText(null);

private void txtidActionPerformed(java.awt.event.ActionEvent evt) {

/**

* @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(ficha_prestamo_reserva.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(ficha_prestamo_reserva.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(ficha_prestamo_reserva.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(ficha_prestamo_reserva.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 ficha_prestamo_reserva().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton btnregistrarprestamo;

private javax.swing.JComboBox cnbcategoria;

private javax.swing.JComboBox cnbsubcategoria;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel11;

private javax.swing.JLabel jLabel12;

private javax.swing.JLabel jLabel13;

private javax.swing.JLabel jLabel14;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;

private javax.swing.JPanel jPanel4;

private javax.swing.JPanel jPanel5;

private javax.swing.JPanel jPanel6;

private javax.swing.JPanel jPanel7;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JScrollPane jScrollPane2;

private javax.swing.JRadioButton rdautor;

private javax.swing.JRadioButton rdcodigo;

private javax.swing.JRadioButton rddocente;

private javax.swing.JRadioButton rdestudiante;

private javax.swing.JRadioButton rdtitulo;

private javax.swing.JTable tabladetalleprestamo;

private javax.swing.JTable tablalibros;

private javax.swing.JTextField txtautor;

public static javax.swing.JTextField txtcargo;

private javax.swing.JTextField txtcodigolibro;

public static javax.swing.JTextField txtcodigousuario;

private javax.swing.JTextField txtdato;

private javax.swing.JTextField txtfechadevolucion;

private javax.swing.JTextField txtfechapresstamo;

private javax.swing.JTextField txtid;

private javax.swing.JTextField txtidpersona;

public static javax.swing.JTextField txtnombre;

private javax.swing.JTextField txttitulo;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JTextField txttitulo1;

// Fin de variables en declaracion

private void cargar_fecha() {

java.util.Date date = new java.util.Date();

java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

String fecha = sdf.format(date);

txtfechapresstamo.setText(fecha);

if (txtcargo.getText().equals("ESTUDIANTE")) {

SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");

String fechadev1="";

try {

fechadev1 = sumarFechasDias(formatoDelTexto.parse(fecha), 1);

txtfechadevolucion.setText(fechadev1);

} catch (ParseException ex) {

JOptionPane.showMessageDialog(this, ex);

if(txtcargo.getText().equals("DOCENTE")) {

SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");

String fechadev="";

try {

fechadev = sumarFechasDias(formatoDelTexto.parse(fecha),1);

txtfechadevolucion.setText(fechadev);

} catch (ParseException ex) {

JOptionPane.showMessageDialog(this, ex);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void cargar_categoria() {

conexion cc =new conexion();

Connection cn=cc.conexion();

ResultSet RS1 = null;

String sql="select *from categoria"; //preparamos la consulta

try {

Statement stmt = cn.createStatement(); // Ejecutamos la consulta

RS1 = stmt.executeQuery(sql);

int i = 0;

for (int j = cnbcategoria.getItemCount() - 1; j >= 0; j--) {

cnbcategoria.removeItemAt(j);

while (RS1.next()) {

list_categoria[0][i] = (String) RS1.getString(1);

list_categoria[1][i] = (String) RS1.getString(2);

cnbcategoria.addItem(list_categoria[1][i]) ;

i++;

RS1.close();

stmt.close();

cn.close();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categoria", 2);

private void cargar_subcategoria() {

conexion cc =new conexion();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
Connection cn=cc.conexion();

ResultSet RS1 = null;

String sql="select distinct p_subcategoria from libros";

try { // Casi en la mayor parte podemos observar consultas junto a statement quien
ejecuta la consulta

Statement stmt = cn.createStatement();

RS1 = stmt.executeQuery(sql);

int i=0;

while (RS1.next()) {

list_subcategoria[i] = (String) RS1.getString(1);

cnbsubcategoria.addItem(list_subcategoria[i]);

i++;

RS1.close();

stmt.close();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categorias", 2);

private void cargar_registros() {

String [] titulos ={"Codigo","Nombre","Titulo","Sub Titulo","Categoria","Editorial","Autor","Serie","Sub


Categoria","Fecha","Cantidad"};

String [] registros=new String[11];

String sql="select *from libros";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

registros[7]=rs.getString(8);

registros[8]=rs.getString(9);

registros[9]=rs.getString(10);

registros[10]=rs.getString(11);

//Hemos agarrado los valores de la tabla libros

model.addRow(registros);

tablalibros.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void limpiar() {

txtautor.setText(null);

txtdato.setText(null);

txttitulo.setText(null);

txttitulo1.setText(null);

txtcodigolibro.setText(null);

SimpleDateFormat formatofecha = new SimpleDateFormat("yyyy-MM-dd");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private String sumarFechasDias(java.util.Date fch, int dias) {

Calendar cal = new GregorianCalendar();

cal.setTime(fch);

cal.add(Calendar.DATE, dias);

return "" + formatofecha.format(cal.getTime());

private void registrar_prestamo() {

conexion cx=new conexion();

Connection con=cx.conexion();

if (txtcargo.getText().equals("ESTUDIANTE")) {

String sqlestudiante="insert into ficha_Pestudiante values(?,?,?,?,?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, txtid.getText());

pst1.setString(2, txtcodigolibro.getText());

pst1.setString(3, txtidpersona.getText());

pst1.setString(4, "1");

pst1.setString(5, txtfechapresstamo.getText());

pst1.setString(6, txtfechadevolucion.getText());

pst1.setString(7, "RESERVADO");

int reg1=pst1.executeUpdate();

if (reg1>0) {

actualizar_stock(txtcodigolibro.getText());

JOptionPane.showMessageDialog(this, "registro con exito");

btnregistrarprestamo.setEnabled(false);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

if (txtcargo.getText().equals("DOCENTE")) {

int reg2=0;

String sqlestudiante="insert into ficha_PDocente values(?,?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, txtid.getText());

pst1.setString(2, txtidpersona.getText());

pst1.setString(3, txtfechapresstamo.getText());

pst1.setString(4, txtfechadevolucion.getText());

int reg1=pst1.executeUpdate();

if (reg1>0) {

for (int i = 0; i < tabladetalleprestamo.getRowCount(); i++) {

PreparedStatement pst2=con.prepareStatement("insert into detalle_ficha_PDocente


values(?,?,?,?)");

pst2.setString(1, txtid.getText());

pst2.setString(2, tabladetalleprestamo.getValueAt(i, 0).toString());

pst2.setString(3, "1");

pst2.setString(4, "RESERVADO");

reg2=pst2.executeUpdate();

actualizar_stock(tabladetalleprestamo.getValueAt(i, 0).toString());

if (reg2>0) {

JOptionPane.showMessageDialog(this, "Registro con Exito");

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);

private void CARGAR_CODIGO() {

String sql="";

try {

conexion cx=new conexion();

Connection con=cx.conexion();

if (txtcargo.getText().equals("ESTUDIANTE")) {

sql="select max(f_codigo) as 'Codigo' from ficha_Pestudiante";

if (txtcargo.getText().equals("DOCENTE")) {

sql="select max(f_codigo) as 'Codigo' from ficha_PDocente";

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery(sql);

if (rs.next()) {

int lastID = rs.getInt(1);

txtid.setText(String.valueOf(lastID + 1));

rs.close();

stmt.close();

} catch (SQLException error) {

System.out.print(error);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private String Buscar_Categoria(int PosicionEntrada, int PosicionSalida, String Texto) {

String texto = "";

try {

for (int i = 0; i < list_categoria[PosicionEntrada].length; i++) {

if (list_categoria[PosicionEntrada][i] == null) {

} else if (list_categoria[PosicionEntrada][i].equals(Texto)) {

texto = list_categoria[PosicionSalida][i];

break;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "ERROR AL BUSCAR categoria ", "ERROR", 2, null);

return texto;

private void filtrar_registro_libros() {

String codigo_categoria=Buscar_Categoria(1, 0, (String)


cnbcategoria.getItemAt(cnbcategoria.getSelectedIndex()));

String SubCtegoria=(String) cnbsubcategoria.getSelectedItem();

String tipo_busqueda="";

if (rdtitulo.isSelected() == true) {

tipo_busqueda ="p_titulo";

}else if (rdautor.isSelected() == true) {

tipo_busqueda = "p_autor";

}else if (rdcodigo.isSelected() == true) {

tipo_busqueda = "p_codigo";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

String [] titulos ={"Codigo","Nombre","Titulo","Sub Titulo","Categoria","Editorial","Autor","Serie","Sub


Categoria","Fecha","Cantidad"};

String [] registros=new String[11];

String sql="SELECT * FROM libros WHERE ca_codigo='"+codigo_categoria+"' and


p_subcategoria='"+SubCtegoria+"' and libros."+tipo_busqueda+" LIKE '%"+txtdato.getText()+"%'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

registros[7]=rs.getString(8);

registros[8]=rs.getString(9);

registros[9]=rs.getString(10);

registros[10]=rs.getString(11);

model.addRow(registros);

tablalibros.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void actualizar_stock( String codigo) {

conexion cn=new conexion();

Connection cc=cn.conexion();

String sql1="update libros set p_cantidad=p_cantidad-1 where p_codigo='"+codigo+"'";

try {

PreparedStatement pst1 = cc.prepareStatement(sql1);

pst1.executeUpdate();

cargar_registros();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "error"+ex);

private boolean verificar_estado_usuario() {

boolean bol=false;

try {

conexion cx=new conexion();

Connection con=cx.conexion();

String sql="";

Statement stm=con.createStatement();

if (txtcargo.getText().equals("ESTUDIANTE")) {

sql="select *from ficha_Pestudiante where id_persona='"+txtidpersona.getText()+"' and


f_estado='SOLICITANDO' or f_estado='EN PRESTAMO' or f_estado='RESERVADO'";

if (txtcargo.getText().equals("DOCENTE")) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
sql="select detalle_ficha_PDocente.df_estado from ficha_PDocente,detalle_ficha_PDocente where
ficha_PDocente.f_codigo=detalle_ficha_PDocente.f_codigo and
ficha_PDocente.id_persona='"+txtidpersona.getText()+"' and detalle_ficha_PDocente.df_estado='SOLICITANDO'
or detalle_ficha_PDocente.df_estado='EN PRESTAMO' or detalle_ficha_PDocente.df_estado='RESERVADO'";

ResultSet rs=stm.executeQuery(sql);

if (rs.next()) {

bol=false;

}else bol=true;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e);

return bol;

private boolean verificar_sancion() {

boolean bol=false;

try {

conexion cx=new conexion();

Connection con=cx.conexion();

String sql="";

Statement stm=con.createStatement();

if (txtcargo.getText().equals("ESTUDIANTE")) {

sql="select *from sancion where s_codigopersona='"+txtcodigousuario.getText()+"' and


s_usuario='ESTUDIANTE' and s_estado='ACTIVO'";

if (txtcargo.getText().equals("DOCENTE")) {

sql="select *from sancion where s_codigopersona='"+txtcodigousuario.getText()+"' and


s_usuario='DOCENTE' and s_estado='ACTIVO'";

ResultSet rs=stm.executeQuery(sql);

if (rs.next()) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
bol=false;

}else bol=true;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, e);

return bol;

Ventanilla de LIBROS

Este código cumple la función de registrar libros,guardar y modificar los


cuales son las funciones mas importantes para esta actividad de los que
hemos analizado .
package presentacion;

import javax.swing.JOptionPane;

import java.sql.*;

import clases.*;

import java.awt.HeadlessException;

import javax.swing.table.DefaultTableModel;

/**

* @author zombyes informaticos

*/

public class libros extends javax.swing.JFrame {

DefaultTableModel model;

public static String[][] list_categoria=new String[9][24];

public static String[] list_subcategoria=new String[200];

String codigo="";

String nombre="";

String titulo="";

String subtitulo="";

String categoria="";

String editorial="";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String autor="";

String serie="";

String subcategoria="";

String fechareg="";

private String cantidad;

/**

* Creates new form libros

*/

public libros() { // creamos nuestro constructor libros

initComponents();

cargar_fecha();

cargar_categoria();

cargar_subcategoria();

cargar_registros();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

jLabel3 = new javax.swing.JLabel();

jLabel4 = new javax.swing.JLabel();

jLabel5 = new javax.swing.JLabel();

txtcodigo = new javax.swing.JTextField();

txtnombre = new javax.swing.JTextField();

txttitulo = new javax.swing.JTextField();

txtsubtitulo = new javax.swing.JTextField();

cnbcategoria = new javax.swing.JComboBox();

jLabel6 = new javax.swing.JLabel();

txteditorial = new javax.swing.JTextField();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel7 = new javax.swing.JLabel();

jLabel8 = new javax.swing.JLabel();

jLabel9 = new javax.swing.JLabel();

jLabel10 = new javax.swing.JLabel();

jLabel11 = new javax.swing.JLabel();

txtcantidad = new javax.swing.JTextField();

txtfecha = new javax.swing.JTextField();

cnbsubcategoria = new javax.swing.JComboBox();

txtserie = new javax.swing.JTextField();

txtautor = new javax.swing.JTextField();

jButton2 = new javax.swing.JButton();

jPanel2 = new javax.swing.JPanel();

jButton1 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

btnmodificar = new javax.swing.JButton();

btnguardar = new javax.swing.JButton();

jPanel3 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablalibros = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(102, 153, 255));

jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel1.setForeground(new java.awt.Color(0, 0, 51));

jLabel1.setText("codigo");

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

jLabel2.setForeground(new java.awt.Color(0, 0, 51));

jLabel2.setText("Nombre");
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel3.setForeground(new java.awt.Color(0, 0, 51));

jLabel3.setText("Titulo");

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

jLabel4.setForeground(new java.awt.Color(0, 0, 51));

jLabel4.setText("Sub Titulo");

jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel5.setForeground(new java.awt.Color(0, 0, 51));

jLabel5.setText("Categoria");

jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel6.setForeground(new java.awt.Color(0, 0, 51));

jLabel6.setText("Editorial");

jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel7.setForeground(new java.awt.Color(0, 0, 51));

jLabel7.setText("Autor");

jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel8.setForeground(new java.awt.Color(0, 0, 51));

jLabel8.setText("Serie");

jLabel9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel9.setForeground(new java.awt.Color(0, 0, 51));

jLabel9.setText("Sub Categoria");

jLabel10.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

jLabel10.setForeground(new java.awt.Color(0, 0, 51));

jLabel10.setText("Fecha Reg");
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel11.setText("Cantidad");

cnbsubcategoria.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbsubcategoriaActionPerformed(evt);

});

jButton2.setText("+");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(jLabel3)

.addComponent(jLabel4)

.addComponent(jLabel5)

.addComponent(jLabel6)

.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 92,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(txtsubtitulo)

.addComponent(txttitulo)

.addComponent(txtnombre)

.addComponent(cnbcategoria, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)

.addComponent(txtcodigo, javax.swing.GroupLayout.DEFAULT_SIZE, 246,


Short.MAX_VALUE)

.addComponent(txteditorial)))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel7)

.addComponent(jLabel8)

.addComponent(jLabel9)

.addComponent(jLabel10)

.addComponent(jLabel11))

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(txtfecha)

.addComponent(cnbsubcategoria, 0, 246, Short.MAX_VALUE)

.addComponent(txtcantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 246,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jButton2))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(11, 11, 11)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(txtserie)

.addComponent(txtautor))))))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2,


jLabel3, jLabel4, jLabel5});

jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]


{cnbcategoria, txtcodigo, txtnombre, txtsubtitulo, txttitulo});

jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]


{cnbsubcategoria, txtautor, txtfecha, txtserie});

jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel7,


jLabel8});

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel2)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel3)

.addComponent(txttitulo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel4)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(txtsubtitulo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel5)

.addComponent(cnbcategoria, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel6)

.addComponent(txteditorial, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel7)

.addComponent(txtautor, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(7, 7, 7)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel8)

.addComponent(txtserie, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(9, 9, 9)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel9)

.addComponent(cnbsubcategoria, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jButton2))

.addGap(5, 5, 5)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel10)

.addComponent(txtfecha, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(15, 15, 15)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jLabel11)

.addComponent(txtcantidad, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1,


jLabel2, jLabel3, jLabel4, jLabel5});

jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {cnbcategoria,


txtcodigo, txtnombre, txtsubtitulo, txttitulo});

jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel7,


jLabel8});

jPanel2.setBackground(new java.awt.Color(0, 204, 204));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton1.setText("SALIR");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/nuevo.png"))); // NOI18N

jButton3.setText("Nuevo");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

btnmodificar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnmodificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/modificar.png"))); //
NOI18N

btnmodificar.setText("modificar");

btnmodificar.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnmodificarActionPerformed(evt);

});

btnguardar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnguardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/guardar.png"))); //
NOI18N

btnguardar.setText("guardar");

btnguardar.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnguardarActionPerformed(evt);

});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()

.addGap(22, 22, 22)

.addComponent(jButton3)

.addGap(26, 26, 26)

.addComponent(btnguardar)

.addGap(30, 30, 30)

.addComponent(btnmodificar)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 145,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1)

.addComponent(jButton3)

.addComponent(btnmodificar)

.addComponent(btnguardar))

.addContainerGap())

);

jButton3.getAccessibleContext().setAccessibleDescription("");

tablalibros.setModel(new javax.swing.table.DefaultTableModel(

new Object [][]

new String [] {

));

tablalibros.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablalibrosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablalibros);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE)

.addContainerGap())

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)

.addContainerGap())

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createSequentialGroup()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 0, Short.MAX_VALUE)))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

this.setVisible(false); //Cerramos lo que se estaba mostrando los valores

private void btnguardarActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

codigo=txtcodigo.getText();

nombre=txtnombre.getText();

titulo=txttitulo.getText();

subtitulo=txtsubtitulo.getText();

categoria=Buscar_Categoria(1, 0, (String) cnbcategoria.getItemAt(cnbcategoria.getSelectedIndex()));

editorial=txteditorial.getText();

autor=txtautor.getText();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
serie=txtserie.getText();

subcategoria=(String) cnbsubcategoria.getSelectedItem();

fechareg=txtfecha.getText();

cantidad=txtcantidad.getText();

registrar_libros(codigo,nombre,titulo,subtitulo,categoria,editorial,autor,serie,subcategoria,fechareg,cantidad);

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

cnbsubcategoria.setEditable(true);

private void cnbsubcategoriaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

cnbsubcategoria.setEditable(false);

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

limpiar();

cargar_subcategoria();

private void tablalibrosMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

int fila=tablalibros.getSelectedRow();

txtcodigo.setText(tablalibros.getValueAt(fila, 0).toString());

txtnombre.setText(tablalibros.getValueAt(fila, 1).toString());

txttitulo.setText(tablalibros.getValueAt(fila, 2).toString());

txtsubtitulo.setText(tablalibros.getValueAt(fila, 3).toString());

cnbcategoria.setSelectedItem(buscar_cat(tablalibros.getValueAt(fila, 4).toString()));
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
txteditorial.setText(tablalibros.getValueAt(fila, 5).toString());

txtautor.setText(tablalibros.getValueAt(fila, 6).toString());

txtserie.setText(tablalibros.getValueAt(fila, 7).toString());

cnbsubcategoria.setSelectedItem(tablalibros.getValueAt(fila, 8));

txtfecha.setText(tablalibros.getValueAt(fila, 9).toString());

txtcantidad.setText(tablalibros.getValueAt(fila,10).toString());

private void btnmodificarActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

codigo=txtcodigo.getText();

nombre=txtnombre.getText();

titulo=txttitulo.getText();

subtitulo=txtsubtitulo.getText();

categoria=Buscar_Categoria(1, 0, (String) cnbcategoria.getItemAt(cnbcategoria.getSelectedIndex()));

editorial=txteditorial.getText();

autor=txtautor.getText();

serie=txtserie.getText();

subcategoria=(String) cnbsubcategoria.getSelectedItem();

fechareg=txtfecha.getText();

cantidad=txtcantidad.getText();

modificar_libros(codigo,nombre,titulo,subtitulo,categoria,editorial,autor,serie,subcategoria,fechareg,cantidad);

/**

* @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) ">
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
/* 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(libros.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(libros.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(libros.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(libros.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 libros().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton btnguardar;

private javax.swing.JButton btnmodificar;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JComboBox cnbcategoria;

private javax.swing.JComboBox cnbsubcategoria;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel11;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JTable tablalibros;

private javax.swing.JTextField txtautor;

private javax.swing.JTextField txtcantidad;

private javax.swing.JTextField txtcodigo;

private javax.swing.JTextField txteditorial;

private javax.swing.JTextField txtfecha;

private javax.swing.JTextField txtnombre;

private javax.swing.JTextField txtserie;

private javax.swing.JTextField txtsubtitulo;

private javax.swing.JTextField txttitulo;

// Fin de las variables en declaraion


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private void cargar_fecha() {

java.util.Date date = new java.util.Date();

java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

String fecha = sdf.format(date);

txtfecha.setText(fecha);

private void cargar_categoria() {

conexion cc =new conexion();

Connection cn=cc.conexion();

ResultSet RS1 = null;

String sql="select *from categoria";

try {

Statement stmt = cn.createStatement();

RS1 = stmt.executeQuery(sql);

int i = 0;

for (int j = cnbcategoria.getItemCount() - 1; j >= 0; j--) {

cnbcategoria.removeItemAt(j);

while (RS1.next()) {

list_categoria[0][i] = (String) RS1.getString(1);

list_categoria[1][i] = (String) RS1.getString(2);

cnbcategoria.addItem(list_categoria[1][i]) ;

i++;

RS1.close();

stmt.close();

cn.close();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categoria", 2);


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void cargar_subcategoria() {

conexion cc =new conexion();

Connection cn=cc.conexion();

ResultSet RS1 = null;

String sql="select distinct p_subcategoria from libros";

try {

Statement stmt = cn.createStatement();

RS1 = stmt.executeQuery(sql);

int i=0;

while (RS1.next()) {

list_subcategoria[i] = (String) RS1.getString(1);

cnbsubcategoria.addItem(list_subcategoria[i]);

i++;

RS1.close();

stmt.close();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "ERROR COMANDO SQL." + ex.getMessage());

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "DRIVER NO ENCONTRADO."+e, "MOSTRAR categorias", 2);

private void cargar_registros() {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String [] titulos ={"Codigo","Nombre","Titulo","Sub Titulo","Categoria","Editorial","Autor","Serie","Sub
Categoria","Fecha","Cantidad"};

String [] registros=new String[11];

String sql="select *from libros";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

registros[7]=rs.getString(8);

registros[8]=rs.getString(9);

registros[9]=rs.getString(10);

registros[10]=rs.getString(11);

model.addRow(registros);

tablalibros.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

private String Buscar_Categoria(int PosicionEntrada , int PosicionSalida, String Texto) {

String texto = "";

try {

for (int i = 0; i < list_categoria[PosicionEntrada].length; i++) {

if (list_categoria[PosicionEntrada][i] == null) {

} else if (list_categoria[PosicionEntrada][i].equals(Texto)) {

texto = list_categoria[PosicionSalida][i];

break;

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "ERROR AL BUSCAR categoria ", "ERROR", 2, null);

return texto;

private void registrar_libros(String codigo, String nombre, String titulo, String subtitulo, String categoria, String
editorial, String autor, String serie, String subcategoria, String fechareg, String cantidad) {

conexion co=new conexion();

Connection cc=co.conexion();

String sql="insert into libros values(?,?,?,?,?,?,?,?,?,?,?)";

try {

PreparedStatement pst=cc.prepareStatement(sql);

pst.setString(1, codigo);

pst.setString(2, nombre);

pst.setString(3, titulo);

pst.setString(4, subtitulo);

pst.setString(5, categoria);

pst.setString(6, editorial);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
pst.setString(7, autor);

pst.setString(8, serie);

pst.setString(9, subcategoria);

pst.setString(10, fechareg);

pst.setString(11, cantidad);

int registro=pst.executeUpdate();

if(registro>0)

JOptionPane.showMessageDialog(this,"Registro con exito");

cargar_registros();

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error....."+e);

private void limpiar() {

txtcodigo.setText(null);

txtnombre.setText(null);

txtautor.setText(null);

txtserie.setText(null);

txttitulo.setText(null);

txtsubtitulo.setText(null);

txteditorial.setText(null);

cnbsubcategoria.removeAllItems();

private String buscar_cat(String codigo) {

String dato="";

try {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
conexion cx=new conexion();

Connection con=cx.conexion();

Statement stm=con.createStatement();

ResultSet rs=stm.executeQuery("select ca_nombre from categoria where ca_codigo='"+codigo+"'");

if (rs.next()) {

dato=rs.getString(1);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error al buscar cat"+e);

return dato;

private void modificar_libros(String codigo, String nombre, String titulo, String subtitulo, String categoria, String
editorial, String autor, String serie, String subcategoria, String fechareg, String cantidad) {

conexion cc=new conexion();

Connection cn=cc.conexion();

String modificar_producto="update libros set


p_nombre='"+nombre+"',p_titulo='"+titulo+"',p_subtitulo='"+subtitulo

+"',ca_codigo='"+categoria+"',p_editorial='"+editorial+"',p_autor='"+autor+"',p_serie='"+serie+"',p_subcategoria='"+
subcategoria+"',p_cantidad='"+cantidad+"' where p_codigo='"+codigo+"'";

try {

PreparedStatement pst1 = cn.prepareStatement(modificar_producto);

pst1.executeUpdate();

JOptionPane.showMessageDialog(this, "ACTUALIZADO");

cargar_registros();

} catch (SQLException | HeadlessException e) {

JOptionPane.showMessageDialog(this, "error!!!! "+e);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
REGISTRAR CATEGORIA DE LIBRO(En este caso los códigos nos permiten registrar a que categoría
pertenecen los libros y como venia diciendo la explicación esta por cada fucion osea que se esta haciendo en
ese tramo )

package presentacion;

import java.sql.*;

import clases.*;

import java.awt.HeadlessException;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

/**

* @author zombyes informaticos

*/

public class categoria extends javax.swing.JFrame {

DefaultTableModel model;

/**

* Creates new form categoria

*/

public categoria() {

initComponents();

cargar_registro_categoria();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

jLabel2 = new javax.swing.JLabel();

txtcodigo = new javax.swing.JTextField();

txtnombre = new javax.swing.JTextField();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel2 = new javax.swing.JPanel();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

panelcat = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablacategoria = new javax.swing.JTable();

jLabel3 = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBackground(new java.awt.Color(102, 255, 255));

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel1.setText("CODIGO");

jLabel2.setBackground(new java.awt.Color(255, 51, 51));

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel2.setText("NOMBRE");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap(36, Short.MAX_VALUE)

.addComponent(jLabel2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 146,
javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(0, 0, Short.MAX_VALUE)

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 146,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(48, 48, 48)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(27, 27, 27)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel2))

.addContainerGap(30, Short.MAX_VALUE))

);

jPanel2.setBackground(new java.awt.Color(204, 204, 255));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/nuevo.png"))); // NOI18N

jButton1.setText("nuevo");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/registrar.png"))); // NOI18N

jButton2.setText("registrar");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton3.setText("salir");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

jButton4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/modificar.png"))); //
NOI18N

jButton4.setText("modificar");

jButton4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()

.addGap(0, 0, Short.MAX_VALUE)

.addComponent(jButton4))

.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel2Layout.createSequentialGroup()

.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 139, Short.MAX_VALUE)

.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addGap(0, 0, Short.MAX_VALUE)))

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jButton1)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jButton2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jButton4)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jButton3)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

jButton1.getAccessibleContext().setAccessibleName("NUEVO");

panelcat.setBackground(new java.awt.Color(0, 0, 153));

tablacategoria.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

));

tablacategoria.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablacategoriaMouseClicked(evt);

});

jScrollPane1.setViewportView(tablacategoria);

javax.swing.GroupLayout panelcatLayout = new javax.swing.GroupLayout(panelcat);

panelcat.setLayout(panelcatLayout);

panelcatLayout.setHorizontalGroup(

panelcatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(panelcatLayout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 481, Short.MAX_VALUE)

.addContainerGap())

);

panelcatLayout.setVerticalGroup(

panelcatLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(panelcatLayout.createSequentialGroup()
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE)

.addGap(26, 26, 26))

);

jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/book.png"))); // NOI18N

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 141,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(55, 55, 55))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))

.addComponent(panelcat, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(25, 25, 25))

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(panelcat, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGroup(layout.createSequentialGroup()

.addGap(11, 11, 11)

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jLabel3)))

.addGap(44, 44, 44))

);

pack();

}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

limpiar();

cargar_codigo();

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (grabar()==true) {

try {

conexion cx=new conexion();

Connection con=cx.conexion();

PreparedStatement pst=con.prepareStatement("insert into categoria values(?,?)");

pst.setString(1, txtcodigo.getText());

pst.setString(2, txtnombre.getText());

int n=pst.executeUpdate();

if (n>0) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
JOptionPane.showMessageDialog(this, "registro exito");

limpiar();

cargar_registro_categoria();

cargar_codigo();

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error al reg. categoria"+e);

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.setVisible(false);

private void tablacategoriaMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

int fila=tablacategoria.getSelectedRow();

txtcodigo.setText(tablacategoria.getValueAt(fila, 0).toString());

txtnombre.setText(tablacategoria.getValueAt(fila, 1).toString());

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if(grabar()==true){

conexion cn=new conexion();

Connection cc=cn.conexion();

String sql1="update categoria set ca_nombre='"+txtnombre.getText()+"' where


ca_codigo='"+txtcodigo.getText()+"'";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

try {

PreparedStatement pst1 = cc.prepareStatement(sql1);

pst1.executeUpdate();

JOptionPane.showMessageDialog(this, "ACTUALIZADO");

cargar_registro_categoria();

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this, "error"+ex);

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

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(categoria.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(categoria.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (IllegalAccessException ex) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
java.util.logging.Logger.getLogger(categoria.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(categoria.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 categoria().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JPanel panelcat;

private javax.swing.JTable tablacategoria;

private javax.swing.JTextField txtcodigo;

private javax.swing.JTextField txtnombre;

// End of variables declaration


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private void limpiar() {

txtcodigo.setText(null);

txtnombre.setText(null);

private void cargar_codigo() {

try {

conexion cx=new conexion();

Connection con=cx.conexion();

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select max(ca_codigo) as 'Codigo' from categoria");

while (rs.next()) {

int lastID = rs.getInt(1);

txtcodigo.setText(String.valueOf(lastID + 1));

rs.close();

stmt.close();

} catch (SQLException error) {

System.out.print(error);

private void cargar_registro_categoria() {

String [] titulos={"ID","NOMBRE"};

String []registros=new String[2];

model=new DefaultTableModel(null,titulos);

try {

conexion cx=new conexion();

Connection con=cx.conexion();

Statement stm=con.createStatement();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
ResultSet rs=stm.executeQuery("select *from categoria");

while (rs.next()) {

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

model.addRow(registros);

tablacategoria.setModel(model);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error al cargar"+e);

private boolean grabar() {

boolean bol=false;

if (!txtcodigo.getText().equals("")) {

if (!txtnombre.getText().equals("")) {

bol=true;

} else {

JOptionPane.showMessageDialog(this, "ingrese codigo");

}else JOptionPane.showMessageDialog(this, "ingrese nombre");

return bol;

VENTANILLA DE CONFIRMAR
PRESTAMO

El código realiza la función de confirmar préstamo de libros que en la ficha de


préstamo de libro se registro lo cual sera confirmado por el bilbiotecario o
administrador.
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
package presentacion;

import clases.conexion;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

/**

* @autor zombyes informaticos

*/

public class confirmar_ficha_prestamo extends javax.swing.JFrame {

DefaultTableModel model;

/**

* Crear nuevo formulario de confirmar prestamo

*/

public confirmar_ficha_prestamo() {

initComponents();

CARGAR_RESGISTRO_PRESTAMO_LIBROS();

rdestudiante.setSelected(true);

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel2 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablaprestamos = new javax.swing.JTable();

rdestudiante = new javax.swing.JRadioButton();

rddocente = new javax.swing.JRadioButton();

jPanel3 = new javax.swing.JPanel();

btnregistrardevolucion = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

txtdato = new javax.swing.JTextField();

jPanel1.setBackground(new java.awt.Color(0, 153, 255));

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("18thCentury", 0, 14), new
java.awt.Color(0, 153, 204))); // NOI18N

jPanel2.setBackground(new java.awt.Color(255, 255, 255));

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE LIBROS PRESTADOS"));

tablaprestamos.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

));

tablaprestamos.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablaprestamosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablaprestamos);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE)

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 26, Short.MAX_VALUE))

);

rdestudiante.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

rdestudiante.setText("ESTUDIANTES");

rdestudiante.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdestudianteActionPerformed(evt);

});

rddocente.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

rddocente.setText("DOCENTES");

rddocente.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rddocenteActionPerformed(evt);

});
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

jPanel3.setBackground(new java.awt.Color(102, 255, 255));

btnregistrardevolucion.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnregistrardevolucion.setText("CONFIRMAR PRESTAMO");

btnregistrardevolucion.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnregistrardevolucionActionPerformed(evt);

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(29, 29, 29)

.addComponent(btnregistrardevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 223,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2)

.addContainerGap())

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(12, 12, 12)

.addComponent(btnregistrardevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 48,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jButton2))

.addContainerGap())

);

jLabel1.setText("CODIGO");

txtdato.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txtdatoMouseClicked(evt);

});

txtdato.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

txtdatoActionPerformed(evt);

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(21, 21, 21)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE, 241,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(rdestudiante)

.addGap(80, 80, 80)

.addComponent(rddocente, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGap(0, 0, Short.MAX_VALUE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(11, 11, 11)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(rdestudiante)

.addComponent(rddocente))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

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()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

private void tablaprestamosMouseClicked(java.awt.event.MouseEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
// TODO add your handling code here:

private void rdestudianteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdestudiante.setSelected(true);

rddocente.setSelected(false);

private void rddocenteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdestudiante.setSelected(false);

rddocente.setSelected(true);

private void txtdatoMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

txtdato.setText(null);

private void txtdatoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (rdestudiante.isSelected() == true) {

para_estudiante();

}else if (rddocente.isSelected() == true) {

para_docente();

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
this.setVisible(false);

private void btnregistrardevolucionActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (rdestudiante.isSelected()==true) {

actualzar_libro();

if (rddocente.isSelected()==true) {

int filas_seleccionadas=tablaprestamos.getSelectedRowCount();

if (filas_seleccionadas>0) {

if (filas_seleccionadas==1) {

int fila=tablaprestamos.getSelectedRow();

actualzar_libro(fila);

}else{

actualzar_libro();

}else JOptionPane.showMessageDialog(this, "Seleccione Registro Detalle Prestamo");

/**

* @param args the command line arguments

*/

public static void main(String args[]) {

/* Establecemos el bloqueo nimbus*/

//<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


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
*/

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(confirmar_ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(confirmar_ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(confirmar_ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(confirmar_ficha_prestamo.class.getName()).log(java.util.logging.Level.SEVER
E, null, ex);

//</editor-fold>

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new confirmar_ficha_prestamo().setVisible(true);

});

// Variables declaration - do not modify


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JButton btnregistrardevolucion;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JRadioButton rddocente;

private javax.swing.JRadioButton rdestudiante;

private javax.swing.JTable tablaprestamos;

private javax.swing.JTextField txtdato;

// End of variables declaration

private void CARGAR_RESGISTRO_PRESTAMO_LIBROS() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


PRESTAMO","FECHA DEVOLUCION","ESTADO"};

String [] registros=new String[8];

String sql="select *from ficha_Pestudiante where f_estado='SOLICITANDO'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_estudiante() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


PRESTAMO","FECHA DEVOLUCION","ESTADO"};

String [] registros=new String[8];

String sql="SELECT * FROM ficha_Pestudiante,estudiante WHERE


ficha_Pestudiante.id_persona=estudiante.id_persona and ficha_Pestudiante.f_estado='SOLICITANDO' and
estudiante.codigo='"+txtdato.getText()+"'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_docente() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO PRODUCTO","CANTIDAD","ESTADO","FECHA


DEVOLUCION"};

String [] registros=new String[7];

String sql="Select
ficha_PDocente.f_codigo,detalle_ficha_pdocente.p_codigo,detalle_ficha_pdocente.df_cantidad,detalle_ficha_pdo
cente.df_estado,ficha_PDocente.f_fechadevolucion FROM detalle_ficha_pdocente,ficha_PDocente,docente
WHERE detalle_ficha_pdocente.f_codigo=ficha_PDocente.f_codigo and
detalle_ficha_pdocente.df_estado='SOLICITANDO' and ficha_PDocente.id_persona=docente.id_persona and
docente.d_codigo='"+txtdato.getText()+"'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
registros[4]=rs.getString(5);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void actualzar_libro() {

conexion cx=new conexion();

Connection con=cx.conexion();

if (rdestudiante.isSelected()==true) {

String codigo_libro=tablaprestamos.getValueAt(0, 1).toString();

String codigo_ficha=tablaprestamos.getValueAt(0, 0).toString();

String sqlestudiante="update libros,ficha_Pestudiante set ficha_Pestudiante.f_estado='EN PRESTAMO'


where libros.p_codigo=ficha_Pestudiante.p_codigo and ficha_Pestudiante.p_codigo='"+codigo_libro+"' and
ficha_Pestudiante.f_codigo='"+codigo_ficha+"'";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

int reg1=pst1.executeUpdate();

if (reg1>0) {

JOptionPane.showMessageDialog(this, "PRESTAMO CONFIRMADO");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error es "+e);

if (rddocente.isSelected()==true) {

int reg2=0;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

try {

for (int i = 0; i < tablaprestamos.getRowCount(); i++) {

String codigo_ficha=tablaprestamos.getValueAt(i, 0).toString();

String codigo_libro=tablaprestamos.getValueAt(i, 1).toString();

String sqldocente="update libros,detalle_ficha_PDocente set


detalle_ficha_PDocente.df_estado='EN PRESTAMO' where libros.p_codigo=detalle_ficha_PDocente.p_codigo
and detalle_ficha_PDocente.p_codigo='"+codigo_libro+"' and
detalle_ficha_PDocente.f_codigo='"+codigo_ficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

reg2=pst1.executeUpdate();

if (reg2>0) {

JOptionPane.showMessageDialog(this, "PRESTAMO CONFIRMADO");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error "+e);

private void actualzar_libro(int fila) {

conexion cx=new conexion();

Connection con=cx.conexion();

int reg2=0;

try {

String codigo_ficha=tablaprestamos.getValueAt(fila, 0).toString();

String codigo_libro=tablaprestamos.getValueAt(fila, 1).toString();

String sqldocente="update libros,detalle_ficha_PDocente set


detalle_ficha_PDocente.df_estado='EN PRESTAMO' where libros.p_codigo=detalle_ficha_PDocente.p_codigo
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
and detalle_ficha_PDocente.p_codigo='"+codigo_libro+"' and
detalle_ficha_PDocente.f_codigo='"+codigo_ficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

reg2=pst1.executeUpdate();

if (reg2>0) {

JOptionPane.showMessageDialog(this, "PRESTAMO CONFIRMADO");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error "+e);

VENTANILLA CONFIRMAR RESERVA

Este código interactua con la ficha de reserva.cuando el bibliotecario haya


reservado un libro mediante la llamada de un lector(estudiante o docente)
.Solamente funciona cuando el bibliotecario reserva libro.
package presentacion;

import clases.conexion;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
/**

* @author zombyes informaticos

*/

public class confirmar_reserva extends javax.swing.JFrame {

DefaultTableModel model;

/**

* Creates new form confirmar_ficha_prestamo

*/

public confirmar_reserva() {

initComponents();

CARGAR_RESGISTRO_PRESTAMO_LIBROS();

rdestudiante.setSelected(true);

/**

* 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">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jPanel2 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablaprestamos = new javax.swing.JTable();

rdestudiante = new javax.swing.JRadioButton();

rddocente = new javax.swing.JRadioButton();

jPanel3 = new javax.swing.JPanel();

btnregistrardevolucion = new javax.swing.JButton();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

txtdato = new javax.swing.JTextField();

jPanel1.setBackground(new java.awt.Color(0, 153, 153));

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "TABLA CONFIRMAR RESERVA",


javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Aharoni", 1, 18), new
java.awt.Color(0, 102, 204))); // NOI18N

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE LIBROS PRESTADOS"));

tablaprestamos.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] { },

new String [] {

));

tablaprestamos.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablaprestamosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablaprestamos);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 874, Short.MAX_VALUE)


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 26, Short.MAX_VALUE))

);

rdestudiante.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

rdestudiante.setText("ESTUDIANTES");

rdestudiante.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdestudianteActionPerformed(evt);

});

rddocente.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

rddocente.setText("DOCENTES");

rddocente.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rddocenteActionPerformed(evt);

});

jPanel3.setBackground(new java.awt.Color(255, 153, 0));

jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

btnregistrardevolucion.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnregistrardevolucion.setText("CONFIRMAR PRESTAMO");

btnregistrardevolucion.addActionListener(new java.awt.event.ActionListener() {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
public void actionPerformed(java.awt.event.ActionEvent evt) {

btnregistrardevolucionActionPerformed(evt);

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton3.setText("ACTUALIZAR RESERVAS");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jButton3)

.addGap(18, 18, 18)

.addComponent(btnregistrardevolucion)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2)

.addContainerGap())

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(12, 12, 12)

.addComponent(btnregistrardevolucion, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(12, 12, 12)

.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 48,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addComponent(jButton2)))

.addContainerGap())

);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel1.setText("CODIGO");

txtdato.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txtdatoMouseClicked(evt);

});

txtdato.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
txtdatoActionPerformed(evt);

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(21, 21, 21)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE, 241,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(rdestudiante)

.addGap(80, 80, 80)

.addComponent(rddocente, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGap(0, 0, Short.MAX_VALUE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(19, 19, 19)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(rdestudiante)

.addComponent(rddocente))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

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()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel1.getAccessibleContext().setAccessibleName("CONFIRMAR RESERVA");

pack();

}// </editor-fold>

private void tablaprestamosMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

private void rdestudianteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdestudiante.setSelected(true);

rddocente.setSelected(false);

private void rddocenteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdestudiante.setSelected(false);

rddocente.setSelected(true);

private void txtdatoMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

txtdato.setText(null);

private void txtdatoActionPerformed(java.awt.event.ActionEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
// TODO add your handling code here:

if (rdestudiante.isSelected() == true) {

para_estudiante();

}else if (rddocente.isSelected() == true) {

para_docente();

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.setVisible(false);

private void btnregistrardevolucionActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (rdestudiante.isSelected()==true) {

actualzar_libro();

if (rddocente.isSelected()==true) {

int filas_seleccionadas=tablaprestamos.getSelectedRowCount();

if (filas_seleccionadas>0) {

if (filas_seleccionadas==1) {

int fila=tablaprestamos.getSelectedRow();

actualzar_libro(fila);

}else{

actualzar_libro();

}else JOptionPane.showMessageDialog(this, "Seleccione Registro Detalle Prestamo");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

Date fechaActual = new Date();

SimpleDateFormat formateador = new SimpleDateFormat("YYYY-MM-dd");

String fechaSistema=formateador.format(fechaActual);

String sql="select *from ficha_pestudiante where f_estado='RESERVADO' or f_estado='SOLICITANDO'";

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

String resultado=compararFechasConDate(rs.getString(6),fechaSistema);

if (resultado.equals("MAYOR")) {

actualizar_liro_ficha_estudiante(rs.getString(1),rs.getString(2));

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

//PARA DOCENTES

String sql2="select
detalle_ficha_pdocente.f_codigo,detalle_ficha_pdocente.p_codigo,detalle_ficha_pdocente.df_estado,ficha_pdoce
nte.f_fechadevolucion from detalle_ficha_pdocente,ficha_pdocente where
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
detalle_ficha_pdocente.f_codigo=ficha_pdocente.f_codigo and detalle_ficha_pdocente.df_estado='RESERVADO'
or detalle_ficha_pdocente.df_estado='SOLICITANDO'";

ResultSet rs1=null;

try {

Statement st=cn.createStatement();

rs1=st.executeQuery(sql2);

while(rs1.next()){

String resultado=compararFechasConDate(rs1.getString(4),fechaSistema);

if (resultado.equals("MAYOR")) {

actualizar_liro_ficha_docente(rs1.getString(1),rs1.getString(2));

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

/**

* @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;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

} catch (ClassNotFoundException ex) {

java.util.logging.Logger.getLogger(confirmar_reserva.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(confirmar_reserva.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(confirmar_reserva.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(confirmar_reserva.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 confirmar_reserva().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton btnregistrardevolucion;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JLabel jLabel1;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JPanel jPanel3;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JRadioButton rddocente;

private javax.swing.JRadioButton rdestudiante;

private javax.swing.JTable tablaprestamos;

private javax.swing.JTextField txtdato;

// Fin de variables en declaracion

private void CARGAR_RESGISTRO_PRESTAMO_LIBROS() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


PRESTAMO","FECHA DEVOLUCION","ESTADO"};

String [] registros=new String[8];

String sql="select *from ficha_Pestudiante where f_estado='SOLICITANDO'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_estudiante() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


RESERVA","FECHA EXPIRACION","ESTADO"};

String [] registros=new String[8];

String sql="SELECT * FROM ficha_Pestudiante,estudiante WHERE


ficha_Pestudiante.id_persona=estudiante.id_persona and ficha_Pestudiante.f_estado='RESERVADO' and
estudiante.codigo='"+txtdato.getText()+"'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_docente() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO PRODUCTO","CANTIDAD","ESTADO","FECHA


EXPIRACION"};

String [] registros=new String[7];

String sql="Select
ficha_PDocente.f_codigo,detalle_ficha_pdocente.p_codigo,detalle_ficha_pdocente.df_cantidad,detalle_ficha_pdo
cente.df_estado,ficha_PDocente.f_fechadevolucion FROM detalle_ficha_pdocente,ficha_PDocente,docente
WHERE detalle_ficha_pdocente.f_codigo=ficha_PDocente.f_codigo and
detalle_ficha_pdocente.df_estado='RESERVADO' and ficha_PDocente.id_persona=docente.id_persona and
docente.d_codigo='"+txtdato.getText()+"'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
} private void actualzar_libro() {

conexion cx=new conexion();

Connection con=cx.conexion();

if (rdestudiante.isSelected()==true) {

String codigo_libro=tablaprestamos.getValueAt(0, 1).toString();

String codigo_ficha=tablaprestamos.getValueAt(0, 0).toString();

String sqlestudiante="update libros,ficha_Pestudiante set ficha_Pestudiante.f_estado='EN PRESTAMO'


where libros.p_codigo=ficha_Pestudiante.p_codigo and ficha_Pestudiante.p_codigo='"+codigo_libro+"' and
ficha_Pestudiante.f_codigo='"+codigo_ficha+"'";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

int reg1=pst1.executeUpdate();

if (reg1>0) {

JOptionPane.showMessageDialog(this, "PRESTAMO CONFIRMADO");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error es "+e);

if (rddocente.isSelected()==true) {

int reg2=0;

try {

for (int i = 0; i < tablaprestamos.getRowCount(); i++) {

String codigo_ficha=tablaprestamos.getValueAt(i, 0).toString();

String codigo_libro=tablaprestamos.getValueAt(i, 1).toString();

String sqldocente="update libros,detalle_ficha_PDocente set


detalle_ficha_PDocente.df_estado='EN PRESTAMO' where libros.p_codigo=detalle_ficha_PDocente.p_codigo
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
and detalle_ficha_PDocente.p_codigo='"+codigo_libro+"' and
detalle_ficha_PDocente.f_codigo='"+codigo_ficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

reg2=pst1.executeUpdate();

if (reg2>0) {

JOptionPane.showMessageDialog(this, "PRESTAMO CONFIRMADO");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error "+e);

private void actualzar_libro(int fila) {

conexion cx=new conexion();

Connection con=cx.conexion();

int reg2=0;

try {

String codigo_ficha=tablaprestamos.getValueAt(fila, 0).toString();

String codigo_libro=tablaprestamos.getValueAt(fila, 1).toString();

String sqldocente="update libros,detalle_ficha_PDocente set


detalle_ficha_PDocente.df_estado='EN PRESTAMO' where libros.p_codigo=detalle_ficha_PDocente.p_codigo
and detalle_ficha_PDocente.p_codigo='"+codigo_libro+"' and
detalle_ficha_PDocente.f_codigo='"+codigo_ficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

reg2=pst1.executeUpdate();

if (reg2>0) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
JOptionPane.showMessageDialog(this, "PRESTAMO CONFIRMADO");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error "+e);

private String compararFechasConDate(String fechasancion, String fechaActual) {

String resultado="";

try {

/**Obtenemos las fechas enviadas en el formato a comparar*/


SimpleDateFormat formateador = new SimpleDateFormat("yyyy-MM-dd");

Date fechaDate1 = formateador.parse(fechaActual);

Date fechaDate2 = formateador.parse(fechasancion);

if ( fechaDate1.before(fechaDate2) ){

resultado= "MENOR ";

}else{

if ( fechaDate2.before(fechaDate1) ){

resultado= "MAYOR";

}else{

resultado= "IGUAL";

} catch (ParseException e) {

JOptionPane.showMessageDialog(this, e);

return resultado;

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private void actualizar_liro_ficha_estudiante(String codigoficha, String codigolibro) {

conexion cx=new conexion();

Connection con=cx.conexion(

String sqlestudiante="update libros,ficha_Pestudiante set


libros.p_cantidad=libros.p_cantidad+1,ficha_Pestudiante.f_estado='CANCELADO' where
libros.p_codigo=ficha_Pestudiante.p_codigo and ficha_Pestudiante.p_codigo='"+codigolibro+"' and
ficha_Pestudiante.f_codigo='"+codigoficha+"'";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.executeUpdate();

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error es "+e);

private void actualizar_liro_ficha_docente(String codigoficha, String codigolibro) {

conexion cx=new conexion();

Connection con=cx.conexion();

try{

String sqldocente="update libros,detalle_ficha_PDocente set


libros.p_cantidad=libros.p_cantidad+1,detalle_ficha_PDocente.df_estado='CANCELADO' where
libros.p_codigo=detalle_ficha_PDocente.p_codigo and detalle_ficha_PDocente.p_codigo='"+codigolibro+"' and
detalle_ficha_PDocente.f_codigo='"+codigoficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

pst1.executeUpdate();

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error "+e);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

VENTANILLA DE CONSULTA
PRESTAMO
En este caso se realiza una consulta de los libros que sea prestado el lector,a esta ventanilla solo podrá ingresar
el lector.

package presentacion; / / Trabajamos en el paquete presentacion

import clases.conexion;

import java.sql.Connection; // Importamos nuestras librerías y la conexión

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

**

* @author zombyes informaticos

*/

public class consulta_prestamo extends javax.swing.JFrame {

DefaultTableModel model;

/**

* Creates new form consulta_prestamo

*/

public consulta_prestamo() {

initComponents();

CARGAR_RESGISTRO_PRESTAMO_LIBROS();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jPanel2 = new javax.swing.JPanel();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jScrollPane1 = new javax.swing.JScrollPane();

tablaprestamos = new javax.swing.JTable();

jPanel3 = new javax.swing.JPanel();

jButton2 = new javax.swing.JButton();

jButton1 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

txtdato = new javax.swing.JTextField();

jPanel6 = new javax.swing.JPanel();

jLabel8 = new javax.swing.JLabel();

txttitulo = new javax.swing.JTextField();

txttitulo1 = new javax.swing.JTextField();

jLabel9 = new javax.swing.JLabel();

jLabel10 = new javax.swing.JLabel();

txtautor = new javax.swing.JTextField();

jLabel13 = new javax.swing.JLabel();

txtcodigolibro = new javax.swing.JTextField();

jLabel2 = new javax.swing.JLabel();

txttipopersona = new javax.swing.JTextField();

jPanel1.setBackground(new java.awt.Color(0, 153, 153));

jPanel2.setBackground(new java.awt.Color(0, 255, 204));

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE LIBROS PRESTADOS"));

tablaprestamos.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] {

},

new String [] {

));

tablaprestamos.addMouseListener(new java.awt.event.MouseAdapter() {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
public void mouseClicked(java.awt.event.MouseEvent evt) {

tablaprestamosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablaprestamos);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1097, Short.MAX_VALUE)

.addContainerGap())

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 26, Short.MAX_VALUE))

);

jPanel3.setBackground(new java.awt.Color(0, 204, 204));

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
});

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Cargarrrr.png"))); //
NOI18N

jButton1.setText("CARGAR");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 169,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2)

.addContainerGap())

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton2)

.addComponent(jButton1))

.addGap(22, 22, 22))


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel1.setText("CODIGO");

txtdato.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txtdatoMouseClicked(evt);

});

txtdato.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

txtdatoActionPerformed(evt);

});

jPanel6.setBackground(new java.awt.Color(255, 204, 51));

jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder("DATOS DEL LIBRO"));

jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel8.setText("TITULO");

jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel9.setText("SUB TITULO");

jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel10.setText("AUTOR");

jLabel13.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel13.setText("CODIGO LIBRO");

javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel6.setLayout(jPanel6Layout);

jPanel6Layout.setHorizontalGroup(

jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel13)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(txtcodigolibro, javax.swing.GroupLayout.PREFERRED_SIZE, 149,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel9)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18,
Short.MAX_VALUE)

.addComponent(txttitulo1, javax.swing.GroupLayout.PREFERRED_SIZE, 390,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGap(18, 18, 18))

.addGroup(jPanel6Layout.createSequentialGroup()

.addComponent(jLabel10)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(txttitulo, javax.swing.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)

.addComponent(txtautor))

.addContainerGap())

);

jPanel6Layout.setVerticalGroup(

jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel6Layout.createSequentialGroup()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel6Layout.createSequentialGroup()

.addGap(8, 8, 8)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel8)

.addComponent(txttitulo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel13)

.addComponent(txtcodigolibro, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel10)

.addComponent(txtautor, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txttitulo1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel9))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel2.setText("TIPO PERSONA");

txttipopersona.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txttipopersonaMouseClicked(evt);

});

txttipopersona.addActionListener(new java.awt.event.ActionListener() {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
public void actionPerformed(java.awt.event.ActionEvent evt) {

txttipopersonaActionPerformed(evt);

});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(21, 21, 21)

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE, 241,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(290, 290, 290)

.addComponent(jLabel2)

.addGap(48, 48, 48)

.addComponent(txttipopersona, javax.swing.GroupLayout.PREFERRED_SIZE, 241,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 0, Short.MAX_VALUE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(25, 25, 25)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel2)

.addComponent(txttipopersona, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(18, 18, 18)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

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()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

private void tablaprestamosMouseClicked(java.awt.event.MouseEvent evt) {

int fila=tablaprestamos.getSelectedRow();

if (fila>-1) {

try {

conexion cx=new conexion();

Connection con=cx.conexion();

Statement stm=con.createStatement();

ResultSet rs=stm.executeQuery("select *from libros where


p_codigo='"+tablaprestamos.getValueAt(fila, 1).toString()+"'");

if(rs.next()) {

txtcodigolibro.setText(rs.getString(1));

txttitulo.setText(rs.getString(3));

txttitulo1.setText(rs.getString(4));

txtautor.setText(rs.getString(7));

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error al cargar"+e);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}else{

JOptionPane.showMessageDialog(this, "no hay registros o SELECCIONE UN REGISTRO");

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.setVisible(false);

private void txtdatoMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

txtdato.setText(null);

private void txtdatoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

private void txttipopersonaMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

private void txttipopersonaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

CARGAR_RESGISTRO_PRESTAMO_LIBROS();

/**

* @param args the command line arguments

*/

public static void main(String args[]) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
/* Set the Nimbus look and feel */

//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

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(consulta_prestamo.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(consulta_prestamo.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(consulta_prestamo.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(consulta_prestamo.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 consulta_prestamo().setVisible(true);

});

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel13;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;

private javax.swing.JPanel jPanel6;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JTable tablaprestamos;

private javax.swing.JTextField txtautor;

private javax.swing.JTextField txtcodigolibro;

public static javax.swing.JTextField txtdato;

public static javax.swing.JTextField txttipopersona;

private javax.swing.JTextField txttitulo;

private javax.swing.JTextField txttitulo1;

// Fin de las variables en declaracion

private void CARGAR_RESGISTRO_PRESTAMO_LIBROS() {

if (txttipopersona.getText().equals("ESTUDIANTE")) {

para_estudiante();

}else if (txttipopersona.getText().equals("DOCENTE")) {

para_docente();

private void para_estudiante() {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


PRESTAMO","FECHA DEVOLUCION","ESTADO"};

String [] registros=new String[8];

String sql="SELECT * FROM ficha_Pestudiante,estudiante WHERE


ficha_Pestudiante.id_persona=estudiante.id_persona and ficha_Pestudiante.f_estado='EN PRESTAMO' or
ficha_Pestudiante.f_estado='RESERVADO' and estudiante.codigo='"+txtdato.getText()+"'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_docente() {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String [] titulos ={"CODIGO PRESTAMO","CODIGO PRODUCTO","CANTIDAD","ESTADO","FECHA
DEVOLUCION"};

String [] registros=new String[7];

String sql="Select
ficha_PDocente.f_codigo,detalle_ficha_pdocente.p_codigo,detalle_ficha_pdocente.df_cantidad,detalle_ficha_pdo
cente.df_estado,ficha_PDocente.f_fechadevolucion FROM detalle_ficha_pdocente,ficha_PDocente,docente
WHERE detalle_ficha_pdocente.f_codigo=ficha_PDocente.f_codigo and detalle_ficha_pdocente.df_estado='EN
PRESTAMO' or detalle_ficha_pdocente.df_estado='RESERVADO' and
ficha_PDocente.id_persona=docente.id_persona and docente.d_codigo='"+txtdato.getText()+"'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

VENTANILLA DE REGISTRAR USUARIOS

El código permite reconocer los datos que se van a ingresar dentro del formulario,
guardarlos en la Base de Datos,en este caso se registrara cada usuario dependiendo
a tipo de persona,nos facilitara el combobox que utilizamos .

package presentacion;

import clases.conexion;

import java.sql.*;

import java.text.SimpleDateFormat;

import javax.swing.ImageIcon;

import javax.swing.JOptionPane;

import javax.swing.JPanel;

/**

* @author zombyes informaticos

*/

public class personas extends javax.swing.JFrame {

conexion cn= new conexion();

Connection con =cn.conexion();

private String id="";

private String tipo="";

private String dni="";

private String nombre="";

private String apellidopat="";

private String apellidomat="";

private String direccion="";

private String fechanc="";

private String fecha="";

private String sexo="";

private String procedencia="";

private String telefono="";

private String codigoestu="";

private String codigoprofes="";


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private String profesion="";

private String carrera="";

private String facultad="";

/**

* Creates new form paciente

*/

public personas() {

initComponents();

// cargar fecha actual en datechoser

java.util.Date date = new java.util.Date();

//java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

txtfechanac.setDate(date);

///----

cargar_fecha();

deshabilitar();

setLocationRelativeTo(null);

setResizable(false);

/**

* 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">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jLabel12 = new javax.swing.JLabel();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel3 = new javax.swing.JPanel();

jLabel22 = new javax.swing.JLabel();

txtprofesion = new javax.swing.JTextField();

jLabel9 = new javax.swing.JLabel();

cnbcarrera = new javax.swing.JComboBox();

jLabel23 = new javax.swing.JLabel();

cnbfacultad = new javax.swing.JComboBox();

jPanel4 = new javax.swing.JPanel();

jLabel7 = new javax.swing.JLabel();

cnbsexo = new javax.swing.JComboBox();

jLabel19 = new javax.swing.JLabel();

txtfechanac = new com.toedter.calendar.JDateChooser();

jLabel20 = new javax.swing.JLabel();

txtfecha = new javax.swing.JTextField();

jLabel8 = new javax.swing.JLabel();

txtedad = new javax.swing.JTextField();

txtdni = new javax.swing.JTextField();

jLabel6 = new javax.swing.JLabel();

txttelefono = new javax.swing.JTextField();

jLabel11 = new javax.swing.JLabel();

jLabel17 = new javax.swing.JLabel();

txtdireccion = new javax.swing.JTextField();

jPanel5 = new javax.swing.JPanel();

jLabel3 = new javax.swing.JLabel();

txtid = new javax.swing.JTextField();

jLabel18 = new javax.swing.JLabel();

cnbtipopersona = new javax.swing.JComboBox();

jLabel10 = new javax.swing.JLabel();

txtcodigo = new javax.swing.JTextField();

jLabel2 = new javax.swing.JLabel();

txtapellidop = new javax.swing.JTextField();

jLabel4 = new javax.swing.JLabel();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
txtapellidom = new javax.swing.JTextField();

jLabel5 = new javax.swing.JLabel();

txtnombre = new javax.swing.JTextField();

jLabel14 = new javax.swing.JLabel();

cnbdepartamento = new javax.swing.JComboBox();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton4 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jPanel1.setBackground(new java.awt.Color(153, 153, 255));

jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

jLabel12.setText("DATOS DE PERSONA");

jLabel22.setText("PROFESION:");

jLabel9.setText("CARRERA PROFESIONAL :");

cnbcarrera.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INGENIERIA DE SISTEMAS


E INFORMATICA", "INGENIERIA FORESTAL", "INGENIERIA AGROINDUSTRIAL", "EDUCACION PRIMARIA ",
"EDUCACION INICIAL", "EDUCACION SECUNDARIA Y COMPUTACION", "CONTABILIDAD",
"ADMINISTRACION", "DERECHO Y CIENCIAS POLITICAS", "ECOTURISMO", "ENFERMERIA", "MEDICINA
VETERINARIA Y ZOOTECNIA", " ", " " }));

cnbcarrera.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbcarreraActionPerformed(evt);

});

jLabel23.setText("FACULTAD:");

cnbfacultad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "INGENIERIA",


"EDUCACION", "ECOTURISMO" }));
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel3Layout.createSequentialGroup()

.addComponent(jLabel9)

.addGap(41, 41, 41)

.addComponent(cnbcarrera, javax.swing.GroupLayout.PREFERRED_SIZE, 235,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel3Layout.createSequentialGroup()

.addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 128,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(62, 62, 62)

.addComponent(cnbfacultad, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addGroup(jPanel3Layout.createSequentialGroup()

.addComponent(jLabel22)

.addGap(118, 118, 118)

.addComponent(txtprofesion)))

.addContainerGap(248, Short.MAX_VALUE))

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel22)

.addComponent(txtprofesion, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel9)

.addComponent(cnbcarrera, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel23)

.addComponent(cnbfacultad, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jLabel7.setText("SEXO :");

cnbsexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "M", "F" }));

jLabel19.setText("FECHA NAC.");

txtfechanac.setDateFormatString("yyyy/MM/dd");

jLabel20.setText("FECHA REG..");

jLabel8.setText("EDAD :");

jLabel6.setText("D.N.I :");

jLabel11.setText("TELEFONO");

jLabel17.setText("DIRECCION :");

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);

jPanel4.setLayout(jPanel4Layout);

jPanel4Layout.setHorizontalGroup(
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addGroup(jPanel4Layout.createSequentialGroup()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(txtdni, javax.swing.GroupLayout.PREFERRED_SIZE, 160,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(txtedad)

.addComponent(txtfechanac, javax.swing.GroupLayout.DEFAULT_SIZE, 119,


Short.MAX_VALUE)

.addComponent(cnbsexo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(txtfecha)

.addComponent(txttelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 160,


javax.swing.GroupLayout.PREFERRED_SIZE)))

.addGroup(jPanel4Layout.createSequentialGroup()

.addComponent(jLabel17)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(txtdireccion)))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {cnbsexo,


txtedad, txtfecha, txtfechanac, txttelefono});

jPanel4Layout.setVerticalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel7)

.addComponent(cnbsexo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addComponent(jLabel19)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel20)

.addComponent(txtfecha, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel8)

.addComponent(txtedad, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel6)

.addComponent(txtdni, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel11)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(txttelefono, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addComponent(txtfechanac, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel17)

.addComponent(txtdireccion, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jLabel3.setText("ID");

txtid.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

txtidActionPerformed(evt);

});

jLabel18.setText("Tipo Persona:");

cnbtipopersona.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ESTUDIANTE",


"DOCENTE", "BIBLIOTECARIO", "ADMINISTRADOR" }));

cnbtipopersona.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

cnbtipopersonaActionPerformed(evt);

});

jLabel10.setText("CODIGO :");

jLabel2.setText("APELLIDO PATERNO :");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel4.setText("APELLIDO MATERNO :");

jLabel5.setText("NOMBRES :");

jLabel14.setText("DEPARTAMENTO :");

cnbdepartamento.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ABANCAY",


"AREQUIPA", "CHICLAYO", "CUSCO", "JULIACA", "LIMA", "MADRE DE DIOS", "MOQUEGUA", "PUNO",
"TRUJILLO", "ICA" }));

javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);

jPanel5.setLayout(jPanel5Layout);

jPanel5Layout.setHorizontalGroup(

jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel5Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel5Layout.createSequentialGroup()

.addComponent(jLabel3)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE, 222,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel5Layout.createSequentialGroup()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)

.addComponent(jLabel18, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jLabel10, javax.swing.GroupLayout.Alignment.LEADING))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(txtapellidop)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 124,


javax.swing.GroupLayout.PREFERRED_SIZE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(cnbtipopersona, 0, 222, Short.MAX_VALUE)))

.addGroup(jPanel5Layout.createSequentialGroup()

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jLabel4)

.addComponent(jLabel5)

.addComponent(jLabel14))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addComponent(txtapellidom, javax.swing.GroupLayout.DEFAULT_SIZE, 122,


Short.MAX_VALUE)

.addComponent(txtnombre, javax.swing.GroupLayout.DEFAULT_SIZE, 135,


Short.MAX_VALUE)

.addComponent(cnbdepartamento, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))))

.addContainerGap())

);

jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10,


jLabel18, jLabel2, jLabel3, jLabel4, jLabel5});

jPanel5Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[]


{cnbtipopersona, txtapellidom, txtapellidop, txtcodigo, txtid, txtnombre});

jPanel5Layout.setVerticalGroup(

jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()

.addGap(0, 11, Short.MAX_VALUE)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel3)

.addComponent(txtid, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel18)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(cnbtipopersona, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel10)

.addComponent(txtcodigo, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel2)

.addComponent(txtapellidop, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(13, 13, 13)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel4)

.addComponent(txtapellidom, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(txtnombre, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel5))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel14)

.addComponent(cnbdepartamento, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap())

);

jPanel5Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[]


{cnbtipopersona, txtapellidom, txtapellidop, txtcodigo, txtid, txtnombre});

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel12)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))

.addContainerGap(23, Short.MAX_VALUE))

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jLabel12)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGap(7, 7, 7))

);

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/guardar.png"))); // NOI18N


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jButton1.setText("GUARDAR");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/modificar.png"))); //
NOI18N

jButton2.setText("MODIFICAR");

jButton4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/nuevo.png"))); // NOI18N

jButton4.setText("NUEVO");

jButton4.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton4ActionPerformed(evt);

});

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton3.setText("SALIR");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

.addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.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, false)

.addGroup(layout.createSequentialGroup()

.addComponent(jButton4)

.addGap(52, 52, 52)

.addComponent(jButton1)

.addGap(53, 53, 53)

.addComponent(jButton2)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton3))

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(40, Short.MAX_VALUE))

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

pack();

}// </editor-fold>

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

id=txtid.getText();

tipo=(String)cnbtipopersona.getSelectedItem();

dni=txtdni.getText();

nombre=txtnombre.getText();

apellidopat=txtapellidop.getText();

apellidomat=txtapellidom.getText();

direccion=txtdireccion.getText();

//agarrar fecha del dataechoser

java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

fechanc=sdf.format(txtfechanac.getDate());

fecha=txtfecha.getText();

sexo=(String) cnbsexo.getSelectedItem();

procedencia=(String) cnbdepartamento.getSelectedItem();

telefono=txttelefono.getText();

codigoestu=txtcodigo.getText();

codigoprofes=txtcodigo.getText();

profesion=txtprofesion.getText();

carrera=(String) cnbcarrera.getSelectedItem();

facultad=(String) cnbfacultad.getSelectedItem();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
//JOptionPane.showMessageDialog(this, sexo);

insertar_persona();

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

limpiar();

cargar_fecha();

CARGAR_CODIGO(); //genera el codigo de persona

private void cnbtipopersonaActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (cnbtipopersona.getSelectedIndex()==0) {

txtprofesion.setEnabled(false);

}else{

txtprofesion.setEnabled(true);

private void cnbcarreraActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.setVisible(false);

private void txtidActionPerformed(java.awt.event.ActionEvent evt) {


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
// TODO add your handling code here:

public static void main(String args[]) {

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(personas.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(personas.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(personas.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(personas.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 personas().setVisible(true);

});

// Variables declaration - do not modify


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JComboBox cnbcarrera;

private javax.swing.JComboBox cnbdepartamento;

private javax.swing.JComboBox cnbfacultad;

private javax.swing.JComboBox cnbsexo;

private javax.swing.JComboBox cnbtipopersona;

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JButton jButton4;

private javax.swing.JLabel jLabel10;

private javax.swing.JLabel jLabel11;

private javax.swing.JLabel jLabel12;

private javax.swing.JLabel jLabel14;

private javax.swing.JLabel jLabel17;

private javax.swing.JLabel jLabel18;

private javax.swing.JLabel jLabel19;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel20;

private javax.swing.JLabel jLabel22;

private javax.swing.JLabel jLabel23;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JLabel jLabel5;

private javax.swing.JLabel jLabel6;

private javax.swing.JLabel jLabel7;

private javax.swing.JLabel jLabel8;

private javax.swing.JLabel jLabel9;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel3;

private javax.swing.JPanel jPanel4;

private javax.swing.JPanel jPanel5;

private javax.swing.JTextField txtapellidom;


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private javax.swing.JTextField txtapellidop;

private javax.swing.JTextField txtcodigo;

private javax.swing.JTextField txtdireccion;

private javax.swing.JTextField txtdni;

private javax.swing.JTextField txtedad;

private javax.swing.JTextField txtfecha;

private com.toedter.calendar.JDateChooser txtfechanac;

private javax.swing.JTextField txtid;

private javax.swing.JTextField txtnombre;

private javax.swing.JTextField txtprofesion;

private javax.swing.JTextField txttelefono;

// End of variables declaration

private void cargar_fecha() {

java.util.Date date=new java.util.Date();

java.text.SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

String fecha=sdf.format(date);

txtfecha.setText(fecha);

private void CARGAR_CODIGO() {

try {

prepara la cunsulta

Statement stmt = con.createStatement();

ResultSet rs = stmt.executeQuery("select max(id_persona) as 'Codigo' from persona");

while (rs.next()) {

int lastID = rs.getInt(1);

txtid.setText(String.valueOf(lastID + 1));

rs.close();

stmt.close();
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
} catch (SQLException error) {

System.out.print(error);

private void deshabilitar() {

txtprofesion.setEnabled(false);

private void insertar_persona() {

String sqlpersona="insert into persona values(?,?,?,?,?,?,?,?,?,?,?,?)"; //Ingresamos los


parametros

try {

//prepara la consulta

PreparedStatement pst=con.prepareStatement(sqlpersona);

pst.setString(1, id);

pst.setString(2, tipo);

pst.setString(3, dni);

pst.setString(4, nombre);

pst.setString(5, apellidopat);

pst.setString(6, apellidomat);

pst.setString(7, direccion);

pst.setString(8, fechanc);

pst.setString(9, sexo);

pst.setString(10, procedencia);

pst.setString(11, fecha);

pst.setString(12, telefono);

int reg=pst.executeUpdate();

if (reg>0) {

if (cnbtipopersona.getSelectedIndex()==0) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
insertarestudiante();

}else if(cnbtipopersona.getSelectedIndex()==1) {

insertar_docentes();

}else if(cnbtipopersona.getSelectedIndex()==2) {

insertar_bibliotecario();

}else {

insertar_administrador();

} catch (SQLException e) {

JOptionPane.showMessageDialog(this,"error persona"+ e);

private void insertarestudiante() {

String sqlestudiante="insert into estudiante values(?,?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, id);

pst1.setString(2, codigoestu);

pst1.setString(3, carrera);

pst1.setString(4, facultad);

int reg1=pst1.executeUpdate();

if (reg1>0) {

registrar_usuario(id,codigoestu,dni);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

private void registrar_usuario(String id, String codigoestu, String dni) {

String sqlusuario="insert into usuario values(?,?,?)";

try {

PreparedStatement pst2=con.prepareStatement(sqlusuario);

pst2.setString(1, id);

pst2.setString(2, codigoestu);

pst2.setString(3, dni);

int reg=pst2.executeUpdate();

if (reg>0) {

JOptionPane.showMessageDialog(this, "registro con exito");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "usuario"+e);

private void insertar_docentes() {

String sqlestudiante="insert into docente values(?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, id);

pst1.setString(2, codigoprofes);

pst1.setString(3, profesion);

int reg1=pst1.executeUpdate();

if (reg1>0) {

registrar_usuario(id,codigoprofes,dni);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void limpiar() {

txtdni.setText(null);

txtnombre.setText(null);

txtapellidom.setText(null);

txtapellidop.setText(null);

txtcodigo.setText(null);

txtedad.setText(null);

txtfecha.setText(null);

txtprofesion.setText(null);

txttelefono.setText(null);

java.util.Date date = new java.util.Date();

//java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

txtfechanac.setDate(date);

txtdireccion.setText(null);

private void insertar_bibliotecario() {

String sqlestudiante="insert into bibliotecario values(?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, id);

pst1.setString(2, codigoprofes);

pst1.setString(3, profesion);

int reg1=pst1.executeUpdate();

if (reg1>0) {

registrar_usuario(id,codigoprofes,dni);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void insertar_administrador() {

String sqlestudiante="insert into administrador values(?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setString(1, id);

pst1.setString(2, codigoprofes);

pst1.setString(3, profesion);

int reg1=pst1.executeUpdate();

if (reg1>0) {

registrar_usuario(id,codigoprofes,dni);

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "tipo persona"+e);

VENTANILLA DE REPORTE DE
REGISTRO DE PRESTAMOS
El código permite mostrar por defecto los datos de préstamo el cual tambien se
puede registrar devolución siempre en cuando que haya préstamo de libro de dicho
lector ,al actualizar registro de prestamos.

package presentacion;

import clases.conexion;

import java.sql.Connection;

import java.sql.PreparedStatement;

import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Calendar;

import java.util.Date;

import java.util.GregorianCalendar;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

/**

* @author zombyes informaticos

*/

public class registro_prestamos extends javax.swing.JFrame {

DefaultTableModel model;

/**

* Creates new form resgistro_prestamos

*/

public registro_prestamos() {

initComponents();

CARGAR_RESGISTRO_PRESTAMO_LIBROS();

rdestudiante.setSelected(true);

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jPanel2 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablaprestamos = new javax.swing.JTable();

rdestudiante = new javax.swing.JRadioButton();

rddocente = new javax.swing.JRadioButton();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel3 = new javax.swing.JPanel();

btnregistrardevolucion = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jLabel1 = new javax.swing.JLabel();

txtdato = new javax.swing.JTextField();

jLabel2 = new javax.swing.JLabel();

jPanel1.setBackground(new java.awt.Color(0, 255, 204));

jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE LIBROS PRESTADOS"));

tablaprestamos.setModel(new javax.swing.table.DefaultTableModel(

new Object [][] { },

new String [] {

));

tablaprestamos.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

tablaprestamosMouseClicked(evt);

});

jScrollPane1.setViewportView(tablaprestamos);

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 891, Short.MAX_VALUE)

.addContainerGap()) );
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addGap(0, 26, Short.MAX_VALUE))

);

rdestudiante.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

rdestudiante.setText("ESTUDIANTES");

rdestudiante.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rdestudianteActionPerformed(evt);

});

rddocente.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

rddocente.setText("DOCENTES");

rddocente.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

rddocenteActionPerformed(evt);

});

btnregistrardevolucion.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

btnregistrardevolucion.setText("REGISTRAR DEVOLUCION");

btnregistrardevolucion.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

btnregistrardevolucionActionPerformed(evt);

});
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton2.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton2ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addGap(32, 32, 32)

.addComponent(btnregistrardevolucion)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 154,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap())

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton2)

.addComponent(btnregistrardevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 48,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGap(22, 22, 22))

);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jLabel1.setText("CODIGO");

txtdato.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txtdatoMouseClicked(evt);

});

txtdato.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

txtdatoActionPerformed(evt);

});

jLabel2.setText("COD PRESTAMO");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(21, 21, 21)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE, 241,


javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addComponent(rdestudiante)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGap(80, 80, 80)

.addComponent(rddocente, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

.addGap(38, 38, 38)

.addComponent(jLabel2)

.addGap(0, 0, Short.MAX_VALUE))

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(11, 11, 11)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(rdestudiante)

.addComponent(rddocente))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtdato, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(jLabel2))

.addGap(18, 18, 18)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

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()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

private void txtdatoActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (rdestudiante.isSelected() == true) {

para_estudiante();

}else if (rddocente.isSelected() == true) {

para_docente();

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void txtdatoMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

txtdato.setText(null);

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.setVisible(false);

private void btnregistrardevolucionActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

if (rdestudiante.isSelected()==true) {

actualzar_libro();

if (rddocente.isSelected()==true) {

int filas_seleccionadas=tablaprestamos.getSelectedRowCount();

if (filas_seleccionadas>0) {

if (filas_seleccionadas==1) {

int fila=tablaprestamos.getSelectedRow();

actualzar_libro(fila);

}else{

actualzar_libro();

}else JOptionPane.showMessageDialog(this, "Seleccione Registro Detalle Prestamo");

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
}

private void rddocenteActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

rdestudiante.setSelected(false);

rddocente.setSelected(true);

private void rdestudianteActionPerformed(java.awt.event.ActionEvent evt) {

rdestudiante.setSelected(true);

rddocente.setSelected(false);

private void tablaprestamosMouseClicked(java.awt.event.MouseEvent evt) {

public static void main(String args[]) {

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(registro_prestamos.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(registro_prestamos.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(registro_prestamos.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(registro_prestamos.class.getName()).log(java.util.logging.Level.SEVERE, null,
ex);

//</editor-fold

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new registro_prestamos().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton btnregistrardevolucion;

private javax.swing.JButton jButton2;

private javax.swing.JLabel jLabel1;

private javax.swing.JLabel jLabel2;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JRadioButton rddocente;

private javax.swing.JRadioButton rdestudiante;

private javax.swing.JTable tablaprestamos;

private javax.swing.JTextField txtdato;

// End of variables declaration

private void CARGAR_RESGISTRO_PRESTAMO_LIBROS() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


PRESTAMO","FECHA DEVOLUCION","ESTADO"};

String [] registros=new String[8];


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String sql="select *from ficha_Pestudiante where f_estado='EN PRESTAMO'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_estudiante() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO LIBRO","CODIGO PERSONA","CANTIDAD","FECHA


PRESTAMO","FECHA DEVOLUCION","ESTADO"};

String [] registros=new String[8];

String sql="SELECT * FROM ficha_Pestudiante,estudiante WHERE


ficha_Pestudiante.id_persona=estudiante.id_persona and ficha_Pestudiante.f_estado='EN PRESTAMO' and
estudiante.codigo='"+txtdato.getText()+"'";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

registros[6]=rs.getString(7);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void para_docente() {

String [] titulos ={"CODIGO PRESTAMO","CODIGO PRODUCTO","CANTIDAD","ESTADO","FECHA


DEVOLUCION"};

String [] registros=new String[7];

String sql="Select
ficha_PDocente.f_codigo,detalle_ficha_pdocente.p_codigo,detalle_ficha_pdocente.df_cantidad,detalle_ficha_pdo
cente.df_estado,ficha_PDocente.f_fechadevolucion FROM detalle_ficha_pdocente,ficha_PDocente,docente
WHERE detalle_ficha_pdocente.f_codigo=ficha_PDocente.f_codigo and detalle_ficha_pdocente.df_estado='EN
PRESTAMO' and ficha_PDocente.id_persona=docente.id_persona and
docente.d_codigo='"+txtdato.getText()+"'";
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

model.addRow(registros);

tablaprestamos.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void actualzar_libro() {

conexion cx=new conexion();

Connection con=cx.conexion();

if (rdestudiante.isSelected()==true) {

String codigo_libro=tablaprestamos.getValueAt(0, 1).toString();

String codigo_ficha=tablaprestamos.getValueAt(0, 0).toString();

String fechadev=tablaprestamos.getValueAt(0, 5).toString();


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String sqlestudiante="update libros,ficha_Pestudiante set
libros.p_cantidad=p_cantidad+1,ficha_Pestudiante.f_estado='DEVUELTO' where
libros.p_codigo=ficha_Pestudiante.p_codigo and ficha_Pestudiante.p_codigo='"+codigo_libro+"' and
ficha_Pestudiante.f_codigo='"+codigo_ficha+"'";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

int reg1=pst1.executeUpdate();

if (reg1>0) {

JOptionPane.showMessageDialog(this, "DEVOLUCION con exito");

registrar_sanciones(fechadev,txtdato.getText(),"ESTUDIANTE");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error es "+e);

if (rddocente.isSelected()==true) {

int reg2=0;

String fechadevolucion="";

try {

for (int i = 0; i < tablaprestamos.getRowCount(); i++) {

String codigo_ficha=tablaprestamos.getValueAt(i, 0).toString();

String codigo_libro=tablaprestamos.getValueAt(i, 1).toString();

fechadevolucion=tablaprestamos.getValueAt(i, 4).toString();

String sqldocente="update libros,detalle_ficha_PDocente set


libros.p_cantidad=p_cantidad+1,detalle_ficha_PDocente.df_estado='DEVUELTO' where
libros.p_codigo=detalle_ficha_PDocente.p_codigo and detalle_ficha_PDocente.p_codigo='"+codigo_libro+"' and
detalle_ficha_PDocente.f_codigo='"+codigo_ficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

reg2=pst1.executeUpdate();

if (reg2>0) {

JOptionPane.showMessageDialog(this, "devolucion con exito");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
registrar_sanciones(fechadevolucion,txtdato.getText(),"DOCENTE");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error "+e);

private void actualzar_libro(int fila) {

conexion cx=new conexion();

Connection con=cx.conexion();

int reg2=0;

try {

String codigo_ficha=tablaprestamos.getValueAt(fila, 0).toString();

String codigo_libro=tablaprestamos.getValueAt(fila, 1).toString();

String fechadevolucion=tablaprestamos.getValueAt(fila, 4).toString();

String sqldocente="update libros,detalle_ficha_PDocente set


libros.p_cantidad=p_cantidad+1,detalle_ficha_PDocente.df_estado='DEVUELTO' where
libros.p_codigo=detalle_ficha_PDocente.p_codigo and detalle_ficha_PDocente.p_codigo='"+codigo_libro+"' and
detalle_ficha_PDocente.f_codigo='"+codigo_ficha+"'";

PreparedStatement pst1=con.prepareStatement(sqldocente);

reg2=pst1.executeUpdate();

if (reg2>0) {

JOptionPane.showMessageDialog(this, "devolucion con exito");

registrar_sanciones(fechadevolucion,txtdato.getText(),"DOCENTE");

} catch (Exception e) {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
JOptionPane.showMessageDialog(this, "error "+e);

private void registrar_sanciones(String fechadev, String codigo_persona, String TIPOPERSONA) {

Date fechaActual = new Date();

SimpleDateFormat formateador = new SimpleDateFormat("YYYY-MM-dd");

String fechaSistema=formateador.format(fechaActual);

String resultado=compararFechasConDate(fechadev,fechaSistema);

if (resultado.equals("MAYOR")) {

String fecha_sancion=fecha_sancion();

conexion cx=new conexion();

Connection con=cx.conexion();

String sqlestudiante="insert into sancion values(?,?,?,?,?,?)";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.setInt(1, 0);

pst1.setString(2, codigo_persona);

pst1.setString(3, fecha_sancion);

pst1.setString(4, fechaSistema);

pst1.setString(5, TIPOPERSONA);

pst1.setString(6, "ACTIVO");

int reg1=pst1.executeUpdate();

if (reg1>0) {

JOptionPane.showMessageDialog(this, "ESTAS SANCIONADO HASTA ");

} catch (Exception e) {

JOptionPane.showMessageDialog(this, " al sancionar "+e);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
private String compararFechasConDate(String fechadev, String fechaActual) {

String resultado="";

try {

/**Obtenemos las fechas enviadas en el formato a comparar*/

SimpleDateFormat formateador = new SimpleDateFormat("yyyy-MM-dd");

Date fechaDate1 = formateador.parse(fechaActual);

Date fechaDate2 = formateador.parse(fechadev);

if ( fechaDate1.before(fechaDate2) ){

resultado= "MENOR ";

}else{

if ( fechaDate2.before(fechaDate1) ){

resultado= "MAYOR";

}else{

resultado= "IGUAL";

} catch (ParseException e) {

JOptionPane.showMessageDialog(this, e);

return resultado;

private String fecha_sancion() {

java.util.Date date = new java.util.Date();

java.text.SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd");

String fecha = sdf.format(date);

String fechasan="";

SimpleDateFormat formatoDelTexto = new SimpleDateFormat("yyyy-MM-dd");


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
try {

fechasan = sumarFechasDias(formatoDelTexto.parse(fecha), 7);

} catch (ParseException ex) {

JOptionPane.showMessageDialog(this, ex);

return fechasan;

SimpleDateFormat formatofecha = new SimpleDateFormat("yyyy-MM-dd");

private String sumarFechasDias(java.util.Date fch, int dias) {

Calendar cal = new GregorianCalendar();

cal.setTime(fch);

cal.add(Calendar.DATE, dias);

return "" + formatofecha.format(cal.getTime());

VENTANILLA DE REGISTRO DE
SANCIONES
En este caso el código muestra por defecto una lista de personas sancionadas o
tambien se puede buscar por código,el código esta realizado para sancionar a
lectores que o devuelven a su debido tiempo.

package presentacion;

import clases.conexion;

import java.sql.Connection;

import java.sql.PreparedStatement;
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
import java.sql.ResultSet;

import java.sql.SQLException;

import java.sql.Statement;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.Date;

import javax.swing.JOptionPane;

import javax.swing.table.DefaultTableModel;

public class registro_sancionados extends javax.swing.JFrame {

DefaultTableModel model;

public registro_sancionados() {

initComponents();

cargar_sanciones();

@SuppressWarnings("unchecked")

// <editor-fold defaultstate="collapsed" desc="Generated Code">

private void initComponents() {

jPanel1 = new javax.swing.JPanel();

jPanel2 = new javax.swing.JPanel();

jLabel1 = new javax.swing.JLabel();

txtbuscar = new javax.swing.JTextField();

jPanel3 = new javax.swing.JPanel();

jScrollPane1 = new javax.swing.JScrollPane();

tablasancionados = new javax.swing.JTable();

jPanel4 = new javax.swing.JPanel();

jButton1 = new javax.swing.JButton();

jButton2 = new javax.swing.JButton();

jButton3 = new javax.swing.JButton();

jPanel1.setBackground(new java.awt.Color(0, 204, 153));

jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
jLabel1.setText("BUSCAR SANCION");

txtbuscar.setForeground(new java.awt.Color(153, 153, 255));

txtbuscar.setHorizontalAlignment(javax.swing.JTextField.CENTER);

txtbuscar.setText("Ingrese codigo usuario");

txtbuscar.addMouseListener(new java.awt.event.MouseAdapter() {

public void mouseClicked(java.awt.event.MouseEvent evt) {

txtbuscarMouseClicked(evt);

});

txtbuscar.addKeyListener(new java.awt.event.KeyAdapter() {

public void keyReleased(java.awt.event.KeyEvent evt) {

txtbuscarKeyReleased(evt);

});

javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);

jPanel2.setLayout(jPanel2Layout);

jPanel2Layout.setHorizontalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addGap(33, 33, 33)

.addComponent(jLabel1)

.addGap(18, 18, 18)

.addComponent(txtbuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 335,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel2Layout.setVerticalGroup(

jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel2Layout.createSequentialGroup()

.addGap(26, 26, 26)


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jLabel1)

.addComponent(txtbuscar, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

.addContainerGap(30, Short.MAX_VALUE))

);

jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("REGISTRO DE SANCIONADOS"));

tablasancionados.setModel(new javax.swing.table.DefaultTableModel(

new Object [][]

new String [] {

));

jScrollPane1.setViewportView(tablasancionados);

javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);

jPanel3.setLayout(jPanel3Layout);

jPanel3Layout.setHorizontalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 899,


javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(23, Short.MAX_VALUE))

);

jPanel3Layout.setVerticalGroup(

jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel3Layout.createSequentialGroup()

.addContainerGap()

.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 168,


javax.swing.GroupLayout.PREFERRED_SIZE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

jPanel4.setBackground(new java.awt.Color(255, 204, 51));

jButton1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/nuevo.png"))); // NOI18N

jButton1.setText("NUEVO ");

jButton1.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton1ActionPerformed(evt);

});

jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salir.png"))); // NOI18N

jButton2.setText("SALIR");

jButton3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

jButton3.setText("ACTUALIZAR SANCION ");

jButton3.addActionListener(new java.awt.event.ActionListener() {

public void actionPerformed(java.awt.event.ActionEvent evt) {

jButton3ActionPerformed(evt);

});

javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);

jPanel4.setLayout(jPanel4Layout);

jPanel4Layout.setHorizontalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addGap(33, 33, 33)


UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jButton1)

.addGap(37, 37, 37)

.addComponent(jButton3)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jButton2)

.addGap(20, 20, 20))

);

jPanel4Layout.setVerticalGroup(

jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel4Layout.createSequentialGroup()

.addGap(19, 19, 19)

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jButton3, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addGroup(jPanel4Layout.createSequentialGroup()

.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(jButton1)

.addComponent(jButton2))

.addGap(0, 0, Short.MAX_VALUE)))

.addContainerGap())

);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

jPanel1.setLayout(jPanel1Layout);

jPanel1Layout.setHorizontalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
.addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.addContainerGap())

);

jPanel1Layout.setVerticalGroup(

jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(jPanel1Layout.createSequentialGroup()

.addGap(21, 21, 21)

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

getContentPane().setLayout(layout);

layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(layout.createSequentialGroup()

.addContainerGap()

.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
);

pack();

}// </editor-fold>

private void txtbuscarMouseClicked(java.awt.event.MouseEvent evt) {

// TODO add your handling code here:

txtbuscar.setText(null);

cargar_sanciones();

private void txtbuscarKeyReleased(java.awt.event.KeyEvent evt) {

// TODO add your handling code here:

String [] titulos ={"Codigo","Codigo Sancionado","Fecha Sancionada","Fecha de


Registro","Usuario","Estado"};

String [] registros=new String[7];

String sql="SELECT * FROM sancion WHERE s_estado='ACTIVO' and s_codigopersona LIKE


'%"+txtbuscar.getText()+"%'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
registros[5]=rs.getString(6);

model.addRow(registros);

tablasancionados.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

cargar_sanciones();

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

Date fechaActual = new Date();

SimpleDateFormat formateador = new SimpleDateFormat("YYYY-MM-dd");

String fechaSistema=formateador.format(fechaActual);

String sql="select *from sancion where s_estado='ACTIVO'";

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {

Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
String resultado=compararFechasConDate(rs.getString(3),fechaSistema);

if (resultado.equals("MAYOR")) {

modificar_sancion(rs.getString(2));

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

public static void main(String args[]) {

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(registro_sancionados.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (InstantiationException ex) {

java.util.logging.Logger.getLogger(registro_sancionados.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (IllegalAccessException ex) {

java.util.logging.Logger.getLogger(registro_sancionados.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

} catch (javax.swing.UnsupportedLookAndFeelException ex) {

java.util.logging.Logger.getLogger(registro_sancionados.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);

//</editor-fold>
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS

/* Create and display the form */

java.awt.EventQueue.invokeLater(new Runnable() {

public void run() {

new registro_sancionados().setVisible(true);

});

// Variables declaration - do not modify

private javax.swing.JButton jButton1;

private javax.swing.JButton jButton2;

private javax.swing.JButton jButton3;

private javax.swing.JLabel jLabel1;

private javax.swing.JPanel jPanel1;

private javax.swing.JPanel jPanel2;

private javax.swing.JPanel jPanel3;

private javax.swing.JPanel jPanel4;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JTable tablasancionados;

private javax.swing.JTextField txtbuscar;

private void cargar_sanciones() {

String [] titulos ={"Codigo","Codigo Sancionado","Fecha Sancionada","Fecha de


Registro","Usuario","Estado"};

String [] registros=new String[7];

String sql="select *from sancion where s_estado='ACTIVO'";

model=new DefaultTableModel(null,titulos);

conexion cc=new conexion();

Connection cn=cc.conexion();

ResultSet rs=null;

try {
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
Statement st=cn.createStatement();

rs=st.executeQuery(sql);

while(rs.next()){

registros[0]=rs.getString(1);

registros[1]=rs.getString(2);

registros[2]=rs.getString(3);

registros[3]=rs.getString(4);

registros[4]=rs.getString(5);

registros[5]=rs.getString(6);

model.addRow(registros);

tablasancionados.setModel(model);

} catch (SQLException ex) {

JOptionPane.showMessageDialog(this,"ERROR"+ ex);

private String compararFechasConDate(String fechasancion, String fechaActual) {

String resultado="";

try {

/**Obtenemos las fechas enviadas en el formato a comparar*/

SimpleDateFormat formateador = new SimpleDateFormat("yyyy-MM-dd");

Date fechaDate1 = formateador.parse(fechaActual);

Date fechaDate2 = formateador.parse(fechasancion);

if ( fechaDate1.before(fechaDate2) ){

resultado= "MENOR ";

}else{

if ( fechaDate2.before(fechaDate1) ){

resultado= "MAYOR";

}else{
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS
resultado= "IGUAL";

} catch (ParseException e) {

JOptionPane.showMessageDialog(this, e);

return resultado;

private void modificar_sancion(String CODIGOPERSONA) {

conexion cx=new conexion();

Connection con=cx.conexion();

String sqlestudiante="update sancion set s_estado='DESACTIVO' where


s_codigopersona='"+CODIGOPERSONA+"'";

try {

PreparedStatement pst1=con.prepareStatement(sqlestudiante);

pst1.executeUpdate();

} catch (Exception e) {

JOptionPane.showMessageDialog(this, "error es "+e);

}
UNIVERSIDAD NACIONAL AMAZONICA DE MADRE DE DIOS