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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
|
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 :");
GroupLayout gl_contentPane = new GroupLayout(contentPane);
gl_contentPane.setHorizontalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addComponent(lblNewLabel)
.addGroup(gl_contentPane.createSequentialGroup()
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblMotsCls)
.addGap(47)
.addComponent(motCle, GroupLayout.PREFERRED_SIZE, 258, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblPaysDeNaissance)
.addGap(18)
.addComponent(comboPays, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblSecteurDeTravail)
.addGap(18)
.addComponent(comboSecteur, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblLocalisationActuelle)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(comboLocal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_contentPane.createSequentialGroup()
.addComponent(lblNiveauDeDiplme)
.addGap(18)
.addComponent(comboNiveau, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(ComponentPlacement.RELATED, 240, Short.MAX_VALUE)
.addComponent(lblNewLabel_1)
.addPreferredGap(ComponentPlacement.RELATED))))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(232)
.addComponent(btnRechercher))
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(table_1, GroupLayout.PREFERRED_SIZE, 689, GroupLayout.PREFERRED_SIZE)))
.addContainerGap(25, GroupLayout.PREFERRED_SIZE))
);
gl_contentPane.setVerticalGroup(
gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addContainerGap()
.addComponent(lblNewLabel)
.addGroup(gl_contentPane.createParallelGroup(Alignment.LEADING)
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(27)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblMotsCls)
.addComponent(motCle, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblNiveauDeDiplme)
.addComponent(comboNiveau, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(18)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblLocalisationActuelle)
.addComponent(comboLocal, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(24)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblPaysDeNaissance)
.addComponent(comboPays, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(24)
.addGroup(gl_contentPane.createParallelGroup(Alignment.BASELINE)
.addComponent(lblSecteurDeTravail)
.addComponent(comboSecteur, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGap(12)
.addComponent(btnRechercher))
.addGroup(gl_contentPane.createSequentialGroup()
.addGap(18)
.addComponent(lblNewLabel_1)))
.addPreferredGap(ComponentPlacement.RELATED, 33, Short.MAX_VALUE)
.addComponent(table_1, GroupLayout.PREFERRED_SIZE, 320, GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
contentPane.setLayout(gl_contentPane);
}
/***************************************************
*
* Cette partie permet d'avoir les pays dans le JComboBox
*/
private void localisation(JComboBox<String> Jc) {
Connection conn = ConnectionManager.getInstance().getConnection();
String sqloc = "SELECT CONCAT_WS(' - ',fr,en) AS world FROM pays_world ORDER BY `rowid`";
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sqloc);
while (rs.next()) {
String i = rs.getString("world");
Jc.addItem(i);
//System.out.println(i);
}
}
catch (Exception e) {
ConnectionManager.getInstance().close();
}
}
/***************************************************
*
* Cette partie permet d'avoir les pays dans le JComboBox
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private void paysnaiss(JComboBox Jc) {
Connection conn = ConnectionManager.getInstance().getConnection();
String sqloc = "SELECT CONCAT_WS(' - ',fr,en) AS world FROM pays_world ORDER BY `rowid`";
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sqloc);
while (rs.next()) {
String i = rs.getString("world");
Jc.addItem(i);
//System.out.println(i);
}
}
catch (Exception e) {
ConnectionManager.getInstance().close();
}
}
/***************************************************
*
* Cette partie permet d'avoir les secteurs dans le JComboBox
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private void secteurlist(JComboBox Jc) {
Connection conn = ConnectionManager.getInstance().getConnection();
String sqloc = "SELECT CONCAT_WS(' - ',secteur_fr,secteur_en) AS sector FROM secteur_en, secteur_fr WHERE secteur_en.id = secteur_fr.id ORDER BY secteur_en.id";
try {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sqloc);
while (rs.next()) {
String i = rs.getString("sector");
Jc.addItem(i);
//System.out.println(i);
}
}
catch (Exception e) {
ConnectionManager.getInstance().close();
}
}
} |
Partager