1
0
Fork 0

Add product and purchase list

Start of the detail
This commit is contained in:
Ethanell 2022-06-29 00:27:40 +02:00
parent 63feda15b0
commit c3975ab084
12 changed files with 473 additions and 264 deletions

View file

@ -9,47 +9,89 @@
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="detail" method="POST"> <form name="detail" method="POST">
<p> <c:choose>
<label for="numero">Numero</label> <c:when test="${type == 'customer'}">
<input type="text" name="numero" value="${client.customerId}" size="30" id="numero" /> <p>
</p> <label for="numero">Numero</label>
<p> <input type="text" name="numero" value="${result.customerId}" size="30" id="numero" />
<label for="nom">Nom</label> </p>
<input type="text" name="nom" value="${client.name}" size="30" id="nom" /> <p>
</p> <label for="nom">Nom</label>
<p> <input type="text" name="nom" value="${result.name}" size="30" id="nom" />
<label for="adresse">Adresse</label> </p>
<input type="text" name="adresse" value="${client.addressline1}" size="30" id="adresse" /> <p>
</p> <label for="adresse">Adresse</label>
<p> <input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
<label for="telephone">Téléphone</label> </p>
<input type="text" name="telephone" value="${client.phone}" size="30" id="tel" /> <p>
</p> <label for="telephone">Téléphone</label>
<p> <input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
<label for="email">E-mail</label> </p>
<input type="text" name="email" value="${client.email}" size="30" id="email"/> <p>
</p> <label for="email">E-mail</label>
<p> <input type="text" name="email" value="${result.email}" size="30" id="email"/>
<label for="Remise">Remise</label> </p>
<select name="code_remise" id="dc"> <p>
<c:forEach items="${code}" var="dc"> <label for="Remise">Remise</label>
<option <c:if test="${dc==client.discountCode}"> selected </c:if>>${dc}</option> <select name="code_remise" id="dc">
</c:forEach> <c:forEach items="${code}" var="dc">
</select> <option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
</p> </c:forEach>
<p> </select>
<label for="cp">Code Postal</label> </p>
<select name="CP" id="cp"> <p>
<c:forEach items="${cpostaux}" var="cp"> <label for="cp">Code Postal</label>
<option <c:if test="${cp==client.zip}"> selected </c:if>>${cp}</option> <select name="CP" id="cp">
</c:forEach> <c:forEach items="${cpostaux}" var="cp">
</select> <option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
</p> </c:forEach>
</select>
</p>
</c:when>
<c:when test="${type == 'product'}">
<p>
<label for="productId">ID</label>
<input type="number" name="productId" value="${result.productId}" size="30" id="productId" />
</p>
<p>
<label for="manufacturerId">Manufacturer</label>
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
</p>
<p>
<label for="productCode">Product Code</label>
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
</p>
<p>
<label for="purchaseCost">Purchase cost</label>
<input type="number" step="0.000000000001" name="purchaseCost" value="${result.purchaseCost}" id="purchaseCost" />
</p>
<p>
<label for="quantityOnHand">Quantity on hand</label>
<input type="number" name="quantityOnHand" value="${result.quantityOnHand}" id="quantityOnHand" />
</p>
<p>
<label for="markup">Markup</label>
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
</p>
<p>
<label for="markup">Available</label>
<input type="text" name="available" value="${result.available}" id="available" size="5" />
</p>
<p>
<label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="50" />
</p>
</c:when>
</c:choose>
<input hidden type="text" name="type" value="${type}" />
<input type="submit" value="Modifier" formaction="update.htm" /> <input type="submit" value="Modifier" formaction="update.htm" />
<input type="submit" value="Supprimer" formaction="delete.htm" /> <input type="submit" value="Supprimer" formaction="delete.htm" />
<input type="submit" value="Afficher les achats" formaction="achats.htm" /> <c:if test="${type == 'customer'}">
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
</c:if>
</form> </form>
</body> </body>
</html> </html>

View file

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

View file

