-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/RolandoCM/enigma
- Loading branch information
Showing
8 changed files
with
738 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
|
||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.