From 1b2d645bf2ee663a145b87226519372d168d3a47 Mon Sep 17 00:00:00 2001 From: Ethanell Date: Thu, 30 Jun 2022 00:30:44 +0200 Subject: [PATCH] Add/fix update of datas --- .../WEB-INF/classes/DAO/MagasinHelper.class | Bin 16009 -> 16333 bytes .../classes/controller/BddController$1.class | Bin 828 -> 828 bytes .../classes/controller/BddController.class | Bin 9137 -> 11394 bytes build/web/WEB-INF/classes/jsp/achats.jsp | 2 +- build/web/WEB-INF/classes/jsp/detail.jsp | 48 +++++++--- build/web/WEB-INF/jsp/detail.jsp | 55 ++++++++---- src/java/DAO/MagasinHelper.java | 22 +++++ src/java/controller/BddController.java | 82 +++++++++++++++--- web/WEB-INF/jsp/detail.jsp | 55 ++++++++---- 9 files changed, 204 insertions(+), 60 deletions(-) diff --git a/build/web/WEB-INF/classes/DAO/MagasinHelper.class b/build/web/WEB-INF/classes/DAO/MagasinHelper.class index 995a28fba4e2681a5068030b5c58e74a3b879ab8..d068cbf37414aade3b94bc357be46828e198ad15 100644 GIT binary patch delta 1626 zcmX}rc~sO@6bJC{eZLugZx$3J69yDq@SG?dKv6~*6wN~=3hDtP@xX|rhtxO(dX9H9B`eLIMDcEF0KkC?Qg$bLi_z7EV*otj7G~j1r*lr9vBz79}E*o~^7bDuE zW3Lshu}@;Z#IF*?#@25(9Kb;v4&ktlBN9g?8YPZN%r|z+k4v18I4N;T;hmWA+UuD2V} zi)yafMbFehbBPKI>gX_y_LO)CZPE%o6Ftsxo(W@|>7xn@@=Fqx+iy2ruGHK6>3FW= zg-XyH=&pLAH$=R&;}tOVCI%7S1FEI)0fol8$f9K!PW2c;-@`-8k#G!q*%bmsN#t)b?&}^+k+T-Ez5AKj-S$gM1%{V4@=k zqoatVM$UE&Npu{kbOJfl#92;Z5}oEuO;|@4R76a?R)yK>v)~Y_Rux?w+CtQLD`Fxk z`wC-M`EsxE<=)`Sy$KiH;?i&PW!^yv-NiJzhgsB&db*EQ^b~vP0rt^D9H2*Nq{leU zYt7W+yYy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z)|<7yti`j|kG1}+4Pb2$YXezJV9mo?B5Q+KOJOaG)~UVjQ_(N8kqV0#hEOpaks=K) z@d^^e2n-P;FJd(SH->&Z$V%i+HmUHW7=1GcRoJ3NCS8jDfah4ib1dXJN_dV%JjaK8 glf`&dEW?{(38o5Odaf(Pr)pyIIQ>iBCxPmJ02Hfv?EnA( diff --git a/build/web/WEB-INF/classes/controller/BddController$1.class b/build/web/WEB-INF/classes/controller/BddController$1.class index 441f65287e9f3589d429f303b810958c589a5299..ec2208031f3bfe41de3ab8d90447adc0721a0031 100644 GIT binary patch delta 21 ccmdnPwuf!QYbMSB22O@R1|f!^$zPZ}07xwc3IG5A delta 21 ccmdnPwuf!QYbH)V22KWl1|f!k$zPZ}07v%*1ONa4 diff --git a/build/web/WEB-INF/classes/controller/BddController.class b/build/web/WEB-INF/classes/controller/BddController.class index aa8baa3b1e32d546576d94d6021aae3ea85282bf..cfea4f5df6ec0ad9157b24c4838ed3d637c98271 100644 GIT binary patch delta 5457 zcmZ`-34B!5)&KwBBzZTJ7m~azWI_T-*b*iX5J(}RA|#+Fn^K^00f%G)q1j9(2viyC zE}OupMZ^jf#UfNK6;P~-OWmK2yC{qtUFSFRiWVXT;+*Prg!c$sou4101<$F=Y z?utG1+*7faVsFI)#X`kCCjDL%(4&VU#l9x{DSV{xslr}`&lEmU_}R;1_SYN(6uwY6 ztnj765rv})UnzX8@Qva*CI@;EK9_?u<6wpF6uwvZLE*T<35B0bmUwZ#yZkGK-I{HP z$)R41z_IQGZChFm0h1WFY62(a-f8)h$*YC**oWiLlf2&xj*Duw~muceVidQJ? z()cvR>55k>1{4k|&QPq<Ah{3K-@rO{mqwY(4x=4|R(53i}lHD;!YxT;Y(( z2JKm+7mL{B%~egFd6n@6|Xb- z2QOChdadUMrFf&sn@rxkxxZ0oeW zC=imh*rr*H4KjOb0&@im)(2|qh=i)VhqLBa!T~w}xu#iZ!JyQm^uR#56mLG1Y-k zfUrA=oG@c{uqsq$a#3VkY>%lM@UV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(To<+OeN#xLSBnMv>jpRs7UIhyO2fyt8T8exB~yl&4s2o}n% z_@iiU@jM6zb49fzKwtbxH1#w3zYwMW58ap1$#Xn9N(P4|&o?B`H-#K;Nsey|Io=Wa zzlW1}Uw&AA!1nl%9q|!+<6{=eZ=Yc}B3I$4T!qg#6`!*bUvL(_RPXbvRFA(Y>FMbi9Zw2bTJ!$JNNoTIO4S}IYh|B;{m=zz%MT#i zg|P)`3mj!|VnN#60|<+4a8g0qyok|Vkk%N{tb(-p5lt1OT_4es_aZemX-20fkzckS zz0Z3bE1GdrW@17!Dl?NZ-I-RV%1my?%}=6pS=z$=$Vgk5wz3(Sk4ic&81|iy6p>#e zDU9O+`8U$i6Vl9Y1@`ZxfhVPN-(wU`VG2&meLUm9Srw@#1}9d=;1n$ir`+2ZMFMe( zTo<{9 diff --git a/build/web/WEB-INF/classes/jsp/achats.jsp b/build/web/WEB-INF/classes/jsp/achats.jsp index db51dc1..f285c3c 100644 --- a/build/web/WEB-INF/classes/jsp/achats.jsp +++ b/build/web/WEB-INF/classes/jsp/achats.jsp @@ -10,7 +10,7 @@ <%@include file="header.jsp" %> -

Achats du client n°<%=request.getParameter("numero")%>

+

Achats du client n°<%=request.getParameter("customerId")%>

diff --git a/build/web/WEB-INF/classes/jsp/detail.jsp b/build/web/WEB-INF/classes/jsp/detail.jsp index eb6d795..45b555f 100644 --- a/build/web/WEB-INF/classes/jsp/detail.jsp +++ b/build/web/WEB-INF/classes/jsp/detail.jsp @@ -13,24 +13,48 @@

- +

- - + +

- - + +

- - + + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

- +

@@ -41,12 +65,8 @@

- - + +

diff --git a/build/web/WEB-INF/jsp/detail.jsp b/build/web/WEB-INF/jsp/detail.jsp index eb6d795..d5734c5 100644 --- a/build/web/WEB-INF/jsp/detail.jsp +++ b/build/web/WEB-INF/jsp/detail.jsp @@ -13,24 +13,48 @@

- +

- - + +

- - + +

- - + + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

- +

@@ -41,12 +65,8 @@

- - + +

@@ -83,8 +103,11 @@

- - checked id="available" /> + + + checked id="isavailable" /> + + checked id="notavailable" />

diff --git a/src/java/DAO/MagasinHelper.java b/src/java/DAO/MagasinHelper.java index 0c53b72..4518d86 100644 --- a/src/java/DAO/MagasinHelper.java +++ b/src/java/DAO/MagasinHelper.java @@ -407,6 +407,28 @@ public void insertCustomer (int _customerId, char _discountCode, String _zip) { } +public void update (Object data) { + + Transaction tx=null; + try{ + if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession(); + session.flush(); + + tx=session.beginTransaction(); + session.update(data); + tx.commit(); + } + catch (Exception e) { + e.printStackTrace(); + tx.rollback(); + throw e; + } + finally{ + if (session.isOpen())session.close(); + } + +} + public void updateCustomer (int _customerId,char _discountCode, String _name, String _adress, String _phone,String _email, String _zip){ Transaction tx=null; diff --git a/src/java/controller/BddController.java b/src/java/controller/BddController.java index 1da7ab9..b07c4b6 100644 --- a/src/java/controller/BddController.java +++ b/src/java/controller/BddController.java @@ -5,6 +5,8 @@ */ package controller; import DAO.*; +import java.math.BigDecimal; +import java.text.SimpleDateFormat; import service.User; import java.util.*; import javax.servlet.http.HttpServletRequest; @@ -203,8 +205,8 @@ public class BddController extends MultiActionController { 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, HttpServletResponse response) throws Exception { sessionInit(request); @@ -241,17 +243,71 @@ public class BddController extends MultiActionController { public ModelAndView update(HttpServletRequest request, HttpServletResponse response) throws Exception { sessionInit(request); - String param1 = request.getParameter("numero"); - String param2 = request.getParameter("code_remise"); - String param3 = request.getParameter("nom"); - String param4 = request.getParameter("adresse"); - String param5 = request.getParameter("telephone"); - String param6 = request.getParameter("email"); - String param7 = request.getParameter("CP"); - System.out.println(request.getParameter("CP")); - - new MagasinHelper().updateCustomer(Integer.valueOf(param1),param2.charAt(0),param3,param4,param5,param6,param7); - return new ModelAndView("confirm").addObject("confirm","mise à jour effectuée"); + 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) { + case "customer": + int customerId = Integer.parseInt(request.getParameter("customerId")); + char discountCode = request.getParameter("discountCode").charAt(0); + String zip = request.getParameter("zip"); + String name = request.getParameter("name"); + String addressline1 = request.getParameter("addressline1"); + String addressline2 = request.getParameter("addressline2"); + String city = request.getParameter("city"); + String state = request.getParameter("state"); + String phone = request.getParameter("phone"); + String fax = request.getParameter("fax"); + String email = request.getParameter("email"); + int creditLimit = Integer.parseInt(request.getParameter("creditLimit")); + data = new Customer(customerId, discountCode, zip, name, addressline1, addressline2, city, state, phone, fax, email, creditLimit); + break; + case "product": + int productId = Integer.parseInt(request.getParameter("productId")); + int manufacturerId = Integer.parseInt(request.getParameter("manufacturerId")); + String productCode = request.getParameter("productCode"); + BigDecimal purchaseCost = BigDecimal.valueOf(Double.parseDouble(request.getParameter("purchaseCost"))); + int quantityOnHand = Integer.parseInt(request.getParameter("quantityOnHand")); + BigDecimal markup = BigDecimal.valueOf(Double.parseDouble(request.getParameter("markup"))); + String available = request.getParameter("available"); + String description = request.getParameter("description"); + data = new Product(productId, manufacturerId, productCode, purchaseCost, quantityOnHand, markup, available, description); + break; + case "purchase": + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + + int orderNum = Integer.parseInt(request.getParameter("orderNum")); + customerId = Integer.parseInt(request.getParameter("customerId")); + productId = Integer.parseInt(request.getParameter("productId")); + Short quantity = Short.parseShort(request.getParameter("quantity")); + BigDecimal shippingCost = BigDecimal.valueOf(Double.parseDouble(request.getParameter("shippingCost"))); + Date salesDate = format.parse(request.getParameter("salesDate")); + Date shippingDate = format.parse(request.getParameter("shippingDate")); + String freightCompany = request.getParameter("freightCompany"); + data = new PurchaseOrder(orderNum, customerId, productId, quantity, shippingCost, salesDate, shippingDate, freightCompany); + break; + case "discount": + discountCode = request.getParameter("discountCode").charAt(0); + BigDecimal rate = BigDecimal.valueOf(Double.parseDouble(request.getParameter("rate"))); + data = new DiscountCode(discountCode, rate); + break; + case "prodCode": + productCode = request.getParameter("prodCode"); + discountCode = request.getParameter("discountCode").charAt(0); + description = request.getParameter("description"); + data = new ProductCode(productCode, discountCode, description); + break; + default: + mv.addObject("error", "Type not found"); + return mv; + } + + new MagasinHelper().update(data); + mv.addObject("confirm","Update completed"); + return mv; } } diff --git a/web/WEB-INF/jsp/detail.jsp b/web/WEB-INF/jsp/detail.jsp index eb6d795..d5734c5 100644 --- a/web/WEB-INF/jsp/detail.jsp +++ b/web/WEB-INF/jsp/detail.jsp @@ -13,24 +13,48 @@

- +

- - + +

- - + +

- - + + +

+

+ + +

+

+ + +

+

+ + +

+

+ + +

+

+ +

- +

@@ -41,12 +65,8 @@

- - + +

@@ -83,8 +103,11 @@

- - checked id="available" /> + + + checked id="isavailable" /> + + checked id="notavailable" />