MysqlGestionVente venteBD = new MysqlGestionVente();
//si bon valide
if(b.getId() != 0){
if((solde + b.getMontant()) >= PrixFilm){
//gestion BD vente
Vente v = new Vente();
v.setIdFilm(idFilm);
v.setIdClient(user.getId());
v.setPrix(PrixFilm);
v.setType("a");
date = System.currentTimeMillis();
v.setDate(date);
int id = venteBD.ajouterVente(v);
if(id != -1){
db.updateSolde(user, (b.getMontant()-PrixFilm));
v.setId(id);
//Mise a jour Bon
b.setDateU(date);
b.setIdClientU(user.getId());
b.setUtilise(1);
b.setIdFilm(idFilm);
b.setType("a");
venteBD.updateBon(b);
return true;
}
}
}else{
if(solde >= PrixFilm){
//gestion BD vente
Vente v = new Vente();
v.setIdFilm(idFilm);
v.setIdClient(user.getId());
v.setPrix(PrixFilm);
v.setType("a");
date = System.currentTimeMillis();
v.setDate(date);
int id = venteBD.ajouterVente(v);
if(id != -1){
db.updateSolde(user, -PrixFilm);
v.setId(id);
return true;
}
}
}
return false;