1
0
Fork 0

Formatting and logout fix

This commit is contained in:
Ethanell 2022-06-30 22:15:08 +02:00
parent cfeb8d56ab
commit 9f582d6e80
58 changed files with 1479 additions and 1469 deletions

View file

@ -8,27 +8,27 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<H1>Achats du client n°<%=request.getParameter("customerId")%></H1> <H1>Achats du client n°<%=request.getParameter("customerId")%></H1>
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">
<c:forEach items="${achats}" var="cli"> <c:forEach items="${achats}" var="cli">
<TR> <TR>
<TD>${cli.orderNum}</TD> <TD>${cli.orderNum}</TD>
<TD>${cli.customerId}</TD> <TD>${cli.customerId}</TD>
<TD>${cli.productId}</TD> <TD>${cli.productId}</TD>
<TD>${cli.quantity}</TD> <TD>${cli.quantity}</TD>
<TD>${cli.shippingCost}</TD> <TD>${cli.shippingCost}</TD>
<TD>${cli.salesDate}</TD> <TD>${cli.salesDate}</TD>
<TD>${cli.shippingDate}</TD> <TD>${cli.shippingDate}</TD>
<TD>${cli.freightCompany}</TD> <TD>${cli.freightCompany}</TD>
</TR> </TR>
</c:forEach> </c:forEach>
</table> </table>
</body> </body>
</html> </html>

View file

@ -13,7 +13,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<h1>${error != null ? error : confirm} </h1> <h1>${error != null ? error : confirm} </h1>
<form action="list.htm" method="POST"> <form action="list.htm" method="POST">
<input hidden type="text" name="type" value="${type}" /> <input hidden type="text" name="type" value="${type}" />

View file

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="detail" method="POST"> <form name="detail" method="POST">
<c:choose> <c:choose>
<c:when test="${type == 'customer'}"> <c:when test="${type == 'customer'}">
@ -106,12 +106,12 @@
<label for="available">Available</label> <label for="available">Available</label>
<label for="isavailable">TRUE:</label> <label for="isavailable">TRUE:</label>
<input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" /> <input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" />
<label for="notavailable">FALSE:</label> <label for="notavailable">FALSE:</label>
<input type="radio" name="available" value="FALSE" <c:if test="${result.available == 'FALSE'}">checked</c:if> id="notavailable" /> <input type="radio" name="available" value="FALSE" <c:if test="${result.available == 'FALSE'}">checked</c:if> id="notavailable" />
</p> </p>
<p> <p>
<label for="description">Description</label> <label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="50" /> <input type="text" name="description" value="${result.description}" id="description" size="50" />
</p> </p>
</c:when> </c:when>
<c:when test="${type == 'purchase'}"> <c:when test="${type == 'purchase'}">
@ -185,7 +185,7 @@
</p> </p>
</c:when> </c:when>
</c:choose> </c:choose>
<input hidden type="text" name="type" value="${type}" /> <input hidden type="text" name="type" value="${type}" />
<c:choose> <c:choose>
<c:when test="${save != null}"> <c:when test="${save != null}">

View file

@ -14,40 +14,40 @@
</head> </head>
<body> <body>
Bienvenue ${user.login} Bienvenue ${user.login}
<form name="inscription" method="POST"> <form name="inscription" method="POST">
<p> <p>
<label for="nom">Nom</label> <label for="nom">Nom</label>
<input type="text" name="nom" value="" size="10" id="nom" /> <input type="text" name="nom" value="" size="10" id="nom" />
</p> </p>
<p> <p>
<label for="adresse">Adresse</label> <label for="adresse">Adresse</label>
<input type="text" name="adresse" value="" size="10" id="adresse" /> <input type="text" name="adresse" value="" size="10" id="adresse" />
</p> </p>
<p> <p>
<label for="telephone">Téléphone</label> <label for="telephone">Téléphone</label>
<input type="text" name="telephone" value="" size="10" id="tel" /> <input type="text" name="telephone" value="" size="10" id="tel" />
</p> </p>
<p> <p>
<label for="email">E-mail</label> <label for="email">E-mail</label>
<input type="text" name="email" value="" size="10" id="email"/> <input type="text" name="email" value="" size="10" id="email"/>
</p> </p>
<p><label for="code_remise">Code Remise</label> <p><label for="code_remise">Code Remise</label>
<select name="code_remise" id="dc"> <select name="code_remise" id="dc">
<c:forEach items="${discount}" var="dc"> <c:forEach items="${discount}" var="dc">
<option>${dc}</option> <option>${dc}</option>
</c:forEach> </c:forEach>
</select> </select>
</p> </p>
<p> <p>
<label for="cp">Code Postal</label> <label for="cp">Code Postal</label>
<select name="CP" id="cp"> <select name="CP" id="cp">
<c:forEach items="${code}" var="cp"> <c:forEach items="${code}" var="cp">
<option>${cp}</option> <option>${cp}</option>
</c:forEach> </c:forEach>
</select> </select>
</p> </p>
<input type="submit" value="Enregistrer" formaction="save.htm" /> <input type="submit" value="Enregistrer" formaction="save.htm" />
</form> </form>

View file

@ -15,7 +15,7 @@
<div style="display: flex; flex-direction: row; justify-content: flex-end"> <div style="display: flex; flex-direction: row; justify-content: flex-end">
<form name="form" method="POST"> <form name="form" method="POST">
<input type="submit" formaction="logout.htm" value="Log out" /> <input type="submit" formaction="logout.htm" value="Log out" />
<input type="text" name="query" /> <input type="text" name="query" />
<input hidden type="text" name="type" value="customer" /> <input hidden type="text" name="type" value="customer" />
<input type="submit" formaction="find.htm" value="Search user" /> <input type="submit" formaction="find.htm" value="Search user" />

View file

@ -2,5 +2,5 @@
<% response.sendRedirect("menu.htm"); %> <% response.sendRedirect("menu.htm");%>

View file

@ -13,20 +13,20 @@
</head> </head>
<body> <body>
<form method="POST" action="j_security_check"> <form method="POST" action="j_security_check">
<table> <table>
<tr> <tr>
<td>Utilisateur :</td> <td>Utilisateur :</td>
<td><input type="text" name="j_username"></td> <td><input type="text" name="j_username"></td>
</tr> </tr>
<tr> <tr>
<td>Mot de passe :</td> <td>Mot de passe :</td>
<td><input type="password" name="j_password" ></td> <td><input type="password" name="j_password" ></td>
</tr> </tr>
<tr> <tr>
<td><input type="submit" value="Entrer" ></td> <td><input type="submit" value="Entrer" ></td>
<td><input type="reset" value="Annuler"></td> <td><input type="reset" value="Annuler"></td>
</tr> </tr>
</table> </table>
</form> </form>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<h1>choisissez une opération dans la liste suivante</h1> <h1>choisissez une opération dans la liste suivante</h1>
<form name="form" action="list.htm" method="POST"> <form name="form" action="list.htm" method="POST">
<input type="submit" value="Customers" /> <br /> <input type="submit" value="Customers" /> <br />
<input hidden type="text" name="type" value="customer" /> <input hidden type="text" name="type" value="customer" />

View file

@ -13,14 +13,14 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="recherche" action="find.htm" method="POST"> <form name="recherche" action="find.htm" method="POST">
<p> <p>
<label for="nom">Nom de l'entreprise</label> <label for="nom">Nom de l'entreprise</label>
<input type="text" name="nom" size="30" id="nom" /> <input type="text" name="nom" size="30" id="nom" />
</p> </p>
<input type="submit" value="rechercher" /> <input type="submit" value="rechercher" />
</form> </form>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<c:choose> <c:choose>
<c:when test="${error != null}"> <c:when test="${error != null}">
<h1>${error}</h1> <h1>${error}</h1>
@ -27,37 +27,37 @@
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">
<TR> <TR>
<c:forEach items="${colonnes}" var="col"> <c:forEach items="${colonnes}" var="col">
<TD>${col}</TD> <TD>${col}</TD>
</c:forEach> </c:forEach>
</TR> </TR>
<c:forEach items="${results}" var="values" varStatus="row" > <c:forEach items="${results}" var="values" varStatus="row" >
<TR> <TR>
<c:forEach items="${values}" var="v" varStatus="vStatus" > <c:forEach items="${values}" var="v" varStatus="vStatus" >
<c:choose> <c:choose>
<c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}"> <c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
<TD> <TD>
<form name="Detail" action="detail.htm" method="POST"> <form name="Detail" action="detail.htm" method="POST">
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/> <input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
<input hidden name="num" value="${v}"/> <input hidden name="num" value="${v}"/>
<input type=submit value="${v}" /> <input type=submit value="${v}" />
</form> </form>
</TD> </TD>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<TD>${v}</TD> <TD>${v}</TD>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</c:forEach> </c:forEach>
<TD> <TD>
<form name="Detail" action="detail.htm" method="POST"> <form name="Detail" action="detail.htm" method="POST">
<input hidden type="text" name="type" value="${type}"/> <input hidden type="text" name="type" value="${type}"/>
<input hidden name="num" value="${values[0]}"/> <input hidden name="num" value="${values[0]}"/>
<input type=submit value="Détail" /> <input type=submit value="Détail" />
</form> </form>
</TD> </TD>
</TR> </TR>
</c:forEach> </c:forEach>
</table> </table>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>

View file

