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
| if (rc.jCheckBoxNomClient.isSelected()) {
s = helper.getSessionFactory().openSession();
s.beginTransaction();
String nom = rc.jTextFieldRechNomClient.getText();
if (rc.jTextFieldRechNomClient.getText().length() == 0) {
JOptionPane.showMessageDialog(null, "Aucune entrer a rechercher", "Error", JOptionPane.ERROR_MESSAGE);
} else {
String SQL_QUERY = ("select client.client_id, client.client_nom, client.client_tel, client.client_email, "
+ " client.client_adresse, client.client_num, commune.commune_nom, commune.commune_cp "
+ " from client, commune "
+ " where client_nom like '" + nom + "%'"
+ " and client.commune_id = commune.commune_id");
Iterator results = s.createSQLQuery(SQL_QUERY).list().iterator();
listModel = new DefaultListModel();
mg.jListClient.setModel(listModel);
while (results.hasNext()) {
Object[] row = (Object[]) results.next();
listModel.addElement("N° Client: " + row[0] + " "
+ " Societé: " + row[1] + " "
+ " Telephone: " + row[2] + " "
+ " Email: " + row[3] + " "
+ " Adresse: " + row[4] + " "
+ " N°: " + row[5] + " "
+ " Commune: " + row[6] + " "
+ " Code Postal: " + row[7]);
mg.jListClient.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1) {
String selected = "" + mg.jListClient.getSelectedIndex();
mg.jTextFieldIdClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldNomClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldTelClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldEmailClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldAdresseClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldNumClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldComClient.setText(mg.jListClient.getSelectedValue().toString());
mg.jTextFieldCpClient.setText(mg.jListClient.getSelectedValue().toString());
}
}
});
}
s.getTransaction().commit();
s.close();
}
} |
Partager