private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            if (txtSenha.TextLength >= 8 && txtSenha.TextLength <= 20 && txtEmail.TextLength >= 10 && txtSenha.TextLength <= 40)
            {
                crypt = new CriptDecript.CripDecript();

                cruds = new Modelo.ModeloLogin();

                cruds.email = txtEmail.Text;
                cruds.senha = crypt.Encrypt(txtSenha.Text, txtSenha.Text);

                bool Logado = cruds.ValidarLogin();

                if (Logado)
                {
                    MessageBox.Show("Usuario logado com sucesso!");

                    string usuario = cruds.getUsuario();
                    int    id      = cruds.getId();

                    this.txtEmail.Text = "";
                    this.txtSenha.Text = "";

                    frmPainel painel = new frmPainel(usuario, cruds.email, id);
                    painel.Show();
                    this.Hide();
                }
                else
                {
                    lblMessage.Text = "Nome de usuario/senha incorretos.";
                }
            }
            else
            {
                lblMessage.Text = "Informe um usuario válido!";
            }
        }
Example #2
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (txtEmail.TextLength >= 10)
            {
                if (txtEmail.TextLength <= 40)
                {
                    if (txtSenha.TextLength >= 8)
                    {
                        if (txtSenha.TextLength <= 20)
                        {
                            if (txtUsuario.TextLength >= 5)
                            {
                                if (txtUsuario.TextLength <= 25)
                                {
                                    cript = new CriptDecript.CripDecript();
                                    cruds = new Modelo.ModeloLogin();

                                    cruds.email   = txtEmail.Text;
                                    cruds.senha   = cript.Encrypt(txtSenha.Text, txtSenha.Text);
                                    cruds.usuario = txtUsuario.Text;

                                    bool criado = cruds.RegistrarUsuario();
                                    if (criado)
                                    {
                                        MessageBox.Show("Usuario criado com sucesso!");
                                        this.Hide();
                                    }
                                    else
                                    {
                                        vermelho("O email/usuario já está em uso!");
                                    }
                                }
                                else
                                {
                                    vermelho("O nome de Usuario não deve ultrapassar 25 caracteres.");
                                }
                            }
                            else
                            {
                                vermelho("O nome de usuario deve ter no minimo 5 carcteres.");
                            }
                        }
                        else
                        {
                            vermelho("A senha não deve ultrapassar 20 caracteres.");
                        }
                    }
                    else
                    {
                        vermelho("A senha deve ter no minimo 8 caracteres.");
                    }
                }
                else
                {
                    vermelho("O Email não deve ultrapassar 40 caracteres.");
                }
            }
            else
            {
                vermelho("O Email deve ter no minimo 10 caracteres.");
            }
        }