1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| //récupération des données de la base de données
String fact = "SELECT nom, prenom, adresse, ville_CP, email, Commande.IDCO, date_commande, mode_paiement, quantité_1, produit, prix "
+ "FROM Client, Commande, Facture, Produit "
+ "WHERE Client.IDC=Commande.IDC AND Commande.IDCO=Facture.IDCO AND Facture.IDP_1=Produit.IDP "
+ "AND Commande.IDCO = (SELECT MAX(IDCO) FROM Commande)";
ResultSet res;
res = stmt.executeQuery(fact); //consultation des données
String nom;
String prenom;
String adresse;
String ville_CP;
String email;
int IDCO;
java.sql.Date date_commande;
String mode_paiement;
int quantité;
String produit;
int prix;
while (res.next()) {
nom = res.getString(1);
prenom = res.getString(2);
adresse = res.getString(3);
ville_CP = res.getString(4);
email = res.getString(5);
IDCO = res.getInt(6);
date_commande = res.getDate(7);
mode_paiement = res.getString(8);
quantité = res.getInt(9);
produit = res.getString(10);
prix = res.getInt(11);
System.out.println(nom + " " + prenom + " a commandé " + quantité + " " + produit + " à " + prix + "");
//génere la facture en format pdf en faisant appel à la classe Facture.java
Facture g = new Facture();
g.genererPdf(nom, prenom, adresse, ville_CP, email, IDCO, date_commande, mode_paiement, produit, quantité, prix); |
Partager