Ejemplo n.º 1
0
 private void passwordTextBoxKeyPressed(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_passwordTextBoxKeyPressed
   // TODO add your handling code here:
   int key = evt.getKeyCode();
   if (key == KeyEvent.VK_ENTER) {
     boolean verify = false;
     String user = usernameTextBox.getText();
     String passwd = passwordTextBox.getText();
     if (user.equals("") || passwd.equals("")) {
       JOptionPane.showMessageDialog(
           AdminLogin.this, "Sorry! You must enter a Username and Password to login ");
       usernameTextBox.requestFocus();
     } else {
       Connection con = getConnection();
       try {
         ResultSet rows;
         Statement s =
             con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
         String select = "Select * from admin;";
         rows = s.executeQuery(select);
         while (rows.next()) {
           String username = rows.getString("Username");
           String password = rows.getString("Password");
           if (user.equals(username) && passwd.equals(password)) {
             verify = true;
             this.dispose();
             //                       btn.btnEnabled();
             break;
           }
         }
         if (verify == false) {
           verify = false;
           JOptionPane.showMessageDialog(
               AdminLogin.this, "Access Denied! Invalid Username or Password");
           usernameTextBox.setText("");
           passwordTextBox.setText("");
           usernameTextBox.requestFocus();
         }
       } catch (SQLException e) {
         System.out.println(e.getMessage());
       }
       if (verify == false) {
         JOptionPane.showMessageDialog(
             AdminLogin.this, "Access Denied!  Invalid Username or Password");
         usernameTextBox.setText("");
         passwordTextBox.setText("");
         usernameTextBox.requestFocus();
       } // TODO add your handling code here:
     }
   }
   if (key == KeyEvent.VK_UP) {
     usernameTextBox.grabFocus();
   }
   if (key == KeyEvent.VK_KP_UP) {
     usernameTextBox.grabFocus();
   }
 } // GEN-LAST:event_passwordTextBoxKeyPressed
Ejemplo n.º 2
0
 private void btnIngresarKeyPressed(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_btnIngresarKeyPressed
   // TODO add your handling code here:
   char car = (char) evt.getKeyCode();
   if (car == evt.VK_ENTER) {
     this.hide();
     // Principal prin = new Principal();
     // prin.show();
     String usu = txtusuario.getText();
     String pas = new String(txtcontra.getPassword());
     acceder(usu, pas);
   }
 } // GEN-LAST:event_btnIngresarKeyPressed
Ejemplo n.º 3
0
 private void txtKasirKeyPressed(
     java.awt.event.KeyEvent evt) { // GEN-FIRST:event_txtKasirKeyPressed
   if (evt.getKeyCode() == evt.VK_ENTER) {
     txtPass.requestFocusInWindow();
   }
 } // GEN-LAST:event_txtKasirKeyPressed