Ejemplo n.º 1
0
 private void jToggleButton1MouseReleased(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_jToggleButton1MouseReleased
   // TODO add your handling code here:
   dispose();
   MenuPrincipal M = new MenuPrincipal();
   M.setVisible(true);
 } // GEN-LAST:event_jToggleButton1MouseReleased
Ejemplo n.º 2
0
  public void registroEntrada() {
    boolean n = true;
    String usr = "", pass = "", sSQL = "", usr2 = "", pass2 = "";
    boolean estado = false;
    usr = txtUsuario.getText();
    pass = passContraseña.getText();

    int dia = 0, mes = 0, año = 0, diaHoy = 0, mesHoy = 0, añoHoy = 0;
    // Date fecha,fechaActual;
    // fecha = new Date(dia,mes,año);
    // fechaActual=new Date(diaHoy,mesHoy,añoHoy);

    /////////////////////////////////////////////

    // JOptionPane.showMessageDialog(null, ""+dia+mes+año);
    /////////////////////////////////////////////
    sSQL =
        "select login,password,estado,fecha from usuario"
            + " where login = '******' and fecha >= current_date() and "
            + "password= md5('"
            + pass
            + "') and estado = true";
    // JOptionPane.showMessageDialog(null, sSQL);
    Connection con = conectar.coneccion();

    try {
      PreparedStatement pst = con.prepareStatement(sSQL);
      ResultSet rs = pst.executeQuery(sSQL);
      while (rs.next()) {
        usr2 = rs.getString("login");
        pass2 = rs.getString("password");
        estado = rs.getBoolean("estado");
        // fecha= rs.getDate("fecha");
        // fechaActual=rs.getDate("current_date()");
        // JOptionPane.showMessageDialog(null, rs.sql);

      }
      // int n =pst.executeQuery();
      n = pst.execute();

    } catch (SQLException ex) {
      JOptionPane.showMessageDialog(null, " error " + ex);
      // *Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
    }

    if (usr.equals(usr2) && estado == true) { // &&(fecha==fechaActual ||fecha.after(fechaActual))){
      JOptionPane.showMessageDialog(null, "usuario aceptado  ");
      MenuPrincipal menuc = new MenuPrincipal();
      menuc.setVisible(true);
      this.dispose();

      sSQL =
          "insert into bitacora(login,fecha_ingreso,hora_ingreso)"
              + "values('"
              + usr
              + "',curdate(),curtime())";
      //  + " where login = '******' and fecha >= current_date() and";
      // like

      try {
        PreparedStatement pst = con.prepareStatement(sSQL);
        n = pst.execute();
      } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "segundo error " + ex);
        // *Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
      }
    } else {
      JOptionPane.showMessageDialog(null, "usuario incorrecto");
      errores++;
    }
    if (errores > 2) {

      JOptionPane.showMessageDialog(null, "Has superado el limite de intentos, prueba mas tarde");
      System.exit(0);
    }
  }