@ -8,27 +8,27 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<H1>Achats du client n°<%=request.getParameter("customerId")%></H1> <H1>Achats du client n°<%=request.getParameter("customerId")%></H1>
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">
<c:forEach items="${achats}" var="cli"> <c:forEach items="${achats}" var="cli">
<TR> <TR>
<TD>${cli.orderNum}</TD> <TD>${cli.orderNum}</TD>
<TD>${cli.customerId}</TD> <TD>${cli.customerId}</TD>
<TD>${cli.productId}</TD> <TD>${cli.productId}</TD>
<TD>${cli.quantity}</TD> <TD>${cli.quantity}</TD>
<TD>${cli.shippingCost}</TD> <TD>${cli.shippingCost}</TD>
<TD>${cli.salesDate}</TD> <TD>${cli.salesDate}</TD>
<TD>${cli.shippingDate}</TD> <TD>${cli.shippingDate}</TD>
<TD>${cli.freightCompany}</TD> <TD>${cli.freightCompany}</TD>
</TR> </TR>
</c:forEach> </c:forEach>
</table> </table>
</body> </body>
</html> </html>

View file

@ -13,7 +13,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<h1>${error != null ? error : confirm} </h1> <h1>${error != null ? error : confirm} </h1>
<form action="list.htm" method="POST"> <form action="list.htm" method="POST">
<input hidden type="text" name="type" value="${type}" /> <input hidden type="text" name="type" value="${type}" />

View file

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="detail" method="POST"> <form name="detail" method="POST">
<c:choose> <c:choose>
<c:when test="${type == 'customer'}"> <c:when test="${type == 'customer'}">
@ -106,12 +106,12 @@
<label for="available">Available</label> <label for="available">Available</label>
<label for="isavailable">TRUE:</label> <label for="isavailable">TRUE:</label>
<input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" /> <input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" />
<label for="notavailable">FALSE:</label> <label for="notavailable">FALSE:</label>
<input type="radio" name="available" value="FALSE" <c:if test="${result.available == 'FALSE'}">checked</c:if> id="notavailable" /> <input type="radio" name="available" value="FALSE" <c:if test="${result.available == 'FALSE'}">checked</c:if> id="notavailable" />
</p> </p>
<p> <p>
<label for="description">Description</label> <label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="50" /> <input type="text" name="description" value="${result.description}" id="description" size="50" />
</p> </p>
</c:when> </c:when>
<c:when test="${type == 'purchase'}"> <c:when test="${type == 'purchase'}">
@ -185,7 +185,7 @@
</p> </p>
</c:when> </c:when>
</c:choose> </c:choose>
<input hidden type="text" name="type" value="${type}" /> <input hidden type="text" name="type" value="${type}" />
<c:choose> <c:choose>
<c:when test="${save != null}"> <c:when test="${save != null}">

View file

@ -1,18 +0,0 @@
<%--
Document : error
Created on : 4 mars 2018, 20:54:56
Author : faycal
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Erreur</title>
</head>
<body>
<%@include file="header.jsp" %>
<h1>${erreur} </h1>
</body>
</html>

View file

@ -14,40 +14,40 @@
</head> </head>
<body> <body>
Bienvenue ${user.login} Bienvenue ${user.login}
<form name="inscription" method="POST"> <form name="inscription" method="POST">
<p> <p>
<label for="nom">Nom</label> <label for="nom">Nom</label>
<input type="text" name="nom" value="" size="10" id="nom" /> <input type="text" name="nom" value="" size="10" id="nom" />
</p> </p>
<p> <p>
<label for="adresse">Adresse</label> <label for="adresse">Adresse</label>
<input type="text" name="adresse" value="" size="10" id="adresse" /> <input type="text" name="adresse" value="" size="10" id="adresse" />
</p> </p>
<p> <p>
<label for="telephone">Téléphone</label> <label for="telephone">Téléphone</label>
<input type="text" name="telephone" value="" size="10" id="tel" /> <input type="text" name="telephone" value="" size="10" id="tel" />
</p> </p>
<p> <p>
<label for="email">E-mail</label> <label for="email">E-mail</label>
<input type="text" name="email" value="" size="10" id="email"/> <input type="text" name="email" value="" size="10" id="email"/>
</p> </p>
<p><label for="code_remise">Code Remise</label> <p><label for="code_remise">Code Remise</label>
<select name="code_remise" id="dc"> <select name="code_remise" id="dc">
<c:forEach items="${discount}" var="dc"> <c:forEach items="${discount}" var="dc">
<option>${dc}</option> <option>${dc}</option>
</c:forEach> </c:forEach>
</select> </select>
</p> </p>
<p> <p>
<label for="cp">Code Postal</label> <label for="cp">Code Postal</label>
<select name="CP" id="cp"> <select name="CP" id="cp">
<c:forEach items="${code}" var="cp"> <c:forEach items="${code}" var="cp">
<option>${cp}</option> <option>${cp}</option>
</c:forEach> </c:forEach>
</select> </select>
</p> </p>
<input type="submit" value="Enregistrer" formaction="save.htm" /> <input type="submit" value="Enregistrer" formaction="save.htm" />
</form> </form>

View file

@ -15,7 +15,7 @@
<div style="display: flex; flex-direction: row; justify-content: flex-end"> <div style="display: flex; flex-direction: row; justify-content: flex-end">
<form name="form" method="POST"> <form name="form" method="POST">
<input type="submit" formaction="logout.htm" value="Log out" /> <input type="submit" formaction="logout.htm" value="Log out" />
<input type="text" name="query" /> <input type="text" name="query" />
<input hidden type="text" name="type" value="customer" /> <input hidden type="text" name="type" value="customer" />
<input type="submit" formaction="find.htm" value="Search user" /> <input type="submit" formaction="find.htm" value="Search user" />

View file

@ -2,5 +2,5 @@
<% response.sendRedirect("menu.htm"); %> <% response.sendRedirect("menu.htm");%>

View file

@ -13,20 +13,20 @@
</head> </head>
<body> <body>
<form method="POST" action="j_security_check"> <form method="POST" action="j_security_check">
<table> <table>
<tr> <tr>
<td>Utilisateur :</td> <td>Utilisateur :</td>
<td><input type="text" name="j_username"></td> <td><input type="text" name="j_username"></td>
</tr> </tr>
<tr> <tr>
<td>Mot de passe :</td> <td>Mot de passe :</td>
<td><input type="password" name="j_password" ></td> <td><input type="password" name="j_password" ></td>
</tr> </tr>
<tr> <tr>
<td><input type="submit" value="Entrer" ></td> <td><input type="submit" value="Entrer" ></td>
<td><input type="reset" value="Annuler"></td> <td><input type="reset" value="Annuler"></td>
</tr> </tr>
</table> </table>
</form> </form>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<h1>choisissez une opération dans la liste suivante</h1> <h1>choisissez une opération dans la liste suivante</h1>
<form name="form" action="list.htm" method="POST"> <form name="form" action="list.htm" method="POST">
<input type="submit" value="Customers" /> <br /> <input type="submit" value="Customers" /> <br />
<input hidden type="text" name="type" value="customer" /> <input hidden type="text" name="type" value="customer" />

View file

@ -13,14 +13,14 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="recherche" action="find.htm" method="POST"> <form name="recherche" action="find.htm" method="POST">
<p> <p>
<label for="nom">Nom de l'entreprise</label> <label for="nom">Nom de l'entreprise</label>
<input type="text" name="nom" size="30" id="nom" /> <input type="text" name="nom" size="30" id="nom" />
</p> </p>
<input type="submit" value="rechercher" /> <input type="submit" value="rechercher" />
</form> </form>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<c:choose> <c:choose>
<c:when test="${error != null}"> <c:when test="${error != null}">
<h1>${error}</h1> <h1>${error}</h1>
@ -27,37 +27,37 @@
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">
<TR> <TR>
<c:forEach items="${colonnes}" var="col"> <c:forEach items="${colonnes}" var="col">
<TD>${col}</TD> <TD>${col}</TD>
</c:forEach> </c:forEach>
</TR> </TR>
<c:forEach items="${results}" var="values" varStatus="row" > <c:forEach items="${results}" var="values" varStatus="row" >
<TR> <TR>
<c:forEach items="${values}" var="v" varStatus="vStatus" > <c:forEach items="${values}" var="v" varStatus="vStatus" >
<c:choose> <c:choose>
<c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}"> <c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
<TD> <TD>
<form name="Detail" action="detail.htm" method="POST"> <form name="Detail" action="detail.htm" method="POST">
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/> <input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
<input hidden name="num" value="${v}"/> <input hidden name="num" value="${v}"/>
<input type=submit value="${v}" /> <input type=submit value="${v}" />
</form> </form>
</TD> </TD>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<TD>${v}</TD> <TD>${v}</TD>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</c:forEach> </c:forEach>
<TD> <TD>
<form name="Detail" action="detail.htm" method="POST"> <form name="Detail" action="detail.htm" method="POST">
<input hidden type="text" name="type" value="${type}"/> <input hidden type="text" name="type" value="${type}"/>
<input hidden name="num" value="${values[0]}"/> <input hidden name="num" value="${values[0]}"/>
<input type=submit value="Détail" /> <input type=submit value="Détail" />
</form> </form>
</TD> </TD>
</TR> </TR>
</c:forEach> </c:forEach>
</table> </table>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>

View file