@ -9,47 +9,89 @@
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="detail" method="POST"> <form name="detail" method="POST">
<p> <c:choose>
<label for="numero">Numero</label> <c:when test="${type == 'customer'}">
<input type="text" name="numero" value="${client.customerId}" size="30" id="numero" /> <p>
</p> <label for="numero">Numero</label>
<p> <input type="text" name="numero" value="${result.customerId}" size="30" id="numero" />
<label for="nom">Nom</label> </p>
<input type="text" name="nom" value="${client.name}" size="30" id="nom" /> <p>
</p> <label for="nom">Nom</label>
<p> <input type="text" name="nom" value="${result.name}" size="30" id="nom" />
<label for="adresse">Adresse</label> </p>
<input type="text" name="adresse" value="${client.addressline1}" size="30" id="adresse" /> <p>
</p> <label for="adresse">Adresse</label>
<p> <input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
<label for="telephone">Téléphone</label> </p>
<input type="text" name="telephone" value="${client.phone}" size="30" id="tel" /> <p>
</p> <label for="telephone">Téléphone</label>
<p> <input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
<label for="email">E-mail</label> </p>
<input type="text" name="email" value="${client.email}" size="30" id="email"/> <p>
</p> <label for="email">E-mail</label>
<p> <input type="text" name="email" value="${result.email}" size="30" id="email"/>
<label for="Remise">Remise</label> </p>
<select name="code_remise" id="dc"> <p>
<c:forEach items="${code}" var="dc"> <label for="Remise">Remise</label>
<option <c:if test="${dc==client.discountCode}"> selected </c:if>>${dc}</option> <select name="code_remise" id="dc">
</c:forEach> <c:forEach items="${code}" var="dc">
</select> <option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
</p> </c:forEach>
<p> </select>
<label for="cp">Code Postal</label> </p>
<select name="CP" id="cp"> <p>
<c:forEach items="${cpostaux}" var="cp"> <label for="cp">Code Postal</label>
<option <c:if test="${cp==client.zip}"> selected </c:if>>${cp}</option> <select name="CP" id="cp">
</c:forEach> <c:forEach items="${cpostaux}" var="cp">
</select> <option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
</p> </c:forEach>
</select>
</p>
</c:when>
<c:when test="${type == 'product'}">
<p>
<label for="productId">ID</label>
<input type="number" name="productId" value="${result.productId}" size="30" id="productId" />
</p>
<p>
<label for="manufacturerId">Manufacturer</label>
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
</p>
<p>
<label for="productCode">Product Code</label>
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
</p>
<p>
<label for="purchaseCost">Purchase cost</label>
<input type="number" step="0.000000000001" name="purchaseCost" value="${result.purchaseCost}" id="purchaseCost" />
</p>
<p>
<label for="quantityOnHand">Quantity on hand</label>
<input type="number" name="quantityOnHand" value="${result.quantityOnHand}" id="quantityOnHand" />
</p>
<p>
<label for="markup">Markup</label>
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
</p>
<p>
<label for="markup">Available</label>
<input type="text" name="available" value="${result.available}" id="available" size="5" />
</p>
<p>
<label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="50" />
</p>
</c:when>
</c:choose>
<input hidden type="text" name="type" value="${type}" />
<input type="submit" value="Modifier" formaction="update.htm" /> <input type="submit" value="Modifier" formaction="update.htm" />
<input type="submit" value="Supprimer" formaction="delete.htm" /> <input type="submit" value="Supprimer" formaction="delete.htm" />
<input type="submit" value="Afficher les achats" formaction="achats.htm" /> <c:if test="${type == 'customer'}">
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
</c:if>
</form> </form>
</body> </body>
</html> </html>

View file

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

View file

@ -2,6 +2,12 @@
<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
<editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/>
<open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2">
<group/> <group>
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/Product.hbm.xml</file>
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/web/WEB-INF/jsp/menu.jsp</file>
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/web/WEB-INF/jsp/resultat.jsp</file>
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/controller/BddController.java</file>
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/MagasinHelper.java</file>
</group>
</open-files> </open-files>
</project-private> </project-private>

