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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
|
package sentalents.apps;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import java.awt.Toolkit;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JTable;
import javax.swing.JButton;
import javax.swing.ImageIcon;
import sentalents.db.ConnectionManager;
import sentalents.db.ResultsSearch;
import sentalents.db.ResultsSearchKeywords;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.Vector;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.InputMethodListener;
import java.awt.event.InputMethodEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
@SuppressWarnings("serial")
public class CVtheque extends JFrame {
private JPanel contentPane;
private JTextField motCle;
private JComboBox<?> comboNiveau;
private JComboBox<String> comboLocal;
private JComboBox<String> comboPays;
private JComboBox<String> comboSecteur;
private JLabel lblPaysDeNaissance;
private JLabel lblSecteurDeTravail;
private JTable table_1;
public CVtheque() {
setIconImage(Toolkit.getDefaultToolkit().getImage(CVtheque.class.getResource("/sentalents/images/images/request.png")));
setResizable(false);
setTitle("Sentalents Apps - CVth\u00E8que");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 918, 673);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
JLabel lblNewLabel = new JLabel("Cette section vous permet de faire vos recherches et de trouver les candidats succeptibles de vous int\u00E9resser.");
JLabel lblMotsCls = new JLabel("Mot(s) cl\u00E9(s) :");
JLabel lblNiveauDeDiplme = new JLabel("Niveau de Dipl\u00F4me :");
JLabel lblLocalisationActuelle = new JLabel("Localisation Actuelle :");
motCle = new JTextField();
motCle.setColumns(10);
String[] choices = {"", "Licence - Bachelor", "Master - Master", "Doctorat - Doctorate, Ph.D."};
comboNiveau = new JComboBox<Object>(choices);
comboLocal = new JComboBox<String>();
localisation(comboLocal);
comboPays = new JComboBox<String>();
paysnaiss(comboPays);
comboSecteur = new JComboBox<String>();
secteurlist(comboSecteur);
/*final String a = motCle.getText();
final Object b = comboNiveau.getSelectedItem();
final Object c = comboLocal.getSelectedItem();
final Object d = comboPays.getSelectedItem();
final Object e = comboSecteur.getSelectedItem();*/
final Vector<String> columnNames = new Vector<String>();
final Vector<Vector<Object>> data = new Vector<Vector<Object>>();
table_1 = new JTable();
contentPane.add(new JScrollPane(table_1));
JButton btnRechercher = new JButton("Rechercher");
btnRechercher.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
//new ResultsSearch(a, b, c, d, e, table_1, columnNames, data);
//new ResultsSearch(a, table_1, columnNames, data);
columnNames.removeAllElements();
data.removeAllElements();
Connection conn = ConnectionManager.getInstance().getConnection();
//String sql = "SELECT nom, prenom, niveau, localisation, pays, secteur1, secteur2, secteur3, photo, cv1, cv2, cv3, langue_cv1, langue_cv2, langue_cv3 FROM infos WHERE niveau ='"+b+"' AND localisation = '"+c+"' AND pays = '"+d+"' AND secteur1 = '"+e+"' AND titre_cv1 LIKE '%"+a+"%'";
//String sql = "SELECT nom, prenom, niveau, localisation, pays FROM infos WHERE (niveau ='"+b+"' AND localisation = '"+c+"' AND pays = '"+d+"' AND secteur1 = '"+e+"') OR CONCAT_WS(' ',titre_cv1, titre_cv2, titre_cv3) LIKE '%"+a+"%'";
//String sql = "SELECT nom, prenom, niveau, localisation, pays FROM infos WHERE titre_cv1 = '"+a+"' AND niveau ='"+b+"' AND localisation = '"+c+"' AND pays = '"+d+"' AND secteur1 = '"+e+"'";
//String sql = "SELECT nom, prenom, niveau, localisation, pays FROM infos WHERE (niveau =? AND localisation = ? AND pays = ? AND secteur1 = ?) OR CONCAT_WS(' ',titre_cv1, titre_cv2, titre_cv3) LIKE '%?%'";
//String sql = "SELECT nom, prenom, niveau, localisation, pays FROM infos WHERE niveau = '"+b+"'";
//String sql = "SELECT * FROM infos";
//String sql = "SELECT nom, prenom, niveau, localisation, pays, secteur1 FROM infos WHERE niveau LIKE '%"+b+"%' AND localisation LIKE '%"+c+"%' AND pays LIKE '%"+d+"%' AND secteur1 LIKE '%"+e+"%' AND (MATCH (titre_cv1) AGAINST ('"+a+"' IN BOOLEAN MODE))";
//System.out.println(sql);
try {
String sql = "SELECT nom, prenom, niveau, localisation, pays, secteur1 FROM infos WHERE (niveau LIKE ? AND localisation LIKE ? AND pays LIKE ? AND secteur1 LIKE ?) OR (MATCH (titre_cv1, titre_cv2, titre_cv3) AGAINST (? IN BOOLEAN MODE))";
//String sql = "SELECT nom, prenom, niveau, localisation, pays, secteur1 FROM infos WHERE MATCH (titre_cv1, titre_cv2, titre_cv3) AGAINST (?,?,?,?,? IN BOOLEAN MODE)";
//String sql = "SELECT nom, prenom, niveau, localisation, pays, secteur1 FROM infos WHERE titre_cv1 LIKE ?";
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setObject(1, ""+comboNiveau.getSelectedItem()+"");
stmt.setObject(2, ""+comboLocal.getSelectedItem()+"");
stmt.setObject(3, ""+comboPays.getSelectedItem()+"");
stmt.setObject(4, ""+comboSecteur.getSelectedItem()+"");
stmt.setString(5, ""+motCle.getText()+"");
ResultSet rs = stmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
int columns = metaData.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement(metaData.getColumnName(i));
while (rs.next()) {
Vector<Object> row = new Vector<Object>(columns);
for (int j = 1; j <= columns; j++) {
row.addElement(rs.getObject(j));
}
data.addElement(row);
System.out.println(row);
}
}
} catch (Exception e1) {
System.err.println(e1);
}
DefaultTableModel model = new DefaultTableModel(data, columnNames);
table_1.setModel(model);
ConnectionManager.getInstance().close();
}
});
JLabel lblNewLabel_1 = new JLabel("");
lblNewLabel_1.setIcon(new ImageIcon(CVtheque.class.getResource("/sentalents/images/images/monitor.gif")));
lblPaysDeNaissance = new JLabel("Pays de Naissance :");
lblSecteurDeTravail = new JLabel("Secteur de Travail :"); |
Partager