Add add data
This commit is contained in:
parent
1b2d645bf2
commit
6d977fc447
11 changed files with 124 additions and 81 deletions
Binary file not shown.
Binary file not shown.
|
@ -103,8 +103,11 @@
|
||||||
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
|
<input type="number" step="0.0001" name="markup" value="${result.markup}" id="markup" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="markup">Available</label>
|
<label for="available">Available</label>
|
||||||
<input type="checkbox" name="available" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="available" />
|
<label for="isavailable">TRUE:</label>
|
||||||
|
<input type="radio" name="available" value="TRUE" <c:if test="${result.available == 'TRUE'}">checked</c:if> id="isavailable" />
|
||||||
|
<label for="notavailable">FALSE:</label>
|
||||||
|
<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>
|
||||||
|
@ -184,11 +187,19 @@
|
||||||
</c:choose>
|
</c:choose>
|
||||||
|
|
||||||
<input hidden type="text" name="type" value="${type}" />
|
<input hidden type="text" name="type" value="${type}" />
|
||||||
<input type="submit" value="Modifier" formaction="update.htm" />
|
<c:choose>
|
||||||
<input type="submit" value="Supprimer" formaction="delete.htm" />
|
<c:when test="${save != null}">
|
||||||
<c:if test="${type == 'customer'}">
|
<input type="submit" value="Add" formaction="add.htm" />
|
||||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
</c:when>
|
||||||
</c:if>
|
<c:otherwise>
|
||||||
|
<input type="submit" value="Edit" formaction="update.htm" />
|
||||||
|
<input type="submit" value="Delete" formaction="delete.htm" />
|
||||||
|
<c:if test="${type == 'customer'}">
|
||||||
|
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||||
|
</c:if>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
<h1>${error}</h1>
|
<h1>${error}</h1>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
|
<form name="Add" action="detail.htm" method="POST">
|
||||||
|
<input hidden type="text" name="type" value="${type}"/>
|
||||||
|
<input type=submit value="Add" />
|
||||||
|
</form>
|
||||||
<table border="1" cellpadding="10">
|
<table border="1" cellpadding="10">
|
||||||
<TR>
|
<TR>
|
||||||
<c:forEach items="${colonnes}" var="col">
|
<c:forEach items="${colonnes}" var="col">
|
||||||
|
|
|
@ -187,12 +187,18 @@
|
||||||
</c:choose>
|
</c:choose>
|
||||||
|
|
||||||
<input hidden type="text" name="type" value="${type}" />
|
<input hidden type="text" name="type" value="${type}" />
|
||||||
<input type="submit" value="Modifier" formaction="update.htm" />
|
<c:choose>
|
||||||
<input type="submit" value="Supprimer" formaction="delete.htm" />
|
<c:when test="${save != null}">
|
||||||
<c:if test="${type == 'customer'}">
|
<input type="submit" value="Add" formaction="save.htm" />
|
||||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
</c:when>
|
||||||
</c:if>
|
<c:otherwise>
|
||||||
|
<input type="submit" value="Edit" formaction="update.htm" />
|
||||||
|
<input type="submit" value="Delete" formaction="delete.htm" />
|
||||||
|
<c:if test="${type == 'customer'}">
|
||||||
|
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||||
|
</c:if>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
<h1>${error}</h1>
|
<h1>${error}</h1>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
|
<form name="Add" action="formAdd.htm" method="POST">
|
||||||
|
<input hidden type="text" name="type" value="${type}"/>
|
||||||
|
<input type=submit value="Add" />
|
||||||
|
</form>
|
||||||
<table border="1" cellpadding="10">
|
<table border="1" cellpadding="10">
|
||||||
<TR>
|
<TR>
|
||||||
<c:forEach items="${colonnes}" var="col">
|
<c:forEach items="${colonnes}" var="col">
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
<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/web/WEB-INF/jsp/detail.jsp</file>
|
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/PurchaseOrder.java</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/DAO/Product.java</file>
|
||||||
|
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/ProductCode.java</file>
|
||||||
|
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/DiscountCode.java</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/controller/BddController.java</file>
|
||||||
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/MagasinHelper.java</file>
|
<file>file:/C:/Users/flifloo/Nextcloud/IUT/JEE/JEE%20Project/Code/src/java/DAO/MagasinHelper.java</file>
|
||||||
</group>
|
</group>
|
||||||
|
|
|
@ -384,16 +384,14 @@ List resultat=null;
|
||||||
}
|
}
|
||||||
return resultat;
|
return resultat;
|
||||||
}
|
}
|
||||||
public void insertCustomer (int _customerId, char _discountCode, String _zip) {
|
public void add (Object data) {
|
||||||
|
|
||||||
Transaction tx=null;
|
Transaction tx=null;
|
||||||
try{
|
try{
|
||||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||||
session.flush();
|
session.flush();
|
||||||
|
|
||||||
tx=session.beginTransaction();
|
tx=session.beginTransaction();
|
||||||
Customer a =new Customer(_customerId,_discountCode,_zip);
|
session.save(data);
|
||||||
session.save(a);
|
|
||||||
tx.commit();
|
tx.commit();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -429,30 +427,6 @@ public void update (Object data) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateCustomer (int _customerId,char _discountCode, String _name, String _adress, String _phone,String _email, String _zip){
|
|
||||||
|
|
||||||
Transaction tx=null;
|
|
||||||
try{
|
|
||||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
|
||||||
session.flush();
|
|
||||||
|
|
||||||
tx=session.beginTransaction();
|
|
||||||
|
|
||||||
Customer a =new Customer(_customerId,_discountCode,_name, _adress, _phone,_email, _zip);
|
|
||||||
|
|
||||||
session.update(a);
|
|
||||||
tx.commit();
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
tx.rollback();
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
finally{
|
|
||||||
if (session.isOpen())session.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public Customer getClient(int id){
|
public Customer getClient(int id){
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,17 +106,41 @@ public class BddController extends MultiActionController {
|
||||||
|
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
public ModelAndView add(HttpServletRequest request,
|
|
||||||
|
public ModelAndView formAdd(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws Exception {
|
HttpServletResponse response) throws Exception {
|
||||||
sessionInit(request);
|
sessionInit(request);
|
||||||
|
String type = request.getParameter("type");
|
||||||
|
ModelAndView mv = new ModelAndView("detail");
|
||||||
|
mv.addObject("user",session.getAttribute("user"));
|
||||||
|
mv.addObject("type", type);
|
||||||
|
mv.addObject("save", true);
|
||||||
|
|
||||||
ModelAndView mv = new ModelAndView("form_inscription");
|
switch (type) {
|
||||||
|
case "customer":
|
||||||
|
mv.addObject("code",new MagasinHelper().getDiscountCodes());
|
||||||
|
mv.addObject("cpostaux",new MagasinHelper().getZipCode());
|
||||||
|
break;
|
||||||
|
case "product":
|
||||||
|
mv.addObject("manufacturers", new MagasinHelper().getManufacturers());
|
||||||
|
mv.addObject("productCodes", new MagasinHelper().getProductCodes());
|
||||||
|
break;
|
||||||
|
case "purchase":
|
||||||
|
mv.addObject("customers", new MagasinHelper().getClients());
|
||||||
|
mv.addObject("products", new MagasinHelper().getProducts());
|
||||||
|
break;
|
||||||
|
case "discount":
|
||||||
|
break;
|
||||||
|
case "prodCode":
|
||||||
|
mv.addObject("code",new MagasinHelper().getDiscountCodes());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mv.addObject("error", "Type not found");
|
||||||
|
}
|
||||||
|
|
||||||
mv.addObject("user",session.getAttribute("user"));
|
return mv;
|
||||||
mv.addObject("discount",new MagasinHelper().getDiscountCodesColums());
|
|
||||||
mv.addObject("code",new MagasinHelper().getZipCode());
|
|
||||||
return mv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelAndView detail(HttpServletRequest request,
|
public ModelAndView detail(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws Exception {
|
HttpServletResponse response) throws Exception {
|
||||||
sessionInit(request);
|
sessionInit(request);
|
||||||
|
@ -194,19 +218,6 @@ public class BddController extends MultiActionController {
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ModelAndView save(HttpServletRequest request,
|
|
||||||
HttpServletResponse response) throws Exception {
|
|
||||||
sessionInit(request);
|
|
||||||
String param1 = request.getParameter("nom");
|
|
||||||
String param2 = request.getParameter("adresse");
|
|
||||||
String param3 = request.getParameter("telephone");
|
|
||||||
String param4 = request.getParameter("email");
|
|
||||||
String param5 = request.getParameter("code_remise");
|
|
||||||
String param6 = request.getParameter("CP");
|
|
||||||
new MagasinHelper().insertCustomer(new MagasinHelper().getMaxId()+1, param5.charAt(0), param6);
|
|
||||||
return new ModelAndView("confirm").addObject("confirm","enregistrement effectué");
|
|
||||||
|
|
||||||
}
|
|
||||||
public ModelAndView delete(HttpServletRequest request,
|
public ModelAndView delete(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws Exception {
|
HttpServletResponse response) throws Exception {
|
||||||
sessionInit(request);
|
sessionInit(request);
|
||||||
|
@ -240,16 +251,12 @@ public class BddController extends MultiActionController {
|
||||||
return mv;
|
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 = null;
|
|
||||||
|
|
||||||
switch (type) {
|
private Object fetchDetailsData(HttpServletRequest request, ModelAndView mv) throws Exception {
|
||||||
|
String type = request.getParameter("type");
|
||||||
|
Object data = null;
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
case "customer":
|
case "customer":
|
||||||
int customerId = Integer.parseInt(request.getParameter("customerId"));
|
int customerId = Integer.parseInt(request.getParameter("customerId"));
|
||||||
char discountCode = request.getParameter("discountCode").charAt(0);
|
char discountCode = request.getParameter("discountCode").charAt(0);
|
||||||
|
@ -305,10 +312,35 @@ public class BddController extends MultiActionController {
|
||||||
return mv;
|
return mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
new MagasinHelper().add(data);
|
||||||
|
mv.addObject("confirm","Save completed");
|
||||||
|
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);
|
||||||
|
|
||||||
new MagasinHelper().update(data);
|
new MagasinHelper().update(data);
|
||||||
mv.addObject("confirm","Update completed");
|
mv.addObject("confirm","Update completed");
|
||||||
return mv;
|
return mv;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,12 +187,18 @@
|
||||||
</c:choose>
|
</c:choose>
|
||||||
|
|
||||||
<input hidden type="text" name="type" value="${type}" />
|
<input hidden type="text" name="type" value="${type}" />
|
||||||
<input type="submit" value="Modifier" formaction="update.htm" />
|
<c:choose>
|
||||||
<input type="submit" value="Supprimer" formaction="delete.htm" />
|
<c:when test="${save != null}">
|
||||||
<c:if test="${type == 'customer'}">
|
<input type="submit" value="Add" formaction="save.htm" />
|
||||||
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
</c:when>
|
||||||
</c:if>
|
<c:otherwise>
|
||||||
|
<input type="submit" value="Edit" formaction="update.htm" />
|
||||||
|
<input type="submit" value="Delete" formaction="delete.htm" />
|
||||||
|
<c:if test="${type == 'customer'}">
|
||||||
|
<input type="submit" value="Afficher les achats" formaction="achats.htm" />
|
||||||
|
</c:if>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -20,6 +20,10 @@
|
||||||
<h1>${error}</h1>
|
<h1>${error}</h1>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
|
<form name="Add" action="formAdd.htm" method="POST">
|
||||||
|
<input hidden type="text" name="type" value="${type}"/>
|
||||||
|
<input type=submit value="Add" />
|
||||||
|
</form>
|
||||||
<table border="1" cellpadding="10">
|
<table border="1" cellpadding="10">
|
||||||
<TR>
|
<TR>
|
||||||
<c:forEach items="${colonnes}" var="col">
|
<c:forEach items="${colonnes}" var="col">
|
||||||
|
|
Reference in a new issue