Ejemplo n.º 1
0
    protected void btnEntrar_Click(object sender, EventArgs e)
    {
        string cpf   = txtCpf.Text.Trim();
        string senha = txtSenha.Text.Trim();

        if (!IsPreenchido(cpf))
        {
            lblMensagem.Text = "Preencha o email";
            txtCpf.Focus();
            return;
        }
        if (!IsPreenchido(senha))
        {
            lblMensagem.Text = "Preencha a senha";
            txtSenha.Focus();
            return;
        }
        PessoaBD bd     = new PessoaBD();
        Pessoa   pessoa = new Pessoa();

        pessoa = bd.Autentica(cpf, senha);
        if (!UsuarioEncontrado(pessoa))
        {
            lblMensagem.Text = "Usuário não encontrado";
            txtCpf.Focus();
            return;
        }
        Session["ID"] = pessoa.Codigo;
        PessoaBD pessoabd = new PessoaBD();
        Pessoa   pescod   = pessoabd.Select(Convert.ToInt32(Session["ID"]));

        Logon logon = new Logon();

        logon.Pessoa = pescod;
        var    time          = DateTime.Now;
        string formattedTime = time.ToString("yyyy/MM/dd hh:mm:ss");

        logon.Tempo = Convert.ToDateTime(formattedTime);
        LogonBD bl = new LogonBD();

        bl.Insert(logon);
        switch (pessoa.Tipo)
        {
        case 0:
            Response.Redirect("HomeAssociado.aspx");
            break;

        case 1:
            Response.Redirect("HomeFuncionario.aspx");
            break;

        default:
            break;
        }
    }
Ejemplo n.º 2
0
    // evento click do botão


    protected void BtnLogar_Click(object sender, EventArgs e)
    {
        string email = txtEmail.Text.Trim();
        string senha = txtSenha.Text.Trim();

        if (!IsPreenchido(email))
        {
            lblMensagem.Text = "Preencha o Email !!";
            txtEmail.Focus();
            return;
        }

        if (!IsPreenchido(senha))
        {
            lblMensagem.Text = "Preencha a Senha !!";
            txtSenha.Focus();
            return;
        }

        PessoaBD bd     = new PessoaBD();
        Pessoa   pessoa = new Pessoa();

        pessoa = bd.Autentica(email, senha);

        if (!UsuarioEncontrado(pessoa))
        {
            lblMensagem.Text = "Usuario não encontrado !!";
            txtEmail.Focus();
            return;
        }

        Session["ID"] = pessoa.Codigo;

        switch (pessoa.Tipo)
        {
        case 'A':

            Response.Redirect("Administrador/Adm.aspx");

            break;

        case 'G':


            Response.Redirect("Garçom/Garçom.aspx");

            break;

        default:

            break;
        }
    }
Ejemplo n.º 3
0
        protected void btnEntrar_Click(object sender, EventArgs e)
        {
            string email = txtEmail.Text.Trim();
            string senha = txtSenha.Text.Trim();

            if (!IsPreenchido(email))
            {
                lblMensagem.Text = "Preencha o email";
                txtEmail.Focus();
                return;
            }
            if (!IsPreenchido(senha))
            {
                lblMensagem.Text = "Preencha a senha";
                txtSenha.Focus();
                return;
            }
            PessoaBD bd     = new PessoaBD();
            Pessoa   pessoa = new Pessoa();

            pessoa = bd.Autentica(email, senha);
            if (!UsuarioEncontrado(pessoa))
            {
                lblMensagem.Text = "Usuário não encontrado";
                txtEmail.Focus();
                return;
            }
            Session["id"] = pessoa.Cpf;
            switch (pessoa.Tipo)
            {
            case 0:
                Response.Redirect("Home.aspx");
                break;

            case 1:
                Response.Redirect("Home.aspx");
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        protected void btnEntrar_Click(object sender, EventArgs e)
        {
            string nome  = txtNome.Text.Trim();
            string senha = txtSenha.Text.Trim();

            if (!IsPreenchido(nome))
            {
                lblMensagem.Text = "Preencha o nome do usuário";
                txtNome.Focus();
                return;
            }
            if (!IsPreenchido(senha))
            {
                lblMensagem.Text = "Preencha a senha";
                txtSenha.Focus();
                return;
            }

            PessoaBD bd     = new PessoaBD();
            Pessoa   pessoa = new Pessoa();

            pessoa = bd.Autentica(nome, senha);
            if (!UsuarioEncontrado(pessoa))
            {
                lblMensagem.Text = "Usuário não encontrado";
                txtNome.Focus();
                return;
            }

            Session["ID"] = pessoa.Codigo;
            switch (pessoa.Tipo)
            {
            case 0:
                Response.Redirect("ADM/Index.aspx");
                break;
            }
        }
Ejemplo n.º 5
0
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string nome  = txtNome.Text.Trim();
        string senha = txtSenha.Text.Trim();

        if (!IsPreenchido(nome))
        {
            Type cstype = this.GetType();

            // Get a ClientScriptManager reference from the Page class.
            ClientScriptManager cs = Page.ClientScript;

            // Check to see if the startup script is already registered.
            if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
            {
                String cstext = "alert('Preencha o Nome');";
                cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
            }
            txtNome.Focus();
            return;
        }
        if (!IsPreenchido(senha))
        {
            Type cstype = this.GetType();

            // Get a ClientScriptManager reference from the Page class.
            ClientScriptManager cs = Page.ClientScript;

            // Check to see if the startup script is already registered.
            if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
            {
                String cstext = "alert('Insira sua Senha');";
                cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
            }
            txtSenha.Focus();
            return;
        }
        PessoaBD bd     = new PessoaBD();
        Pessoa   pessoa = new Pessoa();

        pessoa = bd.Autentica(nome, senha);
        if (!UsuarioEncontrado(pessoa))
        {
            Type cstype = this.GetType();

            // Get a ClientScriptManager reference from the Page class.
            ClientScriptManager cs = Page.ClientScript;

            // Check to see if the startup script is already registered.
            if (!cs.IsStartupScriptRegistered(cstype, "PopupScript"))
            {
                String cstext = "alert('Usuário não encontrado');";
                cs.RegisterStartupScript(cstype, "PopupScript", cstext, true);
            }
            txtNome.Focus();
            return;
        }
        Session["ID"] = pessoa.Codigo;
        switch (pessoa.Tipo)
        {
        case "Administrador":
            Response.Redirect("ADM/Administrador.aspx");
            break;

        case "Funcionário":
            Response.Redirect("Client/Index.aspx");
            break;

        default:
            break;
        }
    }