private boolean validarDatos() { String nombre = this.jtfNombre.getText().trim(); /* * VALIDAR Nombre */ if (nombre.isEmpty()) { this.jtfNombre.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo Nombre esta vacío", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } else if (nombre.length() > 30) { this.jtfNombre.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo Nombre supera 30 caracteres", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } String apellido = jtfApellido.getText().trim(); /* * VALIDAR Apellido */ if (apellido.isEmpty()) { this.jtfApellido.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo Apellido esta vacío", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } else if (apellido.length() > 30) { this.jtfApellido.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo Nombre supera 30 caracteres", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } Date fechaNacimiento = null; if (dccFechaNacimiento.getDate() != null) { try { fechaNacimiento = dccFechaNacimiento.getDate(); } catch (Exception e) { javax.swing.JOptionPane.showMessageDialog( this, "Error en el campo Fecha nacimiento, inserte una fecha válida", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } } Integer cedula = null; if (!jftCedulaIdentidad.getText().isEmpty()) { try { cedula = Integer.valueOf(jftCedulaIdentidad.getText()); if (DB_manager.existCi(cedula)) { this.jftCedulaIdentidad.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "Cédula en uso", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } } catch (Exception e) { this.jftCedulaIdentidad.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "Error en el campo Cédula, inserte solo números", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } } String telefono = jtfTelefonoContacto.getText().trim(); if (telefono.length() > 30) { this.jtfTelefonoContacto.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo telefono supera 30 caracteres", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } else if (telefono.isEmpty()) { telefono = null; } String direccion = jtfDireccionContacto.getText().trim(); if (direccion.length() > 120) { this.jtfDireccionContacto.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo dirección supera 120 caracteres", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } else if (direccion.isEmpty()) { direccion = null; } String email = jtfCorreoElecContacto.getText().trim(); if (email.length() > 30) { this.jtfCorreoElecContacto.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo email supera 30 caracteres", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } else if (email.isEmpty()) { email = null; } String observacion = jtfObservacion.getText().trim(); if (observacion.length() > 120) { this.jtfObservacion.setBackground(Color.red); javax.swing.JOptionPane.showMessageDialog( this, "El campo Observación supera 120 caracteres", "Parametros incorrectos", javax.swing.JOptionPane.OK_OPTION); return false; } else if (observacion.isEmpty()) { observacion = null; } if (accion == CREAR_CLIENTE_CONTACTO || accion == MODIFICAR_CLIENTE_CONTACTO) { clie_contacto = new M_cliente_contacto(); String nacionalidad = jcbNacionalidad.getSelectedItem().toString(); String ciudad = jcbCiudad.getSelectedItem().toString(); String genero = jcbGenero.getSelectedItem().toString(); String estadoCivil = jcbEstadoCivil.getSelectedItem().toString(); clie_contacto.setApellido(apellido); clie_contacto.setCedula(cedula); clie_contacto.setCiudad(ciudad); clie_contacto.setDireccion(direccion); clie_contacto.setEmail(email); clie_contacto.setEstado_civil(estadoCivil); clie_contacto.setFecha_nacimiento(fechaNacimiento); clie_contacto.setNombre(nombre); clie_contacto.setObservacion(observacion); clie_contacto.setPais(nacionalidad); clie_contacto.setSexo(genero); clie_contacto.setTelefono(telefono); clie_contacto.setId_ciudad(DB_manager.obtenerIdCiudad(ciudad)); clie_contacto.setId_estado_civil(DB_manager.obtenerIdEstadoCivil(estadoCivil)); clie_contacto.setId_pais(DB_manager.obtenerIdPais(nacionalidad)); clie_contacto.setId_sexo(DB_manager.obtenerIdGenero(genero)); } else if (accion == CREAR_PROVEEDOR_CONTACTO || accion == MODIFICAR_PROVEEDOR_CONTACTO) { prov_contacto = new M_contacto(); String nacionalidad = jcbNacionalidad.getSelectedItem().toString(); String ciudad = jcbCiudad.getSelectedItem().toString(); String genero = jcbGenero.getSelectedItem().toString(); String estadoCivil = jcbEstadoCivil.getSelectedItem().toString(); prov_contacto.setApellido(apellido); prov_contacto.setCedula(cedula); prov_contacto.setCiudad(ciudad); prov_contacto.setDireccion(direccion); prov_contacto.setEmail(email); prov_contacto.setEstado_civil(estadoCivil); prov_contacto.setFecha_nacimiento(fechaNacimiento); prov_contacto.setNombre(nombre); prov_contacto.setObservacion(observacion); prov_contacto.setPais(nacionalidad); prov_contacto.setSexo(genero); prov_contacto.setTelefono(telefono); prov_contacto.setId_ciudad(DB_manager.obtenerIdCiudad(ciudad)); prov_contacto.setId_estado_civil(DB_manager.obtenerIdEstadoCivil(estadoCivil)); prov_contacto.setId_pais(DB_manager.obtenerIdPais(nacionalidad)); prov_contacto.setId_sexo(DB_manager.obtenerIdGenero(genero)); } return true; }