ajout tous les étudiant et correction bug

This commit is contained in:
2022-11-16 17:03:05 +01:00
parent 4b6321d9b8
commit 5c4413a6fb
6 changed files with 92 additions and 83 deletions

View File

@@ -89,11 +89,15 @@ public class Model{
* @param g le groupe a supprimer
*/
public void delete(Groupe g){
//On ne peut pas supprimer la promo avec la factory
//On ne peut pas supprimer la promo normallement
if(g==this.promo.getPromotion()){
this.promo=null;
this.bd.suprGroupe(g);
this.showGroupe(null);
if(JOptionPane.showConfirmDialog(this.fenetre, "Attention ête vous sûr de vouloir supprimer la promo", "Attention", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION){
this.promo=null;
this.bd.suprGroupe(g);
this.showGroupe(null);
}else{
return;
}
//JOptionPane.showMessageDialog(this.fenetre, "impossible de supprimer la promotion", "alerte", JOptionPane.ERROR_MESSAGE);
}else{
//autrement on récupere les groupe a supprimer par ordre avec une fonction recursive
@@ -159,7 +163,6 @@ public class Model{
this.bd.createGroupe(creer);
//on y ajoute les étudiant
int n=0;
int size=100/ajout.size()+1;
for(Etudiant e:ajout){
if(this.addEtudiant(creer, e)==false)
n++;
@@ -190,14 +193,20 @@ public class Model{
public void addPromo(int min, int max, String name){
public void addPromo(int min, int max, String name, Set<Etudiant> ajout){
Chargement ch=new Chargement();
this.promo=new AbstractGroupeFactoryNP(name, min, max);
this.fenetre.setVisible(false);
this.bd.saveGroupe(this.promo.getPromotion(), this.getTailleGroupe(this.promo.getPromotion()), ch);
ch.addPourcent(20);
int pourcent=85/ajout.size();
for(Etudiant e:ajout){
this.addEtudiant(this.promo.getPromotion(), e);
ch.addPourcent(pourcent);
}
ch.dispose();
this.fenetre.setVisible(true);
this.showGroupe(this.bd.refreshALL(this.promo.getPromotion()));
this.showGroupe(this.promo.getPromotion());
}
/**
@@ -208,8 +217,9 @@ public class Model{
*/
public boolean addEtudiant(Groupe g, Etudiant e){
//Si on a la place
if(this.addEtuToParent(g.getPointPoint(), e)==false)
return false;
if(g!=g.getPointPoint())
if(this.addEtuToParent(g.getPointPoint(), e)==false)
return false;
//On induqe a la BD de sauvegarder cette modification
this.bd.saveEtu(e, g);
return true;
@@ -225,13 +235,16 @@ public class Model{
if(g.getMax()==g.getSize())
return false;
for(Etudiant et:g.getEtudiants()){
if(et==e){
if(et.getId()==e.getId()){
return true;
}
}
if(g.getPointPoint()!=g)
if(this.addEtuToParent(g.getPointPoint(), e)==false){return false;}
this.promo.addToGroupe(g, e);
if(g.getPointPoint()!=g){
if(this.addEtuToParent(g.getPointPoint(), e)==false){
return false;
}
}
this.bd.saveEtu(e, g);
return true;
}
@@ -267,12 +280,10 @@ public class Model{
this.promo=null;
}
}catch(SQLException e){
System.out.println("hooo");
}
rs.close();
pst.close();
}catch(SQLException e){
System.out.println("erreur dans le resultat");
}
this.bd.close(cnx);
return agf;