Modelado UML

  • 404 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
404
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
49
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. DatosInformativos delComponenteEducativo: CICLO TITULACIÓN CREDITOS UTPL-ECTS 4 IngenieríaSistemas Informáticosy Computación. 4 Datosinformativos: Autor: Jackson Masache, Silvana Cuenca, Roberth Loaiza Docente: Ing.Danilo Jaramillo Fecha: 30-05-2013 LOJA–ECUADOR PROYECTO DE FIN DE CICLO
  • 2. TÍTULO: APLICACIÓN PARA UNA MICROEMPRESA DE CONFECCIÓN DE ROPA 1.- Enunciado Se requiere desarrollar una aplicación que permitirá a los empleados registrar la entrada y salida de sus horas laborables. Para ello deben de utilizar su número de cedula; que previamente tiene que estar almacenado en la aplicación con todos sus datos personales, obteniendo un registro y actualización de los datos de empleados con sus respectivas cargos. Permitir al administrador (gerente) y al personal consultar los horarios de trabajo con el fin de poder determinar los atrasos, inasistencias y las horas laboradas;presentando así un reporte. * Los sueldos serán obtenidos de la sumatoria total de horas, por el valor que se deba asignar, dependiendo del gerente como también, mas bonos que el gerente desee darle si hay alguno. *Los descuentos se los asignara si ocurre un daño por el empleado en su area de trabajo. *Los sueldos sólo pueden ser calculados mensualmente. * Las horas de trabajo, atrasos, inasistencias pueden ser visualizadas por los empleados al final del mes, con los descuentos, bonos y la cantidad total de sueldo a recibir para que no exista problemas. Usuarios: - Empleados. - Administrador. Necesidades: - Registrar las horas laborales del personal de empleados. - Registrar las entradas y salidas del personal de empleados. - Almacenar los datos personales de cada empleado con sus cargos de trabajo y horarios. - Permitir al gerente consultar y actualizar los horarios de los empleados. - Permitir al gerente cambiar los datos de los empleados. - Presentar reportes de las horas laboradas de los empleados. - Calcular los sueldos del personal de empleados. - Permitir al empleado visualizar al fin de mes las inasistencias, horas laboradas, atrasos, bonos Requerimientos: R1: Registro de empleados. R2: Actualización del registro de los empleados. R3: Registro de hora de entrada y hora de salida. R4: Asignar las horas de trabajo de los empleados. (quemar la hora de inicio de trabajo)
  • 3. R5: Consulta de horarios de los empleados. R6: Permitir al gerente calcular sueldos. Actores: Actores Descripción Empleados Personal de la empresa que interactuara con el sistema con un registro de sus horas laboradas. Administrador Controla el sistema teniendo mejor organización de los horarios de trabajo del personal. Caso de Uso: C1: Registrode empleados. C2: Actualización de registro de empleados C3: Registrode horarios. C4: Consulta de horas laboradas. C5: Calculo de los sueldos. Especificación Casos de Uso: Nombre: Registro de empleados R1 Descripción: Registrar los datos personales del personal, el cargo. Autor: Loaiza Roberth, Cuenca Silvana, Jackson Masache Fecha: 30/05/2013 Actores: Administrador Precondición: Que sea nuevo en el sistema Poscondición: Registrado en el sistema Flujo Normal Actor Sistema 1. Selecciona la opción Administrad. 2. Presenta la pantalla de ingreso. 3. Ingresar datos (Usuario - Password). 4. Verifica datos 5. Presenta la pantalla Administrador. 6. Selecciona el botón de Empleado 7. Presenta formulario de registro 8. Ingresa los datos del Empleado 9. Valida y almacena datos Flujo Alterno 3.1 No puede dejar campo vacío, el sistema mostrara mensaje de error. 8.1 No puede dejar campo vacío, el sistema mostrara mensaje de error, botón guardar Escenarios
  • 4. Nombre: Actualización de registro de empleados R2 Descripción: Modificar los datos personales del personal, el cargo. Autor: Loaiza Roberth, Cuenca Silvana, Jackson Masache Fecha: 30/05/2013 Actores: Administrador Precondición: Registrado en el sistema Poscondición: Actualización de datos Flujo Normal Actor Sistema 1. Selecciona la opción Administrad. 2. Presenta la pantalla de ingreso. 3. Ingresar datos (Usuario – Contraseña). 4. Verifica datos 5. Presenta la pantalla Administrador. 6. Selecciona el botón de Actualizar 7. Presenta formulario de registro 8. Ingresa numero de cedula 9. Carga la habilitaciónde los datos en los campos 10. Edita los campo 11. Presenta mensaje de confirmación Flujo Alterno 3.1 No puede dejar campo vacío, el sistema mostrara mensaje de error. 8.1 No puede dejar campo vacío, el sistema mostrara mensaje de error, clic en el botón editar. 9.1 Habilita los campos para poder realizar la actualización. 11.1 Datos actualizados como también almacenados. Escenarios Nombre: Registro de horarios R3 Descripción: Determinación de horas laboradas Autor: Loaiza Roberth, Cuenca Silvana, Jackson Masache Fecha: 30/05/2013 Actores: Empleado Precondición: Estar registrado en el sistema. Poscondición: Registrar las horas de horario de trabajo. Flujo Normal Actor Sistema 1. Selección botón Inicio 2. Ingresar cedula. 3. Carga los datos de cada campo 4. Presenta mensaje de confirmación
  • 5. Flujo Alterno 2.1 Presentar formulario de registro de ingreso al trabajo, como también el mensaje de error si los datos son erróneos, presiona la tecla ‘enter’ para guardar. 3.1 Datos del empleado, con la fecha y las horas (entrada y salida) 4.1 Alerta de datos ingresados correctamente, si se da el caso de atraso podrá elegir dentro de una lista de observaciones. Escenarios Nombre: Consulta de horas laboradas R5 Descripción: Registrar los datos personales del personal, el cargo. Autor: Loaiza Roberth, Cuenca Silvana, Jackson Masache Fecha: 30/05/2013 Actores: Administrador / Empleado Precondición: Que este registrado en el sistema Poscondición: Visualización de los registros de horas laboradas Flujo Normal Actor Sistema 1. Selecciona la opción Consulta. 2. Presenta la pantalla de consulta. 3. Ingresar (Cedula). 4. Verifica dato. 5. Presiona la opción consulta 6. Carga los datos en la tabla Flujo Alterno 3.1 No puede dejar campo vacío, el sistema mostrara mensaje de error. 5.1 Muestra horas, atrasos, inasistencias. Escenarios Nombre: Calculo de los sueldos R6 Descripción: Sueldo de los empleados con el total de horas acumuladas. Autor: Loaiza Roberth, Cuenca Silvana, Jackson Masache Fecha: 30/05/2013 Actores: Administrador Precondición: Visualización de los registros de horas laboradas Poscondición: Total del sueldo a pagar. Flujo Normal Actor Sistema 1. Selecciona la opción Administrad. 2. Presenta la pantalla de ingreso. 3. Ingresar datos (Usuario - Password).
  • 6. 4. Verifica datos 5. Presenta la pantalla Administrador. 6. Selecciona el botón Sueldo 7. Presenta la tabla de registro. 8. Clic en el botón Mostrar 9. Carga los valores en la tabla. 10. Ingresa cedula 11. Muestra el total de horas 12. Ingresa el valor por hora 13. Clic en calcular 14. Muestra valor del sueldo. 15. Ingresa valor si hay descuento / bono 16. Muestra valor del sueldo neto. Flujo Alterno 3.1 No puede dejar campo vacío, el sistema mostrara mensaje de error. 7.1 Muestra el total de horas, con su cedula y nombre del empleado 10.1 Presentación de mensaje de error si los datos son erróneos. 13.1 Calcula el numero total de horas por el valor de cada una. 16.1 Calculo del sueldo neto con los bonos y descuentos asignados. Escenarios Diagrama de actividades 1
  • 7. Diagrama de actividades 2
  • 8. Diagrama de actividades 3 Diagrama de actividades 4 Diagrama de actividades 5
  • 9. Diagrama de secuencia C1.- Registro de empleados
  • 10. Diagrama de secuencia C2.- Actualización de registro de empleados.
  • 11. Diagrama de secuencia C3.- Registro de horarios.
  • 12. Diagrama de secuencia C4.- Consulta de horas laboradas.
  • 13. Diagrama de secuencia C5.- Calculo de los sueldos.
  • 14. Diagrama de Clases.
  • 15. CODIGOS. PANTALLA ADMINISTRADOR package Interfaz; import clases.ConexionDB; import java.awt.Dimension; import java.awt.event.KeyEvent; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Date; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; /** * * @author rploaiza */ public class PantallaAdministrador extends javax.swing.JInternalFrame { /** * Creates new form PantallaAdministrador */ public PantallaAdministrador() { // Mostrar los Frame initComponents(); mostrardatos("");
  • 16. this.ocultarBarraTitulo(); this.jempleado.setVisible(false); this.jDatos.setVisible(false); this.jConsulta1.setVisible(false); this.jSueldo.setVisible(false); } void mostrardatos(String valor) { // Metodo para consultar en la BD DefaultTableModel modelo = new DefaultTableModel(); modelo.addColumn("Cedula"); modelo.addColumn("Nombre"); modelo.addColumn("Apellido"); modelo.addColumn("Direccion"); modelo.addColumn("Telefono"); modelo.addColumn("Cargo"); modelo.addColumn("Salario"); modelo.addColumn("Entrada"); TEditar.setModel(modelo); String sql = ""; if (valor.equals("")) { sql = "SELECT * FROM empleados"; } else { sql = "SELECT * FROM empleados WHERE cedula='" + valor + "'"; } String[] datos = new String[8]; try { Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sql); while (rs.next()) { datos[0] = rs.getString(1); datos[1] = rs.getString(2);
  • 17. datos[2] = rs.getString(3); datos[3] = rs.getString(4); datos[4] = rs.getString(5); datos[5] = rs.getString(6); datos[6] = rs.getString(7); datos[7] = rs.getString(8); modelo.addRow(datos); } TEditar.setModel(modelo); } catch (SQLException ex) { Logger.getLogger(PantallaAdministrador.class.getName()).log(Level.SEVERE, null, ex); } } public void ocultarBarraTitulo() { Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane(); dimBarra = Barra.getPreferredSize(); Barra.setSize(0, 0); Barra.setPreferredSize(new Dimension(0, 0)); repaint(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jScrollPane3 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jPopupMenu1 = new javax.swing.JPopupMenu(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuItem2 = new javax.swing.JMenuItem(); empleado = new javax.swing.JButton(); actDatos = new javax.swing.JButton();
  • 18. consulta = new javax.swing.JButton(); sueldo = new javax.swing.JButton(); escritorioAdmin = new javax.swing.JDesktopPane(); jempleado = new javax.swing.JInternalFrame(); 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(); jLabel6 = new javax.swing.JLabel(); jbguardar = new javax.swing.JButton(); jtnombres = new javax.swing.JTextField(); jtapellido = new javax.swing.JTextField(); jtdireccion = new javax.swing.JTextField(); jttelefono = new javax.swing.JTextField(); jtcargo = new javax.swing.JTextField(); jLabel21 = new javax.swing.JLabel(); jLabel25 = new javax.swing.JLabel(); jtsalario = new javax.swing.JTextField(); jtcedula = new javax.swing.JTextField(); jLabel28 = new javax.swing.JLabel(); jtHora = new javax.swing.JComboBox(); jlencabezado_empleado = new javax.swing.JLabel(); jDatos = new javax.swing.JInternalFrame(); jbguardar_ed = new javax.swing.JButton(); jScrollPane5 = new javax.swing.JScrollPane(); TEditar = new javax.swing.JTable(); Mostrar = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jLabel27 = new javax.swing.JLabel(); jtsalario1 = new javax.swing.JTextField(); jLabel23 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel();
  • 19. jt_cargo_ed = new javax.swing.JTextField(); jLabel11 = new javax.swing.JLabel(); jLabel12 = new javax.swing.JLabel(); jtdire = new javax.swing.JTextField(); jttele = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); jt_cedula = new javax.swing.JTextField(); jtnombre_ed = new javax.swing.JTextField(); jtapellidos = new javax.swing.JTextField(); jLabel10 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); Buscar = new javax.swing.JButton(); jtHora1 = new javax.swing.JComboBox(); jSueldo = new javax.swing.JInternalFrame(); jLabel15 = new javax.swing.JLabel(); bMostrar = new javax.swing.JButton(); jLabel16 = new javax.swing.JLabel(); jtcedula_salario = new javax.swing.JTextField(); bcalcular_salario = new javax.swing.JButton(); jLabel22 = new javax.swing.JLabel(); jtdescuento_salario = new javax.swing.JTextField(); jtbono_salario = new javax.swing.JTextField(); jLabel17 = new javax.swing.JLabel(); jLabel18 = new javax.swing.JLabel(); jlsalario_salario = new javax.swing.JLabel(); jLabel20 = new javax.swing.JLabel(); bguardar_salario = new javax.swing.JButton(); jlhoras_salario = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jConsulta1 = new javax.swing.JInternalFrame(); jLabel34 = new javax.swing.JLabel(); jtcedula_cons = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane();
  • 20. thorarios_cons = new javax.swing.JTable(); bconsultar_cons = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel19 = new javax.swing.JLabel(); jLabel24 = new javax.swing.JLabel(); jLabel26 = new javax.swing.JLabel(); jlnombre = new javax.swing.JLabel(); jlapellido = new javax.swing.JLabel(); jlcargo = new javax.swing.JLabel(); jList1.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; public int getSize() { return strings.length; } public Object getElementAt(int i) { return strings[i]; } }); jScrollPane3.setViewportView(jList1); jMenuItem1.setText("Modificar"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jPopupMenu1.add(jMenuItem1); jMenuItem2.setText("Eliminar"); jMenuItem2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem2ActionPerformed(evt); } }); jPopupMenu1.add(jMenuItem2);
  • 21. setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAIS ED)); setPreferredSize(new java.awt.Dimension(1117, 539)); empleado.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N empleado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/Personal.png"))); // NOI18N empleado.setText("Empleado"); // NOI18N empleado.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { empleadoActionPerformed(evt); } }); actDatos.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N actDatos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/edi.png"))); // NOI18N actDatos.setText("Actualizar"); // NOI18N actDatos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { actDatosActionPerformed(evt); } }); consulta.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N consulta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/busq.png"))); // NOI18N consulta.setText("Consulta"); // NOI18N consulta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { consultaActionPerformed(evt); } });
  • 22. sueldo.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N sueldo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/salario.png"))); // NOI18N sueldo.setText("Salario"); // NOI18N sueldo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { sueldoActionPerformed(evt); } }); escritorioAdmin.setPreferredSize(new java.awt.Dimension(1100, 530)); jempleado.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelB order.RAISED)); jempleado.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); jempleado.setEnabled(false); jempleado.setPreferredSize(new java.awt.Dimension(700, 460)); jempleado.setVisible(true); jLabel1.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N jLabel1.setText("Cedula"); // NOI18N jLabel2.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N jLabel2.setText("Nombres"); // NOI18N jLabel3.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N jLabel3.setText("Apellidos"); // NOI18N jLabel4.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N jLabel4.setText("Dirección"); // NOI18N jLabel5.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N jLabel5.setText("Teléfono"); // NOI18N
  • 23. jLabel6.setFont(new java.awt.Font("Consolas", 1, 13)); // NOI18N jLabel6.setText("Cargo"); // NOI18N jbguardar.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jbguardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/guardar.png"))); // NOI18N jbguardar.setText("Guardar"); // NOI18N jbguardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbguardarActionPerformed(evt); } }); jtnombres.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtnombresKeyTyped(evt); } }); jtapellido.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtapellidoKeyTyped(evt); } }); jtdireccion.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtdireccionKeyTyped(evt); } }); jttelefono.addKeyListener(new java.awt.event.KeyAdapter() {
  • 24. public void keyTyped(java.awt.event.KeyEvent evt) { jttelefonoKeyTyped(evt); } }); jtcargo.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtcargoKeyTyped(evt); } }); jLabel21.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel21.setText("Horario de Trabajo"); // NOI18N jLabel25.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel25.setText("Salario por hora"); // NOI18N jtsalario.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtsalarioKeyTyped(evt); } }); jtcedula.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtcedulaKeyTyped(evt); } }); jLabel28.setText("$"); jtHora.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "07:00:00", "08:00:00", "09:00:00" }));
  • 25. jlencabezado_empleado.setText("REGISTRO DE EMPLEADOS"); javax.swing.GroupLayout jempleadoLayout = new javax.swing.GroupLayout(jempleado.getContentPane()); jempleado.getContentPane().setLayout(jempleadoLayout); jempleadoLayout.setHorizontalGroup( jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jempleadoLayout.createSequentialGroup() .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jempleadoLayout.createSequentialGroup() .addGap(97, 97, 97) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jempleadoLayout.createSequentialGroup() .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(jLabel4)) .addGap(25, 25, 25) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILIN G, false) .addComponent(jtcargo, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jtdireccion, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jtcedula, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE) .addComponent(jtnombres))) .addComponent(jLabel6) .addGroup(jempleadoLayout.createSequentialGroup() .addComponent(jLabel21) .addGap(18, 18, 18)
  • 26. .addComponent(jtHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(106, 106, 106) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jempleadoLayout.createSequentialGroup() .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILIN G) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)) .addGap(18, 18, 18) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G, false) .addComponent(jtapellido, javax.swing.GroupLayout.DEFAULT_SIZE, 215, Short.MAX_VALUE) .addComponent(jttelefono))) .addGroup(jempleadoLayout.createSequentialGroup() .addComponent(jLabel25) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel28) .addGap(29, 29, 29) .addComponent(jtsalario, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(jempleadoLayout.createSequentialGroup() .addGap(316, 316, 316) .addComponent(jlencabezado_empleado)) .addGroup(jempleadoLayout.createSequentialGroup() .addGap(335, 335, 335) .addComponent(jbguardar, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(471, Short.MAX_VALUE)) ); jempleadoLayout.setVerticalGroup( jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  • 27. .addGroup(jempleadoLayout.createSequentialGroup() .addGap(26, 26, 26) .addComponent(jlencabezado_empleado) .addGap(45, 45, 45) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jLabel1) .addComponent(jtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jempleadoLayout.createSequentialGroup() .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jtnombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jtdireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(15, 15, 15) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jLabel6) .addComponent(jtcargo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE)
  • 28. .addComponent(jLabel21) .addComponent(jtHora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(43, 43, 43) .addComponent(jbguardar) .addGap(423, 423, 423)) .addGroup(jempleadoLayout.createSequentialGroup() .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jtapellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jttelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addGap(18, 18, 18) .addGroup(jempleadoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jLabel25) .addComponent(jtsalario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel28)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) ); jempleado.setBounds(0, 0, 1230, 560); escritorioAdmin.add(jempleado, javax.swing.JLayeredPane.DEFAULT_LAYER); jDatos.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorde r.RAISED));
  • 29. jDatos.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); jDatos.setEnabled(false); jDatos.setPreferredSize(new java.awt.Dimension(600, 600)); jDatos.setVisible(true); jbguardar_ed.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jbguardar_ed.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/guardar.png"))); // NOI18N jbguardar_ed.setText("Guardar"); // NOI18N jbguardar_ed.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbguardar_edActionPerformed(evt); } }); TEditar.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { } )); TEditar.setComponentPopupMenu(jPopupMenu1); jScrollPane5.setViewportView(TEditar); Mostrar.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N Mostrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/busq.png"))); // NOI18N Mostrar.setText("Mostrar"); // NOI18N Mostrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { MostrarActionPerformed(evt);
  • 30. } }); jLabel27.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel27.setText("Salario x hora"); // NOI18N jLabel23.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel23.setText("Hora de entrada"); // NOI18N jLabel7.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel7.setText("Cargo"); // NOI18N jLabel11.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel11.setText("Teléfono"); // NOI18N jLabel12.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel12.setText("Dirección"); // NOI18N jLabel8.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel8.setText("Cedula"); // NOI18N jLabel10.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel10.setText("Apellidos"); // NOI18N jLabel9.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel9.setText("Nombres"); // NOI18N Buscar.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N Buscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/edi.png"))); // NOI18N Buscar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BuscarActionPerformed(evt);
  • 31. } }); jtHora1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "07:00:00", "08:00:00", "09:00:00" })); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap(30, Short.MAX_VALUE) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel9) .addComponent(jLabel8)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel11) .addComponent(jLabel12) .addComponent(jLabel7))) .addGap(43, 43, 43) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jtdire, javax.swing.GroupLayout.Alignment.TRAILING)
  • 32. .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addComponent(jt_cedula, javax.swing.GroupLayout.PREFERRED_SIZE, 96, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(Buscar)) .addComponent(jtapellidos) .addComponent(jtnombre_ed) .addComponent(jttele) .addComponent(jt_cargo_ed))) .addGroup(jPanel2Layout.createSequentialGroup() .addComponent(jLabel27) .addGap(25, 25, 25) .addComponent(jtsalario1, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(75, 75, 75) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel23) .addComponent(jtHora1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jt_cedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8)) .addComponent(Buscar))
  • 33. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jtnombre_ed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jtapellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel12) .addComponent(jtdire, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11) .addComponent(jttele, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(jt_cargo_ed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel23) .addGap(13, 13, 13) .addComponent(jtHora1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  • 34. .addComponent(jtsalario1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel27)) .addContainerGap()) ); javax.swing.GroupLayout jDatosLayout = new javax.swing.GroupLayout(jDatos.getContentPane()); jDatos.getContentPane().setLayout(jDatosLayout); jDatosLayout.setHorizontalGroup( jDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jDatosLayout.createSequentialGroup() .addGroup(jDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jDatosLayout.createSequentialGroup() .addGap(45, 45, 45) .addComponent(jbguardar_ed) .addGap(22, 22, 22) .addComponent(Mostrar)) .addGroup(jDatosLayout.createSequentialGroup() .addGap(25, 25, 25) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(29, 29, 29) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 535, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); jDatosLayout.setVerticalGroup( jDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jDatosLayout.createSequentialGroup() .addContainerGap() .addGroup(jDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE)
  • 35. .addGroup(jDatosLayout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jbguardar_ed) .addComponent(Mostrar)))) .addContainerGap(149, Short.MAX_VALUE)) ); jDatos.setBounds(0, 0, 1230, 550); escritorioAdmin.add(jDatos, javax.swing.JLayeredPane.DEFAULT_LAYER); jSueldo.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBord er.RAISED)); jSueldo.setEnabled(false); jSueldo.setPreferredSize(new java.awt.Dimension(600, 600)); jSueldo.setVisible(true); jLabel15.setFont(new java.awt.Font("Consolas", 1, 14)); // NOI18N jLabel15.setText("CALCULO DE SUELDOS"); // NOI18N bMostrar.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N bMostrar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/calend.png"))); // NOI18N bMostrar.setText("Mostrar"); // NOI18N bMostrar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bMostrarActionPerformed(evt); } }); jLabel16.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N
  • 36. jLabel16.setText("Cedula"); // NOI18N jtcedula_salario.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtcedula_salarioKeyTyped(evt); } }); bcalcular_salario.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N bcalcular_salario.setText("Calcular"); // NOI18N bcalcular_salario.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bcalcular_salarioActionPerformed(evt); } }); jLabel22.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel22.setText("Horas"); // NOI18N jtdescuento_salario.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jtdescuento_salarioActionPerformed(evt); } }); jLabel17.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel17.setText("Descuento"); // NOI18N jLabel18.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel18.setText("Bono"); // NOI18N jlsalario_salario.setFont(new java.awt.Font("Consolas", 1, 14)); // NOI18N jlsalario_salario.setForeground(new java.awt.Color(51, 0, 255));
  • 37. jlsalario_salario.setText("-.-"); // NOI18N jLabel20.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel20.setText("Salario"); // NOI18N bguardar_salario.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N bguardar_salario.setText("Guardar"); bguardar_salario.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bguardar_salarioActionPerformed(evt); } }); jlhoras_salario.setText("-.-"); jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/registro.jpg"))); // NOI18N javax.swing.GroupLayout jSueldoLayout = new javax.swing.GroupLayout(jSueldo.getContentPane()); jSueldo.getContentPane().setLayout(jSueldoLayout); jSueldoLayout.setHorizontalGroup( jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jSueldoLayout.createSequentialGroup() .addGap(34, 34, 34) .addComponent(jLabel16) .addGap(18, 18, 18) .addComponent(jtcedula_salario, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(36, 36, 36) .addComponent(bMostrar) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jSueldoLayout.createSequentialGroup()
  • 38. .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jSueldoLayout.createSequentialGroup() .addGap(73, 73, 73) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel22) .addComponent(jLabel17) .addComponent(jLabel18) .addComponent(jLabel20)) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jSueldoLayout.createSequentialGroup() .addGap(40, 40, 40) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jSueldoLayout.createSequentialGroup() .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jtbono_salario, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jtdescuento_salario, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(70, 70, 70) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(bcalcular_salario, javax.swing.GroupLayout.DEFAULT_SIZE, 156, Short.MAX_VALUE) .addComponent(bguardar_salario, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(jlhoras_salario, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(jSueldoLayout.createSequentialGroup() .addGap(49, 49, 49) .addComponent(jlsalario_salario))))
  • 39. .addGroup(jSueldoLayout.createSequentialGroup() .addGap(112, 112, 112) .addComponent(jLabel15)) .addGroup(jSueldoLayout.createSequentialGroup() .addGap(148, 148, 148) .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(789, Short.MAX_VALUE)) ); jSueldoLayout.setVerticalGroup( jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jSueldoLayout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(jLabel15) .addGap(10, 10, 10) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel16) .addComponent(jtcedula_salario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bMostrar)) .addGap(18, 18, 18) .addComponent(jLabel13) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel22) .addComponent(jlhoras_salario)) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(bcalcular_salario) .addGroup(jSueldoLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  • 40. .addComponent(jtdescuento_salario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel17)))) .addGap(18, 18, 18) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jtbono_salario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel18) .addComponent(bguardar_salario)) .addGap(18, 18, 18) .addGroup(jSueldoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel20) .addComponent(jlsalario_salario)) .addContainerGap(173, Short.MAX_VALUE)) ); jSueldo.setBounds(0, 0, 1230, 550); escritorioAdmin.add(jSueldo, javax.swing.JLayeredPane.DEFAULT_LAYER); jConsulta1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelB order.RAISED)); jConsulta1.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLO SE); jConsulta1.setEnabled(false); jConsulta1.setPreferredSize(new java.awt.Dimension(600, 600)); jConsulta1.setVisible(true); jLabel34.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel34.setText("# de Cedula"); // NOI18N jtcedula_cons.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) {
  • 41. jtcedula_consKeyPressed(evt); } public void keyTyped(java.awt.event.KeyEvent evt) { jtcedula_consKeyTyped(evt); } }); thorarios_cons.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { }, new String [] { } )); jScrollPane1.setViewportView(thorarios_cons); bconsultar_cons.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N bconsultar_cons.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/calend.png"))); // NOI18N bconsultar_cons.setText("Consultar"); bconsultar_cons.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bconsultar_consActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Personales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Consolas", 1, 12))); // NOI18N jLabel19.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel19.setText("Nombres: ");
  • 42. jLabel24.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel24.setText("Apellidos: "); jLabel26.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel26.setText("Cargo"); jlnombre.setText("#"); jlapellido.setText("#"); jlcargo.setText("#"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(21, 21, 21) .addComponent(jLabel19) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jlnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(36, 36, 36) .addComponent(jLabel24) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jlapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel26) .addGap(18, 18, 18) .addComponent(jlcargo, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(21, Short.MAX_VALUE)) );
  • 43. jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(15, 15, 15) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jlapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jlnombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel19) .addComponent(jLabel24) .addComponent(jLabel26) .addComponent(jlcargo)))) .addContainerGap(23, Short.MAX_VALUE)) ); javax.swing.GroupLayout jConsulta1Layout = new javax.swing.GroupLayout(jConsulta1.getContentPane()); jConsulta1.getContentPane().setLayout(jConsulta1Layout); jConsulta1Layout.setHorizontalGroup( jConsulta1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jConsulta1Layout.createSequentialGroup() .addGroup(jConsulta1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jConsulta1Layout.createSequentialGroup() .addContainerGap() .addComponent(jLabel34) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jtcedula_cons, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
  • 44. .addGap(55, 55, 55) .addComponent(bconsultar_cons)) .addGroup(jConsulta1Layout.createSequentialGroup() .addGap(25, 25, 25) .addGroup(jConsulta1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADIN G) .addGroup(jConsulta1Layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 771, javax.swing.GroupLayout.PREFERRED_SIZE)) .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)) ); jConsulta1Layout.setVerticalGroup( jConsulta1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jConsulta1Layout.createSequentialGroup() .addContainerGap() .addGroup(jConsulta1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELI NE) .addComponent(jLabel34) .addComponent(jtcedula_cons, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bconsultar_cons)) .addGap(41, 41, 41) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 300, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(132, Short.MAX_VALUE)) ); jConsulta1.setBounds(0, 0, 1230, 560);
  • 45. escritorioAdmin.add(jConsulta1, javax.swing.JLayeredPane.DEFAULT_LAYER); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(48, 48, 48) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(sueldo, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(actDatos, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(empleado, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(consulta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addComponent(escritorioAdmin, javax.swing.GroupLayout.DEFAULT_SIZE, 941, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(106, 106, 106) .addComponent(empleado, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(actDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(consulta, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  • 46. .addComponent(sueldo, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(223, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(escritorioAdmin, javax.swing.GroupLayout.DEFAULT_SIZE, 500, Short.MAX_VALUE)) ); pack(); }// </editor-fold> private void actDatosActionPerformed(java.awt.event.ActionEvent evt) { this.escritorioAdmin.removeAll(); this.escritorioAdmin.updateUI(); this.escritorioAdmin.add(jDatos); jDatos.show(); } private void empleadoActionPerformed(java.awt.event.ActionEvent evt) { this.escritorioAdmin.removeAll(); this.escritorioAdmin.updateUI(); this.escritorioAdmin.add(jempleado); jempleado.show(); } private void sueldoActionPerformed(java.awt.event.ActionEvent evt) { this.escritorioAdmin.removeAll(); this.escritorioAdmin.updateUI(); this.escritorioAdmin.add(jSueldo); jSueldo.show();
  • 47. } public long suma_horas(String Hora) { String hora_men, min_men, seg_men; //extraemos en variables separadas el tiempo menor hora_men = Hora.substring(0, 2); min_men = Hora.substring(3, 5); seg_men = Hora.substring(6, 8); Date fecha_may = new Date(2013, 9, 7, 0, 0, 0); Date fecha_men = new Date(2013, 9, 7, Integer.parseInt(hora_men), Integer.parseInt(min_men), Integer.parseInt(seg_men)); long seg = fecha_men.getTime() - fecha_may.getTime(); return seg / 1000; } public String Formatohoras(long seg) { int min = 0, hras = 0; while (seg > 60) { seg -= 60; min++; } while (min > 60) { min -= 60; hras++; } String tfhras = hras + ":" + min + ":" + seg; return tfhras; } private void bMostrarActionPerformed(java.awt.event.ActionEvent evt) {
  • 48. // TODO add your handling code here: String cedula = jtcedula_salario.getText(); Statement sentencia; String cons4 = "select * from horarios where cedula=" + cedula; // Manipulacion de tablas String hora_suma = ""; long suma_hora = 0; String horatotal_sumada = ""; long aux = 0; try { ConexionDB conx = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = conx.obtenerConexion(); // Creamos un objeto de obtener coneccion de la la libreria Connection sentencia = con.createStatement(); ResultSet consulta4 = sentencia.executeQuery(cons4); while (consulta4.next()) { //Asigancion de variables segun la consulta hora_suma = (consulta4.getString("hora_sumada")); aux = suma_horas(hora_suma);// variable segundos suma_hora = suma_hora + aux;// acumulador del tiempo } long horaSal = aux / 60 / 60; horatotal_sumada = Formatohoras(suma_hora); String horaPresentar = "" + horaSal; jlhoras_salario.setText(horaPresentar); } catch (Exception ex) { System.out.print(ex.getMessage()); }
  • 49. } private void bcalcular_salarioActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String cedula = jtcedula_salario.getText(); String salario_hora = null; try { ConexionDB coneccio = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccio.obtenerConexion(); // conexion_basedatos coneccio = new conexion_basedatos(); //LLamada al metodo de conexion String cons = "select * from empleados where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet consulta = coneccio.consulta(cons); consulta.next(); salario_hora = consulta.getString(7); } catch (Exception xw) { } double salario; String horas = jlhoras_salario.getText(); String descuento = jtdescuento_salario.getText(); String bono = jtbono_salario.getText(); int hora = Integer.parseInt(horas); double desc = Double.parseDouble(descuento); double bon = Double.parseDouble(bono); double sa_hora = Double.parseDouble(salario_hora); salario = (hora * sa_hora) + bon - desc; jlsalario_salario.setText(Double.toString(salario)); } private void BuscarActionPerformed(java.awt.event.ActionEvent evt) {
  • 50. // TODO add your handling code here: mostrardatos(jt_cedula.getText()); } private void jtdescuento_salarioActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: } private void jbguardarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String cedula, nombre, apellido, direccion, telefono, cargo, salario, horario; boolean flag = true; if (flag == validarCed(flag)) { if (jtcedula.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese el numero de cedula", "Information", JOptionPane.INFORMATION_MESSAGE); } else if (jtnombres.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese el nombre del emplead@", "Information", JOptionPane.INFORMATION_MESSAGE); } else if (jtapellido.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese el apellido del emplead@", "Information", JOptionPane.INFORMATION_MESSAGE); } else if (jtdireccion.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese la direccion", "Information", JOptionPane.INFORMATION_MESSAGE); } else if (jttelefono.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese el numero de telefono", "Information", JOptionPane.INFORMATION_MESSAGE); } else if (jtcargo.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese el cargo que ocupa en la empresa", "Information", JOptionPane.INFORMATION_MESSAGE); } else if (jtsalario.getText().equals("")) { javax.swing.JOptionPane.showMessageDialog(this, "Ingrese el salario del emplead@", "Information", JOptionPane.INFORMATION_MESSAGE); } else { cedula = this.jtcedula.getText();
  • 51. nombre = this.jtnombres.getText(); apellido = this.jtapellido.getText(); direccion = this.jtdireccion.getText(); telefono = this.jttelefono.getText(); cargo = this.jtcargo.getText(); salario = this.jtsalario.getText(); horario = this.jtHora.getSelectedItem().toString(); try { ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); // conexion_basedatos coneccion = new conexion_basedatos(); //LLamada al metodo de conexion String sInsert = "insert into empleados values(?,?,?,?,?,?,?,?)"; // Manipulacion de tablas PreparedStatement datos = con.prepareStatement(sInsert); datos.setString(1, cedula); datos.setString(2, nombre); datos.setString(3, apellido); datos.setString(4, direccion); datos.setString(5, telefono); datos.setString(6, cargo); datos.setString(7, salario); datos.setString(8, horario); datos.executeUpdate(); coneccion.cerrarConexion(); } catch (Exception ex) { System.out.print(ex.getMessage()); // JOptionPane.showMessageDialog(this, ex.getMessage()); }
  • 52. jtapellido.setText(""); jtcedula.setText(""); jtcargo.setText(""); jtdireccion.setText(""); jtnombres.setText(""); jtsalario.setText(""); jttelefono.setText(""); JOptionPane.showMessageDialog(null, "Usuario Registrado Correctamente", "Sistema", JOptionPane.INFORMATION_MESSAGE); } } else { JOptionPane.showMessageDialog(null, "Cedula incorrecta", "Sistema", JOptionPane.INFORMATION_MESSAGE); } } private void jbguardar_edActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { PreparedStatement pst = cn.prepareStatement("UPDATE empleados SET nombre='" + jtnombre_ed.getText() + "',apellido='" + jtapellidos.getText() + "',direccion='" + jtdire.getText() + "',telefono='" + jttele.getText() + "',cargo='" + jt_cargo_ed.getText() + "',salario='" + jtsalario1.getText() + "',horario='" + jtHora1.getSelectedItem() + "' WHERE cedula='" + jt_cedula.getText() + "'"); pst.executeUpdate(); mostrardatos(""); jtapellidos.setText(""); jt_cedula.setText("");
  • 53. jt_cargo_ed.setText(""); jtdire.setText(""); jtnombre_ed.setText(""); jtsalario1.setText(""); jttele.setText(""); } catch (Exception e) { System.out.print(e.getMessage()); } } private void jtcedulaKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); //coje caracter ingresado if (((k < '0') || (k > '9')) && (k != KeyEvent.VK_BACK_SPACE)) { evt.consume(); } if (jtcedula.getText().length() == 10) { evt.consume(); } } private boolean validarCed(boolean flag) { //no retorna valores String Cedula = jtcedula.getText(); int vector[] = new int[Cedula.length()]; int impar = 0, par = 0, aux = 0; if (vector.length == 10) { for (int i = 0; i < vector.length; i++) { vector[i] = Integer.parseInt(Cedula.substring(i, i + 1)); } for (int i = 0; i < 9; i++) { if (i % 2 == 0) { aux = vector[i] * 2; //par
  • 54. if (aux > 9) { aux = aux - 9; //control de par>9 } par = par + aux; } else { impar = impar + vector[i]; } } aux = par + impar; while (aux % 10 != 0) { aux = aux + 1; } aux = aux - (par + impar); if (aux == vector[9]) { flag = true; return flag; } else { flag = false; return flag; } } else { flag = false; return flag; } } private void jtnombresKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); if (k != 32 && k != 8 && k < 65 || k > 90 && k < 97 || k > 122) { evt.setKeyChar((char) KeyEvent.VK_CLEAR);
  • 55. JOptionPane.showMessageDialog(null, "Solo ingrese letras", "Sistema", JOptionPane.ERROR_MESSAGE); } } private void jtapellidoKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); if (k != 32 && k != 8 && k < 65 || k > 90 && k < 97 || k > 122) { evt.setKeyChar((char) KeyEvent.VK_CLEAR); JOptionPane.showMessageDialog(null, "Solo ingrese letras", "Sistema", JOptionPane.ERROR_MESSAGE); } } private void jtdireccionKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); if (k != 32 && k != 8 && k < 65 || k > 90 && k < 97 || k > 122) { evt.setKeyChar((char) KeyEvent.VK_CLEAR); JOptionPane.showMessageDialog(null, "Solo ingrese letras", "Sistema", JOptionPane.ERROR_MESSAGE); } } private void jttelefonoKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); //coje caracter ingresado if (((k < '0') || (k > '9')) && (k != KeyEvent.VK_BACK_SPACE)) { evt.consume(); } if (jttelefono.getText().length() == 9) { evt.consume(); }
  • 56. } private void jtcargoKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); if (k != 32 && k != 8 && k < 65 || k > 90 && k < 97 || k > 122) { evt.setKeyChar((char) KeyEvent.VK_CLEAR); JOptionPane.showMessageDialog(null, "Solo ingrese letras", "Sistema", JOptionPane.ERROR_MESSAGE); } } private void consultaActionPerformed(java.awt.event.ActionEvent evt) { this.escritorioAdmin.removeAll(); this.escritorioAdmin.updateUI(); this.escritorioAdmin.add(jConsulta1); jConsulta1.show(); } private void MostrarActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: mostrardatos(""); } private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int fila = TEditar.getSelectedRow(); if (fila >= 0) { jt_cedula.setText(TEditar.getValueAt(fila, 0).toString()); jtnombre_ed.setText(TEditar.getValueAt(fila, 1).toString()); jtapellidos.setText(TEditar.getValueAt(fila, 2).toString()); jtdire.setText(TEditar.getValueAt(fila, 3).toString()); jttele.setText(TEditar.getValueAt(fila, 4).toString());
  • 57. jt_cargo_ed.setText(TEditar.getValueAt(fila, 5).toString()); jtsalario1.setText(TEditar.getValueAt(fila, 6).toString()); jtHora1.setSelectedItem(TEditar.getValueAt(fila, 7).toString()); } else { JOptionPane.showMessageDialog(null, "no seleciono fila"); } } private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int fila = TEditar.getSelectedRow(); String valor = ""; valor = TEditar.getValueAt(fila, 0).toString(); int exit = JOptionPane.showConfirmDialog(this, "<html><font face="Consolas"><i>Esta seguro que desea <u><b>eliminar</b></u> ?<i/></font>", "Sistema", JOptionPane.YES_NO_OPTION); if (exit == JOptionPane.YES_OPTION) { try { PreparedStatement pst = cn.prepareStatement("DELETE FROM empleados WHERE cedula='" + valor + "'"); pst.executeUpdate(); mostrardatos(""); } catch (Exception e) { } // JOptionPane.showConfirmDialog(TEditar, exit, null, WIDTH); // JOptionPane.showConfirmDialog(panelNice1, a, null, WIDTH); } } private void jtsalarioKeyTyped(java.awt.event.KeyEvent evt) {
  • 58. // TODO add your handling code here: int k = (int) evt.getKeyChar(); //coje caracter ingresado if (((k < '0') || (k > '9')) && (k != KeyEvent.VK_BACK_SPACE)) { evt.consume(); } if (jtsalario.getText().length() == 10) { evt.consume(); } } private void bguardar_salarioActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: try { PreparedStatement pst = cn.prepareStatement("UPDATE salario SET Descuentos='" + jtdescuento_salario.getText() + "',bono='" + jtbono_salario.getText() //+ "',Observacion='" + jt_cargo_ed.getText() + "',salario='" + jlsalario_salario.getText() + "' WHERE cedula='" + jtcedula_salario.getText() + "'"); pst.executeUpdate(); JOptionPane.showMessageDialog(null, "Datos almacenados correctamente"); } catch (Exception ex) { System.out.print(ex.getMessage()); } } private void jtcedula_salarioKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); //coje caracter ingresado if (((k < '0') || (k > '9')) && (k != KeyEvent.VK_BACK_SPACE)) { evt.consume(); } if (jtcedula_salario.getText().length() == 10) {
  • 59. evt.consume(); } } private void jtcedula_consKeyPressed(java.awt.event.KeyEvent evt) { // TODO add your handling code here: String cedula = jtcedula_cons.getText(); try { ConexionDB coneccion = new ConexionDB(); String cons = "select * from empleados where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet consulta = coneccion.consulta(cons); consulta.next(); jlnombre.setText(consulta.getString(2)); jlapellido.setText(consulta.getString(3)); jlcargo.setText(consulta.getString(6)); } catch (Exception ex) { System.out.print(ex.getMessage()); } } private void jtcedula_consKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: int k = (int) evt.getKeyChar(); //coje caracter ingresado if (((k < '0') || (k > '9')) && (k != KeyEvent.VK_BACK_SPACE)) { evt.consume(); } if (jtcedula.getText().length() == 10) { evt.consume(); } } private void bconsultar_consActionPerformed(java.awt.event.ActionEvent evt) {
  • 60. // TODO add your handling code here: String cedula = jtcedula_cons.getText(); String[] dato = new String[4]; DefaultTableModel thoras = new DefaultTableModel(); thoras.addColumn("Fecha"); thoras.addColumn("Hora de entrada"); thoras.addColumn("Hora de salida"); thoras.addColumn("Observacion"); thorarios_cons.setModel(thoras); try { ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from empleados where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet consulta = coneccion.consulta(cons); consulta.next(); jlnombre.setText(consulta.getString(2)); jlapellido.setText(consulta.getString(3)); jlcargo.setText(consulta.getString(6)); } catch (Exception ex) { System.out.print(ex.getMessage()); } try { ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from horarios where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet cont = coneccion.consulta(cons);
  • 61. cont.next(); while (cont.next()) { dato[0] = cont.getString(2); dato[1] = cont.getString(3); dato[2] = cont.getString(4); dato[3] = cont.getString(7); thoras.addRow(dato); } } catch (Exception ex) { System.out.print(ex.getMessage()); } } // Variables declaration - do not modify private javax.swing.JButton Buscar; private javax.swing.JButton Mostrar; private javax.swing.JTable TEditar; private javax.swing.JButton actDatos; private javax.swing.JButton bMostrar; private javax.swing.JButton bcalcular_salario; private javax.swing.JButton bconsultar_cons; private javax.swing.JButton bguardar_salario; private javax.swing.JButton consulta; private javax.swing.JButton empleado; private javax.swing.JDesktopPane escritorioAdmin; private javax.swing.JInternalFrame jConsulta1; private javax.swing.JInternalFrame jDatos; 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;
  • 62. private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; 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 jLabel21; private javax.swing.JLabel jLabel22; private javax.swing.JLabel jLabel23; private javax.swing.JLabel jLabel24; private javax.swing.JLabel jLabel25; private javax.swing.JLabel jLabel26; private javax.swing.JLabel jLabel27; private javax.swing.JLabel jLabel28; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel34; 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.JList jList1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane3; private javax.swing.JScrollPane jScrollPane5; private javax.swing.JInternalFrame jSueldo;
  • 63. private javax.swing.JButton jbguardar; private javax.swing.JButton jbguardar_ed; private javax.swing.JInternalFrame jempleado; private javax.swing.JLabel jlapellido; private javax.swing.JLabel jlcargo; private javax.swing.JLabel jlencabezado_empleado; private javax.swing.JLabel jlhoras_salario; private javax.swing.JLabel jlnombre; private javax.swing.JLabel jlsalario_salario; private javax.swing.JComboBox jtHora; private javax.swing.JComboBox jtHora1; private javax.swing.JTextField jt_cargo_ed; private javax.swing.JTextField jt_cedula; private javax.swing.JTextField jtapellido; private javax.swing.JTextField jtapellidos; private javax.swing.JTextField jtbono_salario; private javax.swing.JTextField jtcargo; private javax.swing.JTextField jtcedula; private javax.swing.JTextField jtcedula_cons; private javax.swing.JTextField jtcedula_salario; private javax.swing.JTextField jtdescuento_salario; private javax.swing.JTextField jtdire; private javax.swing.JTextField jtdireccion; private javax.swing.JTextField jtnombre_ed; private javax.swing.JTextField jtnombres; private javax.swing.JTextField jtsalario; private javax.swing.JTextField jtsalario1; private javax.swing.JTextField jttele; private javax.swing.JTextField jttelefono; private javax.swing.JButton sueldo; private javax.swing.JTable thorarios_cons; // End of variables declaration
  • 64. private JComponent Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane(); private Dimension dimBarra = null; ConexionDB cc = new ConexionDB(); Connection cn = cc.obtenerConexion(); } PANTALLA CONSULTA /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package Interfaz; import clases.ConexionDB; import java.awt.Dimension; import java.awt.event.KeyEvent; import java.sql.Connection; import java.sql.ResultSet; import javax.swing.JComponent; import javax.swing.table.DefaultTableModel; /** * * @author Usuario */ public class PantallaConsulta extends javax.swing.JInternalFrame { /** * Creates new form PantallaConsulta */
  • 65. public PantallaConsulta() { initComponents(); this.ocultarBarraTitulo(); } public void ocultarBarraTitulo() { Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane(); dimBarra = Barra.getPreferredSize(); Barra.setSize(0, 0); Barra.setPreferredSize(new Dimension(0, 0)); repaint(); } /** * 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() { jLabel1 = new javax.swing.JLabel(); jtcedula = new javax.swing.JTextField(); jScrollPane1 = new javax.swing.JScrollPane(); tcons = new javax.swing.JTable(); jConsulta = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel();
  • 66. jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jlnombre = new javax.swing.JLabel(); jlapellido = new javax.swing.JLabel(); jlcargo = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setNormalBounds(new java.awt.Rectangle(150, 50, 0, 0)); jLabel1.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel1.setText("# de Cedula"); jtcedula.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jtcedulaActionPerformed(evt); } }); jtcedula.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { jtcedulaKeyTyped(evt); } }); tcons.setBorder(javax.swing.BorderFactory.createEtchedBorder()); tcons.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N tcons.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { },
  • 67. new String [] { } )); tcons.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tconsMouseClicked(evt); } }); jScrollPane1.setViewportView(tcons); jConsulta.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jConsulta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/cons.jpg"))); // NOI18N jConsulta.setText("Consultar"); jConsulta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jConsultaActionPerformed(evt); } }); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos Personales", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Consolas", 1, 12))); // NOI18N jLabel2.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel2.setText("Nombres: "); jLabel3.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel3.setText("Apellidos: ");
  • 68. jLabel4.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel4.setText("Cargo"); jlnombre.setText("#"); jlapellido.setText("#"); jlcargo.setText("#"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(21, 21, 21) .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jlnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(36, 36, 36) .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jlapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel4) .addGap(18, 18, 18) .addComponent(jlcargo, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
  • 69. .addContainerGap(21, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(15, 15, 15) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jlapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jlnombre, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jLabel3) .addComponent(jLabel4) .addComponent(jlcargo)))) .addContainerGap(23, 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() .addGap(30, 30, 30) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 875, Short.MAX_VALUE)
  • 70. .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1) .addGap(18, 18, 18) .addComponent(jtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(49, 49, 49) .addComponent(jConsulta))) .addGap(0, 170, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jtcedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jConsulta)) .addGap(18, 18, 18) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 135, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(25, 25, 25)) );
  • 71. java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-931)/2, (screenSize.height-354)/2, 931, 354); }// </editor-fold> private void jConsultaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String cedula = jtcedula.getText(); String[] dato = new String[4]; DefaultTableModel thoras = new DefaultTableModel(); thoras.addColumn("Fecha"); thoras.addColumn("Hora de entrada"); thoras.addColumn("Hora de salida"); thoras.addColumn("Observacion"); tcons.setModel(thoras); try { ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from empleados where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet consulta = coneccion.consulta(cons); consulta.next(); jlnombre.setText(consulta.getString(2)); jlapellido.setText(consulta.getString(3)); jlcargo.setText(consulta.getString(6)); } catch (Exception ex) {
  • 72. System.out.print(ex.getMessage()); } try { ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from horarios where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet cont = coneccion.consulta(cons); cont.next(); while (cont.next()) { dato[0] = cont.getString(2); dato[1] = cont.getString(3); dato[2] = cont.getString(4); dato[3] = cont.getString(7); thoras.addRow(dato); } } catch (Exception ex) { System.out.print(ex.getMessage()); } } private void tconsMouseClicked(java.awt.event.MouseEvent evt) { // TODO add your handling code here: } private void jtcedulaActionPerformed(java.awt.event.ActionEvent evt) {
  • 73. // TODO add your handling code here: } private void jtcedulaKeyTyped(java.awt.event.KeyEvent evt) { // TODO add your handling code here: // TODO add your handling code here: int k = (int) evt.getKeyChar(); //coje caracter ingresado if (((k < '0') || (k > '9')) && (k != KeyEvent.VK_BACK_SPACE)) { evt.consume(); } if (jtcedula.getText().length() == 10) { evt.consume(); } } // Variables declaration - do not modify private javax.swing.JButton jConsulta; 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.JScrollPane jScrollPane1; private javax.swing.JLabel jlapellido; private javax.swing.JLabel jlcargo; private javax.swing.JLabel jlnombre; private javax.swing.JTextField jtcedula; private javax.swing.JTable tcons; // End of variables declaration private JComponent Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane();
  • 74. private Dimension dimBarra = null; } PANTALLA INGRESO package Interfaz; import clases.ConexionDB; import java.awt.Dimension; import java.awt.event.KeyEvent; import java.sql.Connection; import java.sql.ResultSet; import javax.swing.JComponent; import javax.swing.JOptionPane; /** * * @author rploaiza */ public class PantallaIngreso extends javax.swing.JInternalFrame { public PantallaIngreso() { initComponents(); this.ocultarBarraTitulo(); } public void ocultarBarraTitulo() { Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane(); dimBarra = Barra.getPreferredSize(); Barra.setSize(0, 0); Barra.setPreferredSize(new Dimension(0, 0));
  • 75. repaint(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jDesktopPane1 = new javax.swing.JDesktopPane(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jtext_usuario = new javax.swing.JTextField(); jtext_contraseña = new javax.swing.JPasswordField(); jDesktopPane1.setBackground(new java.awt.Color(255, 255, 255)); jDesktopPane1.setPreferredSize(new java.awt.Dimension(1100, 530)); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Usuario", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Consolas", 1, 12))); // NOI18N jLabel1.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel1.setText("Usuario"); // NOI18N jLabel2.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jLabel2.setText("Contraseña"); // NOI18N jtext_contraseña.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { jtext_contraseñaKeyReleased(evt);
  • 76. } }); 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(jLabel1) .addComponent(jLabel2)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 67, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jtext_usuario, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE) .addComponent(jtext_contraseña)) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(jtext_usuario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 28, Short.MAX_VALUE)
  • 77. .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(jtext_contraseña, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(37, 37, 37)) ); jPanel1.setBounds(320, 110, 320, 150); jDesktopPane1.add(jPanel1, javax.swing.JLayeredPane.DEFAULT_LAYER); 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(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1064, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap() .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 472, Short.MAX_VALUE) .addContainerGap()) ); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
  • 78. setBounds((screenSize.width-1100)/2, (screenSize.height-530)/2, 1100, 530); }// </editor-fold> private void jtext_contraseñaKeyReleased(java.awt.event.KeyEvent evt) { // Comandos para al precionar enter ingrese al sistema: if (evt.getKeyCode() == KeyEvent.VK_ENTER) { IngresoSistema(jtext_contraseña.getText().trim(), jtext_usuario.getText().trim()); } } public void IngresoSistema(String usuario, String pass) { //Metodo con parametros que sera llamado para el ingreso PantallaAdministrador pa = new PantallaAdministrador(); usuario = this.jtext_usuario.getText(); pass = this.jtext_contraseña.getText(); try { //conexion base de datos ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from administradores where usuario='" + usuario + "'"; // Manipulacion de tablas ResultSet consulta = coneccion.consulta(cons); consulta.next(); if (consulta.getString(1).equals(usuario) && consulta.getString(2).equals(pass)) { JOptionPane.showMessageDialog(null, "Bienvenido al sistema"); this.jDesktopPane1.removeAll(); this.jDesktopPane1.updateUI(); this.jDesktopPane1.add(pa);
  • 79. pa.show(); } else { JOptionPane.showMessageDialog(null, "La contraseña es incorrecta"); jtext_contraseña.setText(""); jtext_usuario.setText(""); } } catch (Exception ex) { System.out.print(ex.getMessage()); } } // Variables declaration - do not modify private javax.swing.JDesktopPane jDesktopPane1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JPasswordField jtext_contraseña; private javax.swing.JTextField jtext_usuario; // End of variables declaration private JComponent Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane(); private Dimension dimBarra = null; } PANTALLA INICIO package Interfaz; import clases.ConexionDB; import java.awt.Dimension; import java.awt.event.KeyEvent; import java.sql.Connection;
  • 80. import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JOptionPane; /** * * @author rploaiza */ public class PantallaInicio extends javax.swing.JInternalFrame { public PantallaInicio() { initComponents(); this.ocultarBarraTitulo(); Calendar Cal = Calendar.getInstance(); String fec = " " + Cal.get(Cal.DATE) + " / " + (Cal.get(Cal.MONTH) + 1) + " / " + Cal.get(Cal.YEAR); txt_fecha.setText(fec); } public void ocultarBarraTitulo() { Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane(); dimBarra = Barra.getPreferredSize(); Barra.setSize(0, 0);
  • 81. Barra.setPreferredSize(new Dimension(0, 0)); repaint(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jLabel2 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); txt_horaf = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); jtcedula = new javax.swing.JTextField(); txt_fecha = new javax.swing.JTextField(); txt_horai = new javax.swing.JTextField(); clockFace1 = new org.edisoncor.gui.varios.ClockFace(); jPanel1 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jlapellido = new javax.swing.JLabel(); jlnombre = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jlcargo = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setResizable(true);
  • 82. setEnabled(false); setPreferredSize(new java.awt.Dimension(1120, 540)); getContentPane().setLayout(null); jLabel2.setFont(new java.awt.Font("Oriya MN", 3, 14)); // NOI18N jLabel2.setForeground(new java.awt.Color(255, 255, 255)); jLabel2.setText("Cedula :"); getContentPane().add(jLabel2); jLabel2.setBounds(80, 30, 100, 18); jLabel5.setFont(new java.awt.Font("Oriya MN", 3, 14)); // NOI18N jLabel5.setForeground(new java.awt.Color(255, 255, 255)); jLabel5.setText("Fecha"); getContentPane().add(jLabel5); jLabel5.setBounds(420, 30, 100, 18); jLabel4.setFont(new java.awt.Font("Oriya MN", 3, 14)); // NOI18N jLabel4.setForeground(new java.awt.Color(255, 255, 255)); jLabel4.setText("Hora de entrada"); getContentPane().add(jLabel4); jLabel4.setBounds(70, 200, 160, 18); txt_horaf.setEditable(false); getContentPane().add(txt_horaf); txt_horaf.setBounds(220, 250, 230, 40); jLabel6.setFont(new java.awt.Font("Oriya MN", 3, 14)); // NOI18N jLabel6.setForeground(new java.awt.Color(255, 255, 255)); jLabel6.setText("Hora de salida");
  • 83. getContentPane().add(jLabel6); jLabel6.setBounds(70, 260, 140, 18); jtcedula.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { jtcedulaKeyReleased(evt); } }); getContentPane().add(jtcedula); jtcedula.setBounds(190, 18, 190, 40); txt_fecha.setEditable(false); getContentPane().add(txt_fecha); txt_fecha.setBounds(490, 20, 190, 40); txt_horai.setEditable(false); getContentPane().add(txt_horai); txt_horai.setBounds(220, 190, 230, 40); javax.swing.GroupLayout clockFace1Layout = new javax.swing.GroupLayout(clockFace1); clockFace1.setLayout(clockFace1Layout); clockFace1Layout.setHorizontalGroup( clockFace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 150, Short.MAX_VALUE) ); clockFace1Layout.setVerticalGroup( clockFace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 150, Short.MAX_VALUE) );
  • 84. getContentPane().add(clockFace1); clockFace1.setBounds(750, 180, 150, 150); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Datos", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Consolas", 1, 12))); // NOI18N jLabel3.setFont(new java.awt.Font("Consolas", 1, 14)); // NOI18N jLabel3.setText("Nombre"); jLabel7.setFont(new java.awt.Font("Consolas", 1, 14)); // NOI18N jLabel7.setText("Apellido"); jlapellido.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N jlapellido.setText(" --.--"); jlnombre.setBackground(new java.awt.Color(0, 0, 0)); jlnombre.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N jlnombre.setText(" --.--"); jLabel9.setFont(new java.awt.Font("Consolas", 1, 14)); // NOI18N jLabel9.setText("Cargo"); jlcargo.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N jlcargo.setText(" --.--"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(
  • 85. jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(12, 12, 12) .addComponent(jLabel3) .addGap(18, 18, 18) .addComponent(jlnombre, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(27, 27, 27) .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jlapellido, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26) .addComponent(jLabel9) .addGap(18, 18, 18) .addComponent(jlcargo, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(15, 15, 15) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(jlnombre) .addComponent(jLabel7) .addComponent(jlapellido) .addComponent(jLabel9) .addComponent(jlcargo))
  • 86. .addGap(76, 76, 76)) ); getContentPane().add(jPanel1); jPanel1.setBounds(50, 80, 690, 80); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/borde.jpg"))); // NOI18N getContentPane().add(jLabel1); jLabel1.setBounds(-80, -50, 1060, 490); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width-931)/2, (screenSize.height-356)/2, 931, 356); }// </editor-fold> private void jtcedulaKeyReleased(java.awt.event.KeyEvent evt) { // Comandos para al precionar enter se dirija al metodo: if (evt.getKeyCode() == KeyEvent.VK_ENTER) { CedulaValida(jtcedula.getText().trim()); jtcedula.setText(""); } } public void Limpiar() { // Metodo de limpieza de JFields jlnombre.setText(""); jlapellido.setText(""); jlcargo.setText(""); txt_horaf.setText(""); txt_horai.setText(""); } public void CedulaValida(String cedula) { //Metodo con parametros que sera llamado para el ingreso cedula = this.jtcedula.getText();
  • 87. try { //conexion base de datos ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from empleados where cedula=" + cedula; // Manipulacion de tablas ResultSet consulta = coneccion.consulta(cons); consulta.next(); if (consulta.getString(1).equals(cedula)) { //Comparamos que sea igual la cedula con la posicion en la tabla // Ingreso al metodo de registro this.RegistroAsistencia(cedula); } else { JOptionPane.showMessageDialog(null, "No se encuentra registrado", "Sistema", JOptionPane.ERROR_MESSAGE); } } catch (Exception ex) { System.out.print(ex.getMessage()); } } public long diferencia_horas(String fecha_mayor, String fecha_menor) { String hora_may, min_may, seg_may, hora_men, min_men, seg_men; //extraemos en variables separadas el tiempo mayor hora_may = fecha_mayor.substring(0, 2); min_may = fecha_mayor.substring(3, 5); seg_may = fecha_mayor.substring(6, 8); //extraemos en variables separadas el tiempo menor hora_men = fecha_menor.substring(0, 2); min_men = fecha_menor.substring(3, 5);
  • 88. seg_men = fecha_menor.substring(6, 8); Date fecha_may = new Date(2013, 9, 7, Integer.parseInt(hora_may), Integer.parseInt(min_may), Integer.parseInt(seg_may)); Date fecha_men = new Date(2013, 9, 7, Integer.parseInt(hora_men), Integer.parseInt(min_men), Integer.parseInt(seg_men)); long seg = fecha_may.getTime() - fecha_men.getTime(); return seg / 1000; } public String Formatohoras(long seg) { int min = 0, hras = 0; while (seg > 60) { seg -= 60; min++; } while (min > 60) { min -= 60; hras++; } String tfhras = hras + ":" + min + ":" + seg; return tfhras; } public void RegistroAsistencia(String cedula) { cedula = this.jtcedula.getText(); try { ConexionDB coneccion = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = coneccion.obtenerConexion(); String cons = "select * from empleados where cedula='" + cedula + "'"; // Manipulacion de tablas
  • 89. ResultSet consulta = coneccion.consulta(cons); consulta.next(); jlnombre.setText(consulta.getString(2)); jlapellido.setText(consulta.getString(3)); jlcargo.setText(consulta.getString(6)); } catch (Exception ex) { System.out.print(ex.getMessage()); } ConexionDB conx = new ConexionDB(); //Creamos un objeto de la clase Coneccion DB Connection con = conx.obtenerConexion(); // Creamos un objeto de obtener coneccion de la la libreria Connection int hora = 0, minuto = 0, seg = 0, dia = 0, mes = 0, anio = 0; int rows_updated = 0; String horas, segunds, minuts; Calendar cal = new GregorianCalendar(); hora = cal.get(Calendar.HOUR_OF_DAY); minuto = cal.get(Calendar.MINUTE); seg = cal.get(Calendar.SECOND); dia = cal.get(Calendar.DAY_OF_WEEK); mes = cal.get(Calendar.MONTH); anio = cal.get(Calendar.YEAR); if (hora < 10) { horas = "0" + hora; } else { horas = Integer.toString(hora); } if (minuto < 10) { minuts = "0" + minuto; } else { minuts = Integer.toString(minuto);
  • 90. } if (seg < 10) { segunds = "0" + seg; } else { segunds = Integer.toString(seg); } String horaguardari = horas + ":" + minuts + ":" + segunds; String horaguardarf = horas + ":" + minuts + ":" + segunds; String fechaguardar = anio + "-" + mes + "-" + dia; cedula = jtcedula.getText(); ResultSet rs; Statement sentencia; String sql = "select * from horarios where cedula='" + cedula + "' and estado='A'"; String id_horario = ""; if (con != null) { try { sentencia = con.createStatement(); rs = sentencia.executeQuery(sql); while (rs.next()) { //Asigancion de variables segun la consulta id_horario = (rs.getString("ID_HORARIO")); } if (!"".equals(id_horario)) { try { long segundos = 0; String hora_sumada; String prueba; String atraso;
  • 91. String cons2 = "select * from horarios where id_horario='" + id_horario + "'"; // Manipulacion de tablas ResultSet consulta2 = conx.consulta(cons2); consulta2.next(); prueba = consulta2.getString(4); segundos = diferencia_horas(horaguardarf, prueba); hora_sumada = Formatohoras(segundos); PreparedStatement datos = con.prepareStatement("UPDATE horarios SET hora_salida='" + horaguardarf + "', hora_sumada='" + hora_sumada + "' ,estado='I' WHERE id_horario='" + id_horario + "'"); // Manipulacion de tablas rows_updated = datos.executeUpdate(); txt_horai.setText(prueba); txt_horaf.setText(horaguardarf); JOptionPane.showMessageDialog(null, "Salida Correcta"); Limpiar(); } catch (Exception ex) { System.out.print(ex.getMessage()); } } else { try { long segundos = 0; String atraso; PreparedStatement datos = con.prepareStatement("insert into horarios(cedula,fecha,hora_entrada,estado) values (?,?,?,?)"); // Manipulacion de tablas datos.setString(1, jtcedula.getText()); // Cedula datos.setString(2, fechaguardar); // Fecha datos.setString(3, horaguardari);//Hora datos.setString(4, "A");//Estado rows_updated = datos.executeUpdate(); txt_horai.setText(horaguardari); String cons4 = "select * from horarios "; // Manipulacion de tablas
  • 92. String id_ultimoHorario = ""; try { sentencia = con.createStatement(); ResultSet consulta4 = sentencia.executeQuery(cons4); while (consulta4.next()) { //Asigancion de variables segun la consulta id_ultimoHorario = (consulta4.getString("ID_HORARIO")); } } catch (Exception ex) { System.out.print(ex.getMessage()); } String cons3 = "select * from empleados where cedula='" + cedula + "'"; // Manipulacion de tablas ResultSet consulta3 = conx.consulta(cons3); consulta3.next(); String CondAtraso = consulta3.getString(8); //Consulta de inicio segundos = diferencia_horas(horaguardari, CondAtraso); // Almacena diferencia de horas if (segundos > 0) { JFrame frame = new JFrame(); atraso = JOptionPane.showInputDialog(frame, "Motivo de Atraso ?", "SISTEMA", JOptionPane.WARNING_MESSAGE); PreparedStatement dato3 = con.prepareStatement("UPDATE horarios SET observacion='" + atraso + "' WHERE id_horario=" + id_ultimoHorario); // Manipulacion de tablas int rows_updated1 = dato3.executeUpdate(); } JOptionPane.showMessageDialog(null, "Ingreso Correcto"); Limpiar(); } catch (Exception ex) { System.out.print(ex.getMessage());
  • 93. } } } catch (SQLException ex) { System.out.print(ex.getMessage()); } conx.cerrarConexion(); } } // Variables declaration - do not modify private org.edisoncor.gui.varios.ClockFace clockFace1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JLabel jlapellido; private javax.swing.JLabel jlcargo; private javax.swing.JLabel jlnombre; private javax.swing.JTextField jtcedula; private javax.swing.JTextField txt_fecha; private javax.swing.JTextField txt_horaf; private javax.swing.JTextField txt_horai; // End of variables declaration private JComponent Barra = ((javax.swing.plaf.basic.BasicInternalFrameUI) getUI()).getNorthPane();
  • 94. private Dimension dimBarra = null; } PANTALLA PRINCIPAL package Interfaz; import java.awt.Dimension; import java.awt.Image; import java.awt.Toolkit; /** * * @author rploaiza */ public class PantallaPrincipal extends javax.swing.JFrame { /** * Creates new form PantallaPrincipal */ public PantallaPrincipal() { initComponents(); dim = super.getToolkit().getScreenSize(); this.setSize(dim); this.mostrarInicio(); } private Dimension dim; public Image getIconImage() { Image retValue = Toolkit.getDefaultToolkit().getImage(ClassLoader.getSystemResource("imagenes/icono.png"));
  • 95. return retValue; } public void mostrarInicio() { PantallaInicio pi = new PantallaInicio(); this.jDesktopPane1.add(pi); pi.show(); } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jButton1 = new javax.swing.JButton(); jDesktopPane1 = new javax.swing.JDesktopPane(); jButton2 = new javax.swing.JButton(); jButton3 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Contro de personal"); setAutoRequestFocus(false); setIconImage(getIconImage()); setIconImages(getIconImages()); setResizable(false); jButton1.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/inicio.png"))); // NOI18N jButton1.setText("Inicio"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt);
  • 96. } }); jDesktopPane1.setBackground(new java.awt.Color(255, 255, 255)); jDesktopPane1.setForeground(new java.awt.Color(255, 255, 255)); jDesktopPane1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); jDesktopPane1.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION); jDesktopPane1.setDesktopManager(null); jDesktopPane1.setDragMode(javax.swing.JDesktopPane.OUTLINE_DRAG_MODE); jDesktopPane1.setPreferredSize(new java.awt.Dimension(1200, 530)); jButton2.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/adm.png"))); // NOI18N jButton2.setText("Administrador"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton3.setFont(new java.awt.Font("Consolas", 1, 12)); // NOI18N jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/busq.png"))); // NOI18N jButton3.setText("Consulta"); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });
  • 97. 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(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1188, Short.MAX_VALUE) .addContainerGap()) .addGroup(layout.createSequentialGroup() .addGap(400, 400, 400) .addComponent(jButton1) .addGap(35, 35, 35) .addComponent(jButton2) .addGap(35, 35, 35) .addComponent(jButton3) .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.BASELINE, false) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  • 98. .addComponent(jDesktopPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE) .addGap(27, 27, 27)) ); pack(); }// </editor-fold> private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { PantallaInicio pi = new PantallaInicio(); this.jDesktopPane1.removeAll(); this.jDesktopPane1.updateUI(); this.jDesktopPane1.add(pi); pi.show(); } private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { this.jDesktopPane1.removeAll(); this.jDesktopPane1.updateUI(); PantallaIngreso pi = new PantallaIngreso(); this.jDesktopPane1.add(pi); pi.show(); } private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { this.jDesktopPane1.removeAll(); this.jDesktopPane1.updateUI();
  • 99. PantallaConsulta pa = new PantallaConsulta(); this.jDesktopPane1.add(pa); pa.show(); } /** * @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(PantallaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) {
  • 100. java.util.logging.Logger.getLogger(PantallaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(PantallaPrincipal.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 PantallaPrincipal().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.JDesktopPane jDesktopPane1; // End of variables declaration } CLASE ADMINISTRACION package clases; public class Administrador { private String usuario; private String clave;
  • 101. public String getUsuario() { return usuario; } public void setUsuario(String usuario) { this.usuario = usuario; } public String getClave() { return clave; } public void setClave(String clave) { this.clave = clave; } } CLASE CONEXIÓN DB package clases; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; public class ConexionDB { Connection coneccion;//objeto de la clase Connection ResultSet rsDatos; Statement stSentencias; PreparedStatement Sentencias; public ConexionDB() {
  • 102. cargarDriver();//constructor de la clase } //metodo para cargar el driver public void cargarDriver() { try { try { Driver d = (Driver) Class.forName("com.mysql.jdbc.Driver").newInstance();//llamamos al driver para bases de datos de acces } catch (InstantiationException ex) { Logger.getLogger(ConexionDB.class.getName()).log(Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { Logger.getLogger(ConexionDB.class.getName()).log(Level.SEVERE, null, ex); } } catch (ClassNotFoundException ex) { System.out.println("No se puede cargar el driver");//exepcion si el driver no se cargo despliega mensaje por consola de error ex.printStackTrace(); } } //metodo para obtener la coneccion a la BD public Connection obtenerConexion() { try { coneccion = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/basedatos_control", "root", ""); stSentencias = coneccion.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.CONCUR_UPDATABLE); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, "No se puede establecer conexion a base de dato");
  • 103. System.out.println("no se puede establecer conexion a base de datos"); ex.printStackTrace(); } return coneccion;//retorna la coneccion } //metodo para cerrar la coneccion public void cerrarConexion() { try { coneccion.close();//metodo que cierra la conexion a la base de datos } catch (SQLException ex) { ex.printStackTrace(); } } public ResultSet consulta(String sql) throws SQLException { try { rsDatos = stSentencias.executeQuery(sql); } catch (SQLException ex) { throw ex; } return rsDatos; } }