Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RolandoCM/enigma
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandoCM committed Nov 30, 2017
2 parents cc1ac25 + 32b7457 commit 2033636
Show file tree
Hide file tree
Showing 8 changed files with 738 additions and 0 deletions.
52 changes: 52 additions & 0 deletions SIGECU/src/java/dao/Implements/Pais/PaisDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dao.Implements.Pais;

import dao.Interface.IPais.IPaisDAO;
import dto.Pais;
import exception.BusinessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import jdbc.ConectionDB;

/**
*
* @author Dell
*/
public class PaisDAO implements IPaisDAO{
private final ConectionDB database;

public PaisDAO() {
this.database = new ConectionDB();
}

@Override
public void insertar(Pais pa) throws BusinessException{

String sql="INSERT INTO pais(nombre,region) values (?,?)";

try {
Connection conection = database.getConnection();
PreparedStatement ps = conection.prepareStatement(sql);

Pais pais= new Pais();
ps.setInt(1, pais.getIdpais());
ps.setString(2,pais.getNombrepais());
ps.setString(3,pais.getRegion());

int exec = ps.executeUpdate();
ps.close();
conection.close();
}catch(Exception e)
{
e.printStackTrace();
BusinessException be = new BusinessException();
be.setMensaje("error en la capa de base de datos");
be.setIdException("001");
throw be;
}
}
}
17 changes: 17 additions & 0 deletions SIGECU/src/java/dao/Interface/IPais/IPaisDAO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dao.Interface.IPais;

import dto.Pais;
import exception.BusinessException;

/**
*
* @author Dell
*/
public interface IPaisDAO {
public void insertar(Pais pa) throws BusinessException;
}
47 changes: 47 additions & 0 deletions SIGECU/src/java/dto/Pais.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package dto;

/**
*
* @author Dell
*/
public class Pais {

private Integer idpais;
private String nombrepais;
private String region;

public Pais() {
}

public Integer getIdpais() {
return idpais;
}

public void setIdpais(Integer idpais) {
this.idpais = idpais;
}

public String getNombrepais() {
return nombrepais;
}

public void setNombrepais(String nombrepais) {
this.nombrepais = nombrepais;
}

public String getRegion() {
return region;
}

public void setRegion(String region) {
this.region = region;
}



}
39 changes: 39 additions & 0 deletions SIGECU/src/java/service/Implements/Pais/PaisService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package service.Implements.Pais;

import dao.Implements.Pais.PaisDAO;
import dao.Interface.IPais.IPaisDAO;
import dto.Pais;
import exception.BusinessException;
import service.Interface.IPais.IPaisService;

/**
*
* @author Dell
*/
public class PaisService implements IPaisService{

public void insertar(Pais pa) throws BusinessException{
try
{
IPaisDAO paisDAO = new PaisDAO();
paisDAO.insertar(pa);
}
catch (BusinessException e)
{
throw e;
}
catch(Exception ex)
{
ex.printStackTrace();
BusinessException be = new BusinessException();
be.setIdException("201");
be.setMensaje("Error en la capa de negocio, conexion en crear Evento");
throw be;
}
}
}
17 changes: 17 additions & 0 deletions SIGECU/src/java/service/Interface/IPais/IPaisService.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package service.Interface.IPais;

import dto.Pais;
import exception.BusinessException;

/**
*
* @author Dell
*/
public interface IPaisService {
public void insertar(Pais pa) throws BusinessException;
}
79 changes: 79 additions & 0 deletions SIGECU/src/java/servlet/ServletPais.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package servlet;

import dto.Alumno;
import dto.MensajesDTO;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import service.Implements.Pais.PaisService;
import service.Interface.IPais.IPaisService;

/**
*
* @author Dell
*/
@WebServlet( name="/Pais", urlPatterns ={"/vistas/administrador/Pais" })
public class ServletPais extends HttpServlet {

private String direccionar = null;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
String accion = request.getParameter("accion");


IPaisService pais = new PaisService();

switch(accion)
{
// INSERTAR PAIS
case "LDP":
insertarPais(pais , request, response);
break;
//CREAR EVENTOS
case "MP":
modificarPerfil(perfil , request, response);
break;
//todos los alumnos registrados
case "TA":
listarAlumnosRegistrados(perfil , request, response);
break;
//INSERTAR ALUMNOS
case "IA":
insertarAlumnos(perfil , request, response);
break;
default:


break;
}

} catch (Exception e) {
e.printStackTrace();
}
RequestDispatcher despachador = request.getRequestDispatcher(direccionar);
despachador.forward(request, response);
} //fin del metodo service

private void insertarPais(IPaisService pais, HttpServletRequest request, HttpServletResponse response) {
MensajesDTO msjDTO = new MensajesDTO();
Alumno alu = new Alumno();



}


}


8 changes: 8 additions & 0 deletions SIGECU/web/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<servlet>
<servlet-name>ServletPais</servlet-name>
<servlet-class>servlet.ServletPais</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletPais</servlet-name>
<url-pattern>/ServletPais</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>/publico/*</welcome-file>
Expand Down
Loading

0 comments on commit 2033636

Please sign in to comment.