Example #1
0
        private void setTextBoxIntoBean()
        {
            try
            {
                if (bean.idUsuario == 0)
                {
                    bean.idUsuario = Uteis.stringToInt(txtIdUsuario.Text);
                }
                bean.login = txtLogin.Text;
                int id = Uteis.stringToInt(txtIdPessoa.Text);
                bean.pessoa = PessoaDAO.getRecord(id);

                if ((txtSenha1.Text != "") && (txtSenha2.Text != ""))
                {
                    if (txtSenha1.Text.Trim() == txtSenha2.Text)
                    {
                        bean.senha = REFHash.getMD5Hash(txtSenha1.Text);
                    }
                    else
                    {
                        throw new InvalidPassworldException("Senha não diferente de sua confirmação.");
                    }
                }
            }
            catch (InvalidPassworldException i)
            {
                throw i;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
        private void btnConfirmar_Click(object sender, System.EventArgs e)
        {
            tentativas++;
            if (tentativas >= 3)
            {
                closeForm();
            }
            else
            {
                UsuarioBean u = UsuarioDAO.getByLogin(txtLogin.Text, REFHash.getMD5Hash(txtSenha.Text));

                if (u != null && u.idUsuario != 0)
                {
                    usr = u;
                    closeForm();
                }
                else
                {
                    MessageBox.Show("Login ou Senha inválidos! (" + (3 - tentativas) + " tentativas restantes).");
                }
            }
        }