diff --git a/build/web/WEB-INF/classes/DAO/MagasinHelper.class b/build/web/WEB-INF/classes/DAO/MagasinHelper.class index e3f950b..21edcfd 100644 Binary files a/build/web/WEB-INF/classes/DAO/MagasinHelper.class and b/build/web/WEB-INF/classes/DAO/MagasinHelper.class differ diff --git a/build/web/WEB-INF/classes/controller/BddController.class b/build/web/WEB-INF/classes/controller/BddController.class index f1b11c0..a273922 100644 Binary files a/build/web/WEB-INF/classes/controller/BddController.class and b/build/web/WEB-INF/classes/controller/BddController.class differ diff --git a/build/web/WEB-INF/classes/jsp/detail.jsp b/build/web/WEB-INF/classes/jsp/detail.jsp index 25094f9..c7a0739 100644 --- a/build/web/WEB-INF/classes/jsp/detail.jsp +++ b/build/web/WEB-INF/classes/jsp/detail.jsp @@ -33,10 +33,10 @@

- - - +

@@ -92,7 +92,6 @@

-

result: ${result}

@@ -123,7 +122,7 @@

- +

@@ -134,6 +133,34 @@

+ +

+ + +

+

+ + +

+
+ +

+ + +

+

+ + +

+

+ + +

+
diff --git a/build/web/WEB-INF/classes/jsp/resultat.jsp b/build/web/WEB-INF/classes/jsp/resultat.jsp index e3b1710..7c7897a 100644 --- a/build/web/WEB-INF/classes/jsp/resultat.jsp +++ b/build/web/WEB-INF/classes/jsp/resultat.jsp @@ -35,7 +35,7 @@
- +
@@ -48,7 +48,7 @@
- +
diff --git a/build/web/WEB-INF/jsp/detail.jsp b/build/web/WEB-INF/jsp/detail.jsp index 17956f9..c7a0739 100644 --- a/build/web/WEB-INF/jsp/detail.jsp +++ b/build/web/WEB-INF/jsp/detail.jsp @@ -33,10 +33,10 @@

- - - +

@@ -133,6 +133,34 @@

+ +

+ + +

+

+ + +

+
+ +

+ + +

+

+ + +

+

+ + +