@ -1,149 +1,152 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
/** /**
* Customer generated by hbm2java * Customer generated by hbm2java
*/ */
public class Customer implements java.io.Serializable { public class Customer implements java.io.Serializable {
private int customerId;
private int customerId; private char discountCode;
private char discountCode; private String zip;
private String zip; private String name;
private String name; private String addressline1;
private String addressline1; private String addressline2;
private String addressline2; private String city;
private String city; private String state;
private String state; private String phone;
private String phone; private String fax;
private String fax; private String email;
private String email; private Integer creditLimit;
private Integer creditLimit;
public Customer() { public Customer() {
} }
public Customer(int customerId, char discountCode, String zip) { public Customer(int customerId, char discountCode, String zip) {
this.customerId = customerId; this.customerId = customerId;
this.discountCode = discountCode; this.discountCode = discountCode;
this.zip = zip; this.zip = zip;
} }
public Customer(int customerId, char discountCode,String _name, String _adress, String _phone,String _email, String _zip) {
public Customer(int customerId, char discountCode, String _name, String _adress, String _phone, String _email, String _zip) {
this.customerId = customerId; this.customerId = customerId;
this.discountCode = discountCode; this.discountCode = discountCode;
this.name=_name; this.name = _name;
this.addressline1=_adress; this.addressline1 = _adress;
this.phone=_phone; this.phone = _phone;
this.email=_email; this.email = _email;
this.zip = _zip; this.zip = _zip;
} }
public Customer(int customerId, char discountCode, String zip, String name, String addressline1, String addressline2, String city, String state, String phone, String fax, String email, Integer creditLimit) { public Customer(int customerId, char discountCode, String zip, String name, String addressline1, String addressline2, String city, String state, String phone, String fax, String email, Integer creditLimit) {
this.customerId = customerId; this.customerId = customerId;
this.discountCode = discountCode; this.discountCode = discountCode;
this.zip = zip; this.zip = zip;
this.name = name; this.name = name;
this.addressline1 = addressline1; this.addressline1 = addressline1;
this.addressline2 = addressline2; this.addressline2 = addressline2;
this.city = city; this.city = city;
this.state = state; this.state = state;
this.phone = phone; this.phone = phone;
this.fax = fax; this.fax = fax;
this.email = email; this.email = email;
this.creditLimit = creditLimit; this.creditLimit = creditLimit;
} }
public int getCustomerId() { public int getCustomerId() {
return this.customerId; return this.customerId;
} }
public void setCustomerId(int customerId) { public void setCustomerId(int customerId) {
this.customerId = customerId; this.customerId = customerId;
} }
public char getDiscountCode() { public char getDiscountCode() {
return this.discountCode; return this.discountCode;
} }
public void setDiscountCode(char discountCode) { public void setDiscountCode(char discountCode) {
this.discountCode = discountCode; this.discountCode = discountCode;
} }
public String getZip() { public String getZip() {
return this.zip; return this.zip;
} }
public void setZip(String zip) { public void setZip(String zip) {
this.zip = zip; this.zip = zip;
} }
public String getName() { public String getName() {
return this.name; return this.name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getAddressline1() { public String getAddressline1() {
return this.addressline1; return this.addressline1;
} }
public void setAddressline1(String addressline1) { public void setAddressline1(String addressline1) {
this.addressline1 = addressline1; this.addressline1 = addressline1;
} }
public String getAddressline2() { public String getAddressline2() {
return this.addressline2; return this.addressline2;
} }
public void setAddressline2(String addressline2) { public void setAddressline2(String addressline2) {
this.addressline2 = addressline2; this.addressline2 = addressline2;
} }
public String getCity() { public String getCity() {
return this.city; return this.city;
} }
public void setCity(String city) { public void setCity(String city) {
this.city = city; this.city = city;
} }
public String getState() { public String getState() {
return this.state; return this.state;
} }
public void setState(String state) { public void setState(String state) {
this.state = state; this.state = state;
} }
public String getPhone() { public String getPhone() {
return this.phone; return this.phone;
} }
public void setPhone(String phone) { public void setPhone(String phone) {
this.phone = phone; this.phone = phone;
} }
public String getFax() { public String getFax() {
return this.fax; return this.fax;
} }
public void setFax(String fax) { public void setFax(String fax) {
this.fax = fax; this.fax = fax;
} }
public String getEmail() { public String getEmail() {
return this.email; return this.email;
} }
public void setEmail(String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
public Integer getCreditLimit() { public Integer getCreditLimit() {
return this.creditLimit; return this.creditLimit;
} }
public void setCreditLimit(Integer creditLimit) { public void setCreditLimit(Integer creditLimit) {
this.creditLimit = creditLimit; this.creditLimit = creditLimit;
} }
} }

View file

@ -1,48 +1,42 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* DiscountCode generated by hbm2java * DiscountCode generated by hbm2java
*/ */
public class DiscountCode implements java.io.Serializable { public class DiscountCode implements java.io.Serializable {
private char discountCode;
private char discountCode; private BigDecimal rate;
private BigDecimal rate;
public DiscountCode() { public DiscountCode() {
} }
public DiscountCode(char discountCode) { public DiscountCode(char discountCode) {
this.discountCode = discountCode; this.discountCode = discountCode;
} }
public DiscountCode(char discountCode, BigDecimal rate) { public DiscountCode(char discountCode, BigDecimal rate) {
this.discountCode = discountCode; this.discountCode = discountCode;
this.rate = rate; this.rate = rate;
} }
public char getDiscountCode() { public char getDiscountCode() {
return this.discountCode; return this.discountCode;
} }
public void setDiscountCode(char discountCode) { public void setDiscountCode(char discountCode) {
this.discountCode = discountCode; this.discountCode = discountCode;
} }
public BigDecimal getRate() { public BigDecimal getRate() {
return this.rate; return this.rate;
} }
public void setRate(BigDecimal rate) { public void setRate(BigDecimal rate) {
this.rate = rate; this.rate = rate;
} }
} }

View file

@ -8,7 +8,6 @@ package DAO;
import org.hibernate.cfg.AnnotationConfiguration; import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.SessionFactory; import org.hibernate.SessionFactory;
/** /**
* Hibernate Utility class with a convenient method to get Session Factory * Hibernate Utility class with a convenient method to get Session Factory
* object. * object.
@ -18,21 +17,20 @@ import org.hibernate.SessionFactory;
public class HibernateUtil { public class HibernateUtil {
private static final SessionFactory sessionFactory; private static final SessionFactory sessionFactory;
static { static {
try { try {
// Create the SessionFactory from standard (hibernate.cfg.xml) // Create the SessionFactory from standard (hibernate.cfg.xml)
// config file. // config file.
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
} catch (Throwable ex) { } catch (Throwable ex) {
// Log the exception. // Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex); System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex); throw new ExceptionInInitializerError(ex);
} }
} }
public static SessionFactory getSessionFactory() { public static SessionFactory getSessionFactory() {
return sessionFactory; return sessionFactory;
} }

File diff suppressed because it is too large Load diff

View file

@ -1,128 +1,130 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
/** /**
* Manufacturer generated by hbm2java * Manufacturer generated by hbm2java
*/ */
public class Manufacturer implements java.io.Serializable { public class Manufacturer implements java.io.Serializable {
private int manufacturerId;
private int manufacturerId; private String name;
private String name; private String addressline1;
private String addressline1; private String addressline2;
private String addressline2; private String city;
private String city; private String state;
private String state; private String zip;
private String zip; private String phone;
private String phone; private String fax;
private String fax; private String email;
private String email; private String rep;
private String rep;
public Manufacturer() { public Manufacturer() {
} }
public Manufacturer(int manufacturerId) { public Manufacturer(int manufacturerId) {
this.manufacturerId = manufacturerId; this.manufacturerId = manufacturerId;
} }
public Manufacturer(int manufacturerId, String name, String addressline1, String addressline2, String city, String state, String zip, String phone, String fax, String email, String rep) { public Manufacturer(int manufacturerId, String name, String addressline1, String addressline2, String city, String state, String zip, String phone, String fax, String email, String rep) {
this.manufacturerId = manufacturerId; this.manufacturerId = manufacturerId;
this.name = name; this.name = name;
this.addressline1 = addressline1; this.addressline1 = addressline1;
this.addressline2 = addressline2; this.addressline2 = addressline2;
this.city = city; this.city = city;
this.state = state; this.state = state;
this.zip = zip; this.zip = zip;
this.phone = phone; this.phone = phone;
this.fax = fax; this.fax = fax;
this.email = email; this.email = email;
this.rep = rep; this.rep = rep;
} }
public int getManufacturerId() { public int getManufacturerId() {
return this.manufacturerId; return this.manufacturerId;
} }
public void setManufacturerId(int manufacturerId) { public void setManufacturerId(int manufacturerId) {
this.manufacturerId = manufacturerId; this.manufacturerId = manufacturerId;
} }
public String getName() { public String getName() {
return this.name; return this.name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getAddressline1() { public String getAddressline1() {
return this.addressline1; return this.addressline1;
} }
public void setAddressline1(String addressline1) { public void setAddressline1(String addressline1) {
this.addressline1 = addressline1; this.addressline1 = addressline1;
} }
public String getAddressline2() { public String getAddressline2() {
return this.addressline2; return this.addressline2;
} }
public void setAddressline2(String addressline2) { public void setAddressline2(String addressline2) {
this.addressline2 = addressline2; this.addressline2 = addressline2;
} }
public String getCity() { public String getCity() {
return this.city; return this.city;
} }
public void setCity(String city) { public void setCity(String city) {
this.city = city; this.city = city;
} }
public String getState() { public String getState() {
return this.state; return this.state;
} }
public void setState(String state) { public void setState(String state) {
this.state = state; this.state = state;
} }
public String getZip() { public String getZip() {
return this.zip; return this.zip;
} }
public void setZip(String zip) { public void setZip(String zip) {
this.zip = zip; this.zip = zip;
} }
public String getPhone() { public String getPhone() {
return this.phone; return this.phone;
} }
public void setPhone(String phone) { public void setPhone(String phone) {
this.phone = phone; this.phone = phone;
} }
public String getFax() { public String getFax() {
return this.fax; return this.fax;
} }
public void setFax(String fax) { public void setFax(String fax) {
this.fax = fax; this.fax = fax;
} }
public String getEmail() { public String getEmail() {
return this.email; return this.email;
} }
public void setEmail(String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
public String getRep() { public String getRep() {
return this.rep; return this.rep;
} }
public void setRep(String rep) { public void setRep(String rep) {
this.rep = rep; this.rep = rep;
} }
} }

View file

@ -1,65 +1,60 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
/** /**
* MicroMarket generated by hbm2java * MicroMarket generated by hbm2java
*/ */
public class MicroMarket implements java.io.Serializable { public class MicroMarket implements java.io.Serializable {
private String zipCode;
private String zipCode; private Double radius;
private Double radius; private Double areaLength;
private Double areaLength; private Double areaWidth;
private Double areaWidth;
public MicroMarket() { public MicroMarket() {
} }
public MicroMarket(String zipCode) { public MicroMarket(String zipCode) {
this.zipCode = zipCode; this.zipCode = zipCode;
} }
public MicroMarket(String zipCode, Double radius, Double areaLength, Double areaWidth) { public MicroMarket(String zipCode, Double radius, Double areaLength, Double areaWidth) {
this.zipCode = zipCode; this.zipCode = zipCode;
this.radius = radius; this.radius = radius;
this.areaLength = areaLength; this.areaLength = areaLength;
this.areaWidth = areaWidth; this.areaWidth = areaWidth;
} }
public String getZipCode() { public String getZipCode() {
return this.zipCode; return this.zipCode;
} }
public void setZipCode(String zipCode) { public void setZipCode(String zipCode) {
this.zipCode = zipCode; this.zipCode = zipCode;
} }
public Double getRadius() { public Double getRadius() {
return this.radius; return this.radius;
} }
public void setRadius(Double radius) { public void setRadius(Double radius) {
this.radius = radius; this.radius = radius;
} }
public Double getAreaLength() { public Double getAreaLength() {
return this.areaLength; return this.areaLength;
} }
public void setAreaLength(Double areaLength) { public void setAreaLength(Double areaLength) {
this.areaLength = areaLength; this.areaLength = areaLength;
} }
public Double getAreaWidth() { public Double getAreaWidth() {
return this.areaWidth; return this.areaWidth;
} }
public void setAreaWidth(Double areaWidth) { public void setAreaWidth(Double areaWidth) {
this.areaWidth = areaWidth; this.areaWidth = areaWidth;
} }
} }

View file

@ -1,104 +1,104 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
import java.math.BigDecimal; import java.math.BigDecimal;
/** /**
* Product generated by hbm2java * Product generated by hbm2java
*/ */
public class Product implements java.io.Serializable { public class Product implements java.io.Serializable {
private int productId;
private int productId; private int manufacturerId;
private int manufacturerId; private String productCode;
private String productCode; private BigDecimal purchaseCost;
private BigDecimal purchaseCost; private Integer quantityOnHand;
private Integer quantityOnHand; private BigDecimal markup;
private BigDecimal markup; private String available;
private String available; private String description;
private String description;
public Product() { public Product() {
} }
public Product(int productId, int manufacturerId, String productCode) { public Product(int productId, int manufacturerId, String productCode) {
this.productId = productId; this.productId = productId;
this.manufacturerId = manufacturerId; this.manufacturerId = manufacturerId;
this.productCode = productCode; this.productCode = productCode;
} }
public Product(int productId, int manufacturerId, String productCode, BigDecimal purchaseCost, Integer quantityOnHand, BigDecimal markup, String available, String description) { public Product(int productId, int manufacturerId, String productCode, BigDecimal purchaseCost, Integer quantityOnHand, BigDecimal markup, String available, String description) {
this.productId = productId; this.productId = productId;
this.manufacturerId = manufacturerId; this.manufacturerId = manufacturerId;
this.productCode = productCode; this.productCode = productCode;
this.purchaseCost = purchaseCost; this.purchaseCost = purchaseCost;
this.quantityOnHand = quantityOnHand; this.quantityOnHand = quantityOnHand;
this.markup = markup; this.markup = markup;
this.available = available; this.available = available;
this.description = description; this.description = description;
} }
public int getProductId() { public int getProductId() {
return this.productId; return this.productId;
} }
public void setProductId(int productId) { public void setProductId(int productId) {
this.productId = productId; this.productId = productId;
} }
public int getManufacturerId() { public int getManufacturerId() {
return this.manufacturerId; return this.manufacturerId;
} }
public void setManufacturerId(int manufacturerId) { public void setManufacturerId(int manufacturerId) {
this.manufacturerId = manufacturerId; this.manufacturerId = manufacturerId;
} }
public String getProductCode() { public String getProductCode() {
return this.productCode; return this.productCode;
} }
public void setProductCode(String productCode) { public void setProductCode(String productCode) {
this.productCode = productCode; this.productCode = productCode;
} }
public BigDecimal getPurchaseCost() { public BigDecimal getPurchaseCost() {
return this.purchaseCost; return this.purchaseCost;
} }
public void setPurchaseCost(BigDecimal purchaseCost) { public void setPurchaseCost(BigDecimal purchaseCost) {
this.purchaseCost = purchaseCost; this.purchaseCost = purchaseCost;
} }
public Integer getQuantityOnHand() { public Integer getQuantityOnHand() {
return this.quantityOnHand; return this.quantityOnHand;
} }
public void setQuantityOnHand(Integer quantityOnHand) { public void setQuantityOnHand(Integer quantityOnHand) {
this.quantityOnHand = quantityOnHand; this.quantityOnHand = quantityOnHand;
} }
public BigDecimal getMarkup() { public BigDecimal getMarkup() {
return this.markup; return this.markup;
} }
public void setMarkup(BigDecimal markup) { public void setMarkup(BigDecimal markup) {
this.markup = markup; this.markup = markup;
} }
public String getAvailable() { public String getAvailable() {
return this.available; return this.available;
} }
public void setAvailable(String available) { public void setAvailable(String available) {
this.available = available; this.available = available;
} }
public String getDescription() { public String getDescription() {
return this.description; return this.description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
} }

View file

@ -1,57 +1,51 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
/** /**
* ProductCode generated by hbm2java * ProductCode generated by hbm2java
*/ */
public class ProductCode implements java.io.Serializable { public class ProductCode implements java.io.Serializable {
private String prodCode;
private String prodCode; private char discountCode;
private char discountCode; private String description;
private String description;
public ProductCode() { public ProductCode() {
} }
public ProductCode(String prodCode, char discountCode) { public ProductCode(String prodCode, char discountCode) {
this.prodCode = prodCode; this.prodCode = prodCode;
this.discountCode = discountCode; this.discountCode = discountCode;
} }
public ProductCode(String prodCode, char discountCode, String description) { public ProductCode(String prodCode, char discountCode, String description) {
this.prodCode = prodCode; this.prodCode = prodCode;
this.discountCode = discountCode; this.discountCode = discountCode;
this.description = description; this.description = description;
} }
public String getProdCode() { public String getProdCode() {
return this.prodCode; return this.prodCode;
} }
public void setProdCode(String prodCode) { public void setProdCode(String prodCode) {
this.prodCode = prodCode; this.prodCode = prodCode;
} }
public char getDiscountCode() { public char getDiscountCode() {
return this.discountCode; return this.discountCode;
} }
public void setDiscountCode(char discountCode) { public void setDiscountCode(char discountCode) {
this.discountCode = discountCode; this.discountCode = discountCode;
} }
public String getDescription() { public String getDescription() {
return this.description; return this.description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
} }

View file

@ -1,105 +1,105 @@
package DAO; package DAO;
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1 // Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
/** /**
* PurchaseOrder generated by hbm2java * PurchaseOrder generated by hbm2java
*/ */
public class PurchaseOrder implements java.io.Serializable { public class PurchaseOrder implements java.io.Serializable {
private int orderNum;
private int orderNum; private int customerId;
private int customerId; private int productId;
private int productId; private Short quantity;
private Short quantity; private BigDecimal shippingCost;
private BigDecimal shippingCost; private Date salesDate;
private Date salesDate; private Date shippingDate;
private Date shippingDate; private String freightCompany;
private String freightCompany;
public PurchaseOrder() { public PurchaseOrder() {
} }
public PurchaseOrder(int orderNum, int customerId, int productId) { public PurchaseOrder(int orderNum, int customerId, int productId) {
this.orderNum = orderNum; this.orderNum = orderNum;
this.customerId = customerId; this.customerId = customerId;
this.productId = productId; this.productId = productId;
} }
public PurchaseOrder(int orderNum, int customerId, int productId, Short quantity, BigDecimal shippingCost, Date salesDate, Date shippingDate, String freightCompany) { public PurchaseOrder(int orderNum, int customerId, int productId, Short quantity, BigDecimal shippingCost, Date salesDate, Date shippingDate, String freightCompany) {
this.orderNum = orderNum; this.orderNum = orderNum;
this.customerId = customerId; this.customerId = customerId;
this.productId = productId; this.productId = productId;
this.quantity = quantity; this.quantity = quantity;
this.shippingCost = shippingCost; this.shippingCost = shippingCost;
this.salesDate = salesDate; this.salesDate = salesDate;
this.shippingDate = shippingDate; this.shippingDate = shippingDate;
this.freightCompany = freightCompany; this.freightCompany = freightCompany;
} }
public int getOrderNum() { public int getOrderNum() {
return this.orderNum; return this.orderNum;
} }
public void setOrderNum(int orderNum) { public void setOrderNum(int orderNum) {
this.orderNum = orderNum; this.orderNum = orderNum;
} }
public int getCustomerId() { public int getCustomerId() {
return this.customerId; return this.customerId;
} }
public void setCustomerId(int customerId) { public void setCustomerId(int customerId) {
this.customerId = customerId; this.customerId = customerId;
} }
public int getProductId() { public int getProductId() {
return this.productId; return this.productId;
} }
public void setProductId(int productId) { public void setProductId(int productId) {
this.productId = productId; this.productId = productId;
} }
public Short getQuantity() { public Short getQuantity() {
return this.quantity; return this.quantity;
} }
public void setQuantity(Short quantity) { public void setQuantity(Short quantity) {
this.quantity = quantity; this.quantity = quantity;
} }
public BigDecimal getShippingCost() { public BigDecimal getShippingCost() {
return this.shippingCost; return this.shippingCost;
} }
public void setShippingCost(BigDecimal shippingCost) { public void setShippingCost(BigDecimal shippingCost) {
this.shippingCost = shippingCost; this.shippingCost = shippingCost;
} }
public Date getSalesDate() { public Date getSalesDate() {
return this.salesDate; return this.salesDate;
} }
public void setSalesDate(Date salesDate) { public void setSalesDate(Date salesDate) {
this.salesDate = salesDate; this.salesDate = salesDate;
} }
public Date getShippingDate() { public Date getShippingDate() {
return this.shippingDate; return this.shippingDate;
} }
public void setShippingDate(Date shippingDate) { public void setShippingDate(Date shippingDate) {
this.shippingDate = shippingDate; this.shippingDate = shippingDate;
} }
public String getFreightCompany() { public String getFreightCompany() {
return this.freightCompany; return this.freightCompany;
} }
public void setFreightCompany(String freightCompany) { public void setFreightCompany(String freightCompany) {
this.freightCompany = freightCompany; this.freightCompany = freightCompany;
} }
} }

View file

@ -10,6 +10,7 @@ package Exceptions;
* @author flifloo * @author flifloo
*/ */
public class InvalidParameter extends Exception { public class InvalidParameter extends Exception {
public InvalidParameter(String message) { public InvalidParameter(String message) {
super(message); super(message);
} }

View file

@ -4,6 +4,7 @@
* and open the template in the editor. * and open the template in the editor.
*/ */
package controller; package controller;
import DAO.*; import DAO.*;
import Exceptions.InvalidParameter; import Exceptions.InvalidParameter;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -20,424 +21,439 @@ import javax.servlet.http.*;
import javax.servlet.*; import javax.servlet.*;
import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.ConstraintViolationException;
/** /**
* *
* @author faycal * @author faycal
*/ */
public class BddController extends MultiActionController { public class BddController extends MultiActionController {
private String login; private String login;
private String pwd; private String pwd;
private User utilisateur; private User utilisateur;
private HttpSession session; private HttpSession session;
public BddController() {}
public BddController() {
}
private void sessionInit(HttpServletRequest request) { private void sessionInit(HttpServletRequest request) {
if (login == null) if (login == null) {
login=request.getUserPrincipal().getName(); login = request.getUserPrincipal().getName();
if (utilisateur == null) }
utilisateur =new User(login); if (utilisateur == null) {
utilisateur = new User(login);
}
if (session == null) { if (session == null) {
session=request.getSession(); session = request.getSession();
session.setAttribute("user", utilisateur); session.setAttribute("user", utilisateur);
} }
} }
public ModelAndView menu(HttpServletRequest request, public ModelAndView menu(HttpServletRequest request,
HttpServletResponse response){ HttpServletResponse response) {
sessionInit(request); sessionInit(request);
System.out.println ("nbuser="+User.getCompteur()); System.out.println("nbuser=" + User.getCompteur());
return new ModelAndView("menu").addObject("user",utilisateur); return new ModelAndView("menu").addObject("user", utilisateur);
} }
public ModelAndView logout(HttpServletRequest request,
HttpServletResponse response){ public ModelAndView logout(HttpServletRequest request,
sessionInit(request); HttpServletResponse response) {
request.getSession().invalidate(); request.getSession().invalidate();
return new ModelAndView("logout");
return new ModelAndView("deconnexion");
} }
public ModelAndView list(HttpServletRequest request, public ModelAndView list(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request); sessionInit(request);
String type = request.getParameter("type"); String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("resultat"); ModelAndView mv = new ModelAndView("resultat");
mv.addObject("user",session.getAttribute("user")); mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type); mv.addObject("type", type);
switch (type) { switch (type) {
case "customer": case "customer":
mv.addObject("results", new MagasinHelper().getClientsColums()); mv.addObject("results", new MagasinHelper().getClientsColums());
mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate")); mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate"));
break; break;
case "product": case "product":
mv.addObject("results", new MagasinHelper().getProductsColums()); mv.addObject("results", new MagasinHelper().getProductsColums());
mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description")); mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description"));
mv.addObject("relation", new HashMap<String, String>() {{ mv.addObject("relation", new HashMap<String, String>() {
put("productCode", "prodCode"); {
}}); put("productCode", "prodCode");
break; }
case "purchase": });
break;
case "purchase":
mv.addObject("results", new MagasinHelper().getPurchaseColums()); mv.addObject("results", new MagasinHelper().getPurchaseColums());
mv.addObject("colonnes", Arrays.asList("orderNum", "customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany")); mv.addObject("colonnes", Arrays.asList("orderNum", "customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
mv.addObject("relation", new HashMap<String, String>() {{ mv.addObject("relation", new HashMap<String, String>() {
put("customerId", "customer"); {
put("productId", "product"); put("customerId", "customer");
}}); put("productId", "product");
}
});
break; break;
case "discount": case "discount":
mv.addObject("results", new MagasinHelper().getDiscountCodesColums()); mv.addObject("results", new MagasinHelper().getDiscountCodesColums());
mv.addObject("colonnes", Arrays.asList("discountCode", "rate")); mv.addObject("colonnes", Arrays.asList("discountCode", "rate"));
break; break;
case "prodCode": case "prodCode":
mv.addObject("results", new MagasinHelper().getProductCodesColums()); mv.addObject("results", new MagasinHelper().getProductCodesColums());
mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description")); mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description"));
mv.addObject("relation", new HashMap<String, String>() {{ mv.addObject("relation", new HashMap<String, String>() {
put("discountCode", "discount"); {
}}); put("discountCode", "discount");
break; }
default: });
mv.addObject("error", "Type not found"); break;
} default:
mv.addObject("error", "Type not found");
return mv; }
}
return mv;
public ModelAndView formAdd(HttpServletRequest request, }
HttpServletResponse response) throws Exception {
sessionInit(request); public ModelAndView formAdd(HttpServletRequest request,
String type = request.getParameter("type"); HttpServletResponse response) throws Exception {
ModelAndView mv = new ModelAndView("detail"); sessionInit(request);
mv.addObject("user",session.getAttribute("user")); String type = request.getParameter("type");
mv.addObject("type", type); ModelAndView mv = new ModelAndView("detail");
mv.addObject("save", true); mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type);
switch (type) { mv.addObject("save", true);
case "customer":
mv.addObject("code",new MagasinHelper().getDiscountCodes()); switch (type) {
mv.addObject("cpostaux",new MagasinHelper().getZipCode()); case "customer":
break; mv.addObject("code", new MagasinHelper().getDiscountCodes());
case "product": mv.addObject("cpostaux", new MagasinHelper().getZipCode());
mv.addObject("manufacturers", new MagasinHelper().getManufacturers()); break;
mv.addObject("productCodes", new MagasinHelper().getProductCodes()); case "product":
break; mv.addObject("manufacturers", new MagasinHelper().getManufacturers());
case "purchase": mv.addObject("productCodes", new MagasinHelper().getProductCodes());
break;
case "purchase":
mv.addObject("customers", new MagasinHelper().getClients()); mv.addObject("customers", new MagasinHelper().getClients());
mv.addObject("products", new MagasinHelper().getProducts()); mv.addObject("products", new MagasinHelper().getProducts());
break; break;
case "discount": case "discount":
break; break;
case "prodCode": case "prodCode":
mv.addObject("code",new MagasinHelper().getDiscountCodes()); mv.addObject("code", new MagasinHelper().getDiscountCodes());
break; break;
default: default:
mv.addObject("error", "Type not found"); mv.addObject("error", "Type not found");
} }
return mv; return mv;
} }
public ModelAndView detail(HttpServletRequest request, public ModelAndView detail(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request); sessionInit(request);
String type = request.getParameter("type"); String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("detail"); ModelAndView mv = new ModelAndView("detail");
mv.addObject("user",session.getAttribute("user")); mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type); mv.addObject("type", type);
switch (type) { switch (type) {
case "customer": case "customer":
mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num")))); mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num"))));
mv.addObject("code",new MagasinHelper().getDiscountCodes()); mv.addObject("code", new MagasinHelper().getDiscountCodes());
mv.addObject("cpostaux",new MagasinHelper().getZipCode()); mv.addObject("cpostaux", new MagasinHelper().getZipCode());
break; break;
case "product": case "product":
mv.addObject("result", new MagasinHelper().getProduct(Integer.parseInt(request.getParameter("num")))); mv.addObject("result", new MagasinHelper().getProduct(Integer.parseInt(request.getParameter("num"))));
mv.addObject("manufacturers", new MagasinHelper().getManufacturers()); mv.addObject("manufacturers", new MagasinHelper().getManufacturers());
mv.addObject("productCodes", new MagasinHelper().getProductCodes()); mv.addObject("productCodes", new MagasinHelper().getProductCodes());
break; break;
case "purchase": case "purchase":
mv.addObject("result", new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("num")))); mv.addObject("result", new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("num"))));
mv.addObject("customers", new MagasinHelper().getClients()); mv.addObject("customers", new MagasinHelper().getClients());
mv.addObject("products", new MagasinHelper().getProducts()); mv.addObject("products", new MagasinHelper().getProducts());
break; break;
case "discount":
mv.addObject("result", new MagasinHelper().getDiscountCode(request.getParameter("num").charAt(0)));
break;
case "prodCode":
mv.addObject("result", new MagasinHelper().getProductCode(request.getParameter("num")));
mv.addObject("code",new MagasinHelper().getDiscountCodes());
break;
default:
mv.addObject("error", "Type not found");
}
return mv;
}
public ModelAndView find(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("resultat");
mv.addObject("user",session.getAttribute("user"));
mv.addObject("type", type);
String query = request.getParameter("query");
if (query == null || query.isEmpty())
mv.addObject("error", "No query");
else {
List<Customer> customers = new ArrayList<Customer>();
try {
customers.addAll(new MagasinHelper().getClientsColums(Integer.parseInt(query)));
} catch (NumberFormatException exception) {
}
query = "%".concat(query.concat("%"));
customers.addAll(new MagasinHelper().getClientsColums(query));
if (customers.size() == 0)
mv.addObject("error", "No user found :/");
else
mv.addObject("results", customers);
}
MagasinHelper helper = new MagasinHelper();
return mv;
}
public ModelAndView achats(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
ModelAndView mv = new ModelAndView("achats");
mv.addObject("user",session.getAttribute("user"));
mv.addObject("achats",new MagasinHelper().getPurchases(Integer.parseInt(request.getParameter("customerId"))));
return mv;
}
public ModelAndView delete(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("confirm");
mv.addObject("user",session.getAttribute("user"));
mv.addObject("type", type);
switch (type) {
case "customer":
new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("customerId")));
break;
case "product":
new MagasinHelper().deleteProduct(Integer.parseInt(request.getParameter("productId")));
break;
case "purchase":
new MagasinHelper().deletePurchase(Integer.parseInt(request.getParameter("orderNum")));
break;
case "discount":
new MagasinHelper().deleteDiscountCode(request.getParameter("discountCode").charAt(0));
break;
case "prodCode":
new MagasinHelper().deleteProductCode(request.getParameter("prodCode"));
break;
default:
mv.addObject("error", "Type not found");
return mv;
}
mv.addObject("confirm","suppression effectuée");
return mv;
}
private char paramChar(HttpServletRequest request, String name) throws InvalidParameter {
String param = paramNotNull(request, name);
if (param.length() > 1)
throw new InvalidParameter("Invalid ".concat(name));
return param.charAt(0);
}
private int parseParamInt(HttpServletRequest request, String name) throws InvalidParameter {
try {
return Integer.parseInt(request.getParameter(name));
} catch (Exception e) {
throw new InvalidParameter("Invalid numer for ".concat(name));
}
}
private int parseParamInt(String param, String name) throws InvalidParameter {
try {
return Integer.parseInt(param);
} catch (Exception e) {
throw new InvalidParameter("Invalid numer for ".concat(name));
}
}
private BigDecimal parseParamBigDecimal(HttpServletRequest request, String name, int precision) throws InvalidParameter {
BigDecimal bc;
try {
bc = BigDecimal.valueOf(Long.parseLong(request.getParameter("rate")));
} catch (Exception e) {
throw new InvalidParameter("Invalid big int for ".concat(name));
}
if (bc.precision() > precision)
throw new InvalidParameter("Precision for ".concat(name).concat(" shounld be over ".concat(String.valueOf(precision))));
return bc;
}
private Short parseParamShort(HttpServletRequest request, String name) throws InvalidParameter {
try {
return Short.valueOf(request.getParameter("rate"));
} catch (Exception e) {
throw new InvalidParameter("Invalid short number for ".concat(name));
}
}
private String paramNotNull(HttpServletRequest request, String name) throws InvalidParameter {
String param = request.getParameter(name);
if (param == null || param.isEmpty())
throw new InvalidParameter(name.concat(" should not be empty"));
return param;
}
private String paramLength(HttpServletRequest request, String name, int length) throws InvalidParameter {
String param = request.getParameter(name);
if (param.length() > length)
throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters")));
return param;
}
private String paramLength(String param, String name, int length) throws InvalidParameter {
if (param.length() > length)
throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters")));
return param;
}
private String paramAvailable(HttpServletRequest request, String name) throws InvalidParameter {
String param = request.getParameter(name).toUpperCase();
if (!param.equals("TRUE") && !param.equals("FALSE"))
throw new InvalidParameter("It's true or false for ".concat(name));
return param;
}
private Date paramDate(HttpServletRequest request, String name) throws InvalidParameter {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
return format.parse(request.getParameter(name));
} catch(Exception e) {
throw new InvalidParameter("Invalid date for ".concat(name));
}
}
private Object fetchDetailsData(HttpServletRequest request, ModelAndView mv) throws Exception {
String type = request.getParameter("type");
Object data = null;
try {
switch (type) {
case "customer":
int customerId = parseParamInt(request, "customerId");
char discountCode = paramChar(request, "discountCode");
String zip = paramLength(paramNotNull(request, "zip"), "zip", 10);
String name = paramLength(request, "name", 30);
String addressline1 = paramLength(request, "addressline1", 30);
String addressline2 = paramLength(request, "addressline2", 30);
String city = paramLength(request, "city", 25);
String state = paramLength(request, "state", 2);
String phone = paramLength(request, "phone", 12);
String fax = paramLength(request, "fax", 12);
String email = paramLength(request, "email", 40);
int creditLimit = parseParamInt(request, "creditLimit");
data = new Customer(customerId, discountCode, zip, name, addressline1, addressline2, city, state, phone, fax, email, creditLimit);
break;
case "product":
int productId = parseParamInt(request, "productId");
int manufacturerId = parseParamInt(paramNotNull(request, "manufacturerId"), "manufacturerId");
String productCode = paramLength(paramNotNull(request, "productCode"), "productCode", 2);
BigDecimal purchaseCost = parseParamBigDecimal(request, "purchaseCost", 12);
int quantityOnHand = parseParamInt(request, "quantityOnHand");
BigDecimal markup = parseParamBigDecimal(request, "markup", 12);
String available = paramAvailable(request, "available");
String description = paramLength(request, "description", 50);
data = new Product(productId, manufacturerId, productCode, purchaseCost, quantityOnHand, markup, available, description);
break;
case "purchase":
int orderNum = parseParamInt(request, "orderNum");
customerId = parseParamInt(paramNotNull(request, "customerId"), "customerId");
productId = parseParamInt(paramNotNull(request, "productId"), "productId");
Short quantity = parseParamShort(request, "quantity");
BigDecimal shippingCost = parseParamBigDecimal(request, "shippingCost", 12);
Date salesDate = paramDate(request, "salesDate");
Date shippingDate = paramDate(request, "shippingDate");
String freightCompany = paramLength(request, "freightCompany", 30);
data = new PurchaseOrder(orderNum, customerId, productId, quantity, shippingCost, salesDate, shippingDate, freightCompany);
break;
case "discount": case "discount":
discountCode = paramChar(request, "discountCode"); mv.addObject("result", new MagasinHelper().getDiscountCode(request.getParameter("num").charAt(0)));
BigDecimal rate = parseParamBigDecimal(request, "rate", 4);
data = new DiscountCode(discountCode, rate);
break; break;
case "prodCode": case "prodCode":
productCode = paramLength(request, "prodCode", 2); mv.addObject("result", new MagasinHelper().getProductCode(request.getParameter("num")));
discountCode = paramChar(request, "discountCode"); mv.addObject("code", new MagasinHelper().getDiscountCodes());
description = paramLength(request, "description", 10); break;
data = new ProductCode(productCode, discountCode, description); default:
mv.addObject("error", "Type not found");
}
return mv;
}
public ModelAndView find(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("resultat");
mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type);
String query = request.getParameter("query");
if (query == null || query.isEmpty()) {
mv.addObject("error", "No query");
} else {
List<Customer> customers = new ArrayList<Customer>();
try {
customers.addAll(new MagasinHelper().getClientsColums(Integer.parseInt(query)));
} catch (NumberFormatException exception) {
}
query = "%".concat(query.concat("%"));
customers.addAll(new MagasinHelper().getClientsColums(query));
if (customers.size() == 0) {
mv.addObject("error", "No user found :/");
} else {
mv.addObject("results", customers);
}
}
MagasinHelper helper = new MagasinHelper();
return mv;
}
public ModelAndView achats(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
ModelAndView mv = new ModelAndView("achats");
mv.addObject("user", session.getAttribute("user"));
mv.addObject("achats", new MagasinHelper().getPurchases(Integer.parseInt(request.getParameter("customerId"))));
return mv;
}
public ModelAndView delete(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("confirm");
mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type);
switch (type) {
case "customer":
new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("customerId")));
break;
case "product":
new MagasinHelper().deleteProduct(Integer.parseInt(request.getParameter("productId")));
break;
case "purchase":
new MagasinHelper().deletePurchase(Integer.parseInt(request.getParameter("orderNum")));
break;
case "discount":
new MagasinHelper().deleteDiscountCode(request.getParameter("discountCode").charAt(0));
break;
case "prodCode":
new MagasinHelper().deleteProductCode(request.getParameter("prodCode"));
break; break;
default: default:
mv.addObject("error", "Type not found"); mv.addObject("error", "Type not found");
return mv; return mv;
} }
} catch (InvalidParameter e) {
mv.addObject("error", e.getMessage()); mv.addObject("confirm", "suppression effectuée");
} return mv;
return data; }
}
private char paramChar(HttpServletRequest request, String name) throws InvalidParameter {
public ModelAndView save(HttpServletRequest request, String param = paramNotNull(request, name);
HttpServletResponse response) throws Exception { if (param.length() > 1) {
sessionInit(request); throw new InvalidParameter("Invalid ".concat(name));
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("confirm");
mv.addObject("user",session.getAttribute("user"));
mv.addObject("type", type);
Object data = fetchDetailsData(request, mv);
if (data != null) {
try {
new MagasinHelper().add(data);
mv.addObject("confirm","Save completed");
} catch (ConstraintViolationException e) {
mv.addObject("error", e.getSQLException().getMessage());
} catch (Exception e) {
mv.addObject("error", e.getMessage());
} }
} return param.charAt(0);
return mv; }
}
private int parseParamInt(HttpServletRequest request, String name) throws InvalidParameter {
public ModelAndView update(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("confirm");
mv.addObject("user",session.getAttribute("user"));
mv.addObject("type", type);
Object data = fetchDetailsData(request, mv);
if (data != null) {
try { try {
new MagasinHelper().update(data); return Integer.parseInt(request.getParameter(name));
mv.addObject("confirm","Update completed");
} catch (Exception e) { } catch (Exception e) {
mv.addObject("error", e.getMessage()); throw new InvalidParameter("Invalid numer for ".concat(name));
} }
} }
return mv;
} private int parseParamInt(String param, String name) throws InvalidParameter {
try {
return Integer.parseInt(param);
} catch (Exception e) {
throw new InvalidParameter("Invalid numer for ".concat(name));
}
}
private BigDecimal parseParamBigDecimal(HttpServletRequest request, String name, int precision) throws InvalidParameter {
BigDecimal bc;
try {
bc = BigDecimal.valueOf(Long.parseLong(request.getParameter("rate")));
} catch (Exception e) {
throw new InvalidParameter("Invalid big int for ".concat(name));
}
if (bc.precision() > precision) {
throw new InvalidParameter("Precision for ".concat(name).concat(" shounld be over ".concat(String.valueOf(precision))));
}
return bc;
}
private Short parseParamShort(HttpServletRequest request, String name) throws InvalidParameter {
try {
return Short.valueOf(request.getParameter("rate"));
} catch (Exception e) {
throw new InvalidParameter("Invalid short number for ".concat(name));
}
}
private String paramNotNull(HttpServletRequest request, String name) throws InvalidParameter {
String param = request.getParameter(name);
if (param == null || param.isEmpty()) {
throw new InvalidParameter(name.concat(" should not be empty"));
}
return param;
}
private String paramLength(HttpServletRequest request, String name, int length) throws InvalidParameter {
String param = request.getParameter(name);
if (param.length() > length) {
throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters")));
}
return param;
}
private String paramLength(String param, String name, int length) throws InvalidParameter {
if (param.length() > length) {
throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters")));
}
return param;
}
private String paramAvailable(HttpServletRequest request, String name) throws InvalidParameter {
String param = request.getParameter(name).toUpperCase();
if (!param.equals("TRUE") && !param.equals("FALSE")) {
throw new InvalidParameter("It's true or false for ".concat(name));
}
return param;
}
private Date paramDate(HttpServletRequest request, String name) throws InvalidParameter {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
try {
return format.parse(request.getParameter(name));
} catch (Exception e) {
throw new InvalidParameter("Invalid date for ".concat(name));
}
}
private Object fetchDetailsData(HttpServletRequest request, ModelAndView mv) throws Exception {
String type = request.getParameter("type");
Object data = null;
try {
switch (type) {
case "customer":
int customerId = parseParamInt(request, "customerId");
char discountCode = paramChar(request, "discountCode");
String zip = paramLength(paramNotNull(request, "zip"), "zip", 10);
String name = paramLength(request, "name", 30);
String addressline1 = paramLength(request, "addressline1", 30);
String addressline2 = paramLength(request, "addressline2", 30);
String city = paramLength(request, "city", 25);
String state = paramLength(request, "state", 2);
String phone = paramLength(request, "phone", 12);
String fax = paramLength(request, "fax", 12);
String email = paramLength(request, "email", 40);
int creditLimit = parseParamInt(request, "creditLimit");
data = new Customer(customerId, discountCode, zip, name, addressline1, addressline2, city, state, phone, fax, email, creditLimit);
break;
case "product":
int productId = parseParamInt(request, "productId");
int manufacturerId = parseParamInt(paramNotNull(request, "manufacturerId"), "manufacturerId");
String productCode = paramLength(paramNotNull(request, "productCode"), "productCode", 2);
BigDecimal purchaseCost = parseParamBigDecimal(request, "purchaseCost", 12);
int quantityOnHand = parseParamInt(request, "quantityOnHand");
BigDecimal markup = parseParamBigDecimal(request, "markup", 12);
String available = paramAvailable(request, "available");
String description = paramLength(request, "description", 50);
data = new Product(productId, manufacturerId, productCode, purchaseCost, quantityOnHand, markup, available, description);
break;
case "purchase":
int orderNum = parseParamInt(request, "orderNum");
customerId = parseParamInt(paramNotNull(request, "customerId"), "customerId");
productId = parseParamInt(paramNotNull(request, "productId"), "productId");
Short quantity = parseParamShort(request, "quantity");
BigDecimal shippingCost = parseParamBigDecimal(request, "shippingCost", 12);
Date salesDate = paramDate(request, "salesDate");
Date shippingDate = paramDate(request, "shippingDate");
String freightCompany = paramLength(request, "freightCompany", 30);
data = new PurchaseOrder(orderNum, customerId, productId, quantity, shippingCost, salesDate, shippingDate, freightCompany);
break;
case "discount":
discountCode = paramChar(request, "discountCode");
BigDecimal rate = parseParamBigDecimal(request, "rate", 4);
data = new DiscountCode(discountCode, rate);
break;
case "prodCode":
productCode = paramLength(request, "prodCode", 2);
discountCode = paramChar(request, "discountCode");
description = paramLength(request, "description", 10);
data = new ProductCode(productCode, discountCode, description);
break;
default:
mv.addObject("error", "Type not found");
return mv;
}
} catch (InvalidParameter e) {
mv.addObject("error", e.getMessage());
}
return data;
}
public ModelAndView save(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("confirm");
mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type);
Object data = fetchDetailsData(request, mv);
if (data != null) {
try {
new MagasinHelper().add(data);
mv.addObject("confirm", "Save completed");
} catch (ConstraintViolationException e) {
mv.addObject("error", e.getSQLException().getMessage());
} catch (Exception e) {
mv.addObject("error", e.getMessage());
}
}
return mv;
}
public ModelAndView update(HttpServletRequest request,
HttpServletResponse response) throws Exception {
sessionInit(request);
String type = request.getParameter("type");
ModelAndView mv = new ModelAndView("confirm");
mv.addObject("user", session.getAttribute("user"));
mv.addObject("type", type);
Object data = fetchDetailsData(request, mv);
if (data != null) {
try {
new MagasinHelper().update(data);
mv.addObject("confirm", "Update completed");
} catch (Exception e) {
mv.addObject("error", e.getMessage());
}
}
return mv;
}
} }

