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
|
public void UpdateTableSearch() throws SQLException {
String nomS=rechNomField.getText().toString();
String prenomS=rechPrenField.getText().toString();
String emailS=rechemailField.getText().toString();
String telephS=rechtelephField.getText().toString();
if(!nomS.equals("") && !prenomS.equals("") && !emailS.equals("") && !telephS.equals(""))
{
String sql="Select * from personnel WHERE ( nom = ' "+nomS+" ' AND prenom =' " +prenomS+" ' AND email = ' "+emailS+" ' AND telephone = ' "+telephS+" ')";
try {
prepared = cnx.prepareStatement(sql);
resultat=prepared.executeQuery();
//System.out.println("h");
/*DefaultTableModel modele=(DefaultTableModel) table.getModel();
modele.setRowCount(0);
table.setModel(modele);*/
table.setModel(DbUtils.resultSetToTableModel(resultat));
//cacher la colonne id_pers
table.getColumnModel().getColumn(0).setMinWidth(0);
table.getColumnModel().getColumn(0).setMaxWidth(0);
table.getColumnModel().getColumn(0).setPreferredWidth(0);
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
String sql1="Select * from personnel";
prepared = cnx.prepareStatement(sql1);
resultat=prepared.executeQuery();
table.setModel(DbUtils.resultSetToTableModel(resultat));
table.getColumnModel().getColumn(0).setMinWidth(0);
table.getColumnModel().getColumn(0).setMaxWidth(0);
table.getColumnModel().getColumn(0).setPreferredWidth(0);
}} |
Partager