How to make pincode activator via serial?

3

I'm trying to make pincode validator (serial), but I do not know how to do it.

I have two tables: "validation" and "expiration".

In the "validation" table, it has the following fields:

id(int), data(varchar), pincode(varchar), status(int)

In the "expiration" table, you have the following fields:

id(int), data(varchar)

Dates are formatted as " ddmmaaaa ". That is, a date such as "17/11/2016" is "17112016".

My code looks like this:

public void Valida(String senha) {
    conex.conexao();
    conex.executaSql("select * from vencimento");
    try {
        conex.rs.last();
        valida = Integer.parseInt(conex.rs.getString("data"));
        int operacao = (valida + 132) / 4;
        int senhaValidacao = Integer.parseInt(senha);
        if (operacao == senhaValidacao) {
            int dia, mes, ano;
            String AcertaMes, AcertaDia, ProxSenha;
            SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
            Date hoje = new Date();
            String data = df.format(hoje);
            char[] senhachar = data.toCharArray();
            dia = Integer.parseInt("" + senhachar[0] + senhachar[1]);
            mes = Integer.parseInt("" + senhachar[3] + senhachar[4]);
            ano = Integer.parseInt("" + senhachar[6] + senhachar[7] + senhachar[8] + senhachar[9]);

            if (mes < 12) {
                mes++;
                if(mes<10){
                    AcertaMes = "0"+mes;
                }
                else{
                    AcertaMes = ""+mes;
                }
            } else {
                mes = 1;
                ano++;
                AcertaMes = "0"+mes;
            }
            if(dia<10){
                AcertaDia = "0"+dia;

            }else{
                AcertaDia = ""+dia;
            }
            ProxSenha = AcertaDia+AcertaMes+ano;
            PreparedStatement pst = conex.con.prepareStatement("insert into vencimento (data)values(?)");
            pst.setString(1, ProxSenha);
            pst.execute();
            JOptionPane.showMessageDialog(null, "Sistema valido ate: "+dia+"/"+mes+"/"+ano+" Entre novamente!");

        } else {
            JOptionPane.showMessageDialog(null, "PINCODE INCORRETO VERIFIQUE OU ENTRE EM COTATO COM A ADVANCE SISTEMAS");
        }
        // JOptionPane.showMessageDialog(null, valida);
    } catch (SQLException ex) {
        JOptionPane.showMessageDialog(null, "Erro ao Validar" + ex);
    }

Here's the code idea:

  • / li> When the user or client types the pincode, it will make a " update " in the "expiration" table by pulling the "validation" date, and doing an " update "in the" validation "table, in the" status "field, but I can not do this.

asked by anonymous 17.11.2016 / 03:27

0 answers