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

import Controlador.Programa;
import UML.Trabajador;
import java.sql.Date;
import javax.swing.JOptionPane;

/**
 *
 * @author Al
 */
public class VentanaPerfil extends javax.swing.JFrame {

    /**
     * Creates new form ventanaAdministrador
     */
    public VentanaPerfil() {
        initComponents();
    }

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

        bgCategoria = new javax.swing.ButtonGroup();
        panelFondo = new javax.swing.JPanel();
        panelCabecera = new javax.swing.JPanel();
        labelTitulo = new javax.swing.JLabel();
        panelCuerpo = new javax.swing.JPanel();
        labelDni = new javax.swing.JLabel();
        labelNombre = new javax.swing.JLabel();
        labelApellido1 = new javax.swing.JLabel();
        labelApellido2 = new javax.swing.JLabel();
        labelCalle = new javax.swing.JLabel();
        labelPortal = new javax.swing.JLabel();
        labelPiso = new javax.swing.JLabel();
        labelMano = new javax.swing.JLabel();
        labelTelefEmpresa = new javax.swing.JLabel();
        labelTelefPerso = new javax.swing.JLabel();
        labelSalario = new javax.swing.JLabel();
        labelFechaNac = new javax.swing.JLabel();
        tfTelefPerso = new javax.swing.JTextField();
        tfTelefEmpresa = new javax.swing.JTextField();
        tfSalario = new javax.swing.JTextField();
        tfFechaNac = new javax.swing.JTextField();
        tfMano = new javax.swing.JTextField();
        tfPiso = new javax.swing.JTextField();
        tfPortal = new javax.swing.JTextField();
        tfCalle = new javax.swing.JTextField();
        tfApellido2 = new javax.swing.JTextField();
        tfApellido1 = new javax.swing.JTextField();
        tfNombre = new javax.swing.JTextField();
        tfDni = new javax.swing.JTextField();
        labelCentro = new javax.swing.JLabel();
        tfCentro = new javax.swing.JTextField();
        labelCategoria = new javax.swing.JLabel();
        rbAdmin = new javax.swing.JRadioButton();
        rbLogistic = new javax.swing.JRadioButton();
        btLimpiar = new javax.swing.JButton();
        panelPie = new javax.swing.JPanel();
        btAceptar = new javax.swing.JButton();
        btBorrar = new javax.swing.JButton();
        btVolver = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        labelTitulo.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        labelTitulo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        labelTitulo.setText("Perfil Trabajador");
        labelTitulo.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        javax.swing.GroupLayout panelCabeceraLayout = new javax.swing.GroupLayout(panelCabecera);
        panelCabecera.setLayout(panelCabeceraLayout);
        panelCabeceraLayout.setHorizontalGroup(
            panelCabeceraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCabeceraLayout.createSequentialGroup()
                .addGap(239, 239, 239)
                .addComponent(labelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, 361, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        panelCabeceraLayout.setVerticalGroup(
            panelCabeceraLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCabeceraLayout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(labelTitulo)
                .addContainerGap(33, Short.MAX_VALUE))
        );

        labelDni.setText("DNI:");

        labelNombre.setText("NOMBRE:");

        labelApellido1.setText("APELLIDO1:");

        labelApellido2.setText("APELLIDO2:");

        labelCalle.setText("CALLE:");

        labelPortal.setText("PORTAL:");

        labelPiso.setText("PISO:");

        labelMano.setText("MANO:");

        labelTelefEmpresa.setText("TELEFONO EMPRESA:");

        labelTelefPerso.setText("TELEFONO PERSONAL:");

        labelSalario.setText("SALARIO:");

        labelFechaNac.setText("FECHA DE NACIMIENTO:");

        tfTelefPerso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfTelefPersoActionPerformed(evt);
            }
        });

        tfTelefEmpresa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfTelefEmpresaActionPerformed(evt);
            }
        });

        tfMano.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfManoActionPerformed(evt);
            }
        });

        tfPiso.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfPisoActionPerformed(evt);
            }
        });

        tfCalle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfCalleActionPerformed(evt);
            }
        });

        tfApellido2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tfApellido2ActionPerformed(evt);
            }
        });

        labelCentro.setText("CENTRO:");

        labelCategoria.setText("CATEGORIA:");

        bgCategoria.add(rbAdmin);
        rbAdmin.setText("Admin");

        bgCategoria.add(rbLogistic);
        rbLogistic.setText("Logistica");

        btLimpiar.setText("Limpiart Ventana");
        btLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btLimpiarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelCuerpoLayout = new javax.swing.GroupLayout(panelCuerpo);
        panelCuerpo.setLayout(panelCuerpoLayout);
        panelCuerpoLayout.setHorizontalGroup(
            panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCuerpoLayout.createSequentialGroup()
                .addGap(42, 42, 42)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panelCuerpoLayout.createSequentialGroup()
                        .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelTelefPerso)
                            .addGroup(panelCuerpoLayout.createSequentialGroup()
                                .addGap(1, 1, 1)
                                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(labelPortal)
                                    .addComponent(labelApellido1)
                                    .addComponent(labelNombre)
                                    .addComponent(labelPiso)
                                    .addComponent(labelDni)
                                    .addComponent(labelCalle)
                                    .addComponent(labelApellido2)))
                            .addComponent(labelTelefEmpresa)
                            .addComponent(labelSalario)
                            .addComponent(labelMano))
                        .addGap(21, 21, 21)
                        .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tfTelefPerso)
                            .addComponent(tfSalario)
                            .addComponent(tfTelefEmpresa)
                            .addComponent(tfMano, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                            .addComponent(tfPiso)
                            .addComponent(tfPortal)
                            .addComponent(tfCalle)
                            .addComponent(tfApellido2)
                            .addComponent(tfApellido1)
                            .addComponent(tfNombre)
                            .addComponent(tfDni)))
                    .addGroup(panelCuerpoLayout.createSequentialGroup()
                        .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(labelFechaNac)
                            .addComponent(labelCentro)
                            .addComponent(labelCategoria))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tfFechaNac)
                            .addComponent(tfCentro)
                            .addGroup(panelCuerpoLayout.createSequentialGroup()
                                .addComponent(rbAdmin)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 179, Short.MAX_VALUE)
                                .addComponent(rbLogistic)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btLimpiar)
                .addGap(105, 105, 105))
        );
        panelCuerpoLayout.setVerticalGroup(
            panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCuerpoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelDni)
                    .addComponent(tfDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelNombre)
                    .addComponent(tfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelApellido1)
                    .addComponent(tfApellido1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelApellido2)
                    .addComponent(tfApellido2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(labelCalle)
                    .addComponent(tfCalle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelPortal)
                    .addComponent(tfPortal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelPiso)
                    .addComponent(tfPiso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCuerpoLayout.createSequentialGroup()
                        .addComponent(labelMano)
                        .addGap(18, 18, 18)
                        .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCuerpoLayout.createSequentialGroup()
                                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(labelTelefEmpresa)
                                    .addComponent(tfTelefEmpresa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(labelTelefPerso)
                                    .addComponent(tfTelefPerso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addComponent(labelSalario)
                                .addGap(18, 18, 18)
                                .addComponent(labelFechaNac))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCuerpoLayout.createSequentialGroup()
                                .addComponent(tfSalario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(tfFechaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(tfMano, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelCentro)
                    .addComponent(tfCentro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelCuerpoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(labelCategoria)
                    .addComponent(rbAdmin)
                    .addComponent(rbLogistic))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        btAceptar.setText("Aceptar");
        btAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAceptarActionPerformed(evt);
            }
        });

        btBorrar.setText("BORRAR");
        btBorrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btBorrarActionPerformed(evt);
            }
        });

        btVolver.setText("Volver");
        btVolver.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btVolverActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelPieLayout = new javax.swing.GroupLayout(panelPie);
        panelPie.setLayout(panelPieLayout);
        panelPieLayout.setHorizontalGroup(
            panelPieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelPieLayout.createSequentialGroup()
                .addGap(71, 71, 71)
                .addComponent(btAceptar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 271, Short.MAX_VALUE)
                .addComponent(btBorrar)
                .addGap(175, 175, 175)
                .addComponent(btVolver)
                .addGap(136, 136, 136))
        );
        panelPieLayout.setVerticalGroup(
            panelPieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelPieLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelPieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btAceptar)
                    .addComponent(btBorrar)
                    .addComponent(btVolver))
                .addGap(36, 36, 36))
        );

        javax.swing.GroupLayout panelFondoLayout = new javax.swing.GroupLayout(panelFondo);
        panelFondo.setLayout(panelFondoLayout);
        panelFondoLayout.setHorizontalGroup(
            panelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelCuerpo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(panelCabecera, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(panelPie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panelFondoLayout.setVerticalGroup(
            panelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFondoLayout.createSequentialGroup()
                .addComponent(panelCabecera, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelCuerpo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelPie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        getContentPane().add(panelFondo, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 880, 730));

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

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

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

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

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

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

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

    private void btAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAceptarActionPerformed
        // TODO add your handling code here:
        boolean error=false;
        
        Trabajador t=Programa.buscarTrabajador(tfDni.getText());
        int admin = 2;
        do
        {
            if(tfDni.getText()!=null || tfNombre.getText()!=null || tfApellido1.getText()!=null || tfApellido2.getText()!=null ||
                            tfCalle.getText()!=null || tfPortal.getText()!=null || tfPiso.getText()!=null || tfMano.getText()!=null
                    ||tfTelefEmpresa.getText()!=null ||
                            tfTelefPerso.getText()!=null || Double.parseDouble(tfSalario.getText())!=0 ||
                    Date.valueOf(tfFechaNac.getText())!=null ||
                            tfCentro.getText()!=null )
            {
                
                    
                    
                if(rbAdmin.isSelected())
                {
                    //comprobar tipos
                    admin=1;
                }
                if(t!=null)
                {
                   
                    Programa.actualizarTrabajador(tfDni.getText(),tfNombre.getText(),tfApellido1.getText(),tfApellido2.getText(),
                            tfCalle.getText(),tfPortal.getText(),tfPiso.getText(),tfMano.getText(),tfTelefEmpresa.getText(),
                            tfTelefPerso.getText(),Double.parseDouble(tfSalario.getText()),Date.valueOf(tfFechaNac.getText()),
                            tfCentro.getText(),admin);
                     tfDni.setText(t.getDni());
                    tfNombre.setText(t.getNombre());
                    tfApellido1.setText(t.getApellidouno()); 
                    tfApellido2.setText(t.getApellidodos());
                    tfCalle.setText(t.getCalle());
                    tfPortal.setText(t.getPortal());
                    tfPiso.setText(t.getPiso());
                    tfMano.setText(t.getMano());
                    
                    tfTelefEmpresa.setText(t.getTelefempre());
                    tfTelefPerso.setText(t.getTelefperso());
                    tfSalario.setText(t.getSalario()+"");
                    tfFechaNac.setText(t.getFechaNac()+"");
                    tfCentro.setText(t.getC().getIdCentro()+""); 
                    if(t.getCat().getIdTipo()==1)
                    {
                        rbAdmin.setSelected(true);
                    }
                    else
                    {
                        rbLogistic.setSelected(true);
                    }
                    
                }
                else
                {
                    Programa.insertarTrabjador(tfDni.getText(),tfNombre.getText(),tfApellido1.getText(),tfApellido2.getText(),
                            tfCalle.getText(),tfPortal.getText(),tfPiso.getText(),tfMano.getText(),tfTelefEmpresa.getText(),
                            tfTelefPerso.getText(),Double.parseDouble(tfSalario.getText()),Date.valueOf(tfFechaNac.getText()),
                            tfCentro.getText(),admin);
                    
                }
            }
            else
            {
                JOptionPane.showMessageDialog(null,"campo vacio");
                error=true;
            }
        }
        while(error==true);
    }//GEN-LAST:event_btAceptarActionPerformed

    private void btBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btBorrarActionPerformed
        // TODO add your handling code here:
        if(JOptionPane.showConfirmDialog(null,"¿Esta totalmente seguro?")==JOptionPane.YES_OPTION) 
        {
            Programa.borrarPerfil(tfDni.getText());
        }
    }//GEN-LAST:event_btBorrarActionPerformed

    private void btVolverActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btVolverActionPerformed
        // TODO add your handling code here:
        this.dispose();
        Programa.volverAtras();
    }//GEN-LAST:event_btVolverActionPerformed

    private void btLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btLimpiarActionPerformed
        // TODO add your handling code here:
        tfDni.setText("");
        tfNombre.setText("");
        tfApellido1.setText(""); 
        tfApellido2.setText("");
        tfCalle.setText("");
        tfPortal.setText("");
        tfPiso.setText("");
        tfMano.setText("");
        tfTelefEmpresa.setText("");
        tfTelefPerso.setText("");
        tfSalario.setText("");
        tfFechaNac.setText("");
        tfCentro.setText(""); 
        
    }//GEN-LAST:event_btLimpiarActionPerformed

    /**
     * @param args the command line arguments
     */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup bgCategoria;
    private javax.swing.JButton btAceptar;
    private javax.swing.JButton btBorrar;
    private javax.swing.JButton btLimpiar;
    private javax.swing.JButton btVolver;
    private javax.swing.JLabel labelApellido1;
    private javax.swing.JLabel labelApellido2;
    private javax.swing.JLabel labelCalle;
    private javax.swing.JLabel labelCategoria;
    private javax.swing.JLabel labelCentro;
    private javax.swing.JLabel labelDni;
    private javax.swing.JLabel labelFechaNac;
    private javax.swing.JLabel labelMano;
    private javax.swing.JLabel labelNombre;
    private javax.swing.JLabel labelPiso;
    private javax.swing.JLabel labelPortal;
    private javax.swing.JLabel labelSalario;
    private javax.swing.JLabel labelTelefEmpresa;
    private javax.swing.JLabel labelTelefPerso;
    private javax.swing.JLabel labelTitulo;
    private javax.swing.JPanel panelCabecera;
    private javax.swing.JPanel panelCuerpo;
    private javax.swing.JPanel panelFondo;
    private javax.swing.JPanel panelPie;
    private javax.swing.JRadioButton rbAdmin;
    private javax.swing.JRadioButton rbLogistic;
    private javax.swing.JTextField tfApellido1;
    private javax.swing.JTextField tfApellido2;
    private javax.swing.JTextField tfCalle;
    private javax.swing.JTextField tfCentro;
    private javax.swing.JTextField tfDni;
    private javax.swing.JTextField tfFechaNac;
    private javax.swing.JTextField tfMano;
    private javax.swing.JTextField tfNombre;
    private javax.swing.JTextField tfPiso;
    private javax.swing.JTextField tfPortal;
    private javax.swing.JTextField tfSalario;
    private javax.swing.JTextField tfTelefEmpresa;
    private javax.swing.JTextField tfTelefPerso;
    // End of variables declaration//GEN-END:variables
}
