Browse Source

//prova

master
marghe 1 year ago
parent
commit
76a3d2be78
5 changed files with 153 additions and 14 deletions
  1. +9
    -12
      WebContent/cerca-aggiungi.jsp
  2. +83
    -0
      src/bean/Utente.java
  3. +47
    -0
      src/dao/UtenteDao.java
  4. +10
    -0
      src/dao/UtenteDaoI.java
  5. +4
    -2
      src/servlet/OrdiniServlet.java

+ 9
- 12
WebContent/cerca-aggiungi.jsp View File

@@ -10,9 +10,6 @@
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>
@@ -28,7 +25,7 @@
<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">
name="telefono" class="form-control form-control-sm" required>
</div>
<input type="hidden" name="azione" value="cerca">
<button type="submit" class="btn btn-light btn-sm">Cerca</button>
@@ -39,11 +36,11 @@
<div class="cinquanta">
<div class="form-group">
<label>Nome*</label> <input type="text" name="nome"
class="form-control form-control-sm">
class="form-control form-control-sm" required>
</div>
<div class="form-group">
<label>Cognome*</label> <input type="text" name="cognome"
class="form-control form-control-sm">
class="form-control form-control-sm" required>
</div>
<!-- <div class="form-group"> -->
<!-- <label>Servizio sociale</label> <input type="text" -->
@@ -59,11 +56,11 @@
</div>
<div class="form-group">
<label>Indirizzo*</label> <input type="text" name="indirizzo"
class="form-control form-control-sm">
class="form-control form-control-sm" required>
</div>
<div class="form-group">
<label>Numero di telefono*</label> <input type="number"
name="telefono" class="form-control form-control-sm">
name="telefono" class="form-control form-control-sm" required>
</div>
<div class="form-group">
<label>Email</label> <input type="email" name="email"
@@ -75,14 +72,14 @@
<p>Composizione nucleo abitativo*</p>
<div class="form-group">
<label>Neonat_ (0-3 anni)</label> <input type="number"
name="neonat" value="0"
name="neonat" value="0" required
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>
class="form-control form-control-sm number" required><br> <label>Adult_</label>
<input type="number" name="adult" value="0"
class="form-control form-control-sm number"><br> <label>Anzian_ (>65 anni)</label>
class="form-control form-control-sm number" required><br> <label>Anzian_ (>65 anni)</label>
<input type="number" name="anzian" value="0"
class="form-control form-control-sm number"><br>
class="form-control form-control-sm number" required><br>
</div>
<div class="form-group">
<label style="vertical-align: top">Note sacchetto (allergie, diete, necessità...)</label>


+ 83
- 0
src/bean/Utente.java View File

@@ -0,0 +1,83 @@
package bean;

public class Utente {
private String nick;
private String password;
private String ruolo;
public Utente() {
}

public Utente(String nick, String password, String ruolo) {
this.nick = nick;
this.password = password;
this.ruolo = ruolo;
}

public String getNick() {
return nick;
}

public void setNick(String nick) {
this.nick = nick;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getRuolo() {
return ruolo;
}

public void setRuolo(String ruolo) {
this.ruolo = ruolo;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((nick == null) ? 0 : nick.hashCode());
result = prime * result + ((password == null) ? 0 : password.hashCode());
result = prime * result + ((ruolo == null) ? 0 : ruolo.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;
Utente other = (Utente) obj;
if (nick == null) {
if (other.nick != null)
return false;
} else if (!nick.equals(other.nick))
return false;
if (password == null) {
if (other.password != null)
return false;
} else if (!password.equals(other.password))
return false;
if (ruolo == null) {
if (other.ruolo != null)
return false;
} else if (!ruolo.equals(other.ruolo))
return false;
return true;
}

@Override
public String toString() {
return "Utente [nick=" + nick + ", password=" + password + ", ruolo=" + ruolo + "]";
}

}

+ 47
- 0
src/dao/UtenteDao.java View File

@@ -0,0 +1,47 @@
package dao;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import bean.Utente;

public class UtenteDao implements UtenteDaoI {
OracleConnection c = new OracleConnection();

@Override
public boolean registrazione(String nickname, String password, String ruolo) {
Connection connection = c.open();
boolean ok = false;
String query = "insert into utenti values(?, ?, ?)";
try {
PreparedStatement st = connection.prepareStatement(query);

st.setString(1, nickname);

// n = st.executeUpdate();
//
} catch (SQLException e) {
e.printStackTrace();

}

c.close();
// return n == -1 ? false : true;
c.close();
return ok;
}

@Override
public Utente login(String nickname, String password) {
// TODO Auto-generated method stub
return null;
}

}

+ 10
- 0
src/dao/UtenteDaoI.java View File

@@ -0,0 +1,10 @@
package dao;

import bean.Utente;

public interface UtenteDaoI {

boolean registrazione(String nickname, String password, String ruolo);
Utente login(String nickname, String password);
}

+ 4
- 2
src/servlet/OrdiniServlet.java View File

@@ -57,7 +57,9 @@ public class OrdiniServlet extends HttpServlet {

LocalDate ultimaConsegna = contatto.getUltima_consegna();

if (ultimaConsegna == null || ChronoUnit.DAYS.between(LocalDate.now(), ultimaConsegna) >= 5) {
System.out.println("Passati: " + ChronoUnit.DAYS.between(LocalDate.now(), ultimaConsegna));

if (ultimaConsegna == null || ChronoUnit.DAYS.between(ultimaConsegna, LocalDate.now()) >= 5) {
boolean ok = OrdiniService.aggiungi(numero);

if (ok) {
@@ -68,7 +70,7 @@ public class OrdiniServlet extends HttpServlet {
}
} else {
request.setAttribute("messaggio", "Impossibile aggiungere l'ordine, sono passati meno di 5 gioni");
request.getRequestDispatcher("error.jsp").forward(request, response);
request.getRequestDispatcher("home-contatto.jsp?id="+numero).forward(request, response);
}

} else {


Loading…
Cancel
Save