Commit d3c627c3 by Yovan Martinez

Terminado validacion al enviar formulario y creacion de manage_postulante para…

Terminado validacion al enviar formulario y creacion de manage_postulante para aceptar o rechazr los mismos
parent aeb90489
......@@ -10,7 +10,7 @@ public class DataBase {
try{
Class.forName("org.postgresql.Driver");
con= DriverManager
.getConnection("jdbc:postgresql://localhost:5432/bootcamp_th",
.getConnection("jdbc:postgresql://localhost:5433/bootcamp_th",
"postgres", "postgres");
if(con != null){
......
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;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import javafx.geometry.Pos;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import java.util.List;
@WebServlet("/EditServletPostulante")
public class EditServletPostulante extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String sid = request.getParameter("id");
boolean accion;
if (request.getParameter("value") == "Rechazar") {
accion = false;
} else {
accion = true;
}
int id = Integer.parseInt(sid);
Postulante e = new Postulante();
e.setId(id);
e.setAceptado(accion);
int status = PostulanteDao.update(e);
if (status > 0) {
response.sendRedirect("ViewServlet");
} else {
out.println("Sorry! unable to update record");
}
out.close();
}
}
package com.roshka.proyectofinal.Postulante;
import com.roshka.proyectofinal.DataBase;
import com.roshka.proyectofinal.entity.Postulante;
import jakarta.servlet.http.HttpServlet;
import javafx.geometry.Pos;
import javax.xml.crypto.Data;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class PostulanteDao {
public class PostulanteDao extends HttpServlet {
public static int save(Postulante postulante){
int status=0;
......@@ -30,4 +36,48 @@ public class PostulanteDao {
return status;
}
public static List<Postulante> ListarPostulantes(){
List<Postulante> list=new ArrayList<Postulante>();
try{
Connection con= DataBase.getConnection();
PreparedStatement ps=con.prepareStatement("select * from postulante");
ResultSet rs=ps.executeQuery();
while(rs.next()){
Postulante e=new Postulante();
e.setId(rs.getInt("id"));
e.setNombre(rs.getString("nombre"));
//e.setPassword(rs.getString(3));
e.setCorreo(rs.getString("correo"));
e.setApellido(rs.getString("apellido"));
e.setDireccion(rs.getString("direccion"));
list.add(e);
}
con.close();
}catch(Exception e){e.printStackTrace();}
return list;
}
public static int update (Postulante e){
int status=0;
try{
Connection con= DataBase.getConnection();
PreparedStatement ps=con.prepareStatement(
"update postulante set aceptado=? where id=?");
ps.setBoolean(1,e.getAceptado());
ps.setInt(2,e.getId());
status=ps.executeUpdate();
con.close();
}catch(Exception ex){ex.printStackTrace();}
return status;
}
}
......@@ -30,6 +30,7 @@ public class SaveServlet extends HttpServlet {
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"));
......@@ -105,18 +106,21 @@ public class SaveServlet extends HttpServlet {
}
}
if(status >0 && statusLenguaje > 0){
//out.println("<script> window.alert('Postulacion exitosa') </script>");
out.print("<p>Record saved successfully!</p>");
request.getRequestDispatcher("index.html").include(request, response);
request.getRequestDispatcher("formulario.jsp").include(request, response);
}else{
if (rechazarDatos){
if (contador == 0){
out.println("Debe seleccionar al menos una opcion de lenguaje que conoce para postularse");
out.println("<a href=formulario.jsp >Volver al cuestionario</a>");
}else {
out.println("El correo ingresado ya esta registrado para el bootcamp actual");
out.println("<p>El correo ingresado ya esta registrado para el bootcamp actual<p>");
request.getRequestDispatcher("").include(request, response);
}
}else{
out.println("Sorry! unable to save record");
out.println("Error");
out.println("<script> window.alert('Falla al enviar la postulacion,Intente de nuevo') </script>");
}
}
......
package com.roshka.proyectofinal.Postulante;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
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;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import javafx.geometry.Pos;
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;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import java.util.List;
@WebServlet("/ViewServletPostulante")
public class ViewServletPostulantes extends HttpServlet{
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out=response.getWriter();
out.println("<h1>Lista de Postulantes</h1>");
List<Postulante> list=PostulanteDao.ListarPostulantes();
out.print("<table border='1' width='100%'");
out.print("<tr><th>Id</th><th>Nombre</th><th>Apellido</th><th>Email</th><th>Direccion</th> <th>Edit</th><th>Delete</th></tr>");
for(Postulante e:list){
out.print("<tr><td>"+e.getId()+"</td><td>"+e.getNombre()+"</td><td>"+e.getApellido()+"</td> <td>"+e.getCorreo()+"</td><td>"+e.getDireccion()+"</td><td><a href='EditServlet?id="+e.getId()+"'>edit</a></td> <td><a href='DeleteServlet?id="+e.getId()+"'>delete</a></td></tr>");
}
out.print("</table>");
out.close();
}
}
......@@ -30,6 +30,11 @@ public class Postulante {
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getNro_cedula() {
return nroCedula;
}
......
(function() {
const form = document.querySelector('#sectionForm');
const form = document.querySelector('#agarraunolaputa');
const checkboxes = form.querySelectorAll('input[type=checkbox]');
const checkboxLength = checkboxes.length;
const firstCheckbox = checkboxLength > 0 ? checkboxes[0] : null;
......@@ -22,9 +22,8 @@
}
function checkValidity() {
const errorMessage = !isChecked() ? 'Debe de selecionar al menos un lenguaje' : '';
const errorMessage = !isChecked() ? 'Debe seleccionar al menos un lenguaje que conozca' : '';
firstCheckbox.setCustomValidity(errorMessage);
}
init();
})();
\ No newline at end of file
......@@ -521,42 +521,44 @@
<div class="col-lg-7 mx-auto mb-2">
<div class="card card-h mb-4">
<img src="https://zetsan.com/wp-content/uploads/2020/10/1366_2000.jpeg" lazyload " alt=" ">
<img src="https://zetsan.com/wp-content/uploads/2020/10/1366_2000.jpeg" lazyload alt=" ">
<div class="card-body ">
<p class="mb-1 "> BOOTCAMP JAVA </p>
<p class="mb-1 "> Inicio: 18/04/2023</p>
<p class="mb-1 "> Fin: 18/05/2023</p>
<form action="formulario.jsp">
<input type="submit " value="POSTULAR " />
</form>
</div>
</div>
</div>
<div class="col-lg-7 mx-auto mb-2 ">
<div class="card card-h mb-4 ">
<img src="https://www.pngmart.com/files/13/Android-Logo-PNG-File.png " class="card-img-top lazyload " alt="Learning Web Design: A Beginner 's Guide to HTML, CSS, JavaScript, and Web Graphics">
<div class="card-body">
<p class="mb-1"> BOOTCAMP ANDROID </p>
<p class="mb-1"> Inicio: 18/06/2023</p>
<p class="mb-1"> Fin: 18/07/2023</p>
<form action="formulario.jsp">
<input type="submit" value="POSTULAR" />
</form>
</div>
</div>
</div>
<div class="col-lg-7 mx-auto mb-2">
<div class="card card-h mb-4">
<img src="https://p4.wallpaperbetter.com/wallpaper/710/859/671/technology-apple-ios-12-wallpaper-preview.jpg" lazyload " alt=" ">
<div class="card-body ">
<p class="mb-1 "> BOOTCAMP JAVA </p>
<p class="mb-1 "> Inicio: 18/04/2023</p>
<p class="mb-1 "> Fin: 18/05/2023</p>
<p class="mb-1 "> BOOTCAMP iOS </p>
<p class="mb-1 "> Inicio: 18/08/2023</p>
<p class="mb-1 "> Fin: 18/09/2023</p>
<form action="formulario.jsp ">
<input type="submit " value="POSTULAR " />
</form>
</div></div>
</div>
<div class="col-lg-7 mx-auto mb-2 ">
<div class="card card-h mb-4 ">
<img src="https://www.pngmart.com/files/13/Android-Logo-PNG-File.png " class="card-img-top lazyload " alt="Learning Web Design: A Beginner 's Guide to HTML, CSS, JavaScript, and Web Graphics">
<div class="card-body">
<p class="mb-1"> BOOTCAMP ANDROID </p>
<p class="mb-1"> Inicio: 18/06/2023</p>
<p class="mb-1"> Fin: 18/07/2023</p>
<form action="formulario.jsp">
<input type="submit" value="POSTULAR" />
</form>
</div></div>
</div>
<div class="col-lg-7 mx-auto mb-2">
<div class="card card-h mb-4">
<img src="https://p4.wallpaperbetter.com/wallpaper/710/859/671/technology-apple-ios-12-wallpaper-preview.jpg" lazyload" alt="">
<div class="card-body">
<p class="mb-1"> BOOTCAMP iOS </p>
<p class="mb-1"> Inicio: 18/08/2023</p>
<p class="mb-1"> Fin: 18/09/2023</p>
<form action="formulario.jsp">
<input type="submit" value="POSTULAR" />
</form>
</div></div>
</div>
</div>
</body>
......
......@@ -24,9 +24,9 @@
<div class="menu">
<ul>
<li class="link-menu"><a href="">Home</a></li>
<li class="link-menu"><a href="bootcamp.html">Postulate</a></li>
<li class="link-menu"><a href="formulario_bootcamp.jsp">Crear bootcamp</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>
<li class="link-menu"><a href="manage_postulantes.jsp">Manage Postulantes(perdon angel)</a></li>
</ul>
</div>
<!-- menu -->
......
<<<<<<< HEAD
=======
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
......@@ -18,5 +16,4 @@
</body>
</html>
>>>>>>> origin/develop
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>aceptar postulantes</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
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