Formatting and logout fix
This commit is contained in:
parent
cfeb8d56ab
commit
9f582d6e80
58 changed files with 1479 additions and 1469 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,18 +0,0 @@
|
|||
<%--
|
||||
Document : error
|
||||
Created on : 4 mars 2018, 20:54:56
|
||||
Author : faycal
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Erreur</title>
|
||||
</head>
|
||||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
<h1>${erreur} </h1>
|
||||
</body>
|
||||
</html>
|
|
@ -1,14 +1,11 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Customer generated by hbm2java
|
||||
*/
|
||||
public class Customer implements java.io.Serializable {
|
||||
|
||||
|
||||
private int customerId;
|
||||
private char discountCode;
|
||||
private String zip;
|
||||
|
@ -25,12 +22,12 @@ public class Customer implements java.io.Serializable {
|
|||
public Customer() {
|
||||
}
|
||||
|
||||
|
||||
public Customer(int customerId, char discountCode, String zip) {
|
||||
this.customerId = customerId;
|
||||
this.discountCode = discountCode;
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public Customer(int customerId, char discountCode, String _name, String _adress, String _phone, String _email, String _zip) {
|
||||
this.customerId = customerId;
|
||||
this.discountCode = discountCode;
|
||||
|
@ -63,6 +60,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setCustomerId(int customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public char getDiscountCode() {
|
||||
return this.discountCode;
|
||||
}
|
||||
|
@ -70,6 +68,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setDiscountCode(char discountCode) {
|
||||
this.discountCode = discountCode;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return this.zip;
|
||||
}
|
||||
|
@ -77,6 +76,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
@ -84,6 +84,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddressline1() {
|
||||
return this.addressline1;
|
||||
}
|
||||
|
@ -91,6 +92,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setAddressline1(String addressline1) {
|
||||
this.addressline1 = addressline1;
|
||||
}
|
||||
|
||||
public String getAddressline2() {
|
||||
return this.addressline2;
|
||||
}
|
||||
|
@ -98,6 +100,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setAddressline2(String addressline2) {
|
||||
this.addressline2 = addressline2;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
@ -105,6 +108,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
@ -112,6 +116,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return this.phone;
|
||||
}
|
||||
|
@ -119,6 +124,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getFax() {
|
||||
return this.fax;
|
||||
}
|
||||
|
@ -126,6 +132,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setFax(String fax) {
|
||||
this.fax = fax;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
@ -133,6 +140,7 @@ public class Customer implements java.io.Serializable {
|
|||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Integer getCreditLimit() {
|
||||
return this.creditLimit;
|
||||
}
|
||||
|
@ -141,9 +149,4 @@ public class Customer implements java.io.Serializable {
|
|||
this.creditLimit = creditLimit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
@ -9,17 +8,16 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public class DiscountCode implements java.io.Serializable {
|
||||
|
||||
|
||||
private char discountCode;
|
||||
private BigDecimal rate;
|
||||
|
||||
public DiscountCode() {
|
||||
}
|
||||
|
||||
|
||||
public DiscountCode(char discountCode) {
|
||||
this.discountCode = discountCode;
|
||||
}
|
||||
|
||||
public DiscountCode(char discountCode, BigDecimal rate) {
|
||||
this.discountCode = discountCode;
|
||||
this.rate = rate;
|
||||
|
@ -32,6 +30,7 @@ public class DiscountCode implements java.io.Serializable {
|
|||
public void setDiscountCode(char discountCode) {
|
||||
this.discountCode = discountCode;
|
||||
}
|
||||
|
||||
public BigDecimal getRate() {
|
||||
return this.rate;
|
||||
}
|
||||
|
@ -40,9 +39,4 @@ public class DiscountCode implements java.io.Serializable {
|
|||
this.rate = rate;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ package DAO;
|
|||
import org.hibernate.cfg.AnnotationConfiguration;
|
||||
import org.hibernate.SessionFactory;
|
||||
|
||||
|
||||
/**
|
||||
* Hibernate Utility class with a convenient method to get Session Factory
|
||||
* object.
|
||||
|
@ -25,7 +24,6 @@ public class HibernateUtil {
|
|||
// config file.
|
||||
sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
|
||||
|
||||
|
||||
} catch (Throwable ex) {
|
||||
// Log the exception.
|
||||
System.err.println("Initial SessionFactory creation failed." + ex);
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* and open the template in the editor.
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
import org.hibernate.*;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import java.util.*;
|
||||
|
@ -15,6 +16,7 @@ import org.hibernate.exception.ConstraintViolationException;
|
|||
* @author faycal
|
||||
*/
|
||||
public class MagasinHelper {
|
||||
|
||||
Session session = null;
|
||||
|
||||
public List<String> getColonnes() {
|
||||
|
@ -30,18 +32,21 @@ public class MagasinHelper {
|
|||
List<Product> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("select p.productId, p.manufacturerId, p.productCode, p.purchaseCost, p.quantityOnHand, p.markup, p.available, p.description from Product p");
|
||||
resultat = q.list();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen())session.close();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -51,18 +56,21 @@ public class MagasinHelper {
|
|||
List<Product> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("from Product p");
|
||||
resultat = q.list();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen())session.close();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -72,7 +80,9 @@ public class MagasinHelper {
|
|||
Product resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -80,11 +90,12 @@ public class MagasinHelper {
|
|||
q.setInteger("_id", id);
|
||||
resultat = (Product) q.list().iterator().next();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen())session.close();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -94,7 +105,9 @@ public class MagasinHelper {
|
|||
List<Customer> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -102,13 +115,12 @@ public class MagasinHelper {
|
|||
//Query q=session.createQuery("from Customer");
|
||||
resultat = q.list();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -118,20 +130,21 @@ public class MagasinHelper {
|
|||
List<Customer> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("from Customer c");
|
||||
resultat = q.list();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -141,7 +154,9 @@ public class MagasinHelper {
|
|||
List resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -149,12 +164,12 @@ public class MagasinHelper {
|
|||
//Query q=session.createQuery("from Customer");
|
||||
q.setString("_name", name);
|
||||
resultat = q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -164,19 +179,21 @@ public class MagasinHelper {
|
|||
List resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("select a.customerId, a.name, a.addressline1,a.addressline2,a.zip from Customer a where a.customerId = :_id");
|
||||
q.setInteger("_id", _id);
|
||||
resultat = q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -186,18 +203,21 @@ public class MagasinHelper {
|
|||
List<Manufacturer> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("from Manufacturer m");
|
||||
resultat = q.list();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen())session.close();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -207,18 +227,21 @@ public class MagasinHelper {
|
|||
List<ProductCode> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
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();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -228,18 +251,21 @@ public class MagasinHelper {
|
|||
List<ProductCode> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("from ProductCode p");
|
||||
resultat = q.list();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen())session.close();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -249,7 +275,9 @@ public class MagasinHelper {
|
|||
ProductCode resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -257,11 +285,12 @@ public class MagasinHelper {
|
|||
q.setString("_id", id);
|
||||
resultat = (ProductCode) q.list().iterator().next();
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen())session.close();
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -271,76 +300,76 @@ public List getDiscountCodesColums(){
|
|||
List resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("select dc.discountCode, dc.rate from DiscountCode dc");
|
||||
resultat = q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List getDiscountCodes() {
|
||||
List resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())
|
||||
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) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public DiscountCode getDiscountCode(char c) {
|
||||
DiscountCode resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())
|
||||
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) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public List getMicroMarket() {
|
||||
|
@ -354,16 +383,17 @@ List <MicroMarket> resultat=null;
|
|||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("from MicroMarket");
|
||||
resultat = q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public List getZipCode() {
|
||||
List resultat = null;
|
||||
Transaction tx = null;
|
||||
|
@ -375,20 +405,23 @@ List resultat=null;
|
|||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("select a.zipCode from MicroMarket a");
|
||||
resultat = q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
|
||||
}
|
||||
return resultat;
|
||||
}
|
||||
|
||||
public void add(Object data) {
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -398,9 +431,10 @@ public void add (Object data) {
|
|||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -409,42 +443,45 @@ public void update (Object data) {
|
|||
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
session.update(data);
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Customer getClient(int id) {
|
||||
|
||||
|
||||
Customer client = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(" from Customer a where a.customerId =:_id");
|
||||
q.setInteger("_id", id);
|
||||
client = (Customer) q.list().iterator().next();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return client;
|
||||
|
@ -454,26 +491,29 @@ public void deleteCustomer (int _id) {
|
|||
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(" from PurchaseOrder po where po.customerId =:_id");
|
||||
q.setInteger("_id", _id);
|
||||
for (Object po : q.list())
|
||||
for (Object po : q.list()) {
|
||||
session.delete((PurchaseOrder) po);
|
||||
}
|
||||
q = session.createQuery(" from Customer a where a.customerId =:_id");
|
||||
q.setInteger("_id", _id);
|
||||
session.delete((Customer) q.list().iterator().next());
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -482,7 +522,9 @@ public void deleteProduct (int _id) {
|
|||
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -490,14 +532,14 @@ public void deleteProduct (int _id) {
|
|||
q.setInteger("_id", _id);
|
||||
session.delete((Product) q.list().iterator().next());
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -506,7 +548,9 @@ public void deletePurchase(int _id) {
|
|||
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -514,14 +558,14 @@ public void deletePurchase(int _id) {
|
|||
q.setInteger("_id", _id);
|
||||
session.delete((PurchaseOrder) q.list().iterator().next());
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -530,7 +574,9 @@ public void deleteDiscountCode (char _id) {
|
|||
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -538,14 +584,14 @@ public void deleteDiscountCode (char _id) {
|
|||
q.setCharacter("_id", _id);
|
||||
session.delete((DiscountCode) q.list().iterator().next());
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -554,7 +600,9 @@ public void deleteProductCode(String _id) {
|
|||
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
|
@ -562,14 +610,14 @@ public void deleteProductCode(String _id) {
|
|||
q.setString("_id", _id);
|
||||
session.delete((ProductCode) q.list().iterator().next());
|
||||
tx.commit();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
tx.rollback();
|
||||
throw e;
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -578,18 +626,20 @@ public void deleteProductCode(String _id) {
|
|||
List resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("select po.orderNum, 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) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -599,19 +649,21 @@ public void deleteProductCode(String _id) {
|
|||
PurchaseOrder resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(" from PurchaseOrder p where p.orderNum = :_id");
|
||||
q.setInteger("_id", id);
|
||||
resultat = (PurchaseOrder) q.list().iterator().next();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -621,19 +673,21 @@ public void deleteProductCode(String _id) {
|
|||
List<PurchaseOrder> resultat = null;
|
||||
Transaction tx = null;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery(" from PurchaseOrder po where po.customerId = :_id");
|
||||
q.setInteger("_id", id);
|
||||
resultat = q.list();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
@ -643,19 +697,21 @@ public int getMaxId(){
|
|||
Transaction tx = null;
|
||||
int resultat = -1;
|
||||
try {
|
||||
if(!session.isOpen())session=HibernateUtil.getSessionFactory().openSession();
|
||||
if (!session.isOpen()) {
|
||||
session = HibernateUtil.getSessionFactory().openSession();
|
||||
}
|
||||
session.flush();
|
||||
|
||||
tx = session.beginTransaction();
|
||||
Query q = session.createQuery("select MAX(a.customerId) from Customer a");
|
||||
|
||||
resultat = (int) q.list().iterator().next();
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (session.isOpen()) {
|
||||
session.close();
|
||||
}
|
||||
finally{
|
||||
if (session.isOpen())session.close();
|
||||
}
|
||||
|
||||
return resultat;
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Manufacturer generated by hbm2java
|
||||
*/
|
||||
public class Manufacturer implements java.io.Serializable {
|
||||
|
||||
|
||||
private int manufacturerId;
|
||||
private String name;
|
||||
private String addressline1;
|
||||
|
@ -24,10 +21,10 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public Manufacturer() {
|
||||
}
|
||||
|
||||
|
||||
public Manufacturer(int manufacturerId) {
|
||||
this.manufacturerId = manufacturerId;
|
||||
}
|
||||
|
||||
public Manufacturer(int manufacturerId, String name, String addressline1, String addressline2, String city, String state, String zip, String phone, String fax, String email, String rep) {
|
||||
this.manufacturerId = manufacturerId;
|
||||
this.name = name;
|
||||
|
@ -49,6 +46,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setManufacturerId(int manufacturerId) {
|
||||
this.manufacturerId = manufacturerId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
@ -56,6 +54,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getAddressline1() {
|
||||
return this.addressline1;
|
||||
}
|
||||
|
@ -63,6 +62,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setAddressline1(String addressline1) {
|
||||
this.addressline1 = addressline1;
|
||||
}
|
||||
|
||||
public String getAddressline2() {
|
||||
return this.addressline2;
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setAddressline2(String addressline2) {
|
||||
this.addressline2 = addressline2;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
@ -77,6 +78,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
@ -84,6 +86,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return this.zip;
|
||||
}
|
||||
|
@ -91,6 +94,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return this.phone;
|
||||
}
|
||||
|
@ -98,6 +102,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getFax() {
|
||||
return this.fax;
|
||||
}
|
||||
|
@ -105,6 +110,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setFax(String fax) {
|
||||
this.fax = fax;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
@ -112,6 +118,7 @@ public class Manufacturer implements java.io.Serializable {
|
|||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getRep() {
|
||||
return this.rep;
|
||||
}
|
||||
|
@ -120,9 +127,4 @@ public class Manufacturer implements java.io.Serializable {
|
|||
this.rep = rep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* MicroMarket generated by hbm2java
|
||||
*/
|
||||
public class MicroMarket implements java.io.Serializable {
|
||||
|
||||
|
||||
private String zipCode;
|
||||
private Double radius;
|
||||
private Double areaLength;
|
||||
|
@ -17,10 +14,10 @@ public class MicroMarket implements java.io.Serializable {
|
|||
public MicroMarket() {
|
||||
}
|
||||
|
||||
|
||||
public MicroMarket(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public MicroMarket(String zipCode, Double radius, Double areaLength, Double areaWidth) {
|
||||
this.zipCode = zipCode;
|
||||
this.radius = radius;
|
||||
|
@ -35,6 +32,7 @@ public class MicroMarket implements java.io.Serializable {
|
|||
public void setZipCode(String zipCode) {
|
||||
this.zipCode = zipCode;
|
||||
}
|
||||
|
||||
public Double getRadius() {
|
||||
return this.radius;
|
||||
}
|
||||
|
@ -42,6 +40,7 @@ public class MicroMarket implements java.io.Serializable {
|
|||
public void setRadius(Double radius) {
|
||||
this.radius = radius;
|
||||
}
|
||||
|
||||
public Double getAreaLength() {
|
||||
return this.areaLength;
|
||||
}
|
||||
|
@ -49,6 +48,7 @@ public class MicroMarket implements java.io.Serializable {
|
|||
public void setAreaLength(Double areaLength) {
|
||||
this.areaLength = areaLength;
|
||||
}
|
||||
|
||||
public Double getAreaWidth() {
|
||||
return this.areaWidth;
|
||||
}
|
||||
|
@ -57,9 +57,4 @@ public class MicroMarket implements java.io.Serializable {
|
|||
this.areaWidth = areaWidth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
|
@ -9,7 +8,6 @@ import java.math.BigDecimal;
|
|||
*/
|
||||
public class Product implements java.io.Serializable {
|
||||
|
||||
|
||||
private int productId;
|
||||
private int manufacturerId;
|
||||
private String productCode;
|
||||
|
@ -22,12 +20,12 @@ public class Product implements java.io.Serializable {
|
|||
public Product() {
|
||||
}
|
||||
|
||||
|
||||
public Product(int productId, int manufacturerId, String productCode) {
|
||||
this.productId = productId;
|
||||
this.manufacturerId = manufacturerId;
|
||||
this.productCode = productCode;
|
||||
}
|
||||
|
||||
public Product(int productId, int manufacturerId, String productCode, BigDecimal purchaseCost, Integer quantityOnHand, BigDecimal markup, String available, String description) {
|
||||
this.productId = productId;
|
||||
this.manufacturerId = manufacturerId;
|
||||
|
@ -46,6 +44,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setProductId(int productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public int getManufacturerId() {
|
||||
return this.manufacturerId;
|
||||
}
|
||||
|
@ -53,6 +52,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setManufacturerId(int manufacturerId) {
|
||||
this.manufacturerId = manufacturerId;
|
||||
}
|
||||
|
||||
public String getProductCode() {
|
||||
return this.productCode;
|
||||
}
|
||||
|
@ -60,6 +60,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setProductCode(String productCode) {
|
||||
this.productCode = productCode;
|
||||
}
|
||||
|
||||
public BigDecimal getPurchaseCost() {
|
||||
return this.purchaseCost;
|
||||
}
|
||||
|
@ -67,6 +68,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setPurchaseCost(BigDecimal purchaseCost) {
|
||||
this.purchaseCost = purchaseCost;
|
||||
}
|
||||
|
||||
public Integer getQuantityOnHand() {
|
||||
return this.quantityOnHand;
|
||||
}
|
||||
|
@ -74,6 +76,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setQuantityOnHand(Integer quantityOnHand) {
|
||||
this.quantityOnHand = quantityOnHand;
|
||||
}
|
||||
|
||||
public BigDecimal getMarkup() {
|
||||
return this.markup;
|
||||
}
|
||||
|
@ -81,6 +84,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setMarkup(BigDecimal markup) {
|
||||
this.markup = markup;
|
||||
}
|
||||
|
||||
public String getAvailable() {
|
||||
return this.available;
|
||||
}
|
||||
|
@ -88,6 +92,7 @@ public class Product implements java.io.Serializable {
|
|||
public void setAvailable(String available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
@ -96,9 +101,4 @@ public class Product implements java.io.Serializable {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ProductCode generated by hbm2java
|
||||
*/
|
||||
public class ProductCode implements java.io.Serializable {
|
||||
|
||||
|
||||
private String prodCode;
|
||||
private char discountCode;
|
||||
private String description;
|
||||
|
@ -16,11 +13,11 @@ public class ProductCode implements java.io.Serializable {
|
|||
public ProductCode() {
|
||||
}
|
||||
|
||||
|
||||
public ProductCode(String prodCode, char discountCode) {
|
||||
this.prodCode = prodCode;
|
||||
this.discountCode = discountCode;
|
||||
}
|
||||
|
||||
public ProductCode(String prodCode, char discountCode, String description) {
|
||||
this.prodCode = prodCode;
|
||||
this.discountCode = discountCode;
|
||||
|
@ -34,6 +31,7 @@ public class ProductCode implements java.io.Serializable {
|
|||
public void setProdCode(String prodCode) {
|
||||
this.prodCode = prodCode;
|
||||
}
|
||||
|
||||
public char getDiscountCode() {
|
||||
return this.discountCode;
|
||||
}
|
||||
|
@ -41,6 +39,7 @@ public class ProductCode implements java.io.Serializable {
|
|||
public void setDiscountCode(char discountCode) {
|
||||
this.discountCode = discountCode;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
@ -49,9 +48,4 @@ public class ProductCode implements java.io.Serializable {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package DAO;
|
||||
// Generated 8 avr. 2022 15:30:27 by Hibernate Tools 4.3.1
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -10,7 +9,6 @@ import java.util.Date;
|
|||
*/
|
||||
public class PurchaseOrder implements java.io.Serializable {
|
||||
|
||||
|
||||
private int orderNum;
|
||||
private int customerId;
|
||||
private int productId;
|
||||
|
@ -23,12 +21,12 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public PurchaseOrder() {
|
||||
}
|
||||
|
||||
|
||||
public PurchaseOrder(int orderNum, int customerId, int productId) {
|
||||
this.orderNum = orderNum;
|
||||
this.customerId = customerId;
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public PurchaseOrder(int orderNum, int customerId, int productId, Short quantity, BigDecimal shippingCost, Date salesDate, Date shippingDate, String freightCompany) {
|
||||
this.orderNum = orderNum;
|
||||
this.customerId = customerId;
|
||||
|
@ -47,6 +45,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setOrderNum(int orderNum) {
|
||||
this.orderNum = orderNum;
|
||||
}
|
||||
|
||||
public int getCustomerId() {
|
||||
return this.customerId;
|
||||
}
|
||||
|
@ -54,6 +53,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setCustomerId(int customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
public int getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setProductId(int productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public Short getQuantity() {
|
||||
return this.quantity;
|
||||
}
|
||||
|
@ -68,6 +69,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setQuantity(Short quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public BigDecimal getShippingCost() {
|
||||
return this.shippingCost;
|
||||
}
|
||||
|
@ -75,6 +77,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setShippingCost(BigDecimal shippingCost) {
|
||||
this.shippingCost = shippingCost;
|
||||
}
|
||||
|
||||
public Date getSalesDate() {
|
||||
return this.salesDate;
|
||||
}
|
||||
|
@ -82,6 +85,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setSalesDate(Date salesDate) {
|
||||
this.salesDate = salesDate;
|
||||
}
|
||||
|
||||
public Date getShippingDate() {
|
||||
return this.shippingDate;
|
||||
}
|
||||
|
@ -89,6 +93,7 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
public void setShippingDate(Date shippingDate) {
|
||||
this.shippingDate = shippingDate;
|
||||
}
|
||||
|
||||
public String getFreightCompany() {
|
||||
return this.freightCompany;
|
||||
}
|
||||
|
@ -97,9 +102,4 @@ public class PurchaseOrder implements java.io.Serializable {
|
|||
this.freightCompany = freightCompany;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ package Exceptions;
|
|||
* @author flifloo
|
||||
*/
|
||||
public class InvalidParameter extends Exception {
|
||||
|
||||
public InvalidParameter(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* and open the template in the editor.
|
||||
*/
|
||||
package controller;
|
||||
|
||||
import DAO.*;
|
||||
import Exceptions.InvalidParameter;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -20,25 +21,27 @@ import javax.servlet.http.*;
|
|||
import javax.servlet.*;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author faycal
|
||||
*/
|
||||
public class BddController extends MultiActionController {
|
||||
|
||||
private String login;
|
||||
private String pwd;
|
||||
private User utilisateur;
|
||||
private HttpSession session;
|
||||
public BddController() {}
|
||||
|
||||
public BddController() {
|
||||
}
|
||||
|
||||
private void sessionInit(HttpServletRequest request) {
|
||||
if (login == null)
|
||||
if (login == null) {
|
||||
login = request.getUserPrincipal().getName();
|
||||
if (utilisateur == null)
|
||||
}
|
||||
if (utilisateur == null) {
|
||||
utilisateur = new User(login);
|
||||
}
|
||||
|
||||
if (session == null) {
|
||||
session = request.getSession();
|
||||
|
@ -53,13 +56,12 @@ public class BddController extends MultiActionController {
|
|||
return new ModelAndView("menu").addObject("user", utilisateur);
|
||||
|
||||
}
|
||||
|
||||
public ModelAndView logout(HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
sessionInit(request);
|
||||
request.getSession().invalidate();
|
||||
|
||||
|
||||
return new ModelAndView("deconnexion");
|
||||
return new ModelAndView("logout");
|
||||
|
||||
}
|
||||
|
||||
|
@ -79,17 +81,21 @@ public class BddController extends MultiActionController {
|
|||
case "product":
|
||||
mv.addObject("results", new MagasinHelper().getProductsColums());
|
||||
mv.addObject("colonnes", Arrays.asList("productId", "manufacturerId", "productCode", "purchaseCost", "quantityOnHand", "markup", "available", "description"));
|
||||
mv.addObject("relation", new HashMap<String, String>() {{
|
||||
mv.addObject("relation", new HashMap<String, String>() {
|
||||
{
|
||||
put("productCode", "prodCode");
|
||||
}});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "purchase":
|
||||
mv.addObject("results", new MagasinHelper().getPurchaseColums());
|
||||
mv.addObject("colonnes", Arrays.asList("orderNum", "customerId", "productId", "quantity", "shippingCost", "salesDate", "shippingDate", "freightCompany"));
|
||||
mv.addObject("relation", new HashMap<String, String>() {{
|
||||
mv.addObject("relation", new HashMap<String, String>() {
|
||||
{
|
||||
put("customerId", "customer");
|
||||
put("productId", "product");
|
||||
}});
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "discount":
|
||||
mv.addObject("results", new MagasinHelper().getDiscountCodesColums());
|
||||
|
@ -98,9 +104,11 @@ public class BddController extends MultiActionController {
|
|||
case "prodCode":
|
||||
mv.addObject("results", new MagasinHelper().getProductCodesColums());
|
||||
mv.addObject("colonnes", Arrays.asList("prodCode", "discountCode", "description"));
|
||||
mv.addObject("relation", new HashMap<String, String>() {{
|
||||
mv.addObject("relation", new HashMap<String, String>() {
|
||||
{
|
||||
put("discountCode", "discount");
|
||||
}});
|
||||
}
|
||||
});
|
||||
break;
|
||||
default:
|
||||
mv.addObject("error", "Type not found");
|
||||
|
@ -180,6 +188,7 @@ public class BddController extends MultiActionController {
|
|||
|
||||
return mv;
|
||||
}
|
||||
|
||||
public ModelAndView find(HttpServletRequest request,
|
||||
HttpServletResponse response) throws Exception {
|
||||
sessionInit(request);
|
||||
|
@ -189,9 +198,9 @@ public class BddController extends MultiActionController {
|
|||
mv.addObject("type", type);
|
||||
|
||||
String query = request.getParameter("query");
|
||||
if (query == null || query.isEmpty())
|
||||
if (query == null || query.isEmpty()) {
|
||||
mv.addObject("error", "No query");
|
||||
else {
|
||||
} else {
|
||||
List<Customer> customers = new ArrayList<Customer>();
|
||||
try {
|
||||
customers.addAll(new MagasinHelper().getClientsColums(Integer.parseInt(query)));
|
||||
|
@ -202,11 +211,12 @@ public class BddController extends MultiActionController {
|
|||
query = "%".concat(query.concat("%"));
|
||||
customers.addAll(new MagasinHelper().getClientsColums(query));
|
||||
|
||||
if (customers.size() == 0)
|
||||
if (customers.size() == 0) {
|
||||
mv.addObject("error", "No user found :/");
|
||||
else
|
||||
} else {
|
||||
mv.addObject("results", customers);
|
||||
}
|
||||
}
|
||||
MagasinHelper helper = new MagasinHelper();
|
||||
return mv;
|
||||
}
|
||||
|
@ -256,8 +266,9 @@ public class BddController extends MultiActionController {
|
|||
|
||||
private char paramChar(HttpServletRequest request, String name) throws InvalidParameter {
|
||||
String param = paramNotNull(request, name);
|
||||
if (param.length() > 1)
|
||||
if (param.length() > 1) {
|
||||
throw new InvalidParameter("Invalid ".concat(name));
|
||||
}
|
||||
return param.charAt(0);
|
||||
}
|
||||
|
||||
|
@ -285,8 +296,9 @@ public class BddController extends MultiActionController {
|
|||
throw new InvalidParameter("Invalid big int for ".concat(name));
|
||||
}
|
||||
|
||||
if (bc.precision() > precision)
|
||||
if (bc.precision() > precision) {
|
||||
throw new InvalidParameter("Precision for ".concat(name).concat(" shounld be over ".concat(String.valueOf(precision))));
|
||||
}
|
||||
return bc;
|
||||
}
|
||||
|
||||
|
@ -300,28 +312,32 @@ public class BddController extends MultiActionController {
|
|||
|
||||
private String paramNotNull(HttpServletRequest request, String name) throws InvalidParameter {
|
||||
String param = request.getParameter(name);
|
||||
if (param == null || param.isEmpty())
|
||||
if (param == null || param.isEmpty()) {
|
||||
throw new InvalidParameter(name.concat(" should not be empty"));
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
private String paramLength(HttpServletRequest request, String name, int length) throws InvalidParameter {
|
||||
String param = request.getParameter(name);
|
||||
if (param.length() > length)
|
||||
if (param.length() > length) {
|
||||
throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters")));
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
private String paramLength(String param, String name, int length) throws InvalidParameter {
|
||||
if (param.length() > length)
|
||||
if (param.length() > length) {
|
||||
throw new InvalidParameter(name.concat(" should not be more than ".concat(String.valueOf(length)).concat(" characters")));
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
private String paramAvailable(HttpServletRequest request, String name) throws InvalidParameter {
|
||||
String param = request.getParameter(name).toUpperCase();
|
||||
if (!param.equals("TRUE") && !param.equals("FALSE"))
|
||||
if (!param.equals("TRUE") && !param.equals("FALSE")) {
|
||||
throw new InvalidParameter("It's true or false for ".concat(name));
|
||||
}
|
||||
return param;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,15 @@
|
|||
* and open the template in the editor.
|
||||
*/
|
||||
package service;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author faycal
|
||||
*/
|
||||
public class User implements Serializable {
|
||||
|
||||
private String login;
|
||||
private String pwd;
|
||||
private int userId;
|
||||
|
@ -23,10 +26,12 @@ public class User implements Serializable {
|
|||
super();
|
||||
userId = compteur++;
|
||||
}
|
||||
|
||||
public void finalize() {
|
||||
|
||||
compteur--;
|
||||
}
|
||||
|
||||
public User(String login) {
|
||||
this.login = login;
|
||||
userId = compteur++;
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<%--
|
||||
Document : deconnexion
|
||||
Created on : 1 juin 2020, 17:09:38
|
||||
Author : faycal
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Deconnexion</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Vous etes deconnecte</h1>
|
||||
<%response.sendRedirect("/Bdd_Spring_HI/");%>
|
||||
</body>
|
||||
</html>
|
|
@ -1,18 +0,0 @@
|
|||
<%--
|
||||
Document : error
|
||||
Created on : 4 mars 2018, 20:54:56
|
||||
Author : faycal
|
||||
--%>
|
||||
|
||||
<%@page contentType="text/html" pageEncoding="UTF-8"%>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>Erreur</title>
|
||||
</head>
|
||||
<body>
|
||||
<%@include file="header.jsp" %>
|
||||
<h1>${erreur} </h1>
|
||||
</body>
|
||||
</html>
|
|
@ -12,7 +12,7 @@
|
|||
<title>Deconnexion</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Vous etes deconnecte</h1>
|
||||
<%response.sendRedirect("/Bdd_Spring_HI/");%>
|
||||
<h1>You are logout</h1>
|
||||
<%response.sendRedirect("");%>
|
||||
</body>
|
||||
</html>
|
Reference in a new issue