+
diff --git a/build/web/WEB-INF/jsp/resultat.jsp b/build/web/WEB-INF/jsp/resultat.jsp index e3b1710..7c7897a 100644 --- a/build/web/WEB-INF/jsp/resultat.jsp +++ b/build/web/WEB-INF/jsp/resultat.jsp @@ -35,7 +35,7 @@
- +
@@ -48,7 +48,7 @@
- +
diff --git a/src/java/DAO/MagasinHelper.java b/src/java/DAO/MagasinHelper.java index c766991..458a469 100644 --- a/src/java/DAO/MagasinHelper.java +++ b/src/java/DAO/MagasinHelper.java @@ -180,6 +180,27 @@ public class MagasinHelper { return resultat; } + public List getProductCodesColums(){ + List resultat=null; + Transaction tx=null; + try{ + if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + session.flush(); + + tx=session.beginTransaction(); + Query q=session.createQuery("select p.prodCode, p.discountCode, p.description from ProductCode p"); + resultat=q.list(); + + + } catch (Exception e) { + e.printStackTrace(); + } finally{ + if (session.isOpen())session.close(); + } + + return resultat; + } + public List getProductCodes(){ List resultat=null; Transaction tx=null; @@ -200,8 +221,30 @@ public class MagasinHelper { return resultat; } + + public ProductCode getProductCode(String id){ + ProductCode resultat=null; + Transaction tx=null; + try{ + if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + session.flush(); + + tx=session.beginTransaction(); + Query q=session.createQuery("from ProductCode p where p.prodCode = :_id"); + q.setString("_id", id); + resultat=(ProductCode)q.list().iterator().next(); + + + } catch (Exception e) { + e.printStackTrace(); + } finally{ + if (session.isOpen())session.close(); + } -public List getDiscountCode(){ + return resultat; + } + +public List getDiscountCodesColums(){ List resultat=null; Transaction tx=null; try{ @@ -210,7 +253,7 @@ List resultat=null; session.flush(); tx=session.beginTransaction(); - Query q=session.createQuery("select a.discountCode from DiscountCode a"); + Query q=session.createQuery("select dc.discountCode, dc.rate from DiscountCode dc"); resultat=q.list(); } catch (Exception e) { @@ -225,6 +268,58 @@ List resultat=null; } + +public List getDiscountCodes(){ + List resultat=null; + Transaction tx=null; + try{ + if(!session.isOpen()) + session=HibernateUtil.getSessionFactory().openSession(); + session.flush(); + + tx=session.beginTransaction(); + Query q=session.createQuery(" from DiscountCode dc"); + resultat=q.list(); + } + catch (Exception e) { + e.printStackTrace(); + } + finally{ + if (session.isOpen())session.close(); + + } + + return resultat; + + +} + +public DiscountCode getDiscountCode(char c){ + DiscountCode resultat=null; + Transaction tx=null; + try{ + if(!session.isOpen()) + session=HibernateUtil.getSessionFactory().openSession(); + session.flush(); + + tx=session.beginTransaction(); + Query q=session.createQuery(" from DiscountCode dc where dc.discountCode = :_id"); + q.setCharacter("_id", c); + resultat=(DiscountCode)q.list().iterator().next(); + } + catch (Exception e) { + e.printStackTrace(); + } + finally{ + if (session.isOpen())session.close(); + + } + + return resultat; + + +} + public List getMicroMarket(){ List resultat=null; Transaction tx=null; diff --git a/src/java/controller/BddController.java b/src/java/controller/BddController.java index 56fc3fe..da41b5a 100644 --- a/src/java/controller/BddController.java +++ b/src/java/controller/BddController.java @@ -84,6 +84,14 @@ public class BddController extends MultiActionController { put("productId", "product"); }}); break; + case "discount": + mv.addObject("results", new MagasinHelper().getDiscountCodesColums()); + mv.addObject("colonnes", Arrays.asList("discountCode", "rate")); + break; + case "prodCode": + mv.addObject("results", new MagasinHelper().getProductCodesColums()); + mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description")); + break; default: mv.addObject("error", "Type not found"); } @@ -97,7 +105,7 @@ public class BddController extends MultiActionController { ModelAndView mv = new ModelAndView("form_inscription"); mv.addObject("user",session.getAttribute("user")); - mv.addObject("discount",new MagasinHelper().getDiscountCode()); + mv.addObject("discount",new MagasinHelper().getDiscountCodesColums()); mv.addObject("code",new MagasinHelper().getZipCode()); return mv; } @@ -112,7 +120,7 @@ public class BddController extends MultiActionController { switch (type) { case "customer": mv.addObject("result", new MagasinHelper().getClient(Integer.parseInt(request.getParameter("num")))); - mv.addObject("code",new MagasinHelper().getDiscountCode()); + mv.addObject("code",new MagasinHelper().getDiscountCodes()); mv.addObject("cpostaux",new MagasinHelper().getZipCode()); break; case "product": @@ -125,6 +133,13 @@ public class BddController extends MultiActionController { mv.addObject("customers", new MagasinHelper().getClients()); mv.addObject("products", new MagasinHelper().getProducts()); 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"); } diff --git a/web/WEB-INF/jsp/detail.jsp b/web/WEB-INF/jsp/detail.jsp index 17956f9..c7a0739 100644 --- a/web/WEB-INF/jsp/detail.jsp +++ b/web/WEB-INF/jsp/detail.jsp @@ -33,10 +33,10 @@

- - - +

@@ -133,6 +133,34 @@

+ +

+ + +

+

+ + +

+
+ +

+ + +

+

+ + +

+

+ + +

+
diff --git a/web/WEB-INF/jsp/resultat.jsp b/web/WEB-INF/jsp/resultat.jsp index e3b1710..7c7897a 100644 --- a/web/WEB-INF/jsp/resultat.jsp +++ b/web/WEB-INF/jsp/resultat.jsp @@ -35,7 +35,7 @@
- +
@@ -48,7 +48,7 @@
- +