Objects.requireNonNull(c,"On ne peut pas appliquer un changement qui est null");
Etudiante=c.getEtu();
Groupea=c.getA();
Groupeb=c.getB();
if(!agf.knows(a))thrownewIllegalStateException("Le groupe de départ du changement est inconnu. Impossible à mettre en oeuvre.");
if(!agf.knows(b))thrownewIllegalStateException("Le groupe d'arrivée du changement est inconnu. Impossible à mettre en oeuvre.");
// pas encore implanté.
// if(!agf.getGroupesOfEtudiant(e).contains(a)) throw new IllegalStateException("Le groupe de départ ne contient pas l'étudiant. Impossible à mettre en oeuvre.");
agf.dropFromGroupe(a,e);
agf.addToGroupe(b,e);
// En cas de succès, on enlève le changement du cerveau
PreparedStatementpst=cnx.prepareStatement("INSERT INTO `Changement` (`idGroupeA`, `idGroupeB`, `idEtudiant`) VALUES (?, ?, ?);");
pst.setInt(1,A.getId());
pst.setInt(2,B.getId());
pst.setInt(3,e.getId());
pst.executeUpdate();
pst.close();
}catch(SQLExceptioner){
if(this.erreurSQL()){
this.createChangement(A,e,B);
}else{
return;
}
}
this.close(cnx);
}
// **********************
// FONCTION POUR SIMPLIFIER LES Modification BD
// ***********************
privateConnectioncnx(){
//On se Connecte a la BD
try{
Class.forName("org.mariadb.jdbc.Driver");
Connectioncnx=DriverManager.getConnection(
"jdbc:mariadb://dwarves.iut-fbleau.fr/chaignea",
"chaignea","Chaigneauphpmyadmin");
returncnx;
}catch(Exceptione){
if(this.erreurCO()==true){
returnthis.cnx();
}
}
returnnull;
}
privatebooleanerreurCO(){
if(JOptionPane.showConfirmDialog(this.fenetre,"erreur connection a la BD reassayer?","erreur connection",JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
if(JOptionPane.showConfirmDialog(this.fenetre,"erreur lors de la modification, reasssayer?","erreur SQL",JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){