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
| public static void selectedEtudiant(){
connexion = new BDConnectMYSQL();
String MATRICULE = getTxtMatricule().getText();
String ANNEEACA = parent.getTxtANNEESCO().getText();
Statement state;
ResultSet res;
String sql;
//ImageIcon monImg;
try{
state = connexion.getInstance().createStatement();
sql = "SELECT DISTINCT NOMETU,PRENETU, COMPTE,NOMCLASSE, MATRICULE, CODECYCLE,COURS,SCOLARITE_REEL,PHOTO " +
"FROM etudiant E, inscription I " +
"WHERE E.NUMETU = I.NUMETU " +
"AND I.MATRICULE = '"+MATRICULE+"'";
res = state.executeQuery(sql);
while(res.next()){
getTxtNom().setText(" "+res.getString(1));
getTxtPrenom().setText(" "+res.getString(2));
getTxtCompteEtu().setText(res.getString(3));
getTxtClasse().setText(res.getString(4));
getTxtCycle().setText(res.getString(6));
labelCours.setText(res.getString(7));
getTxtScolarite_Reel().setValue(res.getInt(8));
//Affichage de l'image de l'étidiant
ImageIcon monImg = null;
Blob image = res.getBlob(8);
try{
if(image != null && image.length() > 0){
monImg = new ImageIcon(image.getBytes(1, (int)image.length()));
lbPhoto.setText("");
lbPhoto.setIcon(monImg);
}else{
lbPhoto.setText("Pas de photo");
}
}catch(SQLException ex){
ex.printStackTrace();}
lbPhoto.setIcon(monImg);}
if(!state.isClosed()){
state.close();}
if(!res.isClosed()){
res.close();}}
catch(SQLException ex){
JOptionPane.showMessageDialog(null, ex.getMessage(), "SQL ERROR", JOptionPane.ERROR_MESSAGE, null);
}
} |
Partager