View file

@ -4,16 +4,19 @@
* and open the template in the editor. * and open the template in the editor.
*/ */
package service; package service;
import java.io.Serializable; import java.io.Serializable;
/** /**
* *
* @author faycal * @author faycal
*/ */
public class User implements Serializable { public class User implements Serializable {
private String login; private String login;
private String pwd; private String pwd;
private int userId; private int userId;
static private int compteur=0; static private int compteur = 0;
public static int getCompteur() { public static int getCompteur() {
return compteur; return compteur;
@ -21,22 +24,24 @@ public class User implements Serializable {
public User() { public User() {
super(); super();
userId=compteur++; userId = compteur++;
} }
public void finalize(){
public void finalize() {
compteur--; compteur--;
} }
public User(String login) {
public User(String login) {
this.login = login; this.login = login;
userId=compteur++; userId = compteur++;
} }
public User(String login, String pwd) { public User(String login, String pwd) {
this.login = login; this.login = login;
this.pwd = pwd; this.pwd = pwd;
userId=compteur++; userId = compteur++;
} }
public String getLogin() { public String getLogin() {
@ -54,5 +59,5 @@ public class User implements Serializable {
public void setPwd(String pwd) { public void setPwd(String pwd) {
this.pwd = pwd; this.pwd = pwd;
} }
} }

View file

@ -8,27 +8,27 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<H1>Achats du client n°<%=request.getParameter("customerId")%></H1> <H1>Achats du client n°<%=request.getParameter("customerId")%></H1>
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">
<c:forEach items="${achats}" var="cli"> <c:forEach items="${achats}" var="cli">
<TR> <TR>
<TD>${cli.orderNum}</TD> <TD>${cli.orderNum}</TD>
<TD>${cli.customerId}</TD> <TD>${cli.customerId}</TD>
<TD>${cli.productId}</TD> <TD>${cli.productId}</TD>
<TD>${cli.quantity}</TD> <TD>${cli.quantity}</TD>
<TD>${cli.shippingCost}</TD> <TD>${cli.shippingCost}</TD>
<TD>${cli.salesDate}</TD> <TD>${cli.salesDate}</TD>
<TD>${cli.shippingDate}</TD> <TD>${cli.shippingDate}</TD>
<TD>${cli.freightCompany}</TD> <TD>${cli.freightCompany}</TD>
</TR> </TR>
</c:forEach> </c:forEach>
</table> </table>
</body> </body>
</html> </html>

View file

@ -13,7 +13,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<h1>${error != null ? error : confirm} </h1> <h1>${error != null ? error : confirm} </h1>
<form action="list.htm" method="POST"> <form action="list.htm" method="POST">
<input hidden type="text" name="type" value="${type}" /> <input hidden type="text" name="type" value="${type}" />

View file

@ -1,18 +0,0 @@
<%--
Document : deconnexion
Created on : 1 juin 2020, 17:09:38
Author : faycal
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Deconnexion</title>
</head>
<body>
<h1>Vous etes deconnecte</h1>
<%response.sendRedirect("/Bdd_Spring_HI/");%>
</body>
</html>

View file

@ -8,7 +8,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="detail" method="POST"> <form name="detail" method="POST">
<c:choose> <c:choose>
<c:when test="${type == 'customer'}"> <c:when test="${type == 'customer'}">
@ -106,12 +106,12 @@
<label for="available">Available</label> <label for="available">Available</label>
<label for="isavailable">TRUE:</label> <label for="isavailable">TRUE:</label>
<input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" /> <input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" />
<label for="notavailable">FALSE:</label> <label for="notavailable">FALSE:</label>
<input type="radio" name="available" value="FALSE" <c:if test="${result.available == 'FALSE'}">checked</c:if> id="notavailable" /> <input type="radio" name="available" value="FALSE" <c:if test="${result.available == 'FALSE'}">checked</c:if> id="notavailable" />
</p> </p>
<p> <p>
<label for="description">Description</label> <label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="50" /> <input type="text" name="description" value="${result.description}" id="description" size="50" />
</p> </p>
</c:when> </c:when>
<c:when test="${type == 'purchase'}"> <c:when test="${type == 'purchase'}">
@ -185,7 +185,7 @@
</p> </p>
</c:when> </c:when>
</c:choose> </c:choose>
<input hidden type="text" name="type" value="${type}" /> <input hidden type="text" name="type" value="${type}" />
<c:choose> <c:choose>
<c:when test="${save != null}"> <c:when test="${save != null}">

View file

@ -1,18 +0,0 @@
<%--
Document : error
Created on : 4 mars 2018, 20:54:56
Author : faycal
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Erreur</title>
</head>
<body>
<%@include file="header.jsp" %>
<h1>${erreur} </h1>
</body>
</html>

View file

@ -14,40 +14,40 @@
</head> </head>
<body> <body>
Bienvenue ${user.login} Bienvenue ${user.login}
<form name="inscription" method="POST"> <form name="inscription" method="POST">
<p> <p>
<label for="nom">Nom</label> <label for="nom">Nom</label>
<input type="text" name="nom" value="" size="10" id="nom" /> <input type="text" name="nom" value="" size="10" id="nom" />
</p> </p>
<p> <p>
<label for="adresse">Adresse</label> <label for="adresse">Adresse</label>
<input type="text" name="adresse" value="" size="10" id="adresse" /> <input type="text" name="adresse" value="" size="10" id="adresse" />
</p> </p>
<p> <p>
<label for="telephone">Téléphone</label> <label for="telephone">Téléphone</label>
<input type="text" name="telephone" value="" size="10" id="tel" /> <input type="text" name="telephone" value="" size="10" id="tel" />
</p> </p>
<p> <p>
<label for="email">E-mail</label> <label for="email">E-mail</label>
<input type="text" name="email" value="" size="10" id="email"/> <input type="text" name="email" value="" size="10" id="email"/>
</p> </p>
<p><label for="code_remise">Code Remise</label> <p><label for="code_remise">Code Remise</label>
<select name="code_remise" id="dc"> <select name="code_remise" id="dc">
<c:forEach items="${discount}" var="dc"> <c:forEach items="${discount}" var="dc">
<option>${dc}</option> <option>${dc}</option>
</c:forEach> </c:forEach>
</select> </select>
</p> </p>
<p> <p>
<label for="cp">Code Postal</label> <label for="cp">Code Postal</label>
<select name="CP" id="cp"> <select name="CP" id="cp">
<c:forEach items="${code}" var="cp"> <c:forEach items="${code}" var="cp">
<option>${cp}</option> <option>${cp}</option>
</c:forEach> </c:forEach>
</select> </select>
</p> </p>
<input type="submit" value="Enregistrer" formaction="save.htm" /> <input type="submit" value="Enregistrer" formaction="save.htm" />
</form> </form>

View file

@ -15,7 +15,7 @@
<div style="display: flex; flex-direction: row; justify-content: flex-end"> <div style="display: flex; flex-direction: row; justify-content: flex-end">
<form name="form" method="POST"> <form name="form" method="POST">
<input type="submit" formaction="logout.htm" value="Log out" /> <input type="submit" formaction="logout.htm" value="Log out" />
<input type="text" name="query" /> <input type="text" name="query" />
<input hidden type="text" name="type" value="customer" /> <input hidden type="text" name="type" value="customer" />
<input type="submit" formaction="find.htm" value="Search user" /> <input type="submit" formaction="find.htm" value="Search user" />

View file

@ -2,5 +2,5 @@
<% response.sendRedirect("menu.htm"); %> <% response.sendRedirect("menu.htm");%>

View file

@ -13,20 +13,20 @@
</head> </head>
<body> <body>
<form method="POST" action="j_security_check"> <form method="POST" action="j_security_check">
<table> <table>
<tr> <tr>
<td>Utilisateur :</td> <td>Utilisateur :</td>
<td><input type="text" name="j_username"></td> <td><input type="text" name="j_username"></td>
</tr> </tr>
<tr> <tr>
<td>Mot de passe :</td> <td>Mot de passe :</td>
<td><input type="password" name="j_password" ></td> <td><input type="password" name="j_password" ></td>
</tr> </tr>
<tr> <tr>
<td><input type="submit" value="Entrer" ></td> <td><input type="submit" value="Entrer" ></td>
<td><input type="reset" value="Annuler"></td> <td><input type="reset" value="Annuler"></td>
</tr> </tr>
</table> </table>
</form> </form>
</body> </body>
</html> </html>

View file

@ -12,7 +12,7 @@
<title>Deconnexion</title> <title>Deconnexion</title>
</head> </head>
<body> <body>
<h1>Vous etes deconnecte</h1> <h1>You are logout</h1>
<%response.sendRedirect("/Bdd_Spring_HI/");%> <%response.sendRedirect("");%>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<h1>choisissez une opération dans la liste suivante</h1> <h1>choisissez une opération dans la liste suivante</h1>
<form name="form" action="list.htm" method="POST"> <form name="form" action="list.htm" method="POST">
<input type="submit" value="Customers" /> <br /> <input type="submit" value="Customers" /> <br />
<input hidden type="text" name="type" value="customer" /> <input hidden type="text" name="type" value="customer" />

View file

@ -13,14 +13,14 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="recherche" action="find.htm" method="POST"> <form name="recherche" action="find.htm" method="POST">
<p> <p>
<label for="nom">Nom de l'entreprise</label> <label for="nom">Nom de l'entreprise</label>
<input type="text" name="nom" size="30" id="nom" /> <input type="text" name="nom" size="30" id="nom" />
</p> </p>
<input type="submit" value="rechercher" /> <input type="submit" value="rechercher" />
</form> </form>
</body> </body>
</html> </html>

View file

@ -14,7 +14,7 @@
</head> </head>
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<c:choose> <c:choose>
<c:when test="${error != null}"> <c:when test="${error != null}">
<h1>${error}</h1> <h1>${error}</h1>
@ -27,37 +27,37 @@
<table border="1" cellpadding="10"> <table border="1" cellpadding="10">
<TR> <TR>
<c:forEach items="${colonnes}" var="col"> <c:forEach items="${colonnes}" var="col">
<TD>${col}</TD> <TD>${col}</TD>
</c:forEach> </c:forEach>
</TR> </TR>
<c:forEach items="${results}" var="values" varStatus="row" > <c:forEach items="${results}" var="values" varStatus="row" >
<TR> <TR>
<c:forEach items="${values}" var="v" varStatus="vStatus" > <c:forEach items="${values}" var="v" varStatus="vStatus" >
<c:choose> <c:choose>
<c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}"> <c:when test="${relation != null && relation.get(colonnes[vStatus.index]) != null}">
<TD> <TD>
<form name="Detail" action="detail.htm" method="POST"> <form name="Detail" action="detail.htm" method="POST">
<input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/> <input hidden type="text" name="type" value="${relation.get(colonnes[vStatus.index])}"/>
<input hidden name="num" value="${v}"/> <input hidden name="num" value="${v}"/>
<input type=submit value="${v}" /> <input type=submit value="${v}" />
</form> </form>
</TD> </TD>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<TD>${v}</TD> <TD>${v}</TD>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
</c:forEach> </c:forEach>
<TD> <TD>
<form name="Detail" action="detail.htm" method="POST"> <form name="Detail" action="detail.htm" method="POST">
<input hidden type="text" name="type" value="${type}"/> <input hidden type="text" name="type" value="${type}"/>
<input hidden name="num" value="${values[0]}"/> <input hidden name="num" value="${values[0]}"/>
<input type=submit value="Détail" /> <input type=submit value="Détail" />
</form> </form>
</TD> </TD>
</TR> </TR>
</c:forEach> </c:forEach>
</table> </table>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>