1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| private void btn_loginActionPerformed(java.awt.event.ActionEvent evt) {
try{
if(radioBtnSupportTech.isSelected()){
String sql = "select * from Employee where name=? and password=? and technician=1";
preparedSql = connection.prepareStatement(sql);
preparedSql.setString(1, txt_username.getText());
// username = txt_username.getText();
preparedSql.setString(2, String.valueOf(txt_password.getPassword()));
rsult= preparedSql.executeQuery();
// userId = rsult.getString("idEmployee");
// System.out.println(username+" "+userId);
if(rsult.next()){
idEmployee = rsult.getInt("idEmployee"); // lorsque je fais le System.out.println
//il m'affiche le resultat. mais je ne peux acceder a cette valeur en dehors de la method.
JOptionPane.showMessageDialog(this, "Login Successfully");
dispose();
AdminForm onIt = new AdminForm();
onIt.setVisible(true);
}
else{
JOptionPane.showMessageDialog(this, "Login Fail try again");
}
} |
Partager