Commit 52aa56ab by Jose Baez

Merge branch 'develop' of…

Merge branch 'develop' of https://phoebe.roshka.com/gitlab/jbaez/ProyectoFinal-Bootcamp into develop
parents 7080eab9 1154ca50
......@@ -14,7 +14,7 @@ target/
*.iws
*.iml
*.ipr
/encodings.xml
### Eclipse ###
.apt_generated
.classpath
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.roshka.proyectofinal.Postulante;
import com.roshka.proyectofinal.DataBase;
import com.roshka.proyectofinal.entity.Postulante;
import com.roshka.proyectofinal.entity.Bootcamp;
import com.roshka.proyectofinal.entity.PostulanteLenguaje;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
......@@ -15,7 +16,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
@WebServlet("/SaveServlet")
public class SaveServlet extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
......@@ -24,14 +24,13 @@ public class SaveServlet extends HttpServlet {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
boolean rechazarDatos = false;
int bootcampActual = 3;
int bootcampActual = Integer.parseInt(request.getParameter("bootcamp_id"));
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"));
......@@ -44,6 +43,17 @@ public class SaveServlet extends HttpServlet {
rechazarDatos = true;
}
}
rs = stmt.executeQuery("SELECT * FROM lenguaje");
int contador = 0;
while (rs.next()){
String nombreLenguaje = rs.getString("nombre_lenguaje");
if (request.getParameter(nombreLenguaje) != null){
contador++;
}
}
if (contador == 0){
rechazarDatos = true;
}
String telefono=request.getParameter("telefono");
String direccion=request.getParameter("direccion");
boolean experienciaProgramando = false;
......@@ -53,17 +63,17 @@ public class SaveServlet extends HttpServlet {
if (request.getParameter("experiencia_laboral") != null){
experienciaLaboral = true;
}
if (request.getParameter("experiencia_programando") != null) {
experienciaProgramando = true;
}
if (request.getParameter("notebook") != null){
notebook = true;
}
if (request.getParameter("universidad") != null){
universidad = true;
}
Bootcamp bootcamp = new Bootcamp();
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){
postulante.setNombre(nombre);
......@@ -77,8 +87,24 @@ public class SaveServlet extends HttpServlet {
postulante.setNotebook(notebook);
postulante.setBootcampId(bootcampActual);
postulante.setAceptado(false);
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;
while (rs.next()) {
idUltimoPostulante = rs.getInt("id");
}
rs = stmt.executeQuery("SELECT * FROM lenguaje");
while (rs.next()){
int idLenguaje = rs.getInt("id");
String nombreLenguaje = rs.getString("nombre_lenguaje");
if (request.getParameter(nombreLenguaje) != null){
cargarLenguaje.setIdLenguaje(idLenguaje);
cargarLenguaje.setIdPostulante(idUltimoPostulante);
statusLenguaje = PostulanteLenguajeDao.save(cargarLenguaje);
}
}
}
int status=PostulanteDao.save(postulante);
if(status>0){
//out.print("<p>Record saved successfully!</p>");
out.print(" <div class=\"alert\">\n" +
......@@ -88,7 +114,6 @@ public class SaveServlet extends HttpServlet {
request.getRequestDispatcher("formulario.jsp").include(request, response);
}else{
if (rechazarDatos){
//out.println("El correo ingresado ya esta registrado para el bootcamp actual");
out.print(" <div class=\"alert info\">\n" +
" <span class=\"closebtn\" onclick=\"this.parentElement.style.display='none';\">&times;</span> \n" +
" <strong>Formulario ya Cargado!</strong> YA EXISTE EL FORMULARIO\n" +
......@@ -103,7 +128,6 @@ public class SaveServlet extends HttpServlet {
request.getRequestDispatcher("formulario.jsp").include(request, response);
}
}
}catch (Exception ex){
ex.printStackTrace();
}
......
......@@ -44,9 +44,34 @@ public class Postulante {
this.aceptado = aceptado;
}
public int getNroCedula() {
return nroCedula;
}
public String getNombreBootcamp() {
return nombreBootcamp;
}
public boolean isExpLaboral() {
return expLaboral;
}
public boolean isEstudioUniversitario() {
return estudioUniversitario;
}
public boolean isNotebook() {
return notebook;
}
public boolean isAceptado() {
return aceptado;
}
public int getId() {
return id;
}
public int getNro_cedula() {
return nroCedula;
}
......@@ -118,35 +143,13 @@ public class Postulante {
this.id = id;
}
public int getNroCedula() {
return nroCedula;
}
public void setNroCedula(int nroCedula) {
this.nroCedula = nroCedula;
}
public String getNombreBootcamp() {
return nombreBootcamp;
}
public void setNombreBootcamp(String nombreBootcamp) {
this.nombreBootcamp = nombreBootcamp;
}
public boolean isExpLaboral() {
return expLaboral;
}
public boolean isEstudioUniversitario() {
return estudioUniversitario;
}
public boolean isNotebook() {
return notebook;
}
public boolean isAceptado() {
return aceptado;
}
}
(function() {
const form = document.querySelector('#agarraunolaputa');
const checkboxes = form.querySelectorAll('input[type=checkbox]');
const checkboxLength = checkboxes.length;
const firstCheckbox = checkboxLength > 0 ? checkboxes[0] : null;
function init() {
if (firstCheckbox) {
for (let i = 0; i < checkboxLength; i++) {
checkboxes[i].addEventListener('change', checkValidity);
}
checkValidity();
}
}
function isChecked() {
for (let i = 0; i < checkboxLength; i++) {
if (checkboxes[i].checked) return true;
}
return false;
}
function checkValidity() {
const errorMessage = !isChecked() ? 'Debe seleccionar al menos un lenguaje que conozca' : '';
firstCheckbox.setCustomValidity(errorMessage);
}
init();
})();
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,java.sql.Connection,java.sql.ResultSet,com.roshka.proyectofinal.DataBase,jakarta.servlet.http.HttpServlet,jakarta.servlet.http.HttpServletRequest"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="form.css" rel="stylesheet" type="text/css" />
<link href="estilos/form.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="imagenes/roshkaicon.ico" sizes="any" />
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="form.css" type="text/css">
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
<script src="Javascript.js"></script>
<link rel="stylesheet" media="(max-width: 800px)" href="example.css" />
<title>Formulario Postulante</title>
</head>
<body>
......@@ -23,11 +28,26 @@ pageEncoding="UTF-8"%>
<main class="create">
<article class="contenedor">
<div>
<%
int id =Integer.parseInt(request.getParameter("bootcamp"));
Connection con = DataBase.getConnection();
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM bootcamp WHERE id= "+id+ " LIMIT 1" );
rs.next();
%>
<h2>Descripcion:</h2>
<p>
<%= rs.getString("descripcion") %>
</p>
<p class="enter">Si sigues interesado y cumples con los requisitos, completa el siguiente formulario: </p>
<form method="post" action="SaveServlet" class="form">
<label class="mr-2" for="nombre">Ingrese su Nombre:</label>
<input type="hidden" name="bootcamp_id" value="<%= request.getParameter("bootcamp") %>">
<label for="nombre">Ingrese su Nombre:</label>
<input required id="nombre" name="nombre" type="text"><br>
<label for="apellido">Ingrese su Apellido:</label>
......@@ -45,58 +65,74 @@ pageEncoding="UTF-8"%>
<label for="direccion">Direccion:</label>
<input required id="direccion" name="direccion" type="text"><br>
<label for="experiencia_laboral">Experiencia laboral</label>
<!-- Si no lo marca el valor que envia es null y si lo marca es "ON" -->
<input id="experiencia_laboral" name="experiencia_laboral" type="checkbox"><br>
<%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %>
<label for="notebook">Cuenta con notebook</label>
<input id="notebook" name="notebook" type="checkbox"><br>
<label for="universidad">Estudio Universitario </label>
<input id="universidad" name="universidad" type="checkbox"><br>
<p for="experiencia_programando">Lenguajes de programacion que conoces:</p>
<%@ page import="com.roshka.proyectofinal.entity.Lenguaje, com.roshka.proyectofinal.lenguaje.LenguajeDao, java.util.List,java.util.Iterator" %>
<%
LenguajeDao lenDao = new LenguajeDao();
List<Lenguaje> listLenguaje = lenDao.listar();
Iterator<Lenguaje> iter = listLenguaje.iterator();
Lenguaje len = null;
%>
<ul>
<ul id="agarraunolaputa">
<% while(iter.hasNext()){
len = iter.next();
%>
<li class="d-flex check-inline" >
<label for=<%=len.getNombre_lenguaje() %> > <%= len.getNombre_lenguaje() %> </label><input value=<%=len.getId() %> id=
<li class="d-flex">
<label for=<%=len.getNombre_lenguaje() %> > <%= len.getNombre_lenguaje() %> </label>
<input onclick="enviar(id)" value=<%=len.getId() %> id=
<%=len.getNombre_lenguaje() %> name=
<%=len.getNombre_lenguaje() %> type="checkbox"><br>
<%=len.getNombre_lenguaje() %> type="checkbox" >
</li>
<% } %>
</ul>
<li class="d-flex">
<label for="experiencia_laboral" >Experiencia laboral</label>
</li>
<!-- Si no lo marca el valor que envia es null y si lo marca es "ON" -->
<input id="experiencia_laboral" name="experiencia_laboral" type="checkbox" ><br>
<p for="experiencia_programando">Lenguajes de programacion que conoces:</p>
<label for="notebook">Cuenta con notebook</label>
<input id="notebook" name="notebook" type="checkbox"><br>
<label for="universidad">Estudio Universitario </label>
<input id="universidad" name="universidad" type="checkbox"><br>
<input class="enviar info error" type="submit">
<input class="borrar" type="reset" value="Borrar"><br>
<label for="otro">otro</label>
<input id="otro" name="otro" type="checkbox"><br>
<a href="index.html">volver</a>
</form>
</article>
</article>
</main>
</body>
</html>
<script>
(function() {
const form = document.querySelector('#agarraunolaputa');
const checkboxes = form.querySelectorAll('input[type=checkbox]');
const checkboxLength = checkboxes.length;
const firstCheckbox = checkboxLength > 0 ? checkboxes[0] : null;
function init() {
if (firstCheckbox) {
for (let i = 0; i < checkboxLength; i++) {
checkboxes[i].addEventListener('change', checkValidity);
}
checkValidity();
}
}
function isChecked() {
for (let i = 0; i < checkboxLength; i++) {
if (checkboxes[i].checked) return true;
}
return false;
}
function checkValidity() {
const errorMessage = !isChecked() ? 'Debe seleccionar al menos un lenguaje que conozca' : '';
firstCheckbox.setCustomValidity(errorMessage);
}
init();
})();
</script>
\ No newline at end of file
......@@ -26,6 +26,10 @@
<ul>
<li class="link-menu"><a href="">Home</a></li>
<li class="link-menu"><a href="bootcamp.jsp">Postulate</a></li>
<li class="link-menu"><a href="formulario_bootcamp.jsp">Crear bootcamp</a></li>
<li class="link-menu"><a href="manage_postulantes.jsp">Manage Postulantes(perdon angel)</a></li>
<li class="link-menu"><a href="formulario.jsp">Postulate</a></li>
<li class="link-menu"><a href="formulario_bootcamp.jsp">Crear bootcamp</a>
<li class="link-menu"><a href="login.jsp">Login</a>
......@@ -35,6 +39,7 @@
</li>
<li class="link-menu"><a href="formulario_profesor.jsp">Crear profesor</a>
</li>
</ul>
</div>
......
<<<<<<< HEAD
=======
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
......@@ -23,4 +21,3 @@
</body>
</html>
\ No newline at end of file
>>>>>>> origin/develop
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