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 61 62
| public LinkedHashMap effectuerRecherche(String mot){
AdherentBDD adherentBDD = new AdherentBDD(this.request, this.response, this.con);
LinkedHashMap map = new LinkedHashMap() ;
PreparedStatement st ;
try {
//on crée le client
if(mot.length() != 0){
st = c.prepareStatement("SELECT * FROM projet.inscription i , projet.adherent a"+
"where i.adherent_id_adherent = a.id_adherent "+
" and ( a.nom_adherent like ? "+
" or a.prenom_adherent like ? "+
" or a.num_licence like ? ) " );
}else{
st = c.prepareStatement("SELECT * FROM projet.inscription i , projet.adherent a "+
"where i.adherent_id_adherent = a.id_adherent "+
" and ( a.nom_adherent like \"%\" "+
" or a.prenom_adherent like \"%\" "+
" or a.num_licence like \"%\" )" );
}
if(mot.length() != 0){
st.setString(1, "%"+mot+"%");
st.setString(2, "%"+mot+"%");
st.setString(3, "%"+mot+"%");
}
ResultSet rs = st.executeQuery();
while(rs.next()){
AdherentModel ad = adherentBDD.getAdherentbyID(rs.getInt("id_Adherent"));
if(!map.containsKey(ad)){
map.put(ad, new LinkedList());
}
InscriptionSimplifie i = new InscriptionSimplifie();
i.setId_inscription(rs.getInt("id_inscription"));
i.setType(this.getTypeInsription(i.getId_inscription()));
if(i.getType() == 2 ){
i.setNom(this.getNomStage(i.getId_inscription()));
}
String annee ="";
if(rs.getDate("date_inscription").getMonth() <12){
annee += (rs.getDate("date_inscription").getYear())+" - "+(rs.getDate("date_inscription").getYear()+1);
}else{
annee += (rs.getDate("date_inscription").getYear()-1)+" - "+(rs.getDate("date_inscription").getYear());
}
i.setAnnee(annee);
((LinkedList)map.get(ad)).add(i);
}
}catch(Exception e) {
this.afficherException(e);
}
return map ;
} |
Partager