private boolean login() {
javax.swing.JPanel panel = new javax.swing.JPanel();
panel.setBackground(new java.awt.Color(110,220,190);
javax.swing.JTextField usuario = new javax.swing.JTextField();
javax.swing.JPasswordField password = new javax.swing.JPasswordField();
int intentos = 0;
panel.setLayout(new java.awt.GridLayout(2, 2, 10, 10));
panel.add(new javax.swing.JLabel("Usuario:"));
panel.add(usuario);
panel.add(new javax.swing.JLabel("Contraseña:"));
panel.add(password);
while(intentos < 3) {
if(javax.swing.JOptionPane.showConfirmDialog(this, panel, this.getTitle(), javax.swing.JOptionPane.OK_CANCEL_OPTION, javax.swing.JOptionPane.PLAIN_MESSAGE) == javax.swing.JOptionPane.OK_OPTION) {
if(usuario.getText().equals(""))
javax.swing.JOptionPane.showMessageDialog(this, "Se debe digitar el Nombre de Usuario", this.getTitle(), javax.swing.JOptionPane.INFORMATION_MESSAGE);
else if(password.getPassword().length == 0)
javax.swing.JOptionPane.showMessageDialog(this, "Se debe digitar la Contraseña", this.getTitle(), javax.swing.JOptionPane.INFORMATION_MESSAGE);
else{
//aqui se debe validar la contraseña
try {
rs = ConeccionStandar.obtenerResultSet("SELECT * FROM ACO_TUSUARIO WHERE USU_LOGIN = " + "'" + usuario.getText().trim().toUpperCase() + "'" +
" AND USU_PASSWORD = " + "'" + password.getText().trim().toUpperCase() + "'");
usu = usuario.getText().trim();
if(rs.next()){
ConeccionStandar.asignarUsuarioConectado(rs.getInt(1));
break;
}else{
intentos++;
javax.swing.JOptionPane.showMessageDialog(this, "El nombre de usuario o contraseña son invalidos.");
if(intentos == 3)
cerrarVentana();
}
} catch(Exception err) {System.out.println(err);}
}
} else {
cerrarVentana();
}
}
return true;
}