diff --git a/WebContent/cerca-aggiungi.jsp b/WebContent/cerca-aggiungi.jsp index 0cf363e..13a39ec 100644 --- a/WebContent/cerca-aggiungi.jsp +++ b/WebContent/cerca-aggiungi.jsp @@ -10,9 +10,6 @@ integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> - @@ -28,7 +25,7 @@
+ name="telefono" class="form-control form-control-sm" required>
@@ -39,11 +36,11 @@
+ class="form-control form-control-sm" required>
+ class="form-control form-control-sm" required>
@@ -59,11 +56,11 @@
+ class="form-control form-control-sm" required>
+ name="telefono" class="form-control form-control-sm" required>
Composizione nucleo abitativo*



+ class="form-control form-control-sm number" required>

+ class="form-control form-control-sm number" required>

+ class="form-control form-control-sm number" required>
diff --git a/src/bean/Utente.java b/src/bean/Utente.java new file mode 100644 index 0000000..287900f --- /dev/null +++ b/src/bean/Utente.java @@ -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 + "]"; + } + +} diff --git a/src/dao/UtenteDao.java b/src/dao/UtenteDao.java new file mode 100644 index 0000000..79b3ffb --- /dev/null +++ b/src/dao/UtenteDao.java @@ -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; + } + +} diff --git a/src/dao/UtenteDaoI.java b/src/dao/UtenteDaoI.java new file mode 100644 index 0000000..86a9a54 --- /dev/null +++ b/src/dao/UtenteDaoI.java @@ -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); +} diff --git a/src/servlet/OrdiniServlet.java b/src/servlet/OrdiniServlet.java index e380ab3..53017f3 100644 --- a/src/servlet/OrdiniServlet.java +++ b/src/servlet/OrdiniServlet.java @@ -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 {