View file

@ -46,6 +46,28 @@ public class MagasinHelper {
return resultat; return resultat;
} }
public Product getProduct(int id){
Product resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery("from Product p where p.productId = :_id");
q.setInteger("_id", id);
resultat=(Product)q.list().iterator().next();
} catch (Exception e) {
e.printStackTrace();
} finally{
if (session.isOpen())session.close();
}
return resultat;
}
public List getClients(){ public List getClients(){
List <Customer> resultat=null; List <Customer> resultat=null;
Transaction tx=null; Transaction tx=null;
@ -227,29 +249,7 @@ public Customer getClient(int id){
return client; return client;
} }
public Customer getClient(String name){
Customer client=null;
Transaction tx=null;
try{
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery(" from Customer a where a.customerId =:_name");
q.setString("_name", name);
client=(Customer)q.list().iterator().next();
}
catch (Exception e) {
System.out.println("erreur"+e);
e.printStackTrace();
}
finally{
if (session.isOpen())session.close();
}
return client;
}
public void deleteCustomer (int _id) { public void deleteCustomer (int _id) {
Transaction tx=null; Transaction tx=null;
@ -273,7 +273,29 @@ public void deleteCustomer (int _id) {
} }
} }
public List<PurchaseOrder> getAchats(int id){
public List<PurchaseOrder> getPurchase(){
List resultat=null;
Transaction tx=null;
try{
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
session.flush();
tx=session.beginTransaction();
Query q=session.createQuery("select po.customerId, po.productId, po.quantity, po.shippingCost, po.salesDate, po.shippingDate, po.freightCompany from PurchaseOrder po");
resultat=(List<PurchaseOrder>)q.list();
}
catch (Exception e) {
e.printStackTrace();
}
finally{
if (session.isOpen())session.close();
}
return resultat;
}
public List<PurchaseOrder> getPurchase(int id){
List resultat=null; List resultat=null;
Transaction tx=null; Transaction tx=null;
try{ try{

View file

@ -29,26 +29,29 @@ public class BddController extends MultiActionController {
private User utilisateur; private User utilisateur;
private HttpSession session; private HttpSession session;
public BddController() {} public BddController() {}
private void sessionInit(HttpServletRequest request) {
if (login == null)
login=request.getUserPrincipal().getName();
if (utilisateur == null)
utilisateur =new User(login);
if (session == null) {
session=request.getSession();
session.setAttribute("user", utilisateur);
}
}
public ModelAndView menu(HttpServletRequest request, public ModelAndView menu(HttpServletRequest request,
HttpServletResponse response){ HttpServletResponse response){
sessionInit(request);
login=request.getUserPrincipal().getName();
//pwd=request.getParameter("password");
utilisateur =new User(login);
session=request.getSession();
session.setAttribute("user", utilisateur);
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, public ModelAndView logout(HttpServletRequest request,
HttpServletResponse response){ HttpServletResponse response){
sessionInit(request);
request.getSession().invalidate(); request.getSession().invalidate();
@ -58,46 +61,78 @@ public class BddController extends MultiActionController {
public ModelAndView list(HttpServletRequest request, public ModelAndView list(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
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("type", type); mv.addObject("type", type);
switch (type) { switch (type) {
case "customer": case "customer":
mv.addObject("results", new MagasinHelper().getClients()); mv.addObject("results", new MagasinHelper().getClients());
mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate"));
break; break;
case "product": case "product":
mv.addObject("results", new MagasinHelper().getProducts()); mv.addObject("results", new MagasinHelper().getProducts());
mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description"));
break; break;
case "purchase":
mv.addObject("results", new MagasinHelper().getPurchase());
mv.addObject("colonnes", Arrays.asList("customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
mv.addObject("relation", new HashMap<String, String>() {{
put("customerId", "customer");
put("productId", "product");
}});
break;
default:
mv.addObject("error", "Type not found");
} }
return mv; return mv;
} }
public ModelAndView add(HttpServletRequest request, public ModelAndView add(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
ModelAndView mv = new ModelAndView("form_inscription"); ModelAndView mv = new ModelAndView("form_inscription");
mv.addObject("user",session.getAttribute("user")); mv.addObject("user",session.getAttribute("user"));
mv.addObject("discount",new MagasinHelper().getDiscountCode()); mv.addObject("discount",new MagasinHelper().getDiscountCode());
mv.addObject("code",new MagasinHelper().getZipCode()); mv.addObject("code",new MagasinHelper().getZipCode());
return mv; return mv;
} }
public ModelAndView detail(HttpServletRequest request, public ModelAndView detail(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
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("code",new MagasinHelper().getDiscountCode()); mv.addObject("type", type);
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
mv.addObject("client",new MagasinHelper().getClient(request.getParameter("num"))); switch (type) {
case "customer":
mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num"))));
mv.addObject("colonnes", Arrays.asList("customerId", "name", "addressline1", "addressline2", "zip", "rate"));
mv.addObject("code",new MagasinHelper().getDiscountCode());
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
break;
case "product":
mv.addObject("result", new MagasinHelper().getProduct(Integer.parseInt(request.getParameter("num"))));
mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description"));
break;
case "purchase":
mv.addObject("result", new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("num"))));
mv.addObject("colonnes", Arrays.asList("customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
break;
default:
mv.addObject("error", "Type not found");
}
return mv; return mv;
} }
public ModelAndView find(HttpServletRequest request, public ModelAndView find(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
ModelAndView mv ; ModelAndView mv ;
MagasinHelper requeteur = new MagasinHelper(); MagasinHelper requeteur = new MagasinHelper();
@ -117,10 +152,12 @@ public class BddController extends MultiActionController {
} }
public ModelAndView formfind(HttpServletRequest request, public ModelAndView formfind(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
return new ModelAndView("recherche"); return new ModelAndView("recherche");
} }
public ModelAndView achats(HttpServletRequest request, public ModelAndView achats(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
ModelAndView mv = new ModelAndView("achats"); ModelAndView mv = new ModelAndView("achats");
@ -128,12 +165,13 @@ public class BddController extends MultiActionController {
mv.addObject("user",session.getAttribute("user")); mv.addObject("user",session.getAttribute("user"));
System.out.println("num "+Integer.parseInt(request.getParameter("numero"))); System.out.println("num "+Integer.parseInt(request.getParameter("numero")));
mv.addObject("achats",new MagasinHelper().getAchats(Integer.parseInt(request.getParameter("numero")))); mv.addObject("achats",new MagasinHelper().getPurchase(Integer.parseInt(request.getParameter("numero"))));
return mv; return mv;
} }
public ModelAndView save(HttpServletRequest request, public ModelAndView save(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
String param1 = request.getParameter("nom"); String param1 = request.getParameter("nom");
String param2 = request.getParameter("adresse"); String param2 = request.getParameter("adresse");
String param3 = request.getParameter("telephone"); String param3 = request.getParameter("telephone");
@ -146,6 +184,7 @@ public class BddController extends MultiActionController {
} }
public ModelAndView delete(HttpServletRequest request, public ModelAndView delete(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("numero"))); new MagasinHelper().deleteCustomer(Integer.parseInt(request.getParameter("numero")));
return new ModelAndView("confirm").addObject("confirm","suppression effectuée"); return new ModelAndView("confirm").addObject("confirm","suppression effectuée");
@ -153,6 +192,7 @@ public class BddController extends MultiActionController {
} }
public ModelAndView update(HttpServletRequest request, public ModelAndView update(HttpServletRequest request,
HttpServletResponse response) throws Exception { HttpServletResponse response) throws Exception {
sessionInit(request);
String param1 = request.getParameter("numero"); String param1 = request.getParameter("numero");
String param2 = request.getParameter("code_remise"); String param2 = request.getParameter("code_remise");
String param3 = request.getParameter("nom"); String param3 = request.getParameter("nom");

View file

@ -9,47 +9,89 @@
<body> <body>
<%@include file="header.jsp" %> <%@include file="header.jsp" %>
<form name="detail" method="POST"> <form name="detail" method="POST">
<p> <c:choose>
<label for="numero">Numero</label> <c:when test="${type == 'customer'}">
<input type="text" name="numero" value="${client.customerId}" size="30" id="numero" /> <p>
</p> <label for="numero">Numero</label>
<p> <input type="text" name="numero" value="${result.customerId}" size="30" id="numero" />
<label for="nom">Nom</label> </p>
<input type="text" name="nom" value="${client.name}" size="30" id="nom" /> <p>
</p> <label for="nom">Nom</label>
<p> <input type="text" name="nom" value="${result.name}" size="30" id="nom" />
<label for="adresse">Adresse</label> </p>
<input type="text" name="adresse" value="${client.addressline1}" size="30" id="adresse" /> <p>
</p> <label for="adresse">Adresse</label>
<p> <input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
<label for="telephone">Téléphone</label> </p>
<input type="text" name="telephone" value="${client.phone}" size="30" id="tel" /> <p>
</p> <label for="telephone">Téléphone</label>
<p> <input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
<label for="email">E-mail</label> </p>
<input type="text" name="email" value="${client.email}" size="30" id="email"/> <p>
</p> <label for="email">E-mail</label>
<p> <input type="text" name="email" value="${result.email}" size="30" id="email"/>
<label for="Remise">Remise</label> </p>
<select name="code_remise" id="dc"> <p>
<c:forEach items="${code}" var="dc"> <label for="Remise">Remise</label>
<option <c:if test="${dc==client.discountCode}"> selected </c:if>>${dc}</option> <select name="code_remise" id="dc">
</c:forEach> <c:forEach items="${code}" var="dc">
</select> <option <c:if test="${dc==result.discountCode}"> selected </c:if>>${dc}</option>
</p> </c:forEach>
<p> </select>
<label for="cp">Code Postal</label> </p>
<select name="CP" id="cp"> <p>
<c:forEach items="${cpostaux}" var="cp"> <label for="cp">Code Postal</label>
<option <c:if test="${cp==client.zip}"> selected </c:if>>${cp}</option> <select name="CP" id="cp">
</c:forEach> <c:forEach items="${cpostaux}" var="cp">
</select> <option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
</p> </c:forEach>
</select>
</p>
</c:when>
<c:when test="${type == 'product'}">
<p>
<label for="productId">ID</label>
<input type="number" name="productId" value="${result.productId}" size="30" id="productId" />
</p>
<p>
<label for="manufacturerId">Manufacturer</label>
<input type="number" name="manufacturerId" value="${result.manufacturerId}" size="30" id="manufacturerId" />
</p>
<p>
<label for="productCode">Product Code</label>
<input type="text" name="productCode" value="${result.productCode}" size="2" id="productCode" />
</p>
<p>
<label for="purchaseCost">Purchase cost</label>
<input type="number" step="0.000000000001" name="purchaseCost" value="${result.purchaseCost}" id="purchaseCost" />
</p>
<p>
<label for="quantityOnHand">Quantity on hand</label>
<input type="number" name="quantityOnHand" value="${result.quantityOnHand}" id="quantityOnHand" />
</p>
<p>
<label for="markup">Markup</label>
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
</p>
<p>
<label for="markup">Available</label>
<input type="text" name="available" value="${result.available}" id="available" size="5" />
</p>
<p>
<label for="description">Description</label>
<input type="text" name="description" value="${result.description}" id="description" size="50" />
</p>
</c:when>
</c:choose>
<input hidden type="text" name="type" value="${type}" />
<input type="submit" value="Modifier" formaction="update.htm" /> <input type="submit" value="Modifier" formaction="update.htm" />
<input type="submit" value="Supprimer" formaction="delete.htm" /> <input type="submit" value="Supprimer" formaction="delete.htm" />
<input type="submit" value="Afficher les achats" formaction="achats.htm" /> <c:if test="${type == 'customer'}">
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
</c:if>
</form> </form>
</body> </body>
</html> </html>

View file

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