How to make pincode activator via serial?

Asked

Viewed 76 times

3

I’m trying to do brush validator (serial), but I don’t know how to do it.

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

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

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

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

id(int), data(varchar)

The dates are formatted as "ddmmaaaa". That is, a date like "11/17/2016" is "17112016".

My code is 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 is the idea of the code:

  • Every time the validation date arrives, the system will generate a pincode and a status of the next expiration date, which checks whether it has already been active in the "validation table".

  • When the user or client enters the pincode, it will make a "update" on the "maturity" table by pulling the "validation" date, and making a "update" in the "validation" table, in the "status" field, but I’m not able to do this.

  • 1

    It is essential to make a text as clear as possible, when reporting the problem, its was extremely confusing, which makes understanding difficult. I made some edits to improve the text, to make it easier to understand, check if it is consistent with the problem. And in addition, you have to have a little patience yourself.

  • Thank you ! friend !

  • 2

    Remember that of the "so many users", a good part is bringing questions, not answers. Also, as @diegofm commented, it would be better to [Edit] and explain what is pro code to do, and what is the difficulty (or what went wrong). It may have happened that people read your question and did not understand the doubt. I, for example, have no idea what you mean by pincode and validated pincode. If it’s just a 4-digit password, for example, or if you have a special rule. In addition, it is not possible to know if there is an error, if only it does not locate, etc, better you explain. Here are some tips: [Ask].

  • let’s see if now the staff will help me

  • It’s gotten a lot better. Now just be patient, remember that the site is collaborative, IE, no one receives to answer, all help by goodwill and desire to share knowledge. Someone will answer you eventually. ;)

  • If for each validation there is a single expiration and for each expiration there is a single validation, then you could put the two in a single table and it would be much simpler and easier. On the other hand, if a validation can have multiple salaries, then you don’t have any foreign key to relate the two and then, you would have to add a.

  • I reviewed your text and rewritten the code you had removed from the question. The way it was, I couldn’t understand what you wanted to ask.

  • You can enter the class code for the variable conex?

  • Hello good afternoon now I’m in the service, when you get home help me ? thanks !

  • You could have helped me Victor ?

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.