diff --git a/.idea/misc.xml b/.idea/misc.xml index 5b6a5c4..8bb1e38 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -10,7 +10,7 @@ - + \ No newline at end of file diff --git a/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java index a1bd41d..0500e4e 100644 --- a/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java +++ b/src/main/java/com/roshka/proyectofinal/Postulante/SaveServlet.java @@ -23,60 +23,60 @@ public class SaveServlet extends HttpServlet { throws ServletException, IOException { response.setContentType("text/html"); - PrintWriter out=response.getWriter(); + PrintWriter out = response.getWriter(); boolean rechazarDatos = false; int bootcampActual = Integer.parseInt(request.getParameter("bootcamp")); try { Connection con = DataBase.getConnection(); Statement stmt = con.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT correo,bootcamp_id FROM postulante WHERE postulante.bootcamp_id =" + bootcampActual); - - String nombre=request.getParameter("nombre"); - String apellido=request.getParameter("apellido"); - int cedula=Integer.parseInt(request.getParameter("cedula")); - String correo=request.getParameter("correo"); - //BUCLE PARA VERIFICAR EL CORREO EN EL BOOTCAMP ACTUAL - while (rs.next()){ - String correoBase =rs.getString("correo"); + ResultSet rs = stmt.executeQuery( + "SELECT correo,bootcamp_id FROM postulante WHERE postulante.bootcamp_id =" + bootcampActual); + + String nombre = request.getParameter("nombre"); + String apellido = request.getParameter("apellido"); + int cedula = Integer.parseInt(request.getParameter("cedula")); + String correo = request.getParameter("correo"); + // BUCLE PARA VERIFICAR EL CORREO EN EL BOOTCAMP ACTUAL + while (rs.next()) { + String correoBase = rs.getString("correo"); int bootcampIdBase = rs.getInt("bootcamp_id"); - if(correo.equals(correoBase) && (bootcampIdBase==bootcampActual)){ + if (correo.equals(correoBase) && (bootcampIdBase == bootcampActual)) { rechazarDatos = true; } } rs = stmt.executeQuery("SELECT * FROM lenguaje"); int contador = 0; - while (rs.next()){ + while (rs.next()) { String nombreLenguaje = rs.getString("nombre_lenguaje"); - if (request.getParameter(nombreLenguaje) != null){ + if (request.getParameter(nombreLenguaje) != null) { contador++; } } - if (contador == 0){ + if (contador == 0) { rechazarDatos = true; } - String telefono=request.getParameter("telefono"); - String direccion=request.getParameter("direccion"); - boolean experienciaProgramando = false; + String telefono = request.getParameter("telefono"); + String direccion = request.getParameter("direccion"); boolean experienciaLaboral = false; boolean universidad = false; boolean notebook = false; - if (request.getParameter("experiencia_laboral") != null){ + if (request.getParameter("experiencia_laboral") != null) { experienciaLaboral = true; } - if (request.getParameter("notebook") != null){ + if (request.getParameter("notebook") != null) { notebook = true; } - if (request.getParameter("universidad") != null){ + if (request.getParameter("universidad") != null) { universidad = true; } - Postulante postulante=new Postulante(); + Postulante postulante = new Postulante(); PostulanteLenguaje cargarLenguaje = new PostulanteLenguaje(); int status = 0; int statusLenguaje = 0; - //SI LOS DATOS SON CORRECTOS NO SE RECHAZAN ENTONCES CARGA A LA BASE - if (!rechazarDatos){ + // SI LOS DATOS SON CORRECTOS NO SE RECHAZAN ENTONCES CARGA A LA BASE + if (!rechazarDatos) { postulante.setNombre(nombre); postulante.setApellido(apellido); postulante.setNro_cedula(cedula); @@ -88,62 +88,65 @@ public class SaveServlet extends HttpServlet { postulante.setNotebook(notebook); postulante.setBootcampId(bootcampActual); postulante.setAceptado(false); - status=PostulanteDao.save(postulante); + status = PostulanteDao.save(postulante); - rs = stmt.executeQuery("SELECT id FROM postulante WHERE postulante.nro_cedula="+cedula+" AND postulante.bootcamp_id="+bootcampActual+" ORDER BY id DESC LIMIT 1"); - int idUltimoPostulante=0; + rs = stmt.executeQuery("SELECT id FROM postulante WHERE postulante.nro_cedula=" + cedula + + " AND postulante.bootcamp_id=" + bootcampActual + " ORDER BY id DESC LIMIT 1"); + int idUltimoPostulante = 0; while (rs.next()) { idUltimoPostulante = rs.getInt("id"); } rs = stmt.executeQuery("SELECT * FROM lenguaje"); - while (rs.next()){ + while (rs.next()) { int idLenguaje = rs.getInt("id"); String nombreLenguaje = rs.getString("nombre_lenguaje"); - if (request.getParameter(nombreLenguaje) != null){ + if (request.getParameter(nombreLenguaje) != null) { cargarLenguaje.setIdLenguaje(idLenguaje); cargarLenguaje.setIdPostulante(idUltimoPostulante); statusLenguaje = PostulanteLenguajeDao.save(cargarLenguaje); } } } - if(status>0){ - //out.print("

Record saved successfully!

"); - + if (status > 0) { + // out.print("

Record saved successfully!

"); out.print("
\n" + - " × \n" + + " × \n" + + " Formulario Cargado! EXITOSAMENTE CARGADO\n" + "
"); request.setAttribute("bootcamp", bootcampActual); RequestDispatcher rd = request.getRequestDispatcher("formulario.jsp"); rd.include(request, response); - //RequestDispatcher rd = request.getRequestDispatcher("formulario.jsp"); - //rd.include(request, response); - }else{ - if (rechazarDatos){ + // RequestDispatcher rd = request.getRequestDispatcher("formulario.jsp"); + // rd.include(request, response); + } else { + if (rechazarDatos) { out.print("
"); - out.print("×"); + out.print( + "×"); out.print("Formulario ya Cargado! YA EXISTE EL FORMULARIO"); out.print("
"); - //request.getRequestDispatcher("formulario.jsp").include(request, response); + // request.getRequestDispatcher("formulario.jsp").include(request, response); request.setAttribute("bootcamp", bootcampActual); RequestDispatcher rd = request.getRequestDispatcher("formulario.jsp"); rd.include(request, response); - }else { + } else { out.println("Error al cargar datos"); out.print("
" + - "× \n" + + "× \n" + + "Formulario ya Cargado! YA EXISTE EL FORMULARIO\n" + "
"); request.setAttribute("bootcamp", bootcampActual); RequestDispatcher rd = request.getRequestDispatcher("formulario.jsp"); rd.include(request, response); - //request.getRequestDispatcher("formulario.jsp").include(request, response); + // request.getRequestDispatcher("formulario.jsp").include(request, response); } } - }catch (Exception ex){ - ex.printStackTrace(); + } catch (Exception ex) { + ex.printStackTrace(); } out.close(); } diff --git a/src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java b/src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java index 9ef6508..c79b6c3 100644 --- a/src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java +++ b/src/main/java/com/roshka/proyectofinal/profesor/EditServlet.java @@ -17,9 +17,9 @@ public class EditServlet extends HttpServlet { int id = Integer.parseInt(request.getParameter("id")); ProfesorDao profesorDao = new ProfesorDao(); - Profesor profesor = profesorDao.getProfesorById(id); +// Profesor profesor = profesorDao.getProfesorById(id); - request.setAttribute("Profesor", profesor); +// request.setAttribute("Profesor", profesor); RequestDispatcher rd = request.getRequestDispatcher("formulario_profesor.jsp"); rd.include(request, response); } @@ -36,13 +36,13 @@ public class EditServlet extends HttpServlet { Profesor profesor =new Profesor(nro_cedula, nombre, apellido, email); profesor.setId(id); - int status=ProfesorDao.update(profesor); +// int status=ProfesorDao.update(profesor); - if(status>0){ - response.sendRedirect("formulario_profesor.jsp"); - }else{ - System.out.println("Sorry! unable to update record"); - } +// if(status>0){ +// response.sendRedirect("formulario_profesor.jsp"); +// }else{ +// System.out.println("Sorry! unable to update record"); +// } } } diff --git a/src/main/java/com/roshka/proyectofinal/profesor/Filtros.java b/src/main/java/com/roshka/proyectofinal/profesor/Filtros.java new file mode 100644 index 0000000..096a482 --- /dev/null +++ b/src/main/java/com/roshka/proyectofinal/profesor/Filtros.java @@ -0,0 +1,46 @@ +package com.roshka.proyectofinal.profesor; + +import com.roshka.proyectofinal.entity.Profesor; +import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletException; +import jakarta.servlet.annotation.WebServlet; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.List; + +import static com.roshka.proyectofinal.profesor.ProfesorDao.buscarPorNombre; +import static com.roshka.proyectofinal.profesor.ProfesorDao.listarProfesor; + +@WebServlet("/filtros-profesor") +public class Filtros extends HttpServlet { + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + List profesores = listarProfesor(); + String nombre = req.getParameter("nombreBuscar"); + String apellido = req.getParameter("apellidoBuscar"); + System.out.println(nombre); + System.out.println(apellido); + + if(nombre!=null || apellido!=null){ + + profesores = buscarPorNombre(nombre, apellido); + } + + req.getServletContext().setAttribute("profesores", profesores); + RequestDispatcher reqDisp= req.getRequestDispatcher("profesor-consulta.jsp"); + reqDisp.forward(req,resp); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + List nombre = listarProfesor(); + List apellido = listarProfesor(); + req.getServletContext().setAttribute("nombre", nombre); + req.getServletContext().setAttribute("apellido", apellido); + RequestDispatcher reqDisp= req.getRequestDispatcher("profesor-consulta.jsp"); + reqDisp.forward(req,resp); + } +} diff --git a/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java b/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java index 33a857c..630cd4a 100644 --- a/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java +++ b/src/main/java/com/roshka/proyectofinal/profesor/ProfesorDao.java @@ -1,7 +1,6 @@ package com.roshka.proyectofinal.profesor; import com.roshka.proyectofinal.DataBase; -import com.roshka.proyectofinal.entity.Lenguaje; import com.roshka.proyectofinal.entity.Profesor; import java.sql.Connection; @@ -31,55 +30,54 @@ public class ProfesorDao { return status; } - - public static List listar(){ + public static List listarProfesor(){ ArrayList list = new ArrayList<>(); String sql = "select * from profesor"; - try{ Connection con= DataBase.getConnection(); PreparedStatement ps=con.prepareStatement(sql); ResultSet rs = ps.executeQuery(); - - while(rs.next()){ - Profesor profe = new Profesor(); - profe.setId(rs.getInt("id")); - profe.setNombre(rs.getString("nombre")); - profe.setApellido(rs.getString("apellido")); - profe.setNro_cedula(rs.getInt("nro_cedula")); - profe.setCorreo(rs.getString("correo")); - - list.add(profe); + Profesor profesorObject = new Profesor(); + profesorObject.setNombre(rs.getString("nombre")); + profesorObject.setApellido(rs.getString("apellido")); + profesorObject.setNro_cedula(rs.getInt("nro_cedula")); + profesorObject.setCorreo(rs.getString("correo")); + list.add(profesorObject); } - con.close(); } catch (SQLException e) { throw new RuntimeException(e); } return list; } - - public static int update(Profesor p){ - int status=0; + public static List buscarPorNombre(String nombre, String apellido){ + List profesores = new ArrayList<>(); + Profesor profesorObject = new Profesor(); try{ Connection con= DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement( - "update profesor set nombre=?, apellido=?, correo=?, nro_cedula=? where id=?"); - ps.setString(1,p.getNombre()); - ps.setString(2,p.getApellido()); - ps.setString(3,p.getCorreo()); - ps.setInt(4,p.getNro_cedula()); - ps.setInt(5,p.getId()); + PreparedStatement ps=con.prepareStatement("select a.id, a.nombre, a.apellido, a.nro_cedula, a.correo from profesor a " + + " where a.nombre ilike ? and a.apellido ilike ? "); - status=ps.executeUpdate(); - con.close(); - }catch(Exception ex){ex.printStackTrace();} + ps.setString(1, "%" + nombre + "%"); + ps.setString(2, "%" + apellido + "%"); + System.out.println(nombre); + ResultSet rs = ps.executeQuery(); + while(rs.next()){ - return status; + profesorObject.setNombre(rs.getString("nombre")); + profesorObject.setApellido(rs.getString("apellido")); + profesorObject.setNro_cedula(rs.getInt("nro_cedula")); + profesorObject.setCorreo(rs.getString("correo")); + profesores.add(profesorObject); + } + con.close(); + }catch(Exception ex){ + ex.printStackTrace(); + } + return profesores; } - public static int delete(int id){ int status=0; try{ @@ -93,25 +91,4 @@ public class ProfesorDao { return status; } - - public static Profesor getProfesorById(int id){ - Profesor p=new Profesor(); - - try{ - Connection con=DataBase.getConnection(); - PreparedStatement ps=con.prepareStatement("select * from profesor where id=?"); - ps.setInt(1,id); - ResultSet rs=ps.executeQuery(); - if(rs.next()){ - p.setId(rs.getInt("id")); - p.setNombre(rs.getString("nombre")); - p.setApellido(rs.getString("apellido")); - p.setNro_cedula(rs.getInt("nro_cedula")); - p.setCorreo(rs.getString("correo")); - } - con.close(); - }catch(Exception ex){ex.printStackTrace();} - - return p; - } -} +} \ No newline at end of file diff --git a/src/main/webapp/bootcamp.jsp b/src/main/webapp/bootcamp.jsp index fbb0800..87c0f55 100644 --- a/src/main/webapp/bootcamp.jsp +++ b/src/main/webapp/bootcamp.jsp @@ -7,6 +7,7 @@ pageEncoding="UTF-8"%> + Bootcamp diff --git a/src/main/webapp/formJS.js b/src/main/webapp/formJS.js new file mode 100644 index 0000000..d4db8f6 --- /dev/null +++ b/src/main/webapp/formJS.js @@ -0,0 +1,15 @@ +// Get all elements with class="closebtn" +var close = document.getElementsByClassName("closebtn"); +var i; +// Loop through all close buttons +for (i = 0; i < close.length; i++) { + // When someone clicks on a close button + close[i].onclick = function(){ + // Get the parent of (
) + var div = this.parentElement; + // Set the opacity of div to 0 (transparent) + div.style.opacity = "0"; + // Hide the div after 600ms (the same amount of milliseconds it takes to fade out) + setTimeout(function(){ div.style.display = "none"; }, 600); + } +} diff --git a/src/main/webapp/formulario.jsp b/src/main/webapp/formulario.jsp index dfde7cb..cc3cbc7 100644 --- a/src/main/webapp/formulario.jsp +++ b/src/main/webapp/formulario.jsp @@ -11,6 +11,7 @@ pageEncoding="UTF-8"%> + Formulario Postulante @@ -41,7 +42,7 @@ pageEncoding="UTF-8"%>
- "> + ">
@@ -133,4 +134,5 @@ pageEncoding="UTF-8"%> } init(); })(); - \ No newline at end of file + + diff --git a/src/main/webapp/formulario_bootcamp.jsp b/src/main/webapp/formulario_bootcamp.jsp index f64cdcf..5c61b0b 100644 --- a/src/main/webapp/formulario_bootcamp.jsp +++ b/src/main/webapp/formulario_bootcamp.jsp @@ -24,7 +24,7 @@ Lenguaje len = null; ProfesorDao profeDao = new ProfesorDao(); - List listProfesor = profeDao.listar(); + List listProfesor = profeDao.listarProfesor(); Iterator iterProfe = listProfesor.iterator(); Profesor profe = null; %> @@ -130,7 +130,7 @@ Lenguaje len2 = null; ProfesorDao profeDao2 = new ProfesorDao(); - List listProfesor2 = profeDao2.listar(); + List listProfesor2 = profeDao2.listarProfesor(); Iterator iterProfe2 = listProfesor2.iterator(); Profesor profe2 = null; Bootcamp bootcampToEdit = (Bootcamp)request.getAttribute("Bootcamp"); diff --git a/src/main/webapp/formulario_profesor.jsp b/src/main/webapp/formulario_profesor.jsp index 0795aa9..6848d26 100644 --- a/src/main/webapp/formulario_profesor.jsp +++ b/src/main/webapp/formulario_profesor.jsp @@ -11,8 +11,9 @@ +
-

