[EDIT] Cambios

parent 3524a041
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for --> <!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. --> <!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) --> <!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. --> <!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if --> <!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. --> <!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting --> <!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.--> <!-- in the project's Project Properties dialog box.-->
<project name="demojsoncrud" default="default" basedir="."> <project name="demojsoncrud" default="default" basedir=".">
<description>Builds, tests, and runs the project demojsoncrud.</description> <description>Builds, tests, and runs the project demojsoncrud.</description>
<import file="nbproject/build-impl.xml"/> <import file="nbproject/build-impl.xml"/>
<!-- <!--
There exist several targets which are by default empty and which can be There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed used for execution of your tasks. These targets are usually executed
before and after some main targets. They are: before and after some main targets. They are:
-pre-init: called before initialization of project properties -pre-init: called before initialization of project properties
-post-init: called after initialization of project properties -post-init: called after initialization of project properties
-pre-compile: called before javac compilation -pre-compile: called before javac compilation
-post-compile: called after javac compilation -post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file -pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file -post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests -pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests -post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test -pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test -post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building -pre-dist: called before archive building
-post-dist: called after archive building -post-dist: called after archive building
-post-clean: called after cleaning build products -post-clean: called after cleaning build products
-pre-run-deploy: called before deploying -pre-run-deploy: called before deploying
-post-run-deploy: called after deploying -post-run-deploy: called after deploying
Example of pluging an obfuscator after the compilation could look like Example of pluging an obfuscator after the compilation could look like
<target name="-post-compile"> <target name="-post-compile">
<obfuscate> <obfuscate>
<fileset dir="${build.classes.dir}"/> <fileset dir="${build.classes.dir}"/>
</obfuscate> </obfuscate>
</target> </target>
For list of available properties check the imported For list of available properties check the imported
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
Other way how to customize the build is by overriding existing main targets. Other way how to customize the build is by overriding existing main targets.
The target of interest are: The target of interest are:
init-macrodef-javac: defines macro for javac compilation init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging init-macrodef-debug: defines macro for class debugging
do-dist: archive building do-dist: archive building
run: execution of project run: execution of project
javadoc-build: javadoc generation javadoc-build: javadoc generation
Example of overriding the target for project execution could look like Example of overriding the target for project execution could look like
<target name="run" depends="<PROJNAME>-impl.jar"> <target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe"> <exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/> <arg file="${dist.jar}"/>
</exec> </exec>
</target> </target>
Notice that overridden target depends on jar target and not only on Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in properties which you can use check the target you are overriding in
nbproject/build-impl.xml file. nbproject/build-impl.xml file.
--> -->
</project> </project>
This source diff could not be displayed because it is too large. You can view the blob instead.
build.xml.data.CRC32=4cd4cb5e build.xml.data.CRC32=66ba06da
build.xml.script.CRC32=615931b7 build.xml.script.CRC32=615931b7
build.xml.stylesheet.CRC32=651128d4@1.77.1.1 build.xml.stylesheet.CRC32=651128d4@1.77.1.1
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=4cd4cb5e nbproject/build-impl.xml.data.CRC32=66ba06da
nbproject/build-impl.xml.script.CRC32=efa11df6 nbproject/build-impl.xml.script.CRC32=816bdc64
nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1 nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.77.1.1
annotation.processing.enabled=true annotation.processing.enabled=true
annotation.processing.enabled.in.editor=true annotation.processing.enabled.in.editor=true
annotation.processing.processors.list= annotation.processing.processors.list=
annotation.processing.run.all.processors=true annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.web.dir}/WEB-INF/classes build.classes.dir=${build.web.dir}/WEB-INF/classes
build.classes.excludes=**/*.java,**/*.form build.classes.excludes=**/*.java,**/*.form
build.dir=build build.dir=build
build.generated.dir=${build.dir}/generated build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources build.generated.sources.dir=${build.dir}/generated-sources
build.test.classes.dir=${build.dir}/test/classes build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results build.test.results.dir=${build.dir}/test/results
build.web.dir=${build.dir}/web build.web.dir=${build.dir}/web
build.web.excludes=${build.classes.excludes} build.web.excludes=${build.classes.excludes}
client.urlPart= client.urlPart=
compile.jsps=false compile.jsps=false
conf.dir=${source.root}/conf conf.dir=${source.root}/conf
debug.classpath=${build.classes.dir}:${javac.classpath} debug.classpath=${build.classes.dir}:${javac.classpath}
debug.test.classpath=\ debug.test.classpath=\
${run.test.classpath} ${run.test.classpath}
display.browser=true display.browser=true
# Files to be excluded from distribution war # Files to be excluded from distribution war
dist.archive.excludes= dist.archive.excludes=
dist.dir=dist dist.dir=dist
dist.ear.war=${dist.dir}/${war.ear.name} dist.ear.war=${dist.dir}/${war.ear.name}
dist.javadoc.dir=${dist.dir}/javadoc dist.javadoc.dir=${dist.dir}/javadoc
dist.war=${dist.dir}/${war.name} dist.war=${dist.dir}/${war.name}
endorsed.classpath=\ endorsed.classpath=\
${libs.javaee-endorsed-api-7.0.classpath} ${libs.javaee-endorsed-api-7.0.classpath}
excludes= excludes=
file.reference.json-20160810.jar=F:\\LIBRERIAS\\json-20160810.jar file.reference.json-20160212.jar=D:\\LIBRERIAS\\json-20160212.jar
file.reference.sqljdbc4-2.0.jar=F:\\LIBRERIAS\\sqljdbc4-2.0.jar file.reference.sqljdbc4.jar=D:\\LIBRERIAS\\sqljdbc4.jar
includes=** includes=**
j2ee.compile.on.save=true j2ee.compile.on.save=true
j2ee.copy.static.files.on.save=true j2ee.copy.static.files.on.save=true
j2ee.deploy.on.save=true j2ee.deploy.on.save=true
j2ee.platform=1.7-web j2ee.platform=1.7-web
j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar j2ee.platform.classpath=${j2ee.server.home}/modules/endorsed/javax.annotation-api.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/bean-validator.jar:${j2ee.server.home}/modules/cdi-api.jar:${j2ee.server.home}/modules/javax.batch-api.jar:${j2ee.server.home}/modules/javax.ejb-api.jar:${j2ee.server.home}/modules/javax.el.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent-api.jar:${j2ee.server.home}/modules/javax.enterprise.concurrent.jar:${j2ee.server.home}/modules/javax.enterprise.deploy-api.jar:${j2ee.server.home}/modules/javax.faces.jar:${j2ee.server.home}/modules/javax.inject.jar:${j2ee.server.home}/modules/javax.interceptor-api.jar:${j2ee.server.home}/modules/javax.jms-api.jar:${j2ee.server.home}/modules/javax.json.jar:${j2ee.server.home}/modules/javax.mail.jar:${j2ee.server.home}/modules/javax.management.j2ee-api.jar:${j2ee.server.home}/modules/javax.persistence.jar:${j2ee.server.home}/modules/javax.resource-api.jar:${j2ee.server.home}/modules/javax.security.auth.message-api.jar:${j2ee.server.home}/modules/javax.security.jacc-api.jar:${j2ee.server.home}/modules/javax.servlet-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl-api.jar:${j2ee.server.home}/modules/javax.servlet.jsp.jstl.jar:${j2ee.server.home}/modules/javax.transaction-api.jar:${j2ee.server.home}/modules/javax.websocket-api.jar:${j2ee.server.home}/modules/javax.ws.rs-api.jar:${j2ee.server.home}/modules/javax.xml.registry-api.jar:${j2ee.server.home}/modules/javax.xml.rpc-api.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/weld-osgi-bundle.jar:${j2ee.server.middleware}/mq/lib/jaxm-api.jar
j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar j2ee.platform.embeddableejb.classpath=${j2ee.server.home}/lib/embedded/glassfish-embedded-static-shell.jar
j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar j2ee.platform.wscompile.classpath=${j2ee.server.home}/modules/webservices-osgi.jar
j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar j2ee.platform.wsgen.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar
j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar j2ee.platform.wsimport.classpath=${j2ee.server.home}/modules/webservices-osgi.jar:${j2ee.server.home}/modules/endorsed/webservices-api-osgi.jar:${j2ee.server.home}/modules/jaxb-osgi.jar:${j2ee.server.home}/modules/endorsed/jaxb-api.jar
j2ee.platform.wsit.classpath= j2ee.platform.wsit.classpath=
j2ee.server.type=gfv3ee6 j2ee.server.type=gfv3ee6
jar.compress=false jar.compress=false
javac.classpath=\ javac.classpath=\
${file.reference.json-20160810.jar}:\ ${file.reference.json-20160212.jar}:\
${file.reference.sqljdbc4-2.0.jar} ${file.reference.sqljdbc4.jar}
# Space-separated list of extra javac options # Space-separated list of extra javac options
javac.compilerargs= javac.compilerargs=
javac.debug=true javac.debug=true
javac.deprecation=false javac.deprecation=false
javac.processorpath=\ javac.processorpath=\
${javac.classpath} ${javac.classpath}
javac.source=1.8 javac.source=1.8
javac.target=1.8 javac.target=1.8
javac.test.classpath=\ javac.test.classpath=\
${javac.classpath}:\ ${javac.classpath}:\
${build.classes.dir} ${build.classes.dir}
javac.test.processorpath=\ javac.test.processorpath=\
${javac.test.classpath} ${javac.test.classpath}
javadoc.additionalparam= javadoc.additionalparam=
javadoc.author=false javadoc.author=false
javadoc.encoding=${source.encoding} javadoc.encoding=${source.encoding}
javadoc.noindex=false javadoc.noindex=false
javadoc.nonavbar=false javadoc.nonavbar=false
javadoc.notree=false javadoc.notree=false
javadoc.preview=true javadoc.preview=true
javadoc.private=false javadoc.private=false
javadoc.splitindex=true javadoc.splitindex=true
javadoc.use=true javadoc.use=true
javadoc.version=false javadoc.version=false
javadoc.windowtitle= javadoc.windowtitle=
lib.dir=${web.docbase.dir}/WEB-INF/lib lib.dir=${web.docbase.dir}/WEB-INF/lib
persistence.xml.dir=${conf.dir} persistence.xml.dir=${conf.dir}
platform.active=default_platform platform.active=default_platform
resource.dir=setup resource.dir=setup
run.test.classpath=\ run.test.classpath=\
${javac.test.classpath}:\ ${javac.test.classpath}:\
${build.test.classes.dir} ${build.test.classes.dir}
# Space-separated list of JVM arguments used when running a class with a main method or a unit test # Space-separated list of JVM arguments used when running a class with a main method or a unit test
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value): # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value):
runmain.jvmargs= runmain.jvmargs=
source.encoding=UTF-8 source.encoding=UTF-8
source.root=src source.root=src
src.dir=${source.root}/java src.dir=${source.root}/java
test.src.dir=test test.src.dir=test
war.content.additional= war.content.additional=
war.ear.name=${war.name} war.ear.name=${war.name}
war.name=demojsoncrud.war war.name=demojsoncrud.war
web.docbase.dir=web web.docbase.dir=web
webinf.dir=web/WEB-INF webinf.dir=web/WEB-INF
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1"> <project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.web.project</type> <type>org.netbeans.modules.web.project</type>
<configuration> <configuration>
<data xmlns="http://www.netbeans.org/ns/web-project/3"> <data xmlns="http://www.netbeans.org/ns/web-project/3">
<name>demojsoncrud</name> <name>demojsoncrud</name>
<minimum-ant-version>1.6.5</minimum-ant-version> <minimum-ant-version>1.6.5</minimum-ant-version>
<web-module-libraries> <web-module-libraries>
<library dirs="200"> <library dirs="200">
<file>${file.reference.json-20160810.jar}</file> <file>${file.reference.json-20160212.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war> <path-in-war>WEB-INF/lib</path-in-war>
</library> </library>
<library dirs="200"> <library dirs="200">
<file>${file.reference.sqljdbc4-2.0.jar}</file> <file>${file.reference.sqljdbc4.jar}</file>
<path-in-war>WEB-INF/lib</path-in-war> <path-in-war>WEB-INF/lib</path-in-war>
</library> </library>
</web-module-libraries> </web-module-libraries>
<web-module-additional-libraries/> <web-module-additional-libraries/>
<source-roots> <source-roots>
<root id="src.dir"/> <root id="src.dir"/>
</source-roots> </source-roots>
<test-roots> <test-roots>
<root id="test.src.dir"/> <root id="test.src.dir"/>
</test-roots> </test-roots>
</data> </data>
</configuration> </configuration>
</project> </project>
/* package demojsoncrud.beans;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import java.io.Serializable;
* and open the template in the editor.
*/ /**
package demojsoncrud.beans; *
* @author Alonso
import java.io.Serializable; */
public class PersonaBean implements Serializable {
/**
* private String codigo;
* @author Alonso private String dni;
*/ private String apellidos;
public class PersonaBean implements Serializable { private String nombres;
private String edad;
private String codigo; private String correo;
private String dni; private String estado;
private String apellidos;
private String nombres; public PersonaBean() {
private String edad; }
private String correo;
private String estado; public String getCodigo() {
return codigo;
public PersonaBean() { }
}
public void setCodigo(String codigo) {
public String getCodigo() { this.codigo = codigo;
return codigo; }
}
public String getDni() {
public void setCodigo(String codigo) { return dni;
this.codigo = codigo; }
}
public void setDni(String dni) {
public String getDni() { this.dni = dni;
return dni; }
}
public String getApellidos() {
public void setDni(String dni) { return apellidos;
this.dni = dni; }
}
public void setApellidos(String apellidos) {
public String getApellidos() { this.apellidos = apellidos;
return apellidos; }
}
public String getNombres() {
public void setApellidos(String apellidos) { return nombres;
this.apellidos = apellidos; }
}
public void setNombres(String nombres) {
public String getNombres() { this.nombres = nombres;
return nombres; }
}
public String getEdad() {
public void setNombres(String nombres) { return edad;
this.nombres = nombres; }
}
public void setEdad(String edad) {
public String getEdad() { this.edad = edad;
return edad; }
}
public String getCorreo() {
public void setEdad(String edad) { return correo;
this.edad = edad; }
}
public void setCorreo(String correo) {
public String getCorreo() { this.correo = correo;
return correo; }
}
public String getEstado() {
public void setCorreo(String correo) { return estado;
this.correo = correo; }
}
public void setEstado(String estado) {
public String getEstado() { this.estado = estado;
return estado; }
}
}
public void setEstado(String estado) {
this.estado = estado;
}
}
/* package demojsoncrud.dao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.sqlserverdao.SqlserverDAOFactory;
* and open the template in the editor.
*/ public abstract class DAOFactory {
package demojsoncrud.dao;
public static final int SQL_SERVER = 1;
import demojsoncrud.sqlserverdao.SqlserverDAOFactory; public static final int MYSQL = 2;
/** public static DAOFactory getDAOFactory(int whichFactory) {
* switch (whichFactory) {
* @author Alonso case SQL_SERVER:
*/ return new SqlserverDAOFactory();
public abstract class DAOFactory { default:
return null;
public static final int SQL_SERVER = 1; }
public static final int MYSQL = 2; }
public static DAOFactory getDAOFactory(int whichFactory) { public abstract PersonaDAO getPersonaDAO();
switch (whichFactory) {
case SQL_SERVER: }
return new SqlserverDAOFactory();
default:
return null;
}
}
public abstract PersonaDAO getPersonaDAO();
}
/* package demojsoncrud.dao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.beans.PersonaBean;
* and open the template in the editor. import org.json.JSONObject;
*/
package demojsoncrud.dao; public interface PersonaDAO {
import demojsoncrud.beans.PersonaBean; public JSONObject listarPersonaTest();
import org.json.JSONObject;
public JSONObject listarPersona(String search, String draw, String start, String length);
/**
* public JSONObject registrarPersona(PersonaBean bean);
* @author Alonso
*/ public JSONObject editarPersona(PersonaBean bean);
public interface PersonaDAO {
public JSONObject activarPersona(PersonaBean bean);
public JSONObject listarPersonaTest();
public JSONObject desactivarPersona(PersonaBean bean);
public JSONObject listarPersona(String search, String draw, String start, String length);
}
public JSONObject registrarPersona(PersonaBean bean);
public JSONObject editarPersona(PersonaBean bean);
public JSONObject activarPersona(PersonaBean bean);
public JSONObject desactivarPersona(PersonaBean bean);
}
/* package demojsoncrud.services;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.beans.PersonaBean;
* and open the template in the editor. import demojsoncrud.dao.DAOFactory;
*/ import demojsoncrud.dao.PersonaDAO;
package demojsoncrud.services; import org.json.JSONObject;
import demojsoncrud.beans.PersonaBean; public class PersonaService {
import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.PersonaDAO; DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQL_SERVER);
import org.json.JSONObject; PersonaDAO service = daoFactory.getPersonaDAO();
/** public JSONObject listarPersonaTest() {
* JSONObject jsonReturn = null;
* @author Alonso try {
*/ jsonReturn = service.listarPersonaTest();
public class PersonaService { } catch (Exception e) {
e.getMessage();
DAOFactory daoFactory = DAOFactory.getDAOFactory(DAOFactory.SQL_SERVER); }
PersonaDAO service = daoFactory.getPersonaDAO(); return jsonReturn;
}
public JSONObject listarPersonaTest() {
JSONObject jsonReturn = null; public JSONObject listarPersona(String search, String draw, String start, String length) {
try { JSONObject jsonReturn = null;
jsonReturn = service.listarPersonaTest(); try {
} catch (Exception e) { jsonReturn = service.listarPersona(search, draw, start, length);
e.getMessage(); } catch (Exception e) {
} e.getMessage();
return jsonReturn; }
} return jsonReturn;
}
public JSONObject listarPersona(String search, String draw, String start, String length) {
JSONObject jsonReturn = null; public JSONObject registrarPersona(PersonaBean bean) {
try { JSONObject jsonReturn = null;
jsonReturn = service.listarPersona(search, draw, start, length); try {
} catch (Exception e) { jsonReturn = service.registrarPersona(bean);
e.getMessage(); } catch (Exception e) {
} e.getMessage();
return jsonReturn; }
} return jsonReturn;
}
public JSONObject registrarPersona(PersonaBean bean) {
JSONObject jsonReturn = null; public JSONObject editarPersona(PersonaBean bean) {
try { JSONObject jsonReturn = null;
jsonReturn = service.registrarPersona(bean); try {
} catch (Exception e) { jsonReturn = service.editarPersona(bean);
e.getMessage(); } catch (Exception e) {
} e.getMessage();
return jsonReturn; }
} return jsonReturn;
}
public JSONObject editarPersona(PersonaBean bean) {
JSONObject jsonReturn = null; public JSONObject activarPersona(PersonaBean bean) {
try { JSONObject jsonReturn = null;
jsonReturn = service.editarPersona(bean); try {
} catch (Exception e) { jsonReturn = service.activarPersona(bean);
e.getMessage(); } catch (Exception e) {
} }
return jsonReturn; return jsonReturn;
} }
public JSONObject activarPersona(PersonaBean bean) { public JSONObject desactivarPersona(PersonaBean bean) {
JSONObject jsonReturn = null; JSONObject jsonReturn = null;
try { try {
jsonReturn = service.activarPersona(bean); jsonReturn = service.desactivarPersona(bean);
} catch (Exception e) { } catch (Exception e) {
} }
return jsonReturn; return jsonReturn;
} }
public JSONObject desactivarPersona(PersonaBean bean) { }
JSONObject jsonReturn = null;
try {
jsonReturn = service.desactivarPersona(bean);
} catch (Exception e) {
}
return jsonReturn;
}
}
/* package demojsoncrud.servlets;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.beans.PersonaBean;
* and open the template in the editor. import demojsoncrud.services.PersonaService;
*/ import java.io.IOException;
package demojsoncrud.servlets; import java.io.PrintWriter;
import javax.servlet.ServletException;
import demojsoncrud.beans.PersonaBean; import javax.servlet.http.HttpServlet;
import demojsoncrud.services.PersonaService; import javax.servlet.http.HttpServletRequest;
import java.io.IOException; import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter; import org.json.JSONObject;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; public class PersonaServlet extends HttpServlet {
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; @Override
import org.json.JSONObject; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String param = request.getParameter("accion");
/** if ("listarPersonaTest".equals(param)) {
* listarPersonaTest(request, response);
* @author Alonso } else if ("listarPersona".equals(param)) {
*/ listarPersona(request, response);
public class PersonaServlet extends HttpServlet { } else if ("registrarPersona".equals(param)) {
registrarPersona(request, response);
@Override } else if ("editarPersona".equals(param)) {
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { editarPersona(request, response);
String param = request.getParameter("accion"); } else if ("activarPersona".equals(param)) {
if ("listarPersonaTest".equals(param)) { activarPersona(request, response);
listarPersonaTest(request, response); } else if ("desactivarPersona".equals(param)) {
} else if ("listarPersona".equals(param)) { desactivarPersona(request, response);
listarPersona(request, response); }
} else if ("registrarPersona".equals(param)) { }
registrarPersona(request, response);
} else if ("editarPersona".equals(param)) { private void listarPersonaTest(HttpServletRequest request, HttpServletResponse response) throws IOException {
editarPersona(request, response); response.setContentType("application/json");
} else if ("activarPersona".equals(param)) { PrintWriter pw = response.getWriter();
activarPersona(request, response); PersonaService service = new PersonaService();
} else if ("desactivarPersona".equals(param)) { JSONObject json = service.listarPersonaTest();
desactivarPersona(request, response); pw.print(json);
} }
}
private void listarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException {
private void listarPersonaTest(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("application/json");
response.setContentType("application/json"); PrintWriter pw = response.getWriter();
PrintWriter pw = response.getWriter(); PersonaService service = new PersonaService();
PersonaService service = new PersonaService();
JSONObject json = service.listarPersonaTest(); String draw = request.getParameter("draw");
pw.print(json); String start = request.getParameter("start");
} String length = request.getParameter("length");
String search = request.getParameter("search");
private void listarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json"); JSONObject json = service.listarPersona(search, draw, start, length);
PrintWriter pw = response.getWriter(); pw.print(json);
PersonaService service = new PersonaService(); }
String draw = request.getParameter("draw"); private void registrarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException {
String start = request.getParameter("start"); response.setContentType("application/json");
String length = request.getParameter("length"); PrintWriter pw = response.getWriter();
String search = request.getParameter("search"); PersonaService service = new PersonaService();
JSONObject json = service.listarPersona(search, draw, start, length); String json = request.getParameter("json");
pw.print(json); JSONObject jsonObject = new JSONObject(json);
}
String dni = jsonObject.getString("dni");
private void registrarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException { String apellidos = jsonObject.getString("apellidos");
response.setContentType("application/json"); String nombres = jsonObject.getString("nombres");
PrintWriter pw = response.getWriter(); String edad = jsonObject.getString("edad");
PersonaService service = new PersonaService(); String correo = jsonObject.getString("correo");
String json = request.getParameter("json"); PersonaBean bean = new PersonaBean();
JSONObject jsonObject = new JSONObject(json); bean.setDni(dni);
bean.setApellidos(apellidos);
String dni = jsonObject.getString("dni"); bean.setNombres(nombres);
String apellidos = jsonObject.getString("apellidos"); bean.setEdad(edad);
String nombres = jsonObject.getString("nombres"); bean.setCorreo(correo);
String edad = jsonObject.getString("edad");
String correo = jsonObject.getString("correo"); JSONObject jsonReturn = service.registrarPersona(bean);
PersonaBean bean = new PersonaBean(); pw.print(jsonReturn);
bean.setDni(dni);
bean.setApellidos(apellidos); }
bean.setNombres(nombres);
bean.setEdad(edad); private void editarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException {
bean.setCorreo(correo); response.setContentType("application/json");
PersonaService service = new PersonaService();
JSONObject jsonReturn = service.registrarPersona(bean); PrintWriter pw = response.getWriter();
pw.print(jsonReturn); String json = request.getParameter("json");
JSONObject jsonObject = new JSONObject(json);
}
String apellidos = jsonObject.getString("apellidos");
private void editarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException { String nombres = jsonObject.getString("nombres");
response.setContentType("application/json"); String edad = jsonObject.getString("edad");
PersonaService service = new PersonaService(); String correo = jsonObject.getString("correo");
PrintWriter pw = response.getWriter(); String codigo = jsonObject.getString("codigo");
String json = request.getParameter("json"); PersonaBean bean = new PersonaBean();
JSONObject jsonObject = new JSONObject(json); bean.setApellidos(apellidos);
bean.setNombres(nombres);
String apellidos = jsonObject.getString("apellidos"); bean.setEdad(edad);
String nombres = jsonObject.getString("nombres"); bean.setCorreo(correo);
String edad = jsonObject.getString("edad"); bean.setCodigo(codigo);
String correo = jsonObject.getString("correo");
String codigo = jsonObject.getString("codigo"); JSONObject jsonReturn = service.editarPersona(bean);
PersonaBean bean = new PersonaBean(); pw.print(jsonReturn);
bean.setApellidos(apellidos);
bean.setNombres(nombres); }
bean.setEdad(edad);
bean.setCorreo(correo); private void activarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException {
bean.setCodigo(codigo); response.setContentType("application/json");
PersonaService service = new PersonaService();
JSONObject jsonReturn = service.editarPersona(bean); PrintWriter pw = response.getWriter();
pw.print(jsonReturn); String json = request.getParameter("json");
JSONObject jsonObject = new JSONObject(json);
}
String codigo = jsonObject.getString("codigo");
private void activarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException { PersonaBean bean = new PersonaBean();
response.setContentType("application/json"); bean.setCodigo(codigo);
PersonaService service = new PersonaService();
PrintWriter pw = response.getWriter(); JSONObject jsonReturn = service.activarPersona(bean);
String json = request.getParameter("json"); pw.print(jsonReturn);
JSONObject jsonObject = new JSONObject(json); }
String codigo = jsonObject.getString("codigo"); private void desactivarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException {
PersonaBean bean = new PersonaBean(); response.setContentType("application/json");
bean.setCodigo(codigo); PersonaService service = new PersonaService();
PrintWriter pw = response.getWriter();
JSONObject jsonReturn = service.activarPersona(bean);
String json = request.getParameter("json");
pw.print(jsonReturn); JSONObject jsonObject = new JSONObject(json);
}
String codigo = jsonObject.getString("codigo");
private void desactivarPersona(HttpServletRequest request, HttpServletResponse response) throws IOException { PersonaBean bean = new PersonaBean();
response.setContentType("application/json"); bean.setCodigo(codigo);
PersonaService service = new PersonaService();
PrintWriter pw = response.getWriter(); JSONObject jsonReturn = service.desactivarPersona(bean);
String json = request.getParameter("json"); pw.print(jsonReturn);
JSONObject jsonObject = new JSONObject(json); }
String codigo = jsonObject.getString("codigo"); }
PersonaBean bean = new PersonaBean();
bean.setCodigo(codigo);
JSONObject jsonReturn = service.desactivarPersona(bean);
pw.print(jsonReturn);
}
}
/* package demojsoncrud.sqlserverdao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.beans.PersonaBean;
* and open the template in the editor. import demojsoncrud.dao.PersonaDAO;
*/ import demojsoncrud.utilities.ResponseHelper;
package demojsoncrud.sqlserverdao; import java.sql.Connection;
import java.sql.PreparedStatement;
import demojsoncrud.beans.PersonaBean; import java.sql.ResultSet;
import demojsoncrud.dao.PersonaDAO; import java.sql.SQLException;
import demojsoncrud.utils.ResponseHelper; import org.json.JSONArray;
import java.sql.Connection; import org.json.JSONException;
import java.sql.PreparedStatement; import org.json.JSONObject;
import java.sql.ResultSet;
import java.sql.SQLException; public class PersonaSqlserverDAO implements PersonaDAO {
import org.json.JSONArray;
import org.json.JSONException; @Override
import org.json.JSONObject; public JSONObject listarPersonaTest() {
/** JSONObject jsonReturn = new JSONObject();
* JSONArray data = new JSONArray();
* @author Alonso ResponseHelper response = new ResponseHelper();
*/ PreparedStatement psListarPersona = null;
public class PersonaSqlserverDAO implements PersonaDAO { ResultSet rsListarPersona = null;
Connection connection = null;
@Override String base = "demojsoncrud";
public JSONObject listarPersonaTest() {
try {
JSONObject jsonReturn = new JSONObject(); connection = SqlserverDAOFactory.obtenerConexion(base);
JSONArray data = new JSONArray(); String sql
ResponseHelper response = new ResponseHelper(); = "select "
PreparedStatement psListarPersona = null; + "a.codigo, "
ResultSet rsListarPersona = null; + "a.dni, "
Connection connection = null; + "a.apellidos, "
String base = "demojsoncrud"; + "a.nombres, "
+ "a.edad, "
try { + "a.correo, "
connection = SqlserverDAOFactory.obtenerConexion(base); + "a.estado "
String sql + "from persona a ";
= "select "
+ "a.codigo, " psListarPersona = connection.prepareStatement(sql);
+ "a.dni, " rsListarPersona = psListarPersona.executeQuery();
+ "a.apellidos, "
+ "a.nombres, " while (rsListarPersona.next()) {
+ "a.edad, " PersonaBean personaBean = new PersonaBean();
+ "a.correo, " int q = 1; //Contador para las columnas
+ "a.estado " personaBean.setCodigo(rsListarPersona.getString(q++));
+ "from persona a "; personaBean.setDni(rsListarPersona.getString(q++));
personaBean.setApellidos(rsListarPersona.getString(q++));
psListarPersona = connection.prepareStatement(sql); personaBean.setNombres(rsListarPersona.getString(q++));
rsListarPersona = psListarPersona.executeQuery(); personaBean.setEdad(rsListarPersona.getString(q++));
personaBean.setCorreo(rsListarPersona.getString(q++));
while (rsListarPersona.next()) { personaBean.setEstado(rsListarPersona.getString(q++));
PersonaBean personaBean = new PersonaBean(); JSONObject obj = new JSONObject(personaBean);
int q = 1; //Contador para las columnas data.put(obj);
personaBean.setCodigo(rsListarPersona.getString(q++)); }
personaBean.setDni(rsListarPersona.getString(q++));
personaBean.setApellidos(rsListarPersona.getString(q++)); JSONObject jsonData = new JSONObject();
personaBean.setNombres(rsListarPersona.getString(q++)); jsonData.put("personas", data);
personaBean.setEdad(rsListarPersona.getString(q++));
personaBean.setCorreo(rsListarPersona.getString(q++)); response.setData(jsonData);
personaBean.setEstado(rsListarPersona.getString(q++)); response.setMessage("Listado correcto!");
JSONObject obj = new JSONObject(personaBean); response.setStatus(true);
data.put(obj);
} } catch (SQLException e) {
response.setMessage("Error -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
JSONObject jsonData = new JSONObject(); response.setStatus(false);
jsonData.put("personas", data); } finally {
try {
response.setData(jsonData); if (rsListarPersona != null) {
response.setMessage("Listado correcto!"); rsListarPersona.close();
response.setStatus(true); }
if (psListarPersona != null) {
} catch (SQLException e) { psListarPersona.close();
response.setMessage("Error -> " + e.getMessage() + " [" + e.getErrorCode() + "]"); }
response.setStatus(false); if (connection != null) {
} finally { connection.close();
try { }
if (rsListarPersona != null) { } catch (SQLException e) {
rsListarPersona.close(); response.setMessage("Error -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
} response.setStatus(false);
if (psListarPersona != null) { }
psListarPersona.close(); }
}
if (connection != null) { jsonReturn = new JSONObject(response);
connection.close();
} return jsonReturn;
} catch (SQLException e) {
response.setMessage("Error -> " + e.getMessage() + " [" + e.getErrorCode() + "]"); }
response.setStatus(false);
} @Override
} public JSONObject listarPersona(String search, String draw, String start, String length) {
JSONObject jsonReturn = new JSONObject();
jsonReturn = new JSONObject(response); JSONArray data = new JSONArray();
return jsonReturn; PreparedStatement psListarPersona = null;
ResultSet rsListarPersona = null;
} Connection connection = null;
@Override String base = "demojsoncrud";
public JSONObject listarPersona(String search, String draw, String start, String length) { String condicion = "";
JSONObject jsonReturn = new JSONObject(); String condiciones = " (a.nombres like '%" + search + "%' or a.apellidos like '%" + search + "%') ";
JSONArray data = new JSONArray();
int numeroFilas = Integer.parseInt(start) + 1; //Contador para el numero de filas a listar
PreparedStatement psListarPersona = null; int cantidadPersonas = 0;
ResultSet rsListarPersona = null;
Connection connection = null; if (!search.equals("")) {
condicion = " and " + condiciones;
String base = "demojsoncrud"; }
String condicion = "";
String condiciones = " (a.nombres like '%" + search + "%' or a.apellidos like '%" + search + "%') "; try {
connection = SqlserverDAOFactory.obtenerConexion(base);
int numeroFilas = Integer.parseInt(start) + 1; //Contador para el numero de filas a listar String sql
int cantidadPersonas = 0; = "select top " + length + " "
+ "a.codigo, "
if (!search.equals("")) { + "a.dni, "
condicion = " and " + condiciones; + "a.apellidos, "
} + "a.nombres, "
+ "a.edad, "
try { + "a.correo, "
connection = SqlserverDAOFactory.obtenerConexion(base); + "a.estado "
String sql + "from persona a "
= "select top " + length + " " + "where a.codigo not in (select top " + start + " b.codigo from persona b order by 1 desc) "
+ "a.codigo, " + condicion + " "
+ "a.dni, " + "order by 1 desc";
+ "a.apellidos, "
+ "a.nombres, " psListarPersona = connection.prepareStatement(sql);
+ "a.edad, " rsListarPersona = psListarPersona.executeQuery();
+ "a.correo, "
+ "a.estado " while (rsListarPersona.next()) {
+ "from persona a " PersonaBean personaBean = new PersonaBean();
+ "where a.codigo not in (select top " + start + " b.codigo from persona b order by 1 desc) " int c = 1; //Contador para las columnas
+ condicion + " " personaBean.setCodigo(rsListarPersona.getString(c++));
+ "order by 1 desc"; personaBean.setDni(rsListarPersona.getString(c++));
personaBean.setApellidos(rsListarPersona.getString(c++));
psListarPersona = connection.prepareStatement(sql); personaBean.setNombres(rsListarPersona.getString(c++));
rsListarPersona = psListarPersona.executeQuery(); personaBean.setEdad(rsListarPersona.getString(c++));
personaBean.setCorreo(rsListarPersona.getString(c++));
while (rsListarPersona.next()) { personaBean.setEstado(rsListarPersona.getString(c++));
PersonaBean personaBean = new PersonaBean(); JSONObject obj = new JSONObject(personaBean);
int c = 1; //Contador para las columnas data.put(obj);
personaBean.setCodigo(rsListarPersona.getString(c++));
personaBean.setDni(rsListarPersona.getString(c++)); }
personaBean.setApellidos(rsListarPersona.getString(c++)); if (!search.equals("")) {
personaBean.setNombres(rsListarPersona.getString(c++)); condicion = " where " + condiciones;
personaBean.setEdad(rsListarPersona.getString(c++)); }
personaBean.setCorreo(rsListarPersona.getString(c++));
personaBean.setEstado(rsListarPersona.getString(c++)); String sqlCantidadPersonas = "select count(1) as cantidadPersonas from persona a " + condicion;
JSONObject obj = new JSONObject(personaBean);
data.put(obj); PreparedStatement psCantidadPersonas = connection.prepareStatement(sqlCantidadPersonas);
ResultSet rsCantidadPersonas = psCantidadPersonas.executeQuery();
} rsCantidadPersonas.next();
if (!search.equals("")) { cantidadPersonas = rsCantidadPersonas.getInt("cantidadPersonas");
condicion = " where " + condiciones;
} jsonReturn.put("data", data);
jsonReturn.put("recordsFiltered", cantidadPersonas);
String sqlCantidadPersonas = "select count(1) as cantidadPersonas from persona a " + condicion; jsonReturn.put("recordsTotal", cantidadPersonas);
jsonReturn.put("draw", draw);
PreparedStatement psCantidadPersonas = connection.prepareStatement(sqlCantidadPersonas);
ResultSet rsCantidadPersonas = psCantidadPersonas.executeQuery(); } catch (SQLException | JSONException e) {
rsCantidadPersonas.next(); jsonReturn.put("Error", "Error -> " + e.getMessage());
cantidadPersonas = rsCantidadPersonas.getInt("cantidadPersonas"); } finally {
try {
jsonReturn.put("data", data); if (rsListarPersona != null) {
jsonReturn.put("recordsFiltered", cantidadPersonas); rsListarPersona.close();
jsonReturn.put("recordsTotal", cantidadPersonas); }
jsonReturn.put("draw", draw); if (psListarPersona != null) {
psListarPersona.close();
} catch (SQLException | JSONException e) { }
jsonReturn.put("Error", "Error -> " + e.getMessage()); if (connection != null) {
} finally { connection.close();
try { }
if (rsListarPersona != null) { } catch (SQLException e) {
rsListarPersona.close(); jsonReturn.put("Error", "Error inesperado -> " + e.getMessage() + " [" + e.getErrorCode() + "]");
} }
if (psListarPersona != null) { }
psListarPersona.close();
} return jsonReturn;
if (connection != null) { }
connection.close();
} @Override
} catch (SQLException e) { public JSONObject registrarPersona(PersonaBean bean) {
jsonReturn.put("Error", "Error inesperado -> " + e.getMessage() + " [" + e.getErrorCode() + "]"); JSONObject jsonReturn = new JSONObject();
} int resultDni = 0;
} int resultPersona = 0;
String base = "demojsoncrud";
return jsonReturn; PreparedStatement psInsertarPersona = null;
} Connection connection = null;
ResponseHelper response = new ResponseHelper();
@Override try {
public JSONObject registrarPersona(PersonaBean bean) { connection = SqlserverDAOFactory.obtenerConexion(base);
JSONObject jsonReturn = new JSONObject();
int resultDni = 0; String sqlGetDni = "select count(1) dni from persona where dni = ?";
int resultPersona = 0; PreparedStatement psGetDni = connection.prepareStatement(sqlGetDni);
String base = "demojsoncrud"; psGetDni.setString(1, bean.getDni());
PreparedStatement psInsertarPersona = null; ResultSet rsGetDni = psGetDni.executeQuery();
Connection connection = null; rsGetDni.next();
ResponseHelper response = new ResponseHelper(); resultDni = rsGetDni.getInt("dni");
try {
connection = SqlserverDAOFactory.obtenerConexion(base); if (resultDni == 0) {
String sql
String sqlGetDni = "select count(1) dni from persona where dni = ?"; = "insert into persona (dni, apellidos, nombres, edad, correo, estado) values "
PreparedStatement psGetDni = connection.prepareStatement(sqlGetDni); + "(?,RTRIM(UPPER(?)),RTRIM(UPPER(?)),?,RTRIM(UPPER(?)),1)";
psGetDni.setString(1, bean.getDni()); int c = 1; //contador para las columnas
ResultSet rsGetDni = psGetDni.executeQuery(); psInsertarPersona = connection.prepareStatement(sql);
rsGetDni.next(); psInsertarPersona.setString(c++, bean.getDni());
resultDni = rsGetDni.getInt("dni"); psInsertarPersona.setString(c++, bean.getApellidos());
psInsertarPersona.setString(c++, bean.getNombres());
if (resultDni == 0) { psInsertarPersona.setString(c++, bean.getEdad());
String sql psInsertarPersona.setString(c++, bean.getCorreo());
= "insert into persona (dni, apellidos, nombres, edad, correo, estado) values " resultPersona = psInsertarPersona.executeUpdate();
+ "(?,RTRIM(UPPER(?)),RTRIM(UPPER(?)),?,RTRIM(UPPER(?)),1)"; if (resultPersona == 1) {
int c = 1; //contador para las columnas response.setMessage("Registro correcto!");
psInsertarPersona = connection.prepareStatement(sql); response.setStatus(true);
psInsertarPersona.setString(c++, bean.getDni()); } else {
psInsertarPersona.setString(c++, bean.getApellidos()); response.setMessage("Error al registrar");
psInsertarPersona.setString(c++, bean.getNombres()); response.setStatus(false); // ERROR
psInsertarPersona.setString(c++, bean.getEdad()); }
psInsertarPersona.setString(c++, bean.getCorreo());
resultPersona = psInsertarPersona.executeUpdate(); } else {
if (resultPersona == 1) { response.setMessage("El documento ya existe en mi base de datos. Prueba otro.");
response.setMessage("Registro correcto!"); response.setStatus(false); // DNI REPETIDO
response.setStatus(true); }
} else {
response.setMessage("Error al registrar"); } catch (SQLException e) {
response.setStatus(false); // ERROR response.setStatus(false);
} response.setMessage("Error al registrar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
} finally {
} else { try {
response.setMessage("El documento ya existe en mi base de datos. Prueba otro."); if (connection != null) {
response.setStatus(false); // DNI REPETIDO connection.close();
} }
if (psInsertarPersona != null) {
} catch (SQLException e) { psInsertarPersona.close();
response.setStatus(false); }
response.setMessage("Error al registrar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); } catch (SQLException e) {
} finally { response.setStatus(false);
try { response.setMessage("Error al registrar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
if (connection != null) { }
connection.close(); }
}
if (psInsertarPersona != null) { jsonReturn = new JSONObject(response);
psInsertarPersona.close();
} return jsonReturn;
} catch (SQLException e) { }
response.setStatus(false);
response.setMessage("Error al registrar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); @Override
} public JSONObject editarPersona(PersonaBean bean) {
} JSONObject jsonReturn = new JSONObject();
String base = "demojsoncrud";
jsonReturn = new JSONObject(response); Connection connection = null;
PreparedStatement psEditarPersona = null;
return jsonReturn; int resultPersona = 0;
} ResponseHelper response = new ResponseHelper();
@Override try {
public JSONObject editarPersona(PersonaBean bean) { connection = SqlserverDAOFactory.obtenerConexion(base);
JSONObject jsonReturn = new JSONObject(); String sql
String base = "demojsoncrud"; = "update persona "
Connection connection = null; + "set apellidos = RTRIM(UPPER(?)), "
PreparedStatement psEditarPersona = null; + "nombres = RTRIM(UPPER(?)), "
int resultPersona = 0; + "edad = ?, "
ResponseHelper response = new ResponseHelper(); + "correo = RTRIM(UPPER(?)) "
+ "where codigo = ?";
try {
connection = SqlserverDAOFactory.obtenerConexion(base); psEditarPersona = connection.prepareStatement(sql);
String sql int q = 1; // CONTADOR PARA LAS COLUMNAS
= "update persona " psEditarPersona.setString(q++, bean.getApellidos());
+ "set apellidos = RTRIM(UPPER(?)), " psEditarPersona.setString(q++, bean.getNombres());
+ "nombres = RTRIM(UPPER(?)), " psEditarPersona.setString(q++, bean.getEdad());
+ "edad = ?, " psEditarPersona.setString(q++, bean.getCorreo());
+ "correo = RTRIM(UPPER(?)) " psEditarPersona.setString(q++, bean.getCodigo());
+ "where codigo = ?"; resultPersona = psEditarPersona.executeUpdate();
psEditarPersona = connection.prepareStatement(sql); if (resultPersona == 1) {
int q = 1; // CONTADOR PARA LAS COLUMNAS response.setMessage("Se actualizo correctamente");
psEditarPersona.setString(q++, bean.getApellidos()); response.setStatus(true); // ACTUALIZO
psEditarPersona.setString(q++, bean.getNombres()); } else {
psEditarPersona.setString(q++, bean.getEdad()); response.setMessage("Error al actualizar");
psEditarPersona.setString(q++, bean.getCorreo()); response.setStatus(false); // ERROR
psEditarPersona.setString(q++, bean.getCodigo()); }
resultPersona = psEditarPersona.executeUpdate();
} catch (SQLException e) {
if (resultPersona == 1) { response.setStatus(false);
response.setMessage("Se actualizo correctamente"); response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
response.setStatus(true); // ACTUALIZO } finally {
} else { try {
response.setMessage("Error al actualizar"); if (connection != null) {
response.setStatus(false); // ERROR connection.close();
} }
if (psEditarPersona != null) {
} catch (SQLException e) { psEditarPersona.close();
response.setStatus(false); }
response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); } catch (SQLException e) {
} finally { response.setStatus(false);
try { response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
if (connection != null) { }
connection.close(); }
}
if (psEditarPersona != null) { jsonReturn = new JSONObject(response);
psEditarPersona.close();
} return jsonReturn;
} catch (SQLException e) { }
response.setStatus(false);
response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); @Override
} public JSONObject activarPersona(PersonaBean bean) {
} JSONObject jsonReturn = new JSONObject();
String base = "demojsoncrud";
jsonReturn = new JSONObject(response); Connection connection = null;
PreparedStatement psEditarPersona = null;
return jsonReturn; int resultPersona = 0;
} ResponseHelper response = new ResponseHelper();
@Override try {
public JSONObject activarPersona(PersonaBean bean) { connection = SqlserverDAOFactory.obtenerConexion(base);
JSONObject jsonReturn = new JSONObject(); String sql
String base = "demojsoncrud"; = "update persona "
Connection connection = null; + "set estado = 1 "
PreparedStatement psEditarPersona = null; + "where codigo = ?";
int resultPersona = 0;
ResponseHelper response = new ResponseHelper(); psEditarPersona = connection.prepareStatement(sql);
try { psEditarPersona.setString(1, bean.getCodigo());
connection = SqlserverDAOFactory.obtenerConexion(base); resultPersona = psEditarPersona.executeUpdate();
String sql
= "update persona " if (resultPersona == 1) {
+ "set estado = 1 " response.setMessage("Se actualizo correctamente");
+ "where codigo = ?"; response.setStatus(true); // ACTUALIZO
} else {
psEditarPersona = connection.prepareStatement(sql); response.setMessage("Error al actualizar");
response.setStatus(false); // ERROR
psEditarPersona.setString(1, bean.getCodigo()); }
resultPersona = psEditarPersona.executeUpdate();
} catch (SQLException e) {
if (resultPersona == 1) { response.setStatus(false);
response.setMessage("Se actualizo correctamente"); response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
response.setStatus(true); // ACTUALIZO } finally {
} else { try {
response.setMessage("Error al actualizar"); if (connection != null) {
response.setStatus(false); // ERROR connection.close();
} }
if (psEditarPersona != null) {
} catch (SQLException e) { psEditarPersona.close();
response.setStatus(false); }
response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); } catch (SQLException e) {
} finally { response.setStatus(false);
try { response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
if (connection != null) { }
connection.close(); }
}
if (psEditarPersona != null) { jsonReturn = new JSONObject(response);
psEditarPersona.close();
} return jsonReturn;
} catch (SQLException e) { }
response.setStatus(false);
response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); @Override
} public JSONObject desactivarPersona(PersonaBean bean) {
} JSONObject jsonReturn = new JSONObject();
String base = "demojsoncrud";
jsonReturn = new JSONObject(response); Connection connection = null;
PreparedStatement psEditarPersona = null;
return jsonReturn; int resultPersona = 0;
} ResponseHelper response = new ResponseHelper();
@Override try {
public JSONObject desactivarPersona(PersonaBean bean) { connection = SqlserverDAOFactory.obtenerConexion(base);
JSONObject jsonReturn = new JSONObject(); String sql
String base = "demojsoncrud"; = "update persona "
Connection connection = null; + "set estado = 0 "
PreparedStatement psEditarPersona = null; + "where codigo = ?";
int resultPersona = 0;
ResponseHelper response = new ResponseHelper(); psEditarPersona = connection.prepareStatement(sql);
psEditarPersona.setString(1, bean.getCodigo());
try { resultPersona = psEditarPersona.executeUpdate();
connection = SqlserverDAOFactory.obtenerConexion(base);
String sql if (resultPersona == 1) {
= "update persona " response.setMessage("Se actualizo correctamente");
+ "set estado = 0 " response.setStatus(true); // ACTUALIZO
+ "where codigo = ?"; } else {
response.setMessage("Error al actualizar");
psEditarPersona = connection.prepareStatement(sql); response.setStatus(false); // ERROR
psEditarPersona.setString(1, bean.getCodigo()); }
resultPersona = psEditarPersona.executeUpdate();
} catch (SQLException e) {
if (resultPersona == 1) { response.setStatus(false);
response.setMessage("Se actualizo correctamente"); response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
response.setStatus(true); // ACTUALIZO } finally {
} else { try {
response.setMessage("Error al actualizar"); if (connection != null) {
response.setStatus(false); // ERROR connection.close();
} }
if (psEditarPersona != null) {
} catch (SQLException e) { psEditarPersona.close();
response.setStatus(false); }
response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]"); } catch (SQLException e) {
} finally { response.setStatus(false);
try { response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
if (connection != null) { }
connection.close(); }
}
if (psEditarPersona != null) { jsonReturn = new JSONObject(response);
psEditarPersona.close(); return jsonReturn;
} }
} catch (SQLException e) {
response.setStatus(false); }
response.setMessage("Error al actualizar -> " + e.getMessage() + "[" + e.getErrorCode() + "]");
}
}
jsonReturn = new JSONObject(response);
return jsonReturn;
}
}
/* package demojsoncrud.sqlserverdao;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import demojsoncrud.dao.DAOFactory;
* and open the template in the editor. import demojsoncrud.dao.PersonaDAO;
*/ import java.sql.Connection;
package demojsoncrud.sqlserverdao; import java.sql.DriverManager;
import java.sql.SQLException;
import demojsoncrud.dao.DAOFactory;
import demojsoncrud.dao.PersonaDAO; public class SqlserverDAOFactory extends DAOFactory {
import java.sql.Connection;
import java.sql.DriverManager; public static Connection obtenerConexion(String base) {
import java.sql.SQLException; Connection connection = null;
if (base.equalsIgnoreCase("demojsoncrud")) {
/** String user = "sa";
* String pwd = "Saco1357$";
* @author Alonso String url = "jdbc:sqlserver://172.16.2.118:1433;databaseName=demojsoncrud";
*/ String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
public class SqlserverDAOFactory extends DAOFactory { try {
Class.forName(driver);
public static Connection obtenerConexion(String base) { connection = DriverManager.getConnection(url, user, pwd);
Connection connection = null; } catch (ClassNotFoundException | SQLException e) {
if (base.equalsIgnoreCase("demojsoncrud")) { System.out.println("Error al conectarse => " + e.getMessage());
String user = "sa"; }
String pwd = "Saco1357$"; }
String url = "jdbc:sqlserver://localhost:1433;databaseName=demojsoncrud";
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; return connection;
try { }
Class.forName(driver);
connection = DriverManager.getConnection(url, user, pwd); // public static void main(String[] args) {
} catch (ClassNotFoundException | SQLException e) { // SqlserverDAOFactory sqlserverDAOFactory = new SqlserverDAOFactory();
System.out.println("Error al conectarse => " + e.getMessage()); // System.out.println(sqlserverDAOFactory.obtenerConexion("demojsoncrud"));
} // }
} @Override
public PersonaDAO getPersonaDAO() {
return connection; return new PersonaSqlserverDAO();
} }
}
// public static void main(String[] args) {
// SqlserverDAOFactory sqlserverDAOFactory = new SqlserverDAOFactory();
// System.out.println(sqlserverDAOFactory.obtenerConexion("demojsoncrud"));
// }
@Override
public PersonaDAO getPersonaDAO() {
return new PersonaSqlserverDAO();
}
}
/* package demojsoncrud.utilities;
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates import java.io.Serializable;
* and open the template in the editor. import org.json.JSONObject;
*/
package demojsoncrud.utils; public class ResponseHelper implements Serializable {
import java.io.Serializable; private JSONObject data;
import org.json.JSONObject; private boolean status;
private String message;
/**
* public ResponseHelper() {
* @author Alonso
*/ }
public class ResponseHelper implements Serializable {
public JSONObject getData() {
private JSONObject data; return data;
private boolean status; }
private String message;
public boolean isStatus() {
public ResponseHelper() { return status;
}
}
public String getMessage() {
public JSONObject getData() { return message;
return data; }
}
public void setData(JSONObject data) {
public boolean isStatus() { this.data = data;
return status; }
}
public void setStatus(boolean status) {
public String getMessage() { this.status = status;
return message; }
}
public void setMessage(String message) {
public void setData(JSONObject data) { this.message = message;
this.data = data; }
}
}
public void setStatus(boolean status) {
this.status = status;
}
public void setMessage(String message) {
this.message = message;
}
}
/* $(document).ready(function () {
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates listarPersonaTest();
* and open the template in the editor. initInputs();
*/ init(); // METODOS CRUD
MyValidate();
filtrarPersona();
$(document).ready(function () {
$('#btn_agregar_persona').on('click', function () {
listarPersonaTest(); limpiarInputs();
initInputs(); });
init(); // METODOS CRUD
MyValidate(); });
filtrarPersona();
var codigoPersona;
$('#btn_agregar_persona').on('click', function () {
limpiarInputs(); function init() {
}); listarPersona();
registrarPersona();
editarPersona();
}
});
function listarPersonaTest() {
var codigoPersona; $.ajax({
url: '../PersonaServlet?accion=listarPersonaTest',
function init() { type: 'POST',
listarPersona(); beforeSend: function (xhr) {
registrarPersona(); // console.log('Antes de...');
editarPersona(); }, success: function (data, textStatus, jqXHR) {
} console.log(data);
// var personas = data.data.personas;
function listarPersonaTest() { // for (var i = 0; i < personas.length; i++) {
$.ajax({ // var persona = personas[i];
url: '../PersonaServlet?accion=listarPersonaTest', // console.log(persona.apellidos);
type: 'POST', // }
beforeSend: function (xhr) { //// console.log("listadoTest");
// console.log('Antes de...'); }, complete: function (jqXHR, textStatus) {
}, success: function (data, textStatus, jqXHR) { // console.log('Siempre ejecutará esta función');
console.log(data); }
// var personas = data.data.personas; });
// for (var i = 0; i < personas.length; i++) { }
// var persona = personas[i];
// console.log(persona.apellidos); function registrarPersona() {
// } $('#btn_registrar_persona').on('click', function () {
//// console.log("listadoTest");
}, complete: function (jqXHR, textStatus) { var validator = $('#form_registrar_persona').validate({
// console.log('Siempre ejecutará esta función');
} rules: {
}); txt_numero_documento: {required: true, digits: true, minlength: 8, maxlength: 8},
} txt_apellidos: {required: true, lettersonly: true, maxlength: 50},
txt_nombres: {required: true, lettersonly: true, maxlength: 50},
function registrarPersona() { txt_edad: {required: true, digits: true, maxlength: 2},
$('#btn_registrar_persona').on('click', function () { txt_correo: {required: true, email: true, maxlength: 50}
},
var validator = $('#form_registrar_persona').validate({ messages: {
txt_numero_documento: {required: "Ingresar número de documento.", minlength: "Ingresar 8 dígitos.", maxlength: "Ingresar 8 dígitos.", digits: "Ingresar solo números."},
rules: { txt_apellidos: {required: "Ingresar apellidos.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"},
txt_numero_documento: {required: true, digits: true, minlength: 8, maxlength: 8}, txt_nombres: {required: "Ingresar nombres.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"},
txt_apellidos: {required: true, lettersonly: true, maxlength: 50}, txt_edad: {required: "Ingresar edad.", maxlength: "Ingresar 2 dígitos como máximo", digits: "Ingresar solo números"},
txt_nombres: {required: true, lettersonly: true, maxlength: 50}, txt_correo: {required: "Ingresar correo.", maxlength: "Ingresar 50 letras como máximo.", email: "Ingresar un correo válido"}
txt_edad: {required: true, digits: true, maxlength: 2}, }
txt_correo: {required: true, email: true, maxlength: 50} });
},
messages: { var estado = validator.form();
txt_numero_documento: {required: "Ingresar número de documento.", minlength: "Ingresar 8 dígitos.", maxlength: "Ingresar 8 dígitos.", digits: "Ingresar solo números."}, if (estado) {
txt_apellidos: {required: "Ingresar apellidos.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"}, var json = {
txt_nombres: {required: "Ingresar nombres.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"}, dni: $('#txt_numero_documento').val().trim(),
txt_edad: {required: "Ingresar edad.", maxlength: "Ingresar 2 dígitos como máximo", digits: "Ingresar solo números"}, apellidos: $('#txt_apellidos').val().trim(),
txt_correo: {required: "Ingresar correo.", maxlength: "Ingresar 50 letras como máximo.", email: "Ingresar un correo válido"} nombres: $('#txt_nombres').val().trim(),
} edad: $('#txt_edad').val().trim(),
}); correo: $('#txt_correo').val().trim()
};
var estado = validator.form();
if (estado) { $.ajax({
var json = { type: 'POST',
dni: $('#txt_numero_documento').val().trim(), url: '../PersonaServlet?accion=registrarPersona',
apellidos: $('#txt_apellidos').val().trim(), dataType: 'json',
nombres: $('#txt_nombres').val().trim(), data: {json: JSON.stringify(json)},
edad: $('#txt_edad').val().trim(), beforeSend: function (xhr) {
correo: $('#txt_correo').val().trim() console.log('cargando...');
}; },
success: function (data, textStatus, jqXHR) {
$.ajax({ console.log(data);
type: 'POST', var status = data.status;
url: '../PersonaServlet?accion=registrarPersona', if (status) {
dataType: 'json', imprimirAlerta('Correcto!', data.message, 'success');
data: {json: JSON.stringify(json)}, // var table = $('#tabla_persona').DataTable();
beforeSend: function (xhr) { // table.ajax.reload();
console.log('cargando...'); recargarTabla();
}, $('#modal_registrar_persona').modal('hide');
success: function (data, textStatus, jqXHR) { } else {
console.log(data); imprimirAlerta('Error!', data.message, 'error');
var status = data.status; }
if (status) {
imprimirAlerta('Correcto!', data.message, 'success'); },
// var table = $('#tabla_persona').DataTable(); complete: function (jqXHR, textStatus) {
// table.ajax.reload();
recargarTabla(); }
$('#modal_registrar_persona').modal('hide'); });
} else {
imprimirAlerta('Error!', data.message, 'error'); }
}
});
}, }
complete: function (jqXHR, textStatus) {
function editarPersona() {
} $('#btn_editar_persona').on('click', function () {
});
var validator = $('#form_editar_persona').validate({
}
rules: {
}); txt_apellidos_editar: {required: true, lettersonly: true, maxlength: 50},
} txt_nombres_editar: {required: true, lettersonly: true, maxlength: 50},
txt_edad_editar: {required: true, digits: true, maxlength: 2},
function editarPersona() { txt_correo_editar: {required: true, email: true, maxlength: 50}
$('#btn_editar_persona').on('click', function () { },
messages: {
var validator = $('#form_editar_persona').validate({ txt_apellidos_editar: {required: "Ingresar apellidos.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"},
txt_nombres_editar: {required: "Ingresar nombres.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"},
rules: { txt_edad_editar: {required: "Ingresar edad.", maxlength: "Ingresar 2 dígitos como máximo", digits: "Ingresar solo números"},
txt_apellidos_editar: {required: true, lettersonly: true, maxlength: 50}, txt_correo_editar: {required: "Ingresar correo.", maxlength: "Ingresar 50 letras como máximo.", email: "Ingresar un correo válido"}
txt_nombres_editar: {required: true, lettersonly: true, maxlength: 50}, }
txt_edad_editar: {required: true, digits: true, maxlength: 2}, });
txt_correo_editar: {required: true, email: true, maxlength: 50}
}, var estado = validator.form();
messages: {
txt_apellidos_editar: {required: "Ingresar apellidos.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"}, if (estado) {
txt_nombres_editar: {required: "Ingresar nombres.", maxlength: "Ingresar 50 letras como máximo.", lettersonly: "Ingresar solo letras"}, var json = {
txt_edad_editar: {required: "Ingresar edad.", maxlength: "Ingresar 2 dígitos como máximo", digits: "Ingresar solo números"}, apellidos: $('#txt_apellidos_editar').val().trim(),
txt_correo_editar: {required: "Ingresar correo.", maxlength: "Ingresar 50 letras como máximo.", email: "Ingresar un correo válido"} nombres: $('#txt_nombres_editar').val().trim(),
} edad: $('#txt_edad_editar').val().trim(),
}); correo: $('#txt_correo_editar').val().trim(),
codigo: codigoPersona
var estado = validator.form(); };
$.ajax({
if (estado) { type: 'POST',
var json = { url: '../PersonaServlet?accion=editarPersona',
apellidos: $('#txt_apellidos_editar').val().trim(), dataType: 'json',
nombres: $('#txt_nombres_editar').val().trim(), data: {json: JSON.stringify(json)},
edad: $('#txt_edad_editar').val().trim(), beforeSend: function (xhr) {
correo: $('#txt_correo_editar').val().trim(), console.log('cargando...');
codigo: codigoPersona },
}; success: function (data, textStatus, jqXHR) {
$.ajax({ console.log(data);
type: 'POST', var status = data.status;
url: '../PersonaServlet?accion=editarPersona', if (status) {
dataType: 'json', imprimirAlerta('Correcto!', data.message, 'success');
data: {json: JSON.stringify(json)}, recargarTabla();
beforeSend: function (xhr) { $('#modal_editar_persona').modal('hide');
console.log('cargando...'); } else {
}, imprimirAlerta('Error!', data.message, 'error');
success: function (data, textStatus, jqXHR) { }
console.log(data); },
var status = data.status; complete: function (jqXHR, textStatus) {
if (status) { }
imprimirAlerta('Correcto!', data.message, 'success'); });
recargarTabla(); }
$('#modal_editar_persona').modal('hide'); });
} else { }
imprimirAlerta('Error!', data.message, 'error');
} function listarPersona() {
}, var txt_criterio_busqueda = $('#txt_criterio_busqueda').val().trim();
complete: function (jqXHR, textStatus) {
} var tabla_persona = $('#tabla_persona').DataTable({
}); language: {
} paginate: {'next': '&rarr; ', 'previous': ' &larr;'},
}); emptyTable: 'No hay registros'
} },
ajax: {
function listarPersona() { url: '../PersonaServlet?accion=listarPersona',
type: 'POST',
var txt_criterio_busqueda = $('#txt_criterio_busqueda').val().trim(); dataType: 'json',
data: {
search: txt_criterio_busqueda
var tabla_persona = $('#tabla_persona').DataTable({ }
language: { },
paginate: {'next': '&rarr; ', 'previous': ' &larr;'}, processing: true,
emptyTable: 'No hay registros' serverSide: true,
}, responsive: true,
ajax: { iDisplayLength: 10,
url: '../PersonaServlet?accion=listarPersona', bSort: false,
type: 'POST', bInfo: false,
dataType: 'json', searching: false,
data: {search: txt_criterio_busqueda} bLengthChange: false,
}, bFilter: false,
processing: true,
serverSide: true, aaSorting: [],
responsive: true, ordering: false,
iDisplayLength: 10, scrollX: false,
bSort: false, ScrollCollapse: true,
bInfo: false,
searching: false, columns: [
bLengthChange: false, {data: "codigo"},
bFilter: false, {data: "dni"},
{
aaSorting: [], data: null,
ordering: false, render: function (data, type, row) {
scrollX: false, return data.apellidos + ", " + data.nombres;
ScrollCollapse: true, }
},
columns: [ {data: "edad", className: 'text-center'},
{data: "codigo"}, {data: "correo"},
{data: "dni"}, {
{ data: "estado",
data: null, className: 'text-center',
render: function (data, type, row) { render: function (data, type, row) {
return data.apellidos + ", " + data.nombres; return data === "1" ? '<span class="label label-success">activo</span>' : '<span class="label label-danger">inactivo</span>';
} }
}, },
{data: "edad", className: 'text-center'}, {
{data: "correo"}, data: null,
{ className: 'text-center',
data: "estado", render: function (data, type, row) {
className: 'text-center', return data.estado === "1" ? '<ul class="icons-list"><li title="Editar" data-toggle="modal" data-target="#modal_editar_persona" class="text-primary-600"><a href="#" class="editarPersona"><i class="icon-pencil7"></i></a></li><li title="Desactivar" class="text-success-600"><a href="#" class="desactivarPersona"><i class="icon-switch2"></i></a></li></ul>' : '<ul class="icons-list"><li title="Editar" data-toggle="modal" data-target="#modal_editar_persona" class="text-primary-600"><a href="#" class="editarPersona"><i class="icon-pencil7"></i></a></li><li title="Activar" class="text-danger-600"><a href="#" class="activarPersona"><i class="icon-switch2"></i></a></li></ul>';
render: function (data, type, row) { }
return data === "1" ? '<span class="label label-success">activo</span>' : '<span class="label label-danger">inactivo</span>'; }
} ],
}, fnRowCallback: function (row, data, displayIndex, displayIndexFull) {
{
data: null, },
className: 'text-center', fnPreDrawCallback: function (settings) {
render: function (data, type, row) { },
return data.estado === "1" ? '<ul class="icons-list"><li title="Editar" data-toggle="modal" data-target="#modal_editar_persona" class="text-primary-600"><a href="#" class="editarPersona"><i class="icon-pencil7"></i></a></li><li title="Desactivar" class="text-success-600"><a href="#" class="desactivarPersona"><i class="icon-switch2"></i></a></li></ul>' : '<ul class="icons-list"><li title="Editar" data-toggle="modal" data-target="#modal_editar_persona" class="text-primary-600"><a href="#" class="editarPersona"><i class="icon-pencil7"></i></a></li><li title="Activar" class="text-danger-600"><a href="#" class="activarPersona"><i class="icon-switch2"></i></a></li></ul>'; fnDrawCallback: function (settings) {
}
} },
], createdRow: function (row, data, dataIndex) {
fnRowCallback: function (row, data, displayIndex, displayIndexFull) {
},
}, initComplete: function (settings, json) {
fnPreDrawCallback: function (settings) {
}, }
fnDrawCallback: function (settings) { });
}
},
createdRow: function (row, data, dataIndex) { $('#tabla_persona tbody').on('click', '.editarPersona', function () {
var data_row = $('#tabla_persona').DataTable().row($(this).parents('tr')).data();
}, console.log(data_row);
initComplete: function (settings, json) { codigoPersona = '';
$('#txt_numero_documento_editar').val(data_row.dni);
} $('#txt_apellidos_editar').val(data_row.apellidos);
}); $('#txt_nombres_editar').val(data_row.nombres);
} $('#txt_edad_editar').val(data_row.edad);
$('#txt_correo_editar').val(data_row.correo);
$('#tabla_persona tbody').on('click', '.editarPersona', function () { codigoPersona = data_row.codigo;
var data_row = $('#tabla_persona').DataTable().row($(this).parents('tr')).data(); });
console.log(data_row);
codigoPersona = ''; $('#tabla_persona tbody').on('click', '.desactivarPersona', function () {
$('#txt_numero_documento_editar').val(data_row.dni);
$('#txt_apellidos_editar').val(data_row.apellidos); var data_row = $('#tabla_persona').DataTable().row($(this).parents('tr')).data();
$('#txt_nombres_editar').val(data_row.nombres); var json = {
$('#txt_edad_editar').val(data_row.edad); codigo: data_row.codigo
$('#txt_correo_editar').val(data_row.correo); };
codigoPersona = data_row.codigo;
}); swal({
title: "¿Estás seguro?",
$('#tabla_persona tbody').on('click', '.desactivarPersona', function () { text: "¿Desea desactivar a " + data_row.apellidos + ", " + data_row.nombres + " ?",
type: "warning",
var data_row = $('#tabla_persona').DataTable().row($(this).parents('tr')).data(); showCancelButton: true,
var json = { confirmButtonColor: "#EF5350",
codigo: data_row.codigo confirmButtonText: "Si!",
}; cancelButtonText: "No!",
closeOnConfirm: false,
swal({ closeOnCancel: true
title: "¿Estás seguro?", },
text: "¿Desea desactivar a " + data_row.apellidos + ", " + data_row.nombres + " ?", function (isConfirm) {
type: "warning", if (isConfirm) {
showCancelButton: true, $.ajax({
confirmButtonColor: "#EF5350", url: '../PersonaServlet?accion=desactivarPersona',
confirmButtonText: "Si!", type: 'POST',
cancelButtonText: "No!", dataType: 'json',
closeOnConfirm: false, data: {json: JSON.stringify(json)},
closeOnCancel: true beforeSend: function (xhr) {
}, },
function (isConfirm) { success: function (data, textStatus, jqXHR) {
if (isConfirm) { console.log(data);
$.ajax({ var status = data.status;
url: '../PersonaServlet?accion=desactivarPersona', if (status) {
type: 'POST', imprimirAlerta('Desactivado!', data_row.apellidos + ', ' + data_row.nombres + ' fue desactivado con exito!', 'success');
dataType: 'json', recargarTabla();
data: {json: JSON.stringify(json)}, } else {
beforeSend: function (xhr) { imprimirAlerta('Error!', data.message, 'error');
}, }
success: function (data, textStatus, jqXHR) {
console.log(data); }
var status = data.status; });
if (status) { }
imprimirAlerta('Desactivado!', data_row.apellidos + ', ' + data_row.nombres + ' fue desactivado con exito!', 'success'); });
recargarTabla();
} else { });
imprimirAlerta('Error!', data.message, 'error');
} $('#tabla_persona tbody').on('click', '.activarPersona', function () {
} var data_row = $('#tabla_persona').DataTable().row($(this).parents('tr')).data();
}); var json = {
} codigo: data_row.codigo
}); };
}); swal({
title: "¿Estás seguro?",
$('#tabla_persona tbody').on('click', '.activarPersona', function () { text: "¿Desea activar a " + data_row.apellidos + ", " + data_row.nombres + " ?",
type: "warning",
var data_row = $('#tabla_persona').DataTable().row($(this).parents('tr')).data(); showCancelButton: true,
var json = { confirmButtonColor: "#EF5350",
codigo: data_row.codigo confirmButtonText: "Si!",
}; cancelButtonText: "No!",
closeOnConfirm: false,
swal({ closeOnCancel: true
title: "¿Estás seguro?", },
text: "¿Desea activar a " + data_row.apellidos + ", " + data_row.nombres + " ?", function (isConfirm) {
type: "warning", if (isConfirm) {
showCancelButton: true, $.ajax({
confirmButtonColor: "#EF5350", url: '../PersonaServlet?accion=activarPersona',
confirmButtonText: "Si!", type: 'POST',
cancelButtonText: "No!", dataType: 'json',
closeOnConfirm: false, data: {json: JSON.stringify(json)},
closeOnCancel: true beforeSend: function (xhr) {
}, },
function (isConfirm) { success: function (data, textStatus, jqXHR) {
if (isConfirm) { console.log(data);
$.ajax({ var status = data.status;
url: '../PersonaServlet?accion=activarPersona', if (status) {
type: 'POST', imprimirAlerta('Activado!', data_row.apellidos + ', ' + data_row.nombres + ' fue activado con exito!', 'success');
dataType: 'json', recargarTabla();
data: {json: JSON.stringify(json)}, } else {
beforeSend: function (xhr) { imprimirAlerta('Error!', data.message, 'error');
}, }
success: function (data, textStatus, jqXHR) {
console.log(data); }
var status = data.status; });
if (status) { }
imprimirAlerta('Activado!', data_row.apellidos + ', ' + data_row.nombres + ' fue activado con exito!', 'success'); });
recargarTabla(); });
} else {
imprimirAlerta('Error!', data.message, 'error'); function initInputs() {
}
var txt_correo = $('#txt_correo');
} var txt_correo_editar = $('#txt_correo_editar');
});
} txt_correo_editar.attr({
}); disabled: true
}); });
txt_correo.attr({
function initInputs() { disabled: true
});
var txt_correo = $('#txt_correo'); }
var txt_correo_editar = $('#txt_correo_editar');
function imprimirAlerta(title, text, type) {
txt_correo_editar.attr({ var s_col = "#66BB6A";
disabled: true var e_col = "#EF5350";
}); var w_col = "#FF7043";
txt_correo.attr({ var btnCol;
disabled: true
}); if (type === 'error') {
} btnCol = e_col;
} else if (type === 'warning') {
function imprimirAlerta(title, text, type) { btnCol = w_col;
var s_col = "#66BB6A"; } else {
var e_col = "#EF5350"; btnCol = s_col;
var w_col = "#FF7043"; }
var btnCol;
swal({
if (type === 'error') { title: title,
btnCol = e_col; text: text,
} else if (type === 'warning') { confirmButtonColor: btnCol,
btnCol = w_col; type: type
} else { });
btnCol = s_col;
} }
swal({ function recargarTabla() {
title: title,
text: text, $('#tabla_persona').DataTable().destroy();
confirmButtonColor: btnCol, listarPersona();
type: type }
});
function filtrarPersona() {
} // PRIMERA FORMA: CON BOTON
$('#btn_buscar_criterio').on('click', function () {
function recargarTabla() { recargarTabla();
});
$('#tabla_persona').DataTable().destroy();
listarPersona(); // SEGUNDA FORMA: MIENTRAS SE ESCRIBE
} // $('#txt_criterio_busqueda').keyup(function (e) {
// recargarTabla();
function filtrarPersona() { // });
// PRIMERA FORMA: CON BOTON
$('#btn_buscar_criterio').on('click', function () { // TERCERA FORMA: PRESIONANDO ENTER
recargarTabla(); $('#txt_criterio_busqueda').keyup(function (e) {
}); if (e.keyCode === 13) {
recargarTabla();
// SEGUNDA FORMA: MIENTRAS SE ESCRIBE }
// $('#txt_criterio_busqueda').keyup(function (e) { });
// recargarTabla(); }
// });
function limpiarInputs() {
// TERCERA FORMA: PRESIONANDO ENTER $('#txt_numero_documento').attr({
$('#txt_criterio_busqueda').keyup(function (e) { autofocus: true
if (e.keyCode === 13) { });
recargarTabla(); $('#txt_numero_documento').val('');
} $('#txt_apellidos').val('');
}); $('#txt_nombres').val('');
} $('#txt_edad').val('');
$('#txt_correo').val('');
function limpiarInputs() {
$('#txt_numero_documento').attr({ }
autofocus: true
}); function MyValidate() {
$('#txt_numero_documento').val('');
$('#txt_apellidos').val(''); function stripHtml(value) {
$('#txt_nombres').val(''); // remove html tags and space chars
$('#txt_edad').val(''); return value.replace(/<.[^<>]*?>/g, ' ').replace(/&nbsp;|&#160;/gi, ' ')
$('#txt_correo').val(''); // remove numbers and punctuation
.replace(/[0-9.(),;:!?%#$'"_+=\/-]*/g, '');
} }
function MyValidate() { jQuery.validator.addMethod("lettersonly", function (value, element) {
return this.optional(element) || /^[a-z\s]+$/i.test(value);
function stripHtml(value) { }, "Solo letras.");
// remove html tags and space chars
return value.replace(/<.[^<>]*?>/g, ' ').replace(/&nbsp;|&#160;/gi, ' ') jQuery.validator.setDefaults({
// remove numbers and punctuation debug: true,
.replace(/[0-9.(),;:!?%#$'"_+=\/-]*/g, ''); ignore: 'input[type=hidden], .select2-search__field', // ignore hidden fields
} errorClass: 'validation-error-label',
successClass: 'validation-valid-label',
jQuery.validator.addMethod("lettersonly", function (value, element) { highlight: function (element, errorClass) {
return this.optional(element) || /^[a-z\s]+$/i.test(value); $(element).removeClass(errorClass);
}, "Solo letras."); },
unhighlight: function (element, errorClass) {
$(element).removeClass(errorClass);
},
// Different components require proper error label placement
jQuery.validator.setDefaults({ errorPlacement: function (error, element) {
debug: true,
ignore: 'input[type=hidden], .select2-search__field', // ignore hidden fields // Styled checkboxes, radios, bootstrap switch
errorClass: 'validation-error-label', if (element.parents('div').hasClass("checker") || element.parents('div').hasClass("choice") || element.parent().hasClass('bootstrap-switch-container')) {
successClass: 'validation-valid-label', if (element.parents('label').hasClass('checkbox-inline') || element.parents('label').hasClass('radio-inline')) {
highlight: function (element, errorClass) { error.appendTo(element.parent().parent().parent().parent());
$(element).removeClass(errorClass); } else {
}, error.appendTo(element.parent().parent().parent().parent().parent());
unhighlight: function (element, errorClass) { }
$(element).removeClass(errorClass); }
},
// Different components require proper error label placement // Unstyled checkboxes, radios
errorPlacement: function (error, element) { else if (element.parents('div').hasClass('checkbox') || element.parents('div').hasClass('radio')) {
error.appendTo(element.parent().parent().parent());
// Styled checkboxes, radios, bootstrap switch }
if (element.parents('div').hasClass("checker") || element.parents('div').hasClass("choice") || element.parent().hasClass('bootstrap-switch-container')) {
if (element.parents('label').hasClass('checkbox-inline') || element.parents('label').hasClass('radio-inline')) { // Input with icons and Select2
error.appendTo(element.parent().parent().parent().parent()); else if (element.parents('div').hasClass('has-feedback') || element.hasClass('select2-hidden-accessible')) {
} else { error.appendTo(element.parent());
error.appendTo(element.parent().parent().parent().parent().parent()); }
}
} // Inline checkboxes, radios
else if (element.parents('label').hasClass('checkbox-inline') || element.parents('label').hasClass('radio-inline')) {
// Unstyled checkboxes, radios error.appendTo(element.parent().parent());
else if (element.parents('div').hasClass('checkbox') || element.parents('div').hasClass('radio')) { }
error.appendTo(element.parent().parent().parent());
} // Input group, styled file input
else if (element.parent().hasClass('uploader') || element.parents().hasClass('input-group')) {
// Input with icons and Select2 error.appendTo(element.parent().parent());
else if (element.parents('div').hasClass('has-feedback') || element.hasClass('select2-hidden-accessible')) { } else {
error.appendTo(element.parent()); error.insertAfter(element);
} }
}
// Inline checkboxes, radios });
else if (element.parents('label').hasClass('checkbox-inline') || element.parents('label').hasClass('radio-inline')) {
error.appendTo(element.parent().parent()); }
}
function initInputs() {
// Input group, styled file input
else if (element.parent().hasClass('uploader') || element.parents().hasClass('input-group')) { var txt_numero_documento = $('#txt_numero_documento');
error.appendTo(element.parent().parent()); var txt_apellidos = $('#txt_apellidos');
} else { var txt_nombres = $('#txt_nombres');
error.insertAfter(element); var txt_edad = $('#txt_edad');
} var txt_correo = $('#txt_correo');
} var dominio_correo = '.TI@SACOOLIVEROS.EDU.PE';
});
// txt_correo.attr({
} // disabled: true
// });
function initInputs() {
var txt_numero_documento = $('#txt_numero_documento');
var txt_apellidos = $('#txt_apellidos');
var txt_nombres = $('#txt_nombres');
var txt_edad = $('#txt_edad');
var txt_correo = $('#txt_correo');
var dominio_correo = '.TI@SACOOLIVEROS.EDU.PE';
// txt_correo.attr({
// disabled: true
// });
} }
\ No newline at end of file
<%-- <%--
Document : index Document : index
Created on : 05-ene-2018, 20:49:32 Created on : 05-ene-2018, 20:49:32
Author : Alonso Author : Alonso
--%> --%>
<%@page contentType="text/html" pageEncoding="UTF-8"%> <%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<%@include file="templates/header.jsp" %> <%@include file="templates/header.jsp" %>
<!--template-core--> <!--template-core-->
<!--css--> <!--css-->
<!--css--> <!--css-->
</head> </head>
<body> <body>
<%@include file="templates/header-body.jsp" %> <%@include file="templates/header-body.jsp" %>
<!-- content --> <!-- content -->
<div class="row"> <div class="row">
<div class="col-md-6 col-md-offset-3"> <div class="col-md-6 col-md-offset-3">
<div class="panel panel-flat border-top-xlg border-top-primary"> <div class="panel panel-flat border-top-xlg border-top-primary">
<div class="panel-heading"> <div class="panel-heading">
<h6 class="panel-title text-semibold"><i class="icon-cog3 position-left"></i> Mantenimiento persona</h6> <h6 class="panel-title text-semibold"><i class="icon-cog3 position-left"></i> Mantenimiento persona</h6>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="form-group"> <div class="form-group">
<label class="control-label display-block">Ingresar criterio de búsqueda: </label> <label class="control-label display-block">Ingresar criterio de búsqueda: </label>
<div class="input-group input-group-xlg"> <div class="input-group input-group-xlg">
<span class="input-group-addon"><i class="icon-search4"></i></span> <span class="input-group-addon"><i class="icon-search4"></i></span>
<input id="txt_criterio_busqueda" type="text" class="form-control" placeholder="Ingresar criterio"> <input id="txt_criterio_busqueda" type="text" class="form-control" placeholder="Ingresar criterio">
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<button id="btn_buscar_criterio" type="button" class="btn btn-primary"><i class="icon-search4 position-left"></i> Buscar</button> <button id="btn_buscar_criterio" type="button" class="btn btn-primary"><i class="icon-search4 position-left"></i> Buscar</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-10 col-md-offset-1"> <div class="col-md-10 col-md-offset-1">
<div class="panel panel-flat border-top-xlg border-top-primary"> <div class="panel panel-flat border-top-xlg border-top-primary">
<div class="panel-heading"> <div class="panel-heading">
<h6 class="panel-title text-semibold"><i class=" icon-list3 position-left"></i> Listado persona</h6> <h6 class="panel-title text-semibold"><i class=" icon-list3 position-left"></i> Listado persona</h6>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<button id="btn_agregar_persona" type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal_registrar_persona"><i class="icon-plus3 position-left"></i> Agregar</button> <button id="btn_agregar_persona" type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal_registrar_persona"><i class="icon-plus3 position-left"></i> Agregar</button>
</div> </div>
</div><br> </div><br>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped table-sm" id="tabla_persona"> <table class="table table-striped table-sm" id="tabla_persona">
<thead> <thead>
<tr> <tr>
<th>#</th> <th>#</th>
<th>DNI</th> <th>DNI</th>
<th>APELLIDOS Y NOMBRES</th> <th>APELLIDOS Y NOMBRES</th>
<th>EDAD</th> <th>EDAD</th>
<th>CORREO ELECTRONICO</th> <th>CORREO ELECTRONICO</th>
<th>ESTADO</th> <th>ESTADO</th>
<th>ACCIONES</th> <th>ACCIONES</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- / content --> <!-- / content -->
<!-- modal_registrar_persona --> <!-- modal_registrar_persona -->
<div id="modal_registrar_persona" class="modal fade" data-backdrop="static"> <div id="modal_registrar_persona" class="modal fade" data-backdrop="static">
<!--<div id="modal_registrar_persona">--> <!--<div id="modal_registrar_persona">-->
<div class="modal-dialog modal-lg"> <div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header bg-primary"> <div class="modal-header bg-primary">
<h6 class="modal-title">Registrar persona</h6> <h6 class="modal-title">Registrar persona</h6>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form id="form_registrar_persona"> <form id="form_registrar_persona">
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<div class="form-group"> <div class="form-group">
<!--<div class="form-group has-error has-feedback">--> <label class="control-label display-block">Número de documento:<span class="text-danger"> (*)</span></label>
<label class="control-label display-block">Número de documento:<span class="text-danger"> (*)</span></label> <div class="input-group">
<div class="input-group"> <span class="input-group-addon"><i class="icon-vcard"></i></span>
<span class="input-group-addon"><i class="icon-vcard"></i></span> <input id="txt_numero_documento" name="txt_numero_documento" type="text" class="form-control" placeholder="Ingresar número de documento">
<input id="txt_numero_documento" name="txt_numero_documento" type="text" class="form-control" placeholder="Ingresar número de documento"> </div>
</div> </div>
<!-- <div class="form-control-feedback"> </div>
<i class="icon-cancel-circle2"></i> <div class="col-md-4">
</div> <div class="form-group">
<span class="help-block">Error input group helper</span>--> <label class="control-label display-block">Apellidos:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
</div> <span class="input-group-addon"><i class="icon-user"></i></span>
<div class="col-md-4"> <input id="txt_apellidos" name="txt_apellidos" type="text" class="form-control" placeholder="Ingresar apellidos">
<div class="form-group"> </div>
<label class="control-label display-block">Apellidos:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-user"></i></span> <div class="col-md-4">
<input id="txt_apellidos" name="txt_apellidos" type="text" class="form-control" placeholder="Ingresar apellidos"> <div class="form-group">
</div> <label class="control-label display-block">Nombres:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
</div> <span class="input-group-addon"><i class="icon-user"></i></span>
<div class="col-md-4"> <input id="txt_nombres" name="txt_nombres" type="text" class="form-control" placeholder="Ingresar nombres">
<div class="form-group"> </div>
<label class="control-label display-block">Nombres:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-user"></i></span> </div>
<input id="txt_nombres" name="txt_nombres" type="text" class="form-control" placeholder="Ingresar nombres"> <div class="row">
</div> <div class="col-md-4">
</div> <div class="form-group">
</div> <label class="control-label display-block">Edad:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
<div class="row"> <span class="input-group-addon"><i class="icon-user"></i></span>
<div class="col-md-4"> <input id="txt_edad" name="txt_edad" type="text" class="form-control" placeholder="Ingresar edad">
<div class="form-group"> </div>
<label class="control-label display-block">Edad:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-user"></i></span> <div class="col-md-8">
<input id="txt_edad" name="txt_edad" type="text" class="form-control" placeholder="Ingresar edad"> <div class="form-group">
</div> <label class="control-label display-block">Correo electrónico:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
</div> <span class="input-group-addon"><i class="icon-mention"></i></span>
<div class="col-md-8"> <input id="txt_correo" name="txt_correo" type="text" class="form-control" placeholder="Ingresar correo electrónico">
<div class="form-group"> </div>
<label class="control-label display-block">Correo electrónico:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-mention"></i></span> </div>
<input id="txt_correo" name="txt_correo" type="text" class="form-control" placeholder="Ingresar correo electrónico"> <div class="row">
</div> <div class="col-md-12">
</div> <span class="text-danger pull-right">Campos obligatorios (*)</span>
</div> </div>
</div> </div>
<div class="row"> </form>
<div class="col-md-12"> </div>
<span class="text-danger pull-right">Campos obligatorios (*)</span>
</div> <div class="modal-footer text-center">
</div> <button id="btn_registrar_persona" type="button" class="btn btn-primary">Registrar</button>
</form> <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
</div> </div>
</div>
<div class="modal-footer text-center"> </div>
<button id="btn_registrar_persona" type="button" class="btn btn-primary">Registrar</button> </div>
<button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button> <!-- /modal_registrar_persona -->
</div>
</div>
</div> <!-- modal_editar_persona -->
</div> <div id="modal_editar_persona" class="modal fade" data-backdrop="static">
<!-- /modal_registrar_persona --> <div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header bg-primary">
<!-- modal_editar_persona --> <h6 class="modal-title">Editar persona</h6>
<div id="modal_editar_persona" class="modal fade" data-backdrop="static"> </div>
<div class="modal-dialog modal-lg">
<div class="modal-content"> <div class="modal-body">
<div class="modal-header bg-primary"> <form id="form_editar_persona">
<h6 class="modal-title">Editar persona</h6> <div class="row">
</div> <div class="col-md-4">
<div class="form-group">
<div class="modal-body"> <label class="control-label display-block">Número de documento:<span class="text-danger"> (*)</span></label>
<form id="form_editar_persona"> <div class="input-group">
<div class="row"> <span class="input-group-addon"><i class="icon-vcard"></i></span>
<div class="col-md-4"> <input disabled="disabled" id="txt_numero_documento_editar" name="txt_numero_documento_editar" type="text" class="form-control">
<div class="form-group"> </div>
<label class="control-label display-block">Número de documento:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-vcard"></i></span> <div class="col-md-4">
<input disabled="disabled" id="txt_numero_documento_editar" name="txt_numero_documento_editar" type="text" class="form-control"> <div class="form-group">
</div> <label class="control-label display-block">Apellidos:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
</div> <span class="input-group-addon"><i class="icon-user"></i></span>
<div class="col-md-4"> <input id="txt_apellidos_editar" name="txt_apellidos_editar" type="text" class="form-control" placeholder="Ingresar apellidos">
<div class="form-group"> </div>
<label class="control-label display-block">Apellidos:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-user"></i></span> <div class="col-md-4">
<input id="txt_apellidos_editar" name="txt_apellidos_editar" type="text" class="form-control" placeholder="Ingresar apellidos"> <div class="form-group">
</div> <label class="control-label display-block">Nombres:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
</div> <span class="input-group-addon"><i class="icon-user"></i></span>
<div class="col-md-4"> <input id="txt_nombres_editar" name="txt_nombres_editar" type="text" class="form-control" placeholder="Ingresar nombres">
<div class="form-group"> </div>
<label class="control-label display-block">Nombres:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-user"></i></span> </div>
<input id="txt_nombres_editar" name="txt_nombres_editar" type="text" class="form-control" placeholder="Ingresar nombres"> <div class="row">
</div> <div class="col-md-4">
</div> <div class="form-group">
</div> <label class="control-label display-block">Edad:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
<div class="row"> <span class="input-group-addon"><i class="icon-user"></i></span>
<div class="col-md-4"> <input id="txt_edad_editar" name="txt_edad_editar" type="text" class="form-control" placeholder="Ingresar edad">
<div class="form-group"> </div>
<label class="control-label display-block">Edad:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-user"></i></span> <div class="col-md-8">
<input id="txt_edad_editar" name="txt_edad_editar" type="text" class="form-control" placeholder="Ingresar edad"> <div class="form-group">
</div> <label class="control-label display-block">Correo electrónico:<span class="text-danger"> (*)</span></label>
</div> <div class="input-group">
</div> <span class="input-group-addon"><i class="icon-mention"></i></span>
<div class="col-md-8"> <input id="txt_correo_editar" name="txt_correo_editar" type="text" class="form-control" placeholder="Ingresar correo electrónico">
<div class="form-group"> </div>
<label class="control-label display-block">Correo electrónico:<span class="text-danger"> (*)</span></label> </div>
<div class="input-group"> </div>
<span class="input-group-addon"><i class="icon-mention"></i></span> </div>
<input id="txt_correo_editar" name="txt_correo_editar" type="text" class="form-control" placeholder="Ingresar correo electrónico"> <div class="row">
</div> <div class="col-md-12">
</div> <span class="text-danger pull-right">Campos obligatorios (*)</span>
</div> </div>
</div> </div>
<div class="row"> </form>
<div class="col-md-12"> </div>
<span class="text-danger pull-right">Campos obligatorios (*)</span>
</div> <div class="modal-footer text-center">
</div> <button id="btn_editar_persona" type="button" class="btn btn-primary">Editar</button>
</form> <button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button>
</div> </div>
</div>
<div class="modal-footer text-center"> </div>
<button id="btn_editar_persona" type="button" class="btn btn-primary">Editar</button> </div>
<button type="button" class="btn btn-danger" data-dismiss="modal">Cerrar</button> <!-- /modal_editar_persona -->
</div>
</div>
</div>
</div> <%@include file="templates/footer-body.jsp" %>
<!-- /modal_editar_persona -->
<!--js plantilla-->
<!--jQueryValidator-->
<%@include file="templates/footer-body.jsp" %> <script type="text/javascript" src="../plantilla/assets/js/plugins/forms/validation/validate.min.js"></script>
<!--js plantilla--> <!--jQueryValidator-->
<!--jQueryValidator--> <!--form-->
<script type="text/javascript" src="../plantilla/assets/js/plugins/forms/validation/validate.min.js"></script> <script type="text/javascript" src="../plantilla/assets/js/plugins/forms/inputs/touchspin.min.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/pages/form_input_groups.js"></script>
<!--jQueryValidator--> <!--form-->
<!--form--> <!--modal-->
<script type="text/javascript" src="../plantilla/assets/js/plugins/forms/inputs/touchspin.min.js"></script> <script type="text/javascript" src="../plantilla/assets/js/pages/components_modals.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/pages/form_input_groups.js"></script> <!--modal-->
<!--form-->
<!--sweetalerts-->
<!--modal--> <script type="text/javascript" src="../plantilla/assets/js/plugins/notifications/bootbox.min.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/pages/components_modals.js"></script> <script type="text/javascript" src="../plantilla/assets/js/plugins/notifications/sweet_alert.min.js"></script>
<!--modal--> <!--sweetalerts-->
<!--sweetalerts--> <!--datatable-->
<script type="text/javascript" src="../plantilla/assets/js/plugins/notifications/bootbox.min.js"></script> <script type="text/javascript" src="../plantilla/assets/js/plugins/tables/datatables/datatables.min.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/plugins/notifications/sweet_alert.min.js"></script> <script type="text/javascript" src="../plantilla/assets/js/plugins/forms/selects/select2.min.js"></script>
<!--sweetalerts--> <!--datatable-->
<!--datatable--> <!--js plantilla-->
<script type="text/javascript" src="../plantilla/assets/js/plugins/tables/datatables/datatables.min.js"></script>
<script type="text/javascript" src="../plantilla/assets/js/plugins/forms/selects/select2.min.js"></script> <!--mi js-->
<!--datatable--> <script src="../js/pages/persona.js" type="text/javascript"></script>
<!--mi js-->
<!--js plantilla-->
</body>
<!--mi js--> </html>
<script src="../js/pages/persona.js" type="text/javascript"></script>
<!--mi js-->
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment