
commit
4c99607cff
34 changed files with 1905 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<classpath> |
|||
<classpathentry kind="src" path="src"/> |
|||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/> |
|||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/> |
|||
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.5"> |
|||
<attributes> |
|||
<attribute name="owner.project.facets" value="jst.web"/> |
|||
</attributes> |
|||
</classpathentry> |
|||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_172"> |
|||
<attributes> |
|||
<attribute name="owner.project.facets" value="java"/> |
|||
</attributes> |
|||
</classpathentry> |
|||
<classpathentry kind="lib" path="C:/Users/margh/Downloads/ojdbc6.jar"/> |
|||
<classpathentry kind="lib" path="C:/Users/margh/Downloads/mysql-connector-java-5.1.39.jar"/> |
|||
<classpathentry kind="output" path="build/classes"/> |
|||
</classpath> |
@ -0,0 +1 @@ |
|||
/build/ |
@ -0,0 +1,31 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<projectDescription> |
|||
<name>centralino_brigate</name> |
|||
<comment></comment> |
|||
<projects> |
|||
</projects> |
|||
<buildSpec> |
|||
<buildCommand> |
|||
<name>org.eclipse.jdt.core.javabuilder</name> |
|||
<arguments> |
|||
</arguments> |
|||
</buildCommand> |
|||
<buildCommand> |
|||
<name>org.eclipse.wst.common.project.facet.core.builder</name> |
|||
<arguments> |
|||
</arguments> |
|||
</buildCommand> |
|||
<buildCommand> |
|||
<name>org.eclipse.wst.validation.validationbuilder</name> |
|||
<arguments> |
|||
</arguments> |
|||
</buildCommand> |
|||
</buildSpec> |
|||
<natures> |
|||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature> |
|||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature> |
|||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature> |
|||
<nature>org.eclipse.jdt.core.javanature</nature> |
|||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature> |
|||
</natures> |
|||
</projectDescription> |
@ -0,0 +1,12 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<classpath> |
|||
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/> |
|||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/> |
|||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject"> |
|||
<attributes> |
|||
<attribute name="hide" value="true"/> |
|||
</attributes> |
|||
</classpathentry> |
|||
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/> |
|||
<classpathentry kind="output" path=""/> |
|||
</classpath> |
@ -0,0 +1,7 @@ |
|||
eclipse.preferences.version=1 |
|||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
|||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 |
|||
org.eclipse.jdt.core.compiler.compliance=1.8 |
|||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
|||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
|||
org.eclipse.jdt.core.compiler.source=1.8 |
@ -0,0 +1,8 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0"> |
|||
<wb-module deploy-name="centralino_brigate"> |
|||
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/> |
|||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/> |
|||
<property name="context-root" value="centralino_brigate"/> |
|||
<property name="java-output-path" value="/centralino_brigate/build/classes"/> |
|||
</wb-module> |
|||
</project-modules> |
@ -0,0 +1,10 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<faceted-project> |
|||
<runtime name="Apache Tomcat v8.5"/> |
|||
<fixed facet="java"/> |
|||
<fixed facet="wst.jsdt.web"/> |
|||
<fixed facet="jst.web"/> |
|||
<installed facet="java" version="1.8"/> |
|||
<installed facet="jst.web" version="3.0"/> |
|||
<installed facet="wst.jsdt.web" version="1.0"/> |
|||
</faceted-project> |
@ -0,0 +1 @@ |
|||
org.eclipse.wst.jsdt.launching.baseBrowserLibrary |
@ -0,0 +1 @@ |
|||
Window |
@ -0,0 +1,3 @@ |
|||
Manifest-Version: 1.0 |
|||
Class-Path: |
|||
|
@ -0,0 +1,110 @@ |
|||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" |
|||
pageEncoding="UTF-8"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Home</title> |
|||
<link rel="stylesheet" |
|||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" |
|||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" |
|||
crossorigin="anonymous"> |
|||
<link rel="stylesheet" href="css/stile.css"> |
|||
<style> |
|||
|
|||
</style> |
|||
</head> |
|||
<body> |
|||
<jsp:include page="nav.jsp"></jsp:include> |
|||
<% |
|||
String messaggio = (String) request.getAttribute("messaggio"); |
|||
|
|||
if (messaggio != null) { |
|||
out.print("<h4>" + messaggio + "</h4>"); |
|||
} |
|||
%> |
|||
<div style="margin: 25px"> |
|||
<h4>Cerca contatto</h4> |
|||
<form action="contatti-ctrl" method="post"> |
|||
<div class="form-group"> |
|||
<label>Numero di telefono</label> <input type="number" |
|||
name="telefono" class="form-control form-control-sm"> |
|||
</div> |
|||
<input type="hidden" name="azione" value="cerca"> |
|||
<button type="submit" class="btn btn-light btn-sm">Cerca</button> |
|||
</form> |
|||
<hr> |
|||
<h4>Aggiungi nuovo contatto</h4> |
|||
<form action="contatti-ctrl" method="post"> |
|||
<div class="cinquanta"> |
|||
<div class="form-group"> |
|||
<label>Nome*</label> <input type="text" name="nome" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Cognome*</label> <input type="text" name="cognome" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
<!-- <div class="form-group"> --> |
|||
<!-- <label>Servizio sociale</label> <input type="text" --> |
|||
<!-- name="servizioSociale" class="form-control form-control-sm" value="-"> --> |
|||
<!-- </div> --> |
|||
<div class="form-group"> |
|||
<label>Quartiere*</label> <select name="area" |
|||
class="form-control form-control-sm"> |
|||
<option value="Calvairate/Molise">Calvairate/Molise</option> |
|||
<option value="Corvetto">Corvetto</option> |
|||
<option value="Mecenate">Mecenate</option> |
|||
</select> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Indirizzo*</label> <input type="text" name="indirizzo" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Numero di telefono*</label> <input type="number" |
|||
name="telefono" class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Email</label> <input type="email" name="email" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
</div> |
|||
<div class="cinquanta"> |
|||
<div class="form-group"> |
|||
<p>Composizione nucleo abitativo*</p> |
|||
<div class="form-group"> |
|||
<label>Neonat_ (0-3 anni)</label> <input type="number" |
|||
name="neonat" value="0" |
|||
class="form-control form-control-sm number"><br> <label>Bambin_ |
|||
(3-12 anni)</label> <input type="number" name="bambin" value="0" |
|||
class="form-control form-control-sm number"><br> <label>Adult_</label> |
|||
<input type="number" name="adult" value="0" |
|||
class="form-control form-control-sm number"><br> <label>Anzian_ (>65 anni)</label> |
|||
<input type="number" name="anzian" value="0" |
|||
class="form-control form-control-sm number"><br> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label style="vertical-align: top">Note sacchetto (allergie, diete, necessitร ...)</label> |
|||
<textarea name="noteSacchetto" |
|||
class="form-control form-control-sm"></textarea> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<input type="hidden" name="azione" value="aggiungi"><br> |
|||
<button type="submit" class="btn btn-light btn-sm">Aggiungi</button> |
|||
</form> |
|||
</div> |
|||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" |
|||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" |
|||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" |
|||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" |
|||
crossorigin="anonymous"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,29 @@ |
|||
@charset "ISO-8859-1"; |
|||
|
|||
.form-control { |
|||
width: 300px; |
|||
display: inline-block; |
|||
} |
|||
|
|||
.form-group { |
|||
margin-bottom: 10px; |
|||
} |
|||
|
|||
label { |
|||
width: 180px; |
|||
} |
|||
|
|||
.number { |
|||
width: 70px; |
|||
} |
|||
|
|||
|
|||
.cinquanta { |
|||
display: inline-block; |
|||
width: 45%; |
|||
vertical-align: top; |
|||
} |
|||
body { |
|||
background-color: #262626; |
|||
color: white; |
|||
} |
@ -0,0 +1,94 @@ |
|||
<%@page import="util.Data"%> |
|||
<%@page import="service.ContattoService"%> |
|||
<%@page import="service.OrdiniService"%> |
|||
<%@page import="bean.Contatto"%> |
|||
<%@page import="java.util.ArrayList"%> |
|||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" |
|||
pageEncoding="UTF-8"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Elenco contatti</title> |
|||
<link rel="stylesheet" |
|||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" |
|||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" |
|||
crossorigin="anonymous"> |
|||
<link rel="stylesheet" href="css/stile.css"> |
|||
</head> |
|||
<body> |
|||
<jsp:include page="nav.jsp"></jsp:include> |
|||
<div style="margin: 25px"> |
|||
<h4>Elenco contatti</h4> |
|||
<% |
|||
ArrayList<Contatto> elencoContatti = ContattoService.elenco(); |
|||
|
|||
if (elencoContatti.isEmpty()) { |
|||
%> |
|||
<h4>Non ci sono contatti</h4> |
|||
<% |
|||
} else { |
|||
%> |
|||
<table class="table table-dark" style="background-color: #3a3a3a"> |
|||
<thead> |
|||
<tr> |
|||
<th>#</th> |
|||
<th>Nominativo |
|||
<th>Indirizzo</th> |
|||
<th>Zona</th> |
|||
<th>Telefono</th> |
|||
<th>Email</th> |
|||
<th>Componenti</th> |
|||
<th>Composizione nucleo</th> |
|||
<th>Note sacchetto</th> |
|||
<th>Ultima consegna</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<% |
|||
for (int i = 0; i < elencoContatti.size(); i++) { |
|||
Contatto contatto = elencoContatti.get(i); |
|||
%> |
|||
<tr> |
|||
<td><a href="home-contatto.jsp?id=<%=contatto.getTelefono()%>" |
|||
style="color: white; font-weight: bold"><%=i + 1%></a></td> |
|||
<td><%=contatto.getNome()%> <%=contatto.getCognome()%></td> |
|||
<td><%=contatto.getIndirizzo()%></td> |
|||
<td><%=contatto.getArea()%></td> |
|||
<td><%=contatto.getTelefono()%></td> |
|||
<td><%=contatto.getEmail() != null ? contatto.getEmail() : "-"%></td> |
|||
<td><%=contatto.getNumero_persone()%></td> |
|||
<td><%=contatto.getComposizione_nucleo()%></td> |
|||
<td><%=contatto.getNote_sacchetto()%></td> |
|||
<td> |
|||
<% |
|||
if (contatto.getUltima_consegna() == null) { |
|||
out.print("-"); |
|||
} else { |
|||
out.print(Data.formatta(contatto.getUltima_consegna())); |
|||
} |
|||
%> |
|||
</td> |
|||
</tr> |
|||
<% |
|||
} |
|||
%> |
|||
</tbody> |
|||
</table> |
|||
<% |
|||
} |
|||
%> |
|||
</div> |
|||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" |
|||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" |
|||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" |
|||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" |
|||
crossorigin="anonymous"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,103 @@ |
|||
<%@page import="service.OrdiniService"%> |
|||
<%@page import="bean.Contatto"%> |
|||
<%@page import="java.util.ArrayList"%> |
|||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" |
|||
pageEncoding="UTF-8"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Elenco ordini</title> |
|||
<link rel="stylesheet" |
|||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" |
|||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" |
|||
crossorigin="anonymous"> |
|||
<link rel="stylesheet" href="css/stile.css"> |
|||
</head> |
|||
<body> |
|||
<jsp:include page="nav.jsp"></jsp:include> |
|||
<div style="margin: 25px"> |
|||
<h4>Elenco ordini</h4> |
|||
<% |
|||
ArrayList<Contatto> elencoOrdini = OrdiniService.leggiTutti(); |
|||
|
|||
if (request.getAttribute("limit") != null) { |
|||
int limite = (Integer) request.getAttribute("limit"); |
|||
elencoOrdini = OrdiniService.leggiTutti(limite); |
|||
} |
|||
|
|||
if (elencoOrdini.isEmpty()) { |
|||
%> |
|||
<h2>Non ci sono ordini</h2> |
|||
<% |
|||
} else { |
|||
%> |
|||
|
|||
<form action="ordini-ctrl" method="post"> |
|||
Seleziona i primi <select name="limite" |
|||
class="form-control form-control-sm" style="width: 70px"> |
|||
<option value="20">20</option> |
|||
<option value="20">50</option> |
|||
<option value="20">70</option> |
|||
<option value="20">100</option> |
|||
</select><input type="hidden" name="azione" value="selectTop"> <input |
|||
type="submit" value="OK" class="btn btn-light btn-sm" style="vertical-align: top"> |
|||
</form> |
|||
<br> |
|||
<table id="ordini" class="table table-dark" |
|||
style="background-color: #3a3a3a"> |
|||
<tr> |
|||
<th>#</th> |
|||
<th>Nominativo</th> |
|||
<th>Zona</th> |
|||
<th>Indirizzo</th> |
|||
<th>Telefono</th> |
|||
<th>Componenti</th> |
|||
<th>Composizione nucleo</th> |
|||
<th>Note</th> |
|||
<th>Consegnato</th> |
|||
</tr> |
|||
<% |
|||
for (int i = 0; i < elencoOrdini.size(); i++) { |
|||
Contatto contatto = elencoOrdini.get(i); |
|||
%> |
|||
<tr> |
|||
<td><a href="home-contatto.jsp?id=<%=contatto.getTelefono()%>" |
|||
style="color: white; font-weight: bold"><%=i + 1%></a></td> |
|||
<td><%=contatto.getNome()%> <%=contatto.getCognome()%></td> |
|||
<td><%=contatto.getArea()%></td> |
|||
<td><%=contatto.getIndirizzo()%></td> |
|||
<td><%=contatto.getTelefono()%></td> |
|||
<td><%=contatto.getNumero_persone()%></td> |
|||
<td><%=contatto.getComposizione_nucleo()%></td> |
|||
<td><%=contatto.getNote_sacchetto()%></td> |
|||
<th> |
|||
<form action="ordini-ctrl" method="post" style="text-align: center"> |
|||
<input type="hidden" name="azione" value="elimina"> <input |
|||
type="hidden" name="id" value="<%=contatto.getTelefono()%>"> |
|||
<input type="submit" value="×" class="btn btn-danger btn-sm rounded-pill"> |
|||
</form> |
|||
</th> |
|||
</tr> |
|||
|
|||
<% |
|||
} |
|||
%> |
|||
</table> |
|||
<% |
|||
} |
|||
%> |
|||
</div> |
|||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" |
|||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" |
|||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" |
|||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" |
|||
crossorigin="anonymous"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,23 @@ |
|||
<%@ page language="java" contentType="text/html; charset=UTF-8" |
|||
pageEncoding="ISO-8859-1"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<link rel="stylesheet" |
|||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" |
|||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" |
|||
crossorigin="anonymous"> |
|||
<title>ERROR</title> |
|||
</head> |
|||
<body> |
|||
<h1>ERRORE</h1> |
|||
<% |
|||
String messaggio = (String) request.getAttribute("messaggio"); |
|||
|
|||
if(messaggio != null){ |
|||
out.print(messaggio); |
|||
} |
|||
%> |
|||
</body> |
|||
</html> |
@ -0,0 +1,146 @@ |
|||
<%@page import="util.Data"%> |
|||
<%@page import="bean.Contatto"%> |
|||
<%@ page language="java" contentType="text/html; charset=UTF-8" |
|||
pageEncoding="ISO-8859-1"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Contatto</title> |
|||
<link rel="stylesheet" |
|||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" |
|||
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" |
|||
crossorigin="anonymous"> |
|||
<link rel="stylesheet" href="css/stile.css"> |
|||
</head> |
|||
<body> |
|||
<jsp:include page="nav.jsp"></jsp:include> |
|||
<div style="margin: 25px"> |
|||
<% |
|||
Contatto c = (Contatto) request.getAttribute("contatto"); |
|||
|
|||
if (c == null) { |
|||
out.print("ERRORE"); |
|||
} else { |
|||
%> |
|||
<h4><%=c.getNome() + " " + c.getCognome()%> |
|||
<% |
|||
if (c.getServizio_sociale() != null && !c.getServizio_sociale().equals("-")) { |
|||
%>(contatto ottenuto tramite |
|||
<%=c.getServizio_sociale()%>) |
|||
<% |
|||
} |
|||
%> |
|||
</h4> |
|||
Indirizzo: |
|||
<%=c.getIndirizzo() + " (zona " + c.getArea() + ")"%><br> |
|||
Telefono: |
|||
<%=c.getTelefono()%><br> |
|||
<% |
|||
if (c.getEmail() != null) { |
|||
%> |
|||
Email: |
|||
<%=c.getEmail()%><br> |
|||
<% |
|||
} |
|||
%><br> |
|||
<%=c.getNumero_persone()%> |
|||
persone (<%=c.getComposizione_nucleo()%>)<br> Note sacchetto: |
|||
<%=c.getNote_sacchetto()%><br> <br> |
|||
<% |
|||
if (c.getUltima_consegna() == null) { |
|||
out.print("Non ha ancora ricevuto consegne"); |
|||
} else { |
|||
out.print("Ultimo ordine consegnato il" + Data.formatta(c.getUltima_consegna())); |
|||
} |
|||
%> |
|||
<br> <br> |
|||
<form action="ordini-ctrl" method="post"> |
|||
<input type="hidden" name="azione" value="aggiungi"> <input |
|||
type="hidden" name="numero" value="<%=c.getTelefono()%>"> <input |
|||
type="submit" value="Aggiungi agli ordini" |
|||
class="btn btn-primary btn-sm"> |
|||
</form> |
|||
<br> |
|||
<p style="display: inline-block;"> |
|||
<a class="btn btn-warning btn-sm" data-toggle="collapse" |
|||
href="#collapseExample" role="button" aria-expanded="false" |
|||
aria-controls="collapseExample"> Aggiorna dati </a> |
|||
</p> |
|||
<form action="contatti-ctrl" method="post" |
|||
style="display: inline-block"> |
|||
<input type="hidden" name="azione" value="elimina"> <input |
|||
type="hidden" name="id" value="<%=c.getTelefono()%>"> <input |
|||
type="submit" value="Elimina contatto" class="btn btn-danger btn-sm"> |
|||
</form> |
|||
<div class="collapse" id="collapseExample"> |
|||
<form action="contatti-ctrl" method="post"> |
|||
<div class="cinquanta"> |
|||
<div class="form-group"> |
|||
<label>Nome*</label> <input type="text" name="nome" |
|||
value="<%=c.getNome()%>" class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Cognome*</label> <input type="text" name="cognome" |
|||
value="<%=c.getCognome()%>" class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Quartiere*</label> <input type="text" name="area" |
|||
value="<%=c.getArea()%>" class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Indirizzo*</label> <input type="text" name="indirizzo" |
|||
value="<%=c.getIndirizzo()%>" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Numero di telefono*</label> <input type="number" |
|||
value="<%=c.getTelefono()%>" name="telefono" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Email</label> <input type="email" name="email" |
|||
value="<%=c.getEmail()%>" class="form-control form-control-sm"> |
|||
</div> |
|||
</div> |
|||
<div class="cinquanta"> |
|||
<div class="form-group"> |
|||
<label>Numero persone</label> <input type="number" name="numero" |
|||
value="<%=c.getNumero_persone()%>" |
|||
class="form-control form-control-sm number"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label>Composizione nucleo abitativo</label> <input type="text" |
|||
name="composizioneNucleo" value="<%=c.getComposizione_nucleo()%>" |
|||
class="form-control form-control-sm"> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label style="vertical-align: top">Note sacchetto |
|||
(allergie, diete, necessitร ...)</label> |
|||
<textarea name="noteSacchetto" |
|||
class="form-control form-control-sm" |
|||
value="<%=c.getNote_sacchetto()%>"></textarea> |
|||
</div> |
|||
</div> |
|||
|
|||
<input type="hidden" name="azione" value="modifica"><br> |
|||
<button type="submit" class="btn btn-light btn-sm">Modifica</button> |
|||
</form> |
|||
</div> |
|||
<% |
|||
} |
|||
%> |
|||
</div> |
|||
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" |
|||
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" |
|||
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" |
|||
crossorigin="anonymous"></script> |
|||
<script |
|||
src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" |
|||
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" |
|||
crossorigin="anonymous"></script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,12 @@ |
|||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" |
|||
pageEncoding="ISO-8859-1"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="ISO-8859-1"> |
|||
<title>Insert title here</title> |
|||
</head> |
|||
<body> |
|||
<jsp:include page="cerca-aggiungi.jsp"></jsp:include> |
|||
</body> |
|||
</html> |
@ -0,0 +1,32 @@ |
|||
<%@ page language="java" contentType="text/html; charset=UTF-8" |
|||
pageEncoding="UTF-8"%> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<title>Nav</title> |
|||
<style> |
|||
.nav{ |
|||
background-color: #666666; |
|||
} |
|||
|
|||
.nav-link{ |
|||
color: white |
|||
} |
|||
|
|||
.nav-link:hover{ |
|||
color: #f1f1f1; |
|||
} |
|||
</style> |
|||
</head> |
|||
<body> |
|||
<ul class="nav"> |
|||
<li class="nav-item"><a class="nav-link active" |
|||
href="cerca-aggiungi.jsp"><b>HOME</b></a></li> |
|||
<li class="nav-item"><a class="nav-link" |
|||
href="elenco-contatti.jsp">Visualizza contatti</a></li> |
|||
<li class="nav-item"><a class="nav-link" href="elenco-ordini.jsp">Visualizza |
|||
ordini</a></li> |
|||
</ul> |
|||
</body> |
|||
</html> |
@ -0,0 +1,21 @@ |
|||
use brigate; |
|||
|
|||
|
|||
CREATE TABLE CONTATTI |
|||
( NOME VARCHAR(255) NOT NULL, |
|||
COGNOME VARCHAR(255) NOT NULL , |
|||
SERVIZIO_SOCIALE VARCHAR(255), |
|||
AREA VARCHAR(255), |
|||
INDIRIZZO VARCHAR(255) NOT NULL, |
|||
TELEFONO INTEGER PRIMARY KEY, |
|||
NUMERO INTEGER NOT NULL , |
|||
COMPOSIZIONE_NUCLEO VARCHAR(255) NOT NULL , |
|||
NOTE_SACCHETTO VARCHAR(255), |
|||
ULTIMA_CONSEGNA DATE, |
|||
EMAIL VARCHAR(256) |
|||
) ; |
|||
|
|||
|
|||
CREATE TABLE ORDINI |
|||
( TELEFONO INTEGER PRIMARY KEy REFERENCES CONTATTI(TELEFONO) |
|||
) ; |
@ -0,0 +1,18 @@ |
|||
|
|||
CREATE TABLE CONTATTI |
|||
( NOME VARCHAR2(255 BYTE) NOT NULL, |
|||
COGNOME VARCHAR2(255 BYTE) NOT NULL , |
|||
SERVIZIO_SOCIALE VARCHAR2(255 BYTE), |
|||
AREA VARCHAR2(255 BYTE), |
|||
INDIRIZZO VARCHAR2(255 BYTE) NOT NULL, |
|||
TELEFONO NUMBER(10) PRIMARY KEY, |
|||
NUMERO NUMBER(2) NOT NULL , |
|||
COMPOSIZIONE_NUCLEO VARCHAR2(255 BYTE) NOT NULL , |
|||
NOTE_SACCHETTO VARCHAR2(255 BYTE), |
|||
ULTIMA_CONSEGNA DATE, |
|||
EMAIL VARCHAR2(256 BYTE) |
|||
) ; |
|||
|
|||
CREATE TABLE ORDINI |
|||
( TELEFONO NUMBER(10) PRIMARY KEY REFERENCES CONTATTI(TELEFONO) |
|||
) ; |
@ -0,0 +1,208 @@ |
|||
package bean; |
|||
|
|||
import java.time.LocalDate; |
|||
|
|||
public class Contatto { |
|||
private String nome; |
|||
private String email; |
|||
private String cognome; |
|||
private String servizio_sociale; |
|||
private String area; |
|||
private String indirizzo; |
|||
private long telefono; |
|||
private int numero_persone; |
|||
private String composizione_nucleo; |
|||
private String note_sacchetto; |
|||
private LocalDate ultima_consegna; |
|||
|
|||
public Contatto() { |
|||
} |
|||
|
|||
public Contatto(String nome, String cognome, String servizio_sociale, String area, String indirizzo, |
|||
long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto, |
|||
LocalDate ultima_consegna) { |
|||
this.nome = nome; |
|||
this.email=email; |
|||
this.cognome = cognome; |
|||
this.servizio_sociale = servizio_sociale; |
|||
this.area = area; |
|||
this.indirizzo = indirizzo; |
|||
this.telefono = telefono; |
|||
this.numero_persone = numero_persone; |
|||
this.composizione_nucleo = composizione_nucleo; |
|||
this.note_sacchetto = note_sacchetto; |
|||
this.ultima_consegna = ultima_consegna; |
|||
} |
|||
|
|||
public String getNome() { |
|||
return nome; |
|||
} |
|||
|
|||
public void setNome(String nome) { |
|||
this.nome = nome; |
|||
} |
|||
|
|||
public String getEmail() { |
|||
return email; |
|||
} |
|||
|
|||
public void setEmail(String email) { |
|||
this.email = email; |
|||
} |
|||
|
|||
public String getCognome() { |
|||
return cognome; |
|||
} |
|||
|
|||
public void setCognome(String cognome) { |
|||
this.cognome = cognome; |
|||
} |
|||
|
|||
public String getServizio_sociale() { |
|||
return servizio_sociale; |
|||
} |
|||
|
|||
public void setServizio_sociale(String servizio_sociale) { |
|||
this.servizio_sociale = servizio_sociale; |
|||
} |
|||
|
|||
public String getArea() { |
|||
return area; |
|||
} |
|||
|
|||
public void setArea(String area) { |
|||
this.area = area; |
|||
} |
|||
|
|||
public String getIndirizzo() { |
|||
return indirizzo; |
|||
} |
|||
|
|||
public void setIndirizzo(String indirizzo) { |
|||
this.indirizzo = indirizzo; |
|||
} |
|||
|
|||
public long getTelefono() { |
|||
return telefono; |
|||
} |
|||
|
|||
public void setTelefono(long telefono) { |
|||
this.telefono = telefono; |
|||
} |
|||
|
|||
public int getNumero_persone() { |
|||
return numero_persone; |
|||
} |
|||
|
|||
public void setNumero_persone(int numero_persone) { |
|||
this.numero_persone = numero_persone; |
|||
} |
|||
|
|||
public String getComposizione_nucleo() { |
|||
return composizione_nucleo; |
|||
} |
|||
|
|||
public void setComposizione_nucleo(String composizione_nucleo) { |
|||
this.composizione_nucleo = composizione_nucleo; |
|||
} |
|||
|
|||
public String getNote_sacchetto() { |
|||
return note_sacchetto; |
|||
} |
|||
|
|||
public void setNote_sacchetto(String note_sacchetto) { |
|||
this.note_sacchetto = note_sacchetto; |
|||
} |
|||
|
|||
public LocalDate getUltima_consegna() { |
|||
return ultima_consegna; |
|||
} |
|||
|
|||
public void setUltima_consegna(LocalDate ultima_consegna) { |
|||
this.ultima_consegna = ultima_consegna; |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
final int prime = 31; |
|||
int result = 1; |
|||
result = prime * result + ((area == null) ? 0 : area.hashCode()); |
|||
result = prime * result + ((cognome == null) ? 0 : cognome.hashCode()); |
|||
result = prime * result + ((composizione_nucleo == null) ? 0 : composizione_nucleo.hashCode()); |
|||
result = prime * result + ((indirizzo == null) ? 0 : indirizzo.hashCode()); |
|||
result = prime * result + ((nome == null) ? 0 : nome.hashCode()); |
|||
result = prime * result + ((note_sacchetto == null) ? 0 : note_sacchetto.hashCode()); |
|||
result = prime * result + numero_persone; |
|||
result = prime * result + ((servizio_sociale == null) ? 0 : servizio_sociale.hashCode()); |
|||
result = prime * result + (int) (telefono ^ (telefono >>> 32)); |
|||
result = prime * result + ((ultima_consegna == null) ? 0 : ultima_consegna.hashCode()); |
|||
return result; |
|||
} |
|||
|
|||
@Override |
|||
public boolean equals(Object obj) { |
|||
if (this == obj) |
|||
return true; |
|||
if (obj == null) |
|||
return false; |
|||
if (getClass() != obj.getClass()) |
|||
return false; |
|||
Contatto other = (Contatto) obj; |
|||
if (area == null) { |
|||
if (other.area != null) |
|||
return false; |
|||
} else if (!area.equals(other.area)) |
|||
return false; |
|||
if (cognome == null) { |
|||
if (other.cognome != null) |
|||
return false; |
|||
} else if (!cognome.equals(other.cognome)) |
|||
return false; |
|||
if (composizione_nucleo == null) { |
|||
if (other.composizione_nucleo != null) |
|||
return false; |
|||
} else if (!composizione_nucleo.equals(other.composizione_nucleo)) |
|||
return false; |
|||
|
|||
if (indirizzo == null) { |
|||
if (other.indirizzo != null) |
|||
return false; |
|||
} else if (!indirizzo.equals(other.indirizzo)) |
|||
return false; |
|||
if (nome == null) { |
|||
if (other.nome != null) |
|||
return false; |
|||
} else if (!nome.equals(other.nome)) |
|||
return false; |
|||
if (note_sacchetto == null) { |
|||
if (other.note_sacchetto != null) |
|||
return false; |
|||
} else if (!note_sacchetto.equals(other.note_sacchetto)) |
|||
return false; |
|||
if (numero_persone != other.numero_persone) |
|||
return false; |
|||
if (servizio_sociale == null) { |
|||
if (other.servizio_sociale != null) |
|||
return false; |
|||
} else if (!servizio_sociale.equals(other.servizio_sociale)) |
|||
return false; |
|||
if (telefono != other.telefono) |
|||
return false; |
|||
if (ultima_consegna == null) { |
|||
if (other.ultima_consegna != null) |
|||
return false; |
|||
} else if (!ultima_consegna.equals(other.ultima_consegna)) |
|||
return false; |
|||
return true; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "Contatto [ nome=" + nome + ", cognome=" + cognome + ", servizio_sociale=" |
|||
+ servizio_sociale + ", area=" + area + ", indirizzo=" + indirizzo + ", telefono=" + telefono |
|||
+ ", numero_persone=" + numero_persone + ", composizione_nucleo=" + composizione_nucleo |
|||
+ ", note_sacchetto=" + note_sacchetto + ", ultima_consegna=" + ultima_consegna + "]"; |
|||
} |
|||
|
|||
|
|||
} |
@ -0,0 +1,221 @@ |
|||
package dao; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.Date; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
|
|||
import bean.Contatto; |
|||
|
|||
public class ContattoDao implements ContattoDaoI { |
|||
|
|||
OracleConnection c = new OracleConnection(); |
|||
|
|||
@Override |
|||
public boolean create(String nome, String cognome, String servizio_sociale, String area, String indirizzo, |
|||
long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto) { |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
String query = "insert into contatti (nome, cognome, servizio_sociale, area, indirizzo, telefono, email, numero, composizione_nucleo, note_sacchetto) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; |
|||
int n = -1; |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setString(1, nome); |
|||
st.setString(2, cognome); |
|||
st.setString(3, servizio_sociale); |
|||
st.setString(4, area); |
|||
st.setString(5, indirizzo); |
|||
st.setLong(6, telefono); |
|||
st.setString(7, email); |
|||
st.setInt(8, numero_persone); |
|||
st.setString(9, composizione_nucleo); |
|||
st.setString(10, note_sacchetto); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
@Override |
|||
public Contatto read(long telefono) { |
|||
String query = "select nome, cognome, email, servizio_sociale, area, indirizzo, numero, composizione_nucleo, note_sacchetto, ultima_consegna from contatti where telefono = ?"; |
|||
Contatto contatto = null; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
st.setLong(1, telefono); |
|||
|
|||
ResultSet rs = st.executeQuery(); |
|||
|
|||
while (rs.next()) { |
|||
contatto = new Contatto(); |
|||
|
|||
contatto.setTelefono(telefono); |
|||
contatto.setNome(rs.getString(1)); |
|||
contatto.setCognome(rs.getString(2)); |
|||
contatto.setEmail(rs.getString(3)); |
|||
contatto.setServizio_sociale(rs.getString(4)); |
|||
contatto.setArea(rs.getString(5)); |
|||
contatto.setIndirizzo(rs.getString(6)); |
|||
contatto.setNumero_persone(rs.getInt(7)); |
|||
contatto.setComposizione_nucleo(rs.getString(8)); |
|||
contatto.setNote_sacchetto(rs.getString(9)); |
|||
|
|||
Date data = rs.getDate(10); |
|||
|
|||
if (data != null) { |
|||
contatto.setUltima_consegna(data.toLocalDate()); |
|||
} |
|||
|
|||
} |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return contatto; |
|||
} |
|||
|
|||
@Override |
|||
public boolean updateConsegna(long telefono, LocalDate data_consegna) { |
|||
String query = "update contatti set ultima_consegna=? where telefono=?"; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setDate(1, Date.valueOf(data_consegna)); |
|||
st.setLong(2, telefono); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return n == -1 ? false : true; |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public boolean update(String nome, String cognome, String servizio_sociale, String area, String indirizzo, |
|||
long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto) { |
|||
String query = "update contatti set nome=?, cognome=?, servizio_sociale=?, area=?, indirizzo=?, telefono=?, email = ?, numero=?, composizione_nucleo=?, note_sacchetto=? where telefono=?"; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setString(1, nome); |
|||
st.setString(2, cognome); |
|||
st.setString(3, servizio_sociale); |
|||
st.setString(4, area); |
|||
st.setString(5, indirizzo); |
|||
st.setLong(6, telefono); |
|||
st.setString(7, email); |
|||
st.setInt(8, numero_persone); |
|||
st.setString(9, composizione_nucleo); |
|||
st.setString(10, note_sacchetto); |
|||
st.setLong(11, telefono); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
@Override |
|||
public boolean delete(long telefono) { |
|||
String query = "delete from contatti where telefono=?"; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setLong(1, telefono); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
@Override |
|||
public ArrayList<Contatto> leggiTutti() { |
|||
String query = "select telefono, email, nome, cognome, servizio_sociale, area, indirizzo, numero, composizione_nucleo, note_sacchetto, ultima_consegna from contatti"; |
|||
ArrayList<Contatto> contatti = new ArrayList<Contatto>(); |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
ResultSet rs = st.executeQuery(); |
|||
|
|||
while (rs.next()) { |
|||
Contatto contatto = new Contatto(); |
|||
|
|||
contatto.setTelefono(rs.getLong(1)); |
|||
contatto.setEmail(rs.getString(2)); |
|||
contatto.setNome(rs.getString(3)); |
|||
contatto.setCognome(rs.getString(4)); |
|||
contatto.setServizio_sociale(rs.getString(5)); |
|||
contatto.setArea(rs.getString(6)); |
|||
contatto.setIndirizzo(rs.getString(7)); |
|||
contatto.setNumero_persone(rs.getInt(8)); |
|||
contatto.setComposizione_nucleo(rs.getString(9)); |
|||
contatto.setNote_sacchetto(rs.getString(10)); |
|||
|
|||
Date data = rs.getDate(11); |
|||
|
|||
if (data != null) { |
|||
contatto.setUltima_consegna(data.toLocalDate()); |
|||
} |
|||
|
|||
contatti.add(contatto); |
|||
} |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
c.close(); |
|||
return contatti; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,22 @@ |
|||
package dao; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
|
|||
import bean.Contatto; |
|||
|
|||
public interface ContattoDaoI { |
|||
boolean create(String nome, String cognome, String servizio_sociale, String area, String indirizzo, |
|||
long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto); |
|||
|
|||
Contatto read(long telefono); |
|||
|
|||
boolean update(String nome, String cognome, String servizio_sociale, String area, String indirizzo, |
|||
long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto); |
|||
|
|||
boolean updateConsegna(long telefono, LocalDate data_consegna); |
|||
|
|||
boolean delete(long telefono); |
|||
|
|||
ArrayList<Contatto> leggiTutti(); |
|||
} |
@ -0,0 +1,45 @@ |
|||
|
|||
package dao; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.DriverManager; |
|||
import java.sql.SQLException; |
|||
|
|||
public class MySqlConnection { |
|||
|
|||
public static void main(String[] args) { |
|||
MySqlConnection c = new MySqlConnection(); |
|||
c.open(); |
|||
} |
|||
|
|||
|
|||
private Connection connection; |
|||
|
|||
|
|||
public Connection open() { |
|||
String nomeDriver = "com.mysql.driverDriver"; |
|||
String utente = "brigate"; //nome utente
|
|||
String password = "password"; //password
|
|||
String url = "jdbc:oracle:thin:@localhost:1521:orcl"; |
|||
|
|||
try { |
|||
Class.forName(nomeDriver); |
|||
this.connection = DriverManager.getConnection(url, utente, password); |
|||
} catch (ClassNotFoundException e) { |
|||
e.printStackTrace(); |
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return connection; |
|||
} |
|||
|
|||
public void close() { |
|||
try { |
|||
connection.close(); |
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
|
|||
package dao; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.DriverManager; |
|||
import java.sql.SQLException; |
|||
|
|||
public class OracleConnection { |
|||
|
|||
public static void main(String[] args) { |
|||
OracleConnection c = new OracleConnection(); |
|||
c.open(); |
|||
} |
|||
|
|||
private Connection connection; |
|||
|
|||
|
|||
public Connection open() { |
|||
String nomeDriver = "oracle.jdbc.driver.OracleDriver"; |
|||
String utente = "C##brigate"; //nome utente
|
|||
String password = "password"; //password
|
|||
String url = "jdbc:oracle:thin:@localhost:1521:orcl"; |
|||
|
|||
try { |
|||
Class.forName(nomeDriver); |
|||
|
|||
this.connection = DriverManager.getConnection(url, utente, password); |
|||
} catch (ClassNotFoundException e) { |
|||
e.printStackTrace(); |
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return connection; |
|||
} |
|||
|
|||
public void close() { |
|||
try { |
|||
connection.close(); |
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,223 @@ |
|||
package dao; |
|||
|
|||
import java.sql.Connection; |
|||
import java.sql.PreparedStatement; |
|||
import java.sql.ResultSet; |
|||
import java.sql.SQLException; |
|||
import java.util.ArrayList; |
|||
|
|||
import bean.Contatto; |
|||
|
|||
public class OrdiniDao implements OrdiniDaoI { |
|||
ContattoDao cd = new ContattoDao(); |
|||
|
|||
OracleConnection c = new OracleConnection(); |
|||
|
|||
@Override |
|||
public boolean aggiungi(long telefono) { |
|||
|
|||
// Cerca contatto nel db
|
|||
Contatto contatto = cd.read(telefono); |
|||
Connection connection = c.open(); |
|||
|
|||
// Se esiste, aggiungilo agli ordini
|
|||
if (contatto != null) { |
|||
String query = "insert into ordini values (?)"; |
|||
int n = -1; |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setLong(1, telefono); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
c.close(); |
|||
return n == -1 ? false : true; |
|||
} else { |
|||
c.close(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public boolean rimuovi(long telefono) { |
|||
String query = "delete from ordini where telefono=?"; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setLong(1, telefono); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
@Override |
|||
public boolean aggiungi(Contatto contatto) { |
|||
|
|||
// Cerca contatto nel db
|
|||
Contatto cont = cd.read(contatto.getTelefono()); |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
// Se esiste, aggiungilo agli ordini
|
|||
if (c != null) { |
|||
String query = "insert into ordini values (?)"; |
|||
int n = -1; |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setLong(1, cont.getTelefono()); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
c.close(); |
|||
return n == -1 ? false : true; |
|||
} else { |
|||
c.close(); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
@Override |
|||
public boolean rimuovi(Contatto contatto) { |
|||
String query = "delete from ordini where telefono=?"; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
st.setLong(1, contatto.getTelefono()); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
c.close(); |
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
@Override |
|||
public ArrayList<Contatto> leggiTutti() { |
|||
String query = "select * from ordini"; |
|||
ArrayList<Contatto> contatti = new ArrayList<Contatto>(); |
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
ResultSet rs = st.executeQuery(); |
|||
|
|||
while (rs.next()) { |
|||
long telefono = rs.getLong(1); |
|||
|
|||
Contatto contatto = cd.read(telefono); |
|||
|
|||
contatti.add(contatto); |
|||
} |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return contatti; |
|||
} |
|||
|
|||
@Override |
|||
public ArrayList<Contatto> leggiTutti(int limit) { |
|||
String query = "select o.telefono from ordini o, contatti c where rownum <= " + limit + " and o.telefono=c.telefono order by c.area"; |
|||
ArrayList<Contatto> contatti = new ArrayList<Contatto>(); |
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
ResultSet rs = st.executeQuery(); |
|||
|
|||
while (rs.next()) { |
|||
System.out.println("query eseguita"); |
|||
long telefono = rs.getLong(1); |
|||
|
|||
Contatto contatto = cd.read(telefono); |
|||
|
|||
contatti.add(contatto); |
|||
} |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return contatti; |
|||
} |
|||
|
|||
@Override |
|||
public boolean rimuoviTutti() { |
|||
String query = "delete from ordini"; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
|
|||
} |
|||
|
|||
c.close(); |
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
@Override |
|||
public boolean rimuoviPrimi(int numero) { |
|||
String query = "delete from ordini limit " + numero; |
|||
int n = -1; |
|||
|
|||
Connection connection = c.open(); |
|||
|
|||
try { |
|||
PreparedStatement st = connection.prepareStatement(query); |
|||
|
|||
n = st.executeUpdate(); |
|||
|
|||
} catch (SQLException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
c.close(); |
|||
|
|||
return n == -1 ? false : true; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,24 @@ |
|||
package dao; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
import bean.Contatto; |
|||
|
|||
public interface OrdiniDaoI { |
|||
|
|||
boolean aggiungi(long telefono); |
|||
|
|||
boolean aggiungi(Contatto contatto); |
|||
|
|||
boolean rimuovi(long telefono); |
|||
|
|||
boolean rimuovi(Contatto contatto); |
|||
|
|||
ArrayList<Contatto> leggiTutti(); |
|||
|
|||
ArrayList<Contatto> leggiTutti(int limit); |
|||
|
|||
boolean rimuoviTutti(); |
|||
|
|||
boolean rimuoviPrimi(int numero); |
|||
} |
@ -0,0 +1,77 @@ |
|||
package filtri; |
|||
|
|||
import java.io.IOException; |
|||
import javax.servlet.Filter; |
|||
import javax.servlet.FilterChain; |
|||
import javax.servlet.FilterConfig; |
|||
import javax.servlet.ServletException; |
|||
import javax.servlet.ServletRequest; |
|||
import javax.servlet.ServletResponse; |
|||
import javax.servlet.annotation.WebFilter; |
|||
import javax.servlet.http.HttpServletRequest; |
|||
import javax.servlet.http.HttpServletResponse; |
|||
|
|||
import bean.Contatto; |
|||
import service.ContattoService; |
|||
|
|||
/** |
|||
* Servlet Filter implementation class FiltroContatto |
|||
*/ |
|||
@WebFilter("/home-contatto.jsp") |
|||
public class FiltroContatto implements Filter { |
|||
|
|||
/** |
|||
* Default constructor. |
|||
*/ |
|||
public FiltroContatto() { |
|||
// TODO Auto-generated constructor stub
|
|||
} |
|||
|
|||
/** |
|||
* @see Filter#destroy() |
|||
*/ |
|||
public void destroy() { |
|||
// TODO Auto-generated method stub
|
|||
} |
|||
|
|||
/** |
|||
* @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain) |
|||
*/ |
|||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { |
|||
HttpServletRequest req = (HttpServletRequest)request; |
|||
HttpServletResponse res = (HttpServletResponse)response; |
|||
|
|||
String tel = req.getParameter("id"); |
|||
System.out.println("tel"); |
|||
|
|||
if(tel != null) { |
|||
Long telefono = Long.parseLong(tel); |
|||
System.out.println(telefono); |
|||
|
|||
Contatto c = ContattoService.cercaPerNumero(telefono); |
|||
|
|||
System.out.println("Filtro"); |
|||
|
|||
if(c != null) { |
|||
req.setAttribute("contatto", c); |
|||
System.out.println("Filtro ::" + c); |
|||
chain.doFilter(req, res); |
|||
}else { |
|||
res.sendRedirect("error.jsp"); |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
// pass the request along the filter chain
|
|||
|
|||
} |
|||
|
|||
/** |
|||
* @see Filter#init(FilterConfig) |
|||
*/ |
|||
public void init(FilterConfig fConfig) throws ServletException { |
|||
// TODO Auto-generated method stub
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package service; |
|||
|
|||
import java.time.LocalDate; |
|||
import java.util.ArrayList; |
|||
|
|||
import bean.Contatto; |
|||
import dao.ContattoDao; |
|||
|
|||
public class ContattoService { |
|||
|
|||
private static ContattoDao cd = new ContattoDao(); |
|||
|
|||
public static boolean aggiungiContatto(String nome, String cognome, String servizio_sociale, String area, |
|||
String indirizzo, long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto) { |
|||
return cd.create(nome, cognome, servizio_sociale, area, indirizzo, telefono, email, numero_persone, |
|||
composizione_nucleo, note_sacchetto); |
|||
|
|||
} |
|||
|
|||
public static Contatto cercaPerNumero(long telefono) { |
|||
return cd.read(telefono); |
|||
} |
|||
|
|||
public static boolean aggiorna(String nome, String cognome, String servizio_sociale, String area, String indirizzo, |
|||
long telefono, String email, int numero_persone, String composizione_nucleo, String note_sacchetto) { |
|||
return cd.update(nome, cognome, servizio_sociale, area, indirizzo, telefono, email, numero_persone, |
|||
composizione_nucleo, note_sacchetto); |
|||
} |
|||
|
|||
public static boolean consegnatoOggi(long telefono) { |
|||
return cd.updateConsegna(telefono, LocalDate.now()); |
|||
} |
|||
|
|||
public static boolean consegnatoIl(long telefono, LocalDate data) { |
|||
return cd.updateConsegna(telefono, data); |
|||
} |
|||
|
|||
public static boolean elimina(long telefono) { |
|||
return cd.delete(telefono); |
|||
} |
|||
|
|||
public static ArrayList<Contatto> elenco() { |
|||
return cd.leggiTutti(); |
|||
} |
|||
} |
@ -0,0 +1,43 @@ |
|||
package service; |
|||
|
|||
import java.util.ArrayList; |
|||
|
|||
import bean.Contatto; |
|||
import dao.OrdiniDao; |
|||
|
|||
public class OrdiniService { |
|||
private static OrdiniDao od = new OrdiniDao(); |
|||
|
|||
public static boolean aggiungi(long telefono) { |
|||
return od.aggiungi(telefono); |
|||
} |
|||
|
|||
public static boolean aggiungi(Contatto contatto) { |
|||
return od.aggiungi(contatto); |
|||
} |
|||
|
|||
|
|||
public static boolean rimuovi(long telefono) { |
|||
return od.rimuovi(telefono); |
|||
} |
|||
|
|||
public static boolean rimuovi(Contatto telefono) { |
|||
return od.rimuovi(telefono); |
|||
} |
|||
|
|||
public static ArrayList<Contatto> leggiTutti(){ |
|||
return od.leggiTutti(); |
|||
} |
|||
|
|||
public static ArrayList<Contatto> leggiTutti(int limit){ |
|||
return od.leggiTutti(limit); |
|||
} |
|||
|
|||
public static boolean rimuoviTutti() { |
|||
return od.rimuoviTutti(); |
|||
} |
|||
|
|||
public static boolean rimuoviPrimi(int numero) { |
|||
return od.rimuoviPrimi(numero); |
|||
} |
|||
} |
@ -0,0 +1,150 @@ |
|||
package servlet; |
|||
|
|||
import java.io.IOException; |
|||
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 bean.Contatto; |
|||
import service.ContattoService; |
|||
import service.OrdiniService; |
|||
|
|||
/** |
|||
* Servlet implementation class ContattiServlet |
|||
*< |