CREAR PROFESOR

+

CREAR PROFESOR Y FILTRAR

<%@ page import="com.roshka.proyectofinal.entity.Profesor, com.roshka.proyectofinal.profesor.ProfesorDao, java.util.List,java.util.Iterator" %> @@ -21,7 +22,7 @@
<% ProfesorDao profeDao = new ProfesorDao(); - List listProfe = profeDao.listar(); + List listProfe = profeDao.listarProfesor(); Iterator iterProfe = listProfe.iterator(); Profesor profesor = null; %> @@ -51,6 +52,14 @@ Crear Profesor +
+
+ + + +

diff --git a/src/main/webapp/menu.css b/src/main/webapp/menu.css index 1796088..d081613 100644 --- a/src/main/webapp/menu.css +++ b/src/main/webapp/menu.css @@ -1,7 +1,7 @@ * { box-sizing: border-box; } - + body { font-family: 'Concert One', cursive; font-size: 13px diff --git a/src/main/webapp/menu.html b/src/main/webapp/menu.html new file mode 100644 index 0000000..b718dca --- /dev/null +++ b/src/main/webapp/menu.html @@ -0,0 +1,101 @@ + + + + + + + + + +
+

MENU TH

+

EN LOS SIGUIENTES LINKS PUEDE MODIFICAR, AGREGAR O ELIMINAR DATOS DE LA BASE DE DATOS DEL BOOTCAMP

+
+ + +
+

PUEDE ACCEDER A LOS SIGUIENTES LINKS:

+
+ + + + + + + diff --git a/src/main/webapp/postulante-consulta.jsp b/src/main/webapp/postulante-consulta.jsp index 1ddbda0..030510a 100644 --- a/src/main/webapp/postulante-consulta.jsp +++ b/src/main/webapp/postulante-consulta.jsp @@ -14,13 +14,40 @@ + +
+

Lista Postulantes

+
+
+ + + + +
+ + + + +
+ + + + +
+ + + + + +
+ +
-

LISTA POSTULANTES

-
- - - +
@@ -33,26 +60,17 @@ - + - + diff --git a/src/main/webapp/postulante.css b/src/main/webapp/postulante.css index 003bc2f..5ae626b 100644 --- a/src/main/webapp/postulante.css +++ b/src/main/webapp/postulante.css @@ -1,10 +1,82 @@ -@import 'https://fonts.googleapis.com/css?family=Open+Sans|Quicksand:400,700'; + body{ -background-image: url(imagenes/descarga.svg); -height: 100%; -font-family: 'Quicksand', sans-serif; -color: white; -webkit-font-smoothing: antialiased; --moz-osx-font-smoothing: grayscale; -} -h1{ font-size: 40px \ No newline at end of file + background-image: url(imagenes/descarga.svg); + font-family:Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif; + font-weight: bold; + font-size: medium; +} + +img{ + width: 165px; + padding: 5px; +} +.container{ + width: 300%; + max-width: 785px; + min-width: 320px; + border-radius: 15px; + padding: 1rem; + +} +table{ + /* background-color: wheat; */ + text-align: left; + border-collapse: collapse; + width: 150%; + /* border: solid 3px black; */ +} +a{ + text-decoration: none; + color: antiquewhite; +} +h1{ + font-family:Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif; + text-align: right; + color:wheat; + font-weight:bold; + +} + +button{ + margin:5px; + background-image: url(imagenes/descarga.svg); + color: aliceblue; +} +th,td{ + margin: 2px; + +} +table tr:nth-child(odd) { /* background-color: aliceblue; */ + + /* background-color: rgba(11, 49, 110, 0.75) */ + background-color: transparent; +} + +table tr:nth-child(even) { background-image: url(imagenes/descarga.svg); +} +td{ + padding: 3px; + border-color: red; + text-align: center; + /* border: solid 1px coral; */ +} +th{ + padding: 5px; + text-align: center; + /* border: solid 4px black; */ +} +th:hover{ + background-color: brown; +} + +tbody{ + margin: 15px; +padding: 15px +} + +tr:hover td { background: aqua; } +th { border: 1px solid black; height: 30px; + background-image: url(imagenes/descarga.svg); + } +button:hover{ +color: yellow;} diff --git a/src/main/webapp/profesor-consulta.jsp b/src/main/webapp/profesor-consulta.jsp new file mode 100644 index 0000000..0f911b2 --- /dev/null +++ b/src/main/webapp/profesor-consulta.jsp @@ -0,0 +1,51 @@ +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> +<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %> + + + + + + + + + + + Profesor MANAGE + + + +
+

LISTA PROFESORES

+
+ + + + +
#Experiencia laboral Estudio universitario -
- - -
+ Notebooks
-
- - -
+ Bootcamps
-
- - -
+ Aceptado
${myIndex.index + 1}-
+ + + + + + + + + + + + + + + + + + + + +
#NombreApellidoNumero de CedulaCorreoEditarEliminar
${myIndex.index + 1}- ${profesor.nombre} ${profesor.apellido} ${profesor.nro_cedula} ${profesor.correo}
+
+ + + \ No newline at end of file diff --git a/src/main/webapp/usrebe.html b/src/main/webapp/usrebe.html index 797f287..fe84cf7 100644 --- a/src/main/webapp/usrebe.html +++ b/src/main/webapp/usrebe.html @@ -10,6 +10,7 @@ Pinterest: https://pinterest.com/mycnlz/