vista.empleados.DiagEmpleadoPersona.java Source code

Java tutorial

Introduction

Here is the source code for vista.empleados.DiagEmpleadoPersona.java

Source

/*
 * 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 vista.empleados;

import entidades.cliente.Organismo;
import entidades.cliente.Persona;
import entidades.empleado.Empleado;
import entidades.empleado.TipoEmpleado;
import entidades.localidad.Departamento;
import entidades.localidad.Localidad;
import entidades.localidad.Provincia;
import entidades.persona.CorreoElectronico;
import entidades.persona.DocumentoIdentidad;
import entidades.persona.Domicilio;
import entidades.persona.Sexo;
import entidades.persona.Telefono;
import entidades.persona.TipoDocumento;
import entidades.persona.TipoTelefono;
import facade.ClienteFacade;
import facade.DepartamentoFacade;
import facade.EmpleadoFacade;
import facade.ListaPrecioFacade;
import facade.LocalidadFacade;
import facade.ProvinciaFacade;
import facade.TipoDocumentoFacade;
import facade.TipoEmpleadoFacade;
import facade.TipoTelefonoFacade;
import includes.Comunes;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;
import org.apache.commons.validator.routines.BigIntegerValidator;
import org.apache.commons.validator.routines.LongValidator;

/**
 *
 * @author hugo
 */
public class DiagEmpleadoPersona extends javax.swing.JDialog {

    private String tipoOperacion;
    List<Telefono> telefonos = new ArrayList<>();
    List<CorreoElectronico> correosElectronicos = new ArrayList<>();
    //private Persona persona;
    private Empleado empleado;
    private String tipoEntidad;
    private Organismo organismo;
    private Persona personaCliente;

    /**
     * Creates new form DiagClientePersona
     */
    public DiagEmpleadoPersona(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        inicializarComponentes();
    }

    public DiagEmpleadoPersona(java.awt.Frame parent, boolean modal, String tipoEntidad, String tipoOperacion,
            Empleado empleado) {
        super(parent, modal);
        initComponents();
        this.empleado = empleado;
        //this.persona = empleado.getPersona();
        this.tipoEntidad = tipoEntidad;
        this.tipoOperacion = tipoOperacion;
        inicializarComponentes();
    }

    public DiagEmpleadoPersona(java.awt.Frame parent, boolean modal, String tipoEntidad, String tipoOperacion) {
        super(parent, modal);
        initComponents();
        this.tipoEntidad = tipoEntidad;
        this.tipoOperacion = tipoOperacion;
        inicializarComponentes();

    }

