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
| public void RechercheClient() {
if (rc.jRadioButtonIdClient.isSelected()) {
s = helper.getSessionFactory().openSession();
s.beginTransaction();
cl = (Client) s.get(Client.class, Integer.parseInt(rc.jTextFieldRechIdClient.getText()));
co = (Commune) s.get(Commune.class, cl.getCommune().getCommuneId());
s.getTransaction().commit();
s.close();
mg.jTextAreaClient.append(this.SupplierID = " N° Supplier: " + cl.getClientId() + " ");
mg.jTextAreaClient.append(this.SupplierName = "Nom de la Societé: " + cl.getClientNom() + " ");
//t2.jTextFieldRechNomSupplier.setText(su.getSupplierName());
mg.jTextAreaClient.append(this.SupplierTel = " Telephone: " + cl.getClientTel() + " ");
//t2.jTextFieldRechTelSupplier.setText(su.getSupplierPhone());
mg.jTextAreaClient.append(this.SupplierEmail = " Email: " + cl.getClientEmail() + " ");
//t2.jTextFieldRechEmailSupplier.setText(su.getSupplierEmail());
mg.jTextAreaClient.append(this.SupplierAdr = " Adresse: " + cl.getClientAdresse() + " ");
//t2.jTextFieldRechAdrSupplier.setText(su.getSupplierAddress());
mg.jTextAreaClient.append(this.SupplierNum = " N°: " + cl.getClientNum() + " ");
//t2.jTextFieldRechNumSupplier.setText(String.valueOf(su.getSupplierNumber()));
mg.jTextAreaClient.append(this.SupplierCom = " Commune: " + co.getCommuneNom());
//t2.jTextFieldRechComSupplier.setText(to.getTownName());
mg.jTextAreaClient.append(this.SupplierCp = " Code Postal: " + co.getCommuneCp());
//t2.jTextFieldRechCpSupplier.setText(to.getTownPostcode());
s = helper.getSessionFactory().openSession();
s.beginTransaction();
s.getTransaction().commit();
s.close();
} else {
s = helper.getSessionFactory().openSession();
s.beginTransaction();
String nom = rc.jTextFieldRechNomClient.getText();
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();
while (results.hasNext()) {
Object[] row = (Object[]) results.next();
mg.jTextAreaClient.(this.SupplierID = " N° Supplier: " + row[0] + " ");
mg.jTextAreaClient.append(this.SupplierName = "Nom de la Societé: " + row[1] + " ");
mg.jTextAreaClient.append(this.SupplierTel = " Telephone: " + row[2] + " ");
mg.jTextAreaClient.append(this.SupplierEmail = " Email: " + row[3] + " ");
mg.jTextAreaClient.append(this.SupplierAdr = " Adresse: " + row[4] + " ");
mg.jTextAreaClient.append(this.SupplierNum = " N°: " + row[5] + " ");
mg.jTextAreaClient.append(this.SupplierCom = " Commune: " + row[6]);
mg.jTextAreaClient.append(this.SupplierCp = " Code Postal: " + row[7]);
mg.jTextAreaClient.append("\n");
}
s.getTransaction().commit();
s.close();
}
} |
Partager