Add/fix update of datas
This commit is contained in:
parent
c5fcc072cc
commit
1b2d645bf2
9 changed files with 204 additions and 60 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -10,7 +10,7 @@
|
||||||
<%@include file="header.jsp" %>
|
<%@include file="header.jsp" %>
|
||||||
|
|
||||||
|
|
||||||
<H1>Achats du client n°<%=request.getParameter("numero")%></H1>
|
<H1>Achats du client n°<%=request.getParameter("customerId")%></H1>
|
||||||
<table border="1" cellpadding="10">
|
<table border="1" cellpadding="10">
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,24 +13,48 @@
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${type == 'customer'}">
|
<c:when test="${type == 'customer'}">
|
||||||
<p>
|
<p>
|
||||||
<label for="customerId">Numero</label>
|
<label for="customerId">ID</label>
|
||||||
<input type="text" name="customerId" value="${result.customerId}" size="30" id="customerId" />
|
<input type="text" name="customerId" value="${result.customerId}" size="30" id="customerId" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="nom">Nom</label>
|
<label for="name">Nom</label>
|
||||||
<input type="text" name="nom" value="${result.name}" size="30" id="nom" />
|
<input type="text" name="name" value="${result.name}" size="30" id="name" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="adresse">Adresse</label>
|
<label for="addressline1">Adresse</label>
|
||||||
<input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
|
<input type="text" name="addressline1" value="${result.addressline1}" size="30" id="addressline1" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="telephone">Téléphone</label>
|
<label for="addressline2">Adresse 2</label>
|
||||||
<input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
|
<input type="text" name="addressline2" value="${result.addressline2}" size="30" id="addressline2" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="city">City</label>
|
||||||
|
<input type="text" name="city" value="${result.city}" size="25" id="city" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="zip">Code Postal</label>
|
||||||
|
<select name="zip" id="zip">
|
||||||
|
<c:forEach items="${cpostaux}" var="cp">
|
||||||
|
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
||||||
|
</c:forEach>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="state">State</label>
|
||||||
|
<input type="text" name="state" value="${result.state}" size="2" id="state" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="phone">Phone</label>
|
||||||
|
<input type="text" name="phone" value="${result.phone}" size="12" id="phone" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="fax">Fax</label>
|
||||||
|
<input type="text" name="fax" value="${result.fax}" size="12" id="fax" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="email">E-mail</label>
|
<label for="email">E-mail</label>
|
||||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
<input type="text" name="email" value="${result.email}" size="40" id="email"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="discountCode">Remise</label>
|
<label for="discountCode">Remise</label>
|
||||||
|
@ -41,12 +65,8 @@
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="cp">Code Postal</label>
|
<label for="creditLimit">Credit limit</label>
|
||||||
<select name="CP" id="cp">
|
<input type="number" name="creditLimit" value="${result.creditLimit}" id="creditLimit"/>
|
||||||
<c:forEach items="${cpostaux}" var="cp">
|
|
||||||
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
|
||||||
</c:forEach>
|
|
||||||
</select>
|
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:when test="${type == 'product'}">
|
<c:when test="${type == 'product'}">
|
||||||
|
|
|
@ -13,24 +13,48 @@
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${type == 'customer'}">
|
<c:when test="${type == 'customer'}">
|
||||||
<p>
|
<p>
|
||||||
<label for="customerId">Numero</label>
|
<label for="customerId">ID</label>
|
||||||
<input type="text" name="customerId" value="${result.customerId}" size="30" id="customerId" />
|
<input type="text" name="customerId" value="${result.customerId}" size="30" id="customerId" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="nom">Nom</label>
|
<label for="name">Nom</label>
|
||||||
<input type="text" name="nom" value="${result.name}" size="30" id="nom" />
|
<input type="text" name="name" value="${result.name}" size="30" id="name" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="adresse">Adresse</label>
|
<label for="addressline1">Adresse</label>
|
||||||
<input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
|
<input type="text" name="addressline1" value="${result.addressline1}" size="30" id="addressline1" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="telephone">Téléphone</label>
|
<label for="addressline2">Adresse 2</label>
|
||||||
<input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
|
<input type="text" name="addressline2" value="${result.addressline2}" size="30" id="addressline2" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="city">City</label>
|
||||||
|
<input type="text" name="city" value="${result.city}" size="25" id="city" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="zip">Code Postal</label>
|
||||||
|
<select name="zip" id="zip">
|
||||||
|
<c:forEach items="${cpostaux}" var="cp">
|
||||||
|
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
||||||
|
</c:forEach>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="state">State</label>
|
||||||
|
<input type="text" name="state" value="${result.state}" size="2" id="state" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="phone">Phone</label>
|
||||||
|
<input type="text" name="phone" value="${result.phone}" size="12" id="phone" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="fax">Fax</label>
|
||||||
|
<input type="text" name="fax" value="${result.fax}" size="12" id="fax" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="email">E-mail</label>
|
<label for="email">E-mail</label>
|
||||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
<input type="text" name="email" value="${result.email}" size="40" id="email"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="discountCode">Remise</label>
|
<label for="discountCode">Remise</label>
|
||||||
|
@ -41,12 +65,8 @@
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="cp">Code Postal</label>
|
<label for="creditLimit">Credit limit</label>
|
||||||
<select name="CP" id="cp">
|
<input type="number" name="creditLimit" value="${result.creditLimit}" id="creditLimit"/>
|
||||||
<c:forEach items="${cpostaux}" var="cp">
|
|
||||||
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
|
||||||
</c:forEach>
|
|
||||||
</select>
|
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:when test="${type == 'product'}">
|
<c:when test="${type == 'product'}">
|
||||||
|
@ -83,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>
|
||||||
|
|
|
@ -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){
|
public void updateCustomer (int _customerId,char _discountCode, String _name, String _adress, String _phone,String _email, String _zip){
|
||||||
|
|
||||||
Transaction tx=null;
|
Transaction tx=null;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
*/
|
*/
|
||||||
package controller;
|
package controller;
|
||||||
import DAO.*;
|
import DAO.*;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import service.User;
|
import service.User;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
@ -241,17 +243,71 @@ 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);
|
sessionInit(request);
|
||||||
String param1 = request.getParameter("numero");
|
String type = request.getParameter("type");
|
||||||
String param2 = request.getParameter("code_remise");
|
ModelAndView mv = new ModelAndView("confirm");
|
||||||
String param3 = request.getParameter("nom");
|
mv.addObject("user",session.getAttribute("user"));
|
||||||
String param4 = request.getParameter("adresse");
|
mv.addObject("type", type);
|
||||||
String param5 = request.getParameter("telephone");
|
Object data = null;
|
||||||
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);
|
switch (type) {
|
||||||
return new ModelAndView("confirm").addObject("confirm","mise à jour effectuée");
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,24 +13,48 @@
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${type == 'customer'}">
|
<c:when test="${type == 'customer'}">
|
||||||
<p>
|
<p>
|
||||||
<label for="customerId">Numero</label>
|
<label for="customerId">ID</label>
|
||||||
<input type="text" name="customerId" value="${result.customerId}" size="30" id="customerId" />
|
<input type="text" name="customerId" value="${result.customerId}" size="30" id="customerId" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="nom">Nom</label>
|
<label for="name">Nom</label>
|
||||||
<input type="text" name="nom" value="${result.name}" size="30" id="nom" />
|
<input type="text" name="name" value="${result.name}" size="30" id="name" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="adresse">Adresse</label>
|
<label for="addressline1">Adresse</label>
|
||||||
<input type="text" name="adresse" value="${result.addressline1}" size="30" id="adresse" />
|
<input type="text" name="addressline1" value="${result.addressline1}" size="30" id="addressline1" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="telephone">Téléphone</label>
|
<label for="addressline2">Adresse 2</label>
|
||||||
<input type="text" name="telephone" value="${result.phone}" size="30" id="tel" />
|
<input type="text" name="addressline2" value="${result.addressline2}" size="30" id="addressline2" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="city">City</label>
|
||||||
|
<input type="text" name="city" value="${result.city}" size="25" id="city" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="zip">Code Postal</label>
|
||||||
|
<select name="zip" id="zip">
|
||||||
|
<c:forEach items="${cpostaux}" var="cp">
|
||||||
|
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
||||||
|
</c:forEach>
|
||||||
|
</select>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="state">State</label>
|
||||||
|
<input type="text" name="state" value="${result.state}" size="2" id="state" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="phone">Phone</label>
|
||||||
|
<input type="text" name="phone" value="${result.phone}" size="12" id="phone" />
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label for="fax">Fax</label>
|
||||||
|
<input type="text" name="fax" value="${result.fax}" size="12" id="fax" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="email">E-mail</label>
|
<label for="email">E-mail</label>
|
||||||
<input type="text" name="email" value="${result.email}" size="30" id="email"/>
|
<input type="text" name="email" value="${result.email}" size="40" id="email"/>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="discountCode">Remise</label>
|
<label for="discountCode">Remise</label>
|
||||||
|
@ -41,12 +65,8 @@
|
||||||
</select>
|
</select>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="cp">Code Postal</label>
|
<label for="creditLimit">Credit limit</label>
|
||||||
<select name="CP" id="cp">
|
<input type="number" name="creditLimit" value="${result.creditLimit}" id="creditLimit"/>
|
||||||
<c:forEach items="${cpostaux}" var="cp">
|
|
||||||
<option <c:if test="${cp==result.zip}"> selected </c:if>>${cp}</option>
|
|
||||||
</c:forEach>
|
|
||||||
</select>
|
|
||||||
</p>
|
</p>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:when test="${type == 'product'}">
|
<c:when test="${type == 'product'}">
|
||||||
|
@ -83,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>
|
||||||
|
|
Reference in a new issue