    /**
     * 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() {

        jPanel1 = new javax.swing.JPanel();
        cboTipoDoc = new javax.swing.JComboBox();
        lbDocumento = new javax.swing.JLabel();
        tfDocumento = new javax.swing.JTextField();
        lbNombre = new javax.swing.JLabel();
        tfNombre = new javax.swing.JTextField();
        tfApellido = new javax.swing.JTextField();
        lbApellido = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        tfCalle = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        tfNumero = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        tfPiso = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        tfDpto = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        tfCodigoPostal = new javax.swing.JTextField();
        cboProvincias = new javax.swing.JComboBox();
        cboLocalidades = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        cboDepartamentos = new javax.swing.JComboBox();
        jLabel17 = new javax.swing.JLabel();
        tfEntreCalles = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        tfReferencia = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        tfBarrio = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        tfCuil = new javax.swing.JTextField();
        lbSexo = new javax.swing.JLabel();
        cboSexo = new javax.swing.JComboBox();
        lbFechaNac = new javax.swing.JLabel();
        jxdFechaNacimiento = new org.jdesktop.swingx.JXDatePicker();
        jPanel3 = new javax.swing.JPanel();
        cboTiposTelefonos = new javax.swing.JComboBox();
        tfNumeroTelefono = new javax.swing.JTextField();
        btnAgregarTelefono = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListTelefonos = new javax.swing.JList();
        btnEliminarTelefono = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        tfCorreoElectronico = new javax.swing.JTextField();
        btnAgregarCorreoElectronico = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jListCorreosElectronicos = new javax.swing.JList();
        btnEliminarCorreoElectronico = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        cboTipoEmpleado = new javax.swing.JComboBox();
        jxdpFechaBaja = new org.jdesktop.swingx.JXDatePicker();
        jCheckActivar = new javax.swing.JCheckBox();
        jLabel2 = new javax.swing.JLabel();
        btnAceptar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.title")); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle
                .getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.jPanel1.border.title"))); // NOI18N

        cboTipoDoc.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lbDocumento.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.lbDocumento.text")); // NOI18N

        tfDocumento.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.tfDocumento.text")); // NOI18N

        lbNombre.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.lbNombre.text")); // NOI18N

        tfNombre.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.tfNombre.text")); // NOI18N

        tfApellido.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.tfApellido.text")); // NOI18N

        lbApellido.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.lbApellido.text")); // NOI18N

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle
                .getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.jPanel2.border.title"))); // NOI18N

        jLabel5.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel5.text")); // NOI18N

        jLabel6.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel6.text")); // NOI18N

        jLabel7.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel7.text")); // NOI18N

        jLabel8.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel8.text")); // NOI18N

        jLabel9.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel9.text")); // NOI18N

        jLabel10.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel10.text")); // NOI18N

        jLabel11.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel11.text")); // NOI18N

        cboProvincias.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboProvinciasItemStateChanged(evt);
            }
        });

        jLabel16.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel16.text")); // NOI18N

        cboDepartamentos.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cboDepartamentosItemStateChanged(evt);
            }
        });

        jLabel17.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel17.text")); // NOI18N

        jLabel18.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel18.text")); // NOI18N

        jLabel19.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel19.text")); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(jPanel2Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup().addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jLabel11).addComponent(jLabel6).addComponent(jLabel5)
                                .addComponent(jLabel17).addComponent(jLabel18).addComponent(jLabel19)
                                .addComponent(jLabel9).addComponent(jLabel16).addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(cboDepartamentos, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        Short.MAX_VALUE)
                                .addComponent(
                                        cboProvincias, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(tfCalle)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(tfNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 53,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(jLabel7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tfPiso, javax.swing.GroupLayout.PREFERRED_SIZE, 38,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18).addComponent(jLabel8)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tfDpto, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addComponent(tfEntreCalles).addComponent(tfReferencia).addComponent(tfBarrio)
                                .addComponent(cboLocalidades, javax.swing.GroupLayout.Alignment.TRAILING, 0,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(tfCodigoPostal, javax.swing.GroupLayout.PREFERRED_SIZE, 65,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(27, 27, 27)));
        jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel5).addComponent(tfCalle, 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(jLabel6)
                                .addComponent(tfNumero, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel7)
                                .addComponent(tfPiso, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel8).addComponent(tfDpto, 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(jLabel17).addComponent(tfEntreCalles,
                                        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(jLabel18).addComponent(tfReferencia,
                                        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(jLabel19).addComponent(tfBarrio,
                                        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(jLabel9)
                                .addComponent(cboProvincias, 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(jLabel16).addComponent(cboDepartamentos,
                                        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(jLabel10).addComponent(cboLocalidades,
                                        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(jLabel11).addComponent(tfCodigoPostal,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(17, Short.MAX_VALUE)));

        jLabel12.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel12.text")); // NOI18N

        tfCuil.setText(
                org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.tfCuil.text")); // NOI18N

        lbSexo.setText(
                org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.lbSexo.text")); // NOI18N

        cboSexo.setModel(
                new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        lbFechaNac.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.lbFechaNac.text")); // NOI18N

        jxdFechaNacimiento.setFormats("dd/MM/yyyy");

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle
                .getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.jPanel3.border.title"))); // NOI18N

        btnAgregarTelefono.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.btnAgregarTelefono.text")); // NOI18N
        btnAgregarTelefono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarTelefonoActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(jListTelefonos);

        btnEliminarTelefono.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.btnEliminarTelefono.text")); // NOI18N
        btnEliminarTelefono.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarTelefonoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(jPanel3Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                                        .addComponent(cboTiposTelefonos, javax.swing.GroupLayout.PREFERRED_SIZE, 75,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(tfNumeroTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 108,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addGap(10, 10, 10).addComponent(
                                        jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 191,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnEliminarTelefono, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(btnAgregarTelefono, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap()));
        jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel3Layout.createSequentialGroup().addGroup(jPanel3Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cboTiposTelefonos, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(tfNumeroTelefono, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnAgregarTelefono))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnEliminarTelefono))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle
                .getMessage(DiagEmpleadoPersona.class, "DiagEmpleadoPersona.jPanel5.border.title"))); // NOI18N

        btnAgregarCorreoElectronico.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.btnAgregarCorreoElectronico.text")); // NOI18N
        btnAgregarCorreoElectronico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAgregarCorreoElectronicoActionPerformed(evt);
            }
        });

        jScrollPane3.setViewportView(jListCorreosElectronicos);

        btnEliminarCorreoElectronico.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.btnEliminarCorreoElectronico.text")); // NOI18N
        btnEliminarCorreoElectronico.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarCorreoElectronicoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(jPanel5Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                                .addComponent(tfCorreoElectronico, javax.swing.GroupLayout.Alignment.LEADING,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 181,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnAgregarCorreoElectronico)
                                .addComponent(btnEliminarCorreoElectronico))
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
        jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel5Layout.createSequentialGroup().addGroup(jPanel5Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(tfCorreoElectronico, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnAgregarCorreoElectronico))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(btnEliminarCorreoElectronico).addComponent(jScrollPane3,
                                        javax.swing.GroupLayout.PREFERRED_SIZE, 66,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))));

        jLabel1.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel1.text")); // NOI18N

        jCheckActivar.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jCheckActivar.text")); // NOI18N
        jCheckActivar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckActivarActionPerformed(evt);
            }
        });

        jLabel2.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.jLabel2.text")); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(jPanel1Layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(45, 45, 45).addComponent(lbApellido)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tfApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 196,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(lbNombre)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(tfNombre))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(68, 68, 68)
                                .addGroup(
                                        jPanel1Layout
                                                .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                                .addComponent(lbSexo).addComponent(jLabel12))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(cboSexo, javax.swing.GroupLayout.PREFERRED_SIZE, 149,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addComponent(tfCuil, javax.swing.GroupLayout.PREFERRED_SIZE, 155,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(lbFechaNac).addComponent(jLabel2))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout
                                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(jxdFechaNacimiento,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                                .addGap(0, 0, Short.MAX_VALUE))
                                        .addGroup(jPanel1Layout.createSequentialGroup()
                                                .addComponent(cboTipoDoc, 0, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        Short.MAX_VALUE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(lbDocumento)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(tfDocumento, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                        184, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGroup(jPanel1Layout.createSequentialGroup().addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(cboTipoEmpleado, javax.swing.GroupLayout.PREFERRED_SIZE, 322,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(28, 28, 28).addComponent(jCheckActivar)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jxdpFechaBaja, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel1Layout.createSequentialGroup().addGap(6, 6, 6)
                                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(27, 27, 27).addGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                        .addContainerGap()));
        jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup().addGap(6, 6, 6).addGroup(jPanel1Layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
                        .addComponent(cboTipoEmpleado, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jxdpFechaBaja, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jCheckActivar)).addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lbApellido)
                                .addComponent(tfApellido, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lbNombre).addComponent(tfNombre,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(
                                javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(cboTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(tfDocumento, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lbDocumento)
                                .addComponent(tfCuil, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel12).addComponent(jLabel2))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(lbSexo)
                                .addComponent(cboSexo, javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lbFechaNac).addComponent(jxdFechaNacimiento,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(14, 14, 14).addComponent(jPanel5,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                        javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(19, 19, 19)));

        btnAceptar.setText(org.openide.util.NbBundle.getMessage(DiagEmpleadoPersona.class,
                "DiagEmpleadoPersona.btnAceptar.text")); // NOI18N
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addGap(399, 399, 399)
                        .addComponent(btnAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 125,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addContainerGap(26, Short.MAX_VALUE)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,
                                javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(88, 88, 88)));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().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)
                        .addComponent(btnAceptar)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

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

    private void cboProvinciasItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProvinciasItemStateChanged
        cargarDepartamentos();
    }//GEN-LAST:event_cboProvinciasItemStateChanged

    private void cboDepartamentosItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDepartamentosItemStateChanged
        cargarLocalidades();
    }//GEN-LAST:event_cboDepartamentosItemStateChanged

    private void btnAgregarTelefonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarTelefonoActionPerformed
        agregarTelefono();
    }//GEN-LAST:event_btnAgregarTelefonoActionPerformed

    private void btnEliminarTelefonoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarTelefonoActionPerformed
        eliminarTelefono();
    }//GEN-LAST:event_btnEliminarTelefonoActionPerformed

    private void btnAgregarCorreoElectronicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAgregarCorreoElectronicoActionPerformed
        agregarCorreoElectronico();
    }//GEN-LAST:event_btnAgregarCorreoElectronicoActionPerformed

    private void btnEliminarCorreoElectronicoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarCorreoElectronicoActionPerformed
        eliminarCorreoElectronico();
    }//GEN-LAST:event_btnEliminarCorreoElectronicoActionPerformed

    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
        aceptar();
    }//GEN-LAST:event_btnAceptarActionPerformed

    private void jCheckActivarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckActivarActionPerformed

        if (jCheckActivar.isSelected()) {
            jxdpFechaBaja.setEnabled(true);
        } else {
            jxdpFechaBaja.setEnabled(false);
            //empleado.setFechaBaja(null);
        }
    }//GEN-LAST:event_jCheckActivarActionPerformed

    /**
     * @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(DiagEmpleadoPersona.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(DiagEmpleadoPersona.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(DiagEmpleadoPersona.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(DiagEmpleadoPersona.class.getName())
                    .log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                DiagEmpleadoPersona dialog = new DiagEmpleadoPersona(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnAgregarCorreoElectronico;
    private javax.swing.JButton btnAgregarTelefono;
    private javax.swing.JButton btnEliminarCorreoElectronico;
    private javax.swing.JButton btnEliminarTelefono;
    private javax.swing.JComboBox cboDepartamentos;
    private javax.swing.JComboBox cboLocalidades;
    private javax.swing.JComboBox cboProvincias;
    private javax.swing.JComboBox cboSexo;
    private javax.swing.JComboBox cboTipoDoc;
    private javax.swing.JComboBox cboTipoEmpleado;
    private javax.swing.JComboBox cboTiposTelefonos;
    private javax.swing.JCheckBox jCheckActivar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    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 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 jListCorreosElectronicos;
    private javax.swing.JList jListTelefonos;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private org.jdesktop.swingx.JXDatePicker jxdFechaNacimiento;
    private org.jdesktop.swingx.JXDatePicker jxdpFechaBaja;
    private javax.swing.JLabel lbApellido;
    private javax.swing.JLabel lbDocumento;
    private javax.swing.JLabel lbFechaNac;
    private javax.swing.JLabel lbNombre;
    private javax.swing.JLabel lbSexo;
    private javax.swing.JTextField tfApellido;
    private javax.swing.JTextField tfBarrio;
    private javax.swing.JTextField tfCalle;
    private javax.swing.JTextField tfCodigoPostal;
    private javax.swing.JTextField tfCorreoElectronico;
    private javax.swing.JTextField tfCuil;
    private javax.swing.JTextField tfDocumento;
    private javax.swing.JTextField tfDpto;
    private javax.swing.JTextField tfEntreCalles;
    private javax.swing.JTextField tfNombre;
    private javax.swing.JTextField tfNumero;
    private javax.swing.JTextField tfNumeroTelefono;
    private javax.swing.JTextField tfPiso;
    private javax.swing.JTextField tfReferencia;

    // End of variables declaration//GEN-END:variables
    private void cargarDepartamentos() {
        try {
            Comunes.cargarJComboConBlanco(cboDepartamentos, DepartamentoFacade.getInstance()
                    .listarTodosDepartamentoOrdenados((Provincia) cboProvincias.getSelectedItem()));
            cargarLocalidades();
        } catch (java.lang.ClassCastException ex) {
        }
    }

    private void cargarLocalidades() {
        try {
            Comunes.cargarJComboConBlanco(cboLocalidades, LocalidadFacade.getInstance()
                    .listarTodosLocalidadOrdenados((Departamento) cboDepartamentos.getSelectedItem()));
        } catch (java.lang.ClassCastException ex) {
        }

    }

    private void cargarProvincias() {
        try {
            Comunes.cargarJComboConBlanco(cboProvincias,
                    ProvinciaFacade.getInstance().listarTodosProvinciaOrdenados());
            cargarDepartamentos();
        } catch (java.lang.ClassCastException ex) {
        }
    }

    private void inicializarComponentes() {
        Comunes.formatearJXdatePicker(jxdpFechaBaja);
        cargarTiposEmpleados();
        cargarTiposDocumento();
        cargarProvincias();
        cargarSexos();
        cargarTiposTelefono();
        jxdpFechaBaja.setEnabled(false);
        if (tipoOperacion.equals("ModificacinEmpleado")) {
            cargarPersona();
        }

    }

    private void cargarTiposDocumento() {
        Comunes.cargarJComboConBlanco(cboTipoDoc, TipoDocumentoFacade.getInstance().getTodos());
    }

    private void agregarTelefono() {
        if (cboTiposTelefonos.getSelectedIndex() > 0) {
            if (BigIntegerValidator.getInstance().isValid(tfNumeroTelefono.getText())) {
                Telefono telefono = new Telefono();
                telefono.setNumero(tfNumeroTelefono.getText());
                telefono.setTipoTelefono((TipoTelefono) cboTiposTelefonos.getSelectedItem());
                telefonos.add(telefono);
                Comunes.cargarJList(jListTelefonos, telefonos);
                cboTiposTelefonos.setSelectedIndex(0);
                tfNumeroTelefono.setText("");
                tfNumeroTelefono.requestFocus();
            } else {
                JOptionPane.showMessageDialog(null, "Nmero de telfono incorrecto", "Error",
                        JOptionPane.ERROR_MESSAGE);
                tfNumeroTelefono.requestFocus();
            }
        } else {
            JOptionPane.showMessageDialog(null, "Debe escoger un tipo de telfono", "Error",
                    JOptionPane.ERROR_MESSAGE);
            cboTiposTelefonos.requestFocus();
        }
    }

    private void agregarCorreoElectronico() {
        if (Comunes.validarEmail(tfCorreoElectronico)) {
            CorreoElectronico correoElectronico = new CorreoElectronico();
            correoElectronico.setDireccion(tfCorreoElectronico.getText());
            correosElectronicos.add(correoElectronico);
            Comunes.cargarJList(jListCorreosElectronicos, correosElectronicos);
            tfCorreoElectronico.setText("");
            tfCorreoElectronico.requestFocus();
        } else {
            JOptionPane.showMessageDialog(null, "Correo electrnico incorrecto", "Error",
                    JOptionPane.ERROR_MESSAGE);
            tfCorreoElectronico.requestFocus();
        }

    }

    private void eliminarTelefono() {
        if (jListTelefonos.getSelectedIndex() != -1) {
            telefonos.remove((Telefono) jListTelefonos.getSelectedValue());
            Comunes.cargarJList(jListTelefonos, telefonos);
        }
    }

    private void eliminarCorreoElectronico() {
        if (jListCorreosElectronicos.getSelectedIndex() != -1) {
            correosElectronicos.remove((CorreoElectronico) jListCorreosElectronicos.getSelectedValue());
            Comunes.cargarJList(jListCorreosElectronicos, correosElectronicos);
        }
    }

    private void cargarSexos() {
        cboSexo.setModel(new javax.swing.DefaultComboBoxModel(Sexo.values()));
    }

    private void cargarTiposTelefono() {
        Comunes.cargarJComboConBlanco(cboTiposTelefonos, TipoTelefonoFacade.getInstance().getTodos());
    }

    private void aceptar() {
        if (tipoOperacion.equals("AltaPersona")) {
            if (validarPersona()) {
                empleado = new Empleado();
                personaCliente = new Persona();
                //persona = new Persona();
                cargarEntidadPersona();
                cargarEntidadCliente();
                //                ClienteFacade.getInstance().alta(persona);
                //                empleado.setPersona(persona);
                EmpleadoFacade.getInstance().alta(empleado);
                personaCliente.setListaPrecio(ListaPrecioFacade.getInstance().getPorDescripcion("COMUN"));
                if (!ClienteFacade.getInstance()
                        .buscarDniPersona(personaCliente.getDocumentoIdentidad().getNumero())) {
                    ClienteFacade.getInstance().alta(personaCliente);
                } else {
                    JOptionPane.showMessageDialog(rootPane,
                            "Empleado ya existe como cliente,\n solo se dar de alta como empleado");
                }

                JOptionPane.showMessageDialog(null, "Empleado Agregado!");
                this.dispose();
            }
        }

        if (tipoOperacion.equals("ModificacinEmpleado")) {
            System.out.println("Entro Modificacion Empleado");
            if (validarPersona()) {
                cargarEntidadPersona();
                try {
                    personaCliente = ClienteFacade.getInstance().getPersonaXDni(tfDocumento.getText());
                    cargarEntidadCliente();
                    ClienteFacade.getInstance().modificar(personaCliente);
                } catch (Exception e) {

                }

                //                ClienteFacade.getInstance().modificar(persona);
                //                empleado.setPersona(persona);
                EmpleadoFacade.getInstance().modificar(empleado);

                JOptionPane.showMessageDialog(null, "Empleado modificado!");
                this.dispose();

            }

        }

    }

    private boolean validarPersona() {
        if (cboTipoEmpleado.getSelectedIndex() == 0) {
            JOptionPane.showMessageDialog(null, "Debe seleccionar el Tipo de Empleado", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }
        if (tfNombre.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Debe escribir un nombre", "Error", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        if (tfApellido.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Debe escribir un apellido", "Error", JOptionPane.ERROR_MESSAGE);
            return false;
        }
        if (!tfCuil.getText().equals("") && !Comunes.validarTextFieldCuit(tfCuil)) {
            JOptionPane.showMessageDialog(null, "Debe escribir cuil correctamente", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }
        if (cboTipoDoc.getSelectedIndex() == 0) {
            JOptionPane.showMessageDialog(null, "Debe seleccionar tipo de documento", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }

        if (tfDocumento.getText().isEmpty()) {
            JOptionPane.showMessageDialog(null, "Debe ingresar el numero de Documento", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }

        if (!LongValidator.getInstance().isValid(tfDocumento.getText())) {
            JOptionPane.showMessageDialog(null, "Nmero de documento incorrecto", "Error",
                    JOptionPane.ERROR_MESSAGE);
            return false;
        }
        if (EmpleadoFacade.getInstance().existeDNI(tfDocumento.getText().trim())
                && tipoOperacion.equals("AltaPersona")) {
            JOptionPane.showMessageDialog(null, "DNI ya existe", "Error", JOptionPane.ERROR_MESSAGE);
            return false;
        }

        return true;
    }

    private void cargarPersona() {
        System.out.println("entro cargar Empleado");
        tfApellido.setText(empleado.getApellido());
        tfNombre.setText(empleado.getNombre());
        tfCuil.setText(empleado.getCuil());
        try {
            cboTipoEmpleado.setSelectedItem(empleado.getTipoEmpleado());
        } catch (Exception e) {
        }
        try {
            cboTipoDoc.setSelectedItem(empleado.getDocumentoIdentidad().getTipoDocumento());
        } catch (Exception e) {

        }
        try {
            tfDocumento.setText(empleado.getDocumentoIdentidad().getNumero());
        } catch (Exception e) {

        }
        try {
            cboSexo.setSelectedItem(empleado.getSexo());
        } catch (Exception e) {

        }
        jxdFechaNacimiento.setDate(empleado.getFechaNacimiento());

        //fecha de baja habilitar o deshabilitar
        if (empleado.getFechaBaja() != null) {
            jxdpFechaBaja.setDate(empleado.getFechaBaja());
            jxdpFechaBaja.setEnabled(true);
            jCheckActivar.setSelected(true);
        }

        try {
            telefonos = empleado.getTelefonos();
            Comunes.cargarJList(jListTelefonos, telefonos);
        } catch (Exception e) {

        }
        try {
            correosElectronicos = empleado.getCorreosElectronicos();
            Comunes.cargarJList(jListCorreosElectronicos, correosElectronicos);
        } catch (Exception e) {

        }
        try {
            tfCalle.setText(empleado.getDomicilio().getCalle());
        } catch (Exception e) {

        }
        try {
            tfNumero.setText(empleado.getDomicilio().getNumero());
        } catch (Exception e) {

        }
        try {
            tfPiso.setText(empleado.getDomicilio().getPiso());
        } catch (Exception e) {

        }
        try {
            tfDpto.setText(empleado.getDomicilio().getDpto());
        } catch (Exception e) {

        }
        try {
            tfEntreCalles.setText(empleado.getDomicilio().getEntreCalles());
        } catch (Exception e) {

        }
        try {
            tfReferencia.setText(empleado.getDomicilio().getReferencia());
        } catch (Exception e) {

        }
        try {
            tfBarrio.setText(empleado.getDomicilio().getBarrio());
        } catch (Exception e) {

        }
        try {
            cboProvincias.setSelectedItem(empleado.getDomicilio().getLocalidad().getDepartamento().getProvincia());
            cargarDepartamentos();
        } catch (java.lang.NullPointerException ex) {
        }
        try {
            cboDepartamentos.setSelectedItem(empleado.getDomicilio().getLocalidad().getDepartamento());
            cargarLocalidades();
        } catch (java.lang.NullPointerException ex) {
        }
        try {
            if (empleado.getDomicilio().getLocalidad() != null) {
                cboLocalidades.setSelectedItem(empleado.getDomicilio().getLocalidad());
            }
        } catch (java.lang.NullPointerException ex) {
        }
        try {
            tfCodigoPostal.setText(empleado.getDomicilio().getCodigoPostal());
        } catch (java.lang.NullPointerException ex) {
        }

    }

    private void cargarEntidadPersona() {

        empleado.setTipoEmpleado((TipoEmpleado) cboTipoEmpleado.getSelectedItem());
        empleado.setApellido(tfApellido.getText().toUpperCase());
        empleado.setNombre(tfNombre.getText().toUpperCase());
        empleado.setCorreosElectronicos(correosElectronicos);
        empleado.setCuil(tfCuil.getText());
        DocumentoIdentidad documentoIdentidad = new DocumentoIdentidad();
        try {
            documentoIdentidad.setTipoDocumento((TipoDocumento) cboTipoDoc.getSelectedItem());
        } catch (Exception e) {

        }
        documentoIdentidad.setNumero(tfDocumento.getText());
        empleado.setDocumentoIdentidad(documentoIdentidad);
        empleado.setFechaNacimiento(jxdFechaNacimiento.getDate());
        empleado.setSexo((Sexo) cboSexo.getSelectedItem());
        empleado.setTelefonos(telefonos);
        Domicilio domicilio = new Domicilio();
        domicilio.setCalle(tfCalle.getText());
        domicilio.setNumero(tfNumero.getText());
        domicilio.setPiso(tfPiso.getText());
        domicilio.setDpto(tfDpto.getText());
        domicilio.setEntreCalles(tfEntreCalles.getText());
        domicilio.setReferencia(tfReferencia.getText());
        domicilio.setBarrio(tfBarrio.getText());
        domicilio.setLocalidad((Localidad) cboLocalidades.getSelectedItem());
        domicilio.setCodigoPostal(tfCodigoPostal.getText());
        empleado.setDomicilio(domicilio);
        if (jxdpFechaBaja.isEnabled()) {
            empleado.setFechaBaja(jxdpFechaBaja.getDate());
        } else {
            empleado.setFechaBaja(null);
        }

    }

    private void cargarTiposEmpleados() {
        Comunes.cargarJComboConBlanco(cboTipoEmpleado, TipoEmpleadoFacade.getInstance().getTodos());

    }

    private void cargarEntidadCliente() {

        personaCliente.setApellido(tfApellido.getText().toUpperCase());
        personaCliente.setNombre(tfNombre.getText().toUpperCase());
        personaCliente.setCorreosElectronicos(correosElectronicos);
        personaCliente.setCuil(tfCuil.getText());
        DocumentoIdentidad documentoIdentidad = new DocumentoIdentidad();
        try {
            documentoIdentidad.setTipoDocumento((TipoDocumento) cboTipoDoc.getSelectedItem());
        } catch (Exception e) {

        }
        documentoIdentidad.setNumero(tfDocumento.getText());
        personaCliente.setDocumentoIdentidad(documentoIdentidad);
        personaCliente.setFechaNacimiento(jxdFechaNacimiento.getDate());
        personaCliente.setSexo((Sexo) cboSexo.getSelectedItem());
        personaCliente.setTelefonos(telefonos);
        Domicilio domicilio = new Domicilio();
        domicilio.setCalle(tfCalle.getText());
        domicilio.setNumero(tfNumero.getText());
        domicilio.setPiso(tfPiso.getText());
        domicilio.setDpto(tfDpto.getText());
        domicilio.setEntreCalles(tfEntreCalles.getText());
        domicilio.setReferencia(tfReferencia.getText());
        domicilio.setBarrio(tfBarrio.getText());
        domicilio.setLocalidad((Localidad) cboLocalidades.getSelectedItem());
        domicilio.setCodigoPostal(tfCodigoPostal.getText());
        personaCliente.setDomicilio(domicilio);

    }
}