-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModifsProduit.java
More file actions
60 lines (49 loc) · 2.29 KB
/
ModifsProduit.java
File metadata and controls
60 lines (49 loc) · 2.29 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//Insert new produit
Connection connexion = … ;
String instructionSQL = "INSERT INTO Produit VALUES(?, ?, ?, NULL, ?)";
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setInt(1,produit.getReference());
prepStat.setString(2,produit.getLibelle());
prepStat.setDouble(3,produit.getPrixBase());
prepStat.setInt(4,produit.getTVA());
prepStat.executeUpdate();
if(produit.getPrixVidange() != NULL){
instructionSQL = "UPDATE Produit set PrixVidange = ? where Reference = "+produit.getReference();
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setDouble(4,produit.getPrixVidange());
prepStat.executeUpdate();
}
if (produit.getReduction() != NULL){
instructionSQL = "UPDATE Produit set Reduction = ? where Reference = "+produit.getReference();
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setBoolean(6,produit.getReduction());
prepStat.executeUpdate();
}
if (produit.getDateFinReduc() != NULL){
instructionSQL = "UPDATE Produit set DateFinReduc = ? where Reference = "+produit.getReference();
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setDate(7,new java.sql.Date(produit.getDateFinReduc().getTimeInMillis()));
prepStat.executeUpdate();
}
if (produit.getPourcReduc != NULL){
instructionSQL = "UPDATE Produit set PourcReduc = ? where Reference = "+produit.getReference();
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setDouble(8,produit.getPourcReduc());
prepStat.executeUpdate();
}
if (produit.getQteStock != NULL){
instructionSQL = "UPDATE Produit set QteStock = ? where Reference = "+produit.getReference();
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setInt(9,produit.getQteStock());
prepStat.executeUpdate();
}
//Modif produit
String instructionSQL = "UPDATE Produit SET colonne = valeur where Reference = ?)";
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setInt(1,produit.getReference());
int nbIns = prepStat.executeUpdate( );
//Supr Produit
String instructionSQL = "DELETE FROM Produit where Reference = ?)";
PreparedStatementprepStat = connexion.prepareStatement(instructionSQL);
prepStat.setInt(1,produit.getReference());
int nbIns = prepStat.executeUpdate();