protected void cmdLogar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    AlunoDTO dto = new AlunoDTO();
                    dto.email    = txtUsuario.Text;
                    dto.password = cript2.code.business.SimpleCripto.Encrypt(txtPass.Text + txtUsuario.Text.Substring(0, 2), System.Configuration.ConfigurationManager.AppSettings["cript2Hash"].ToString());
                    dto.ano      = DateTime.Now.Year;

                    AlunoBRL  brl     = new AlunoBRL();
                    DataTable dtTable = brl.searchUserLogin(dto);

                    if (dtTable != null && dtTable.Rows.Count > 0)
                    {
                        string _nome = HttpUtility.UrlEncode(dtTable.Rows[0]["Nome"].ToString(), Encoding.GetEncoding(28597)).Replace("+", " ");

                        if (Request.QueryString["ReturnUrl"] == null)
                        {
                            CriarCookie(_nome,
                                        dtTable.Rows[0]["Email"].ToString(),
                                        dtTable.Rows[0]["IdAluno"].ToString(),
                                        dtTable.Rows[0]["Situacao"].ToString(),
                                        "");

                            FormsAuthentication.SetAuthCookie("webformAlunoAutentication", false);
                            Response.Redirect("/Alunos/Default", true);
                        }
                        else
                        {
                            FormsAuthentication.RedirectFromLoginPage("webformAutentication", true);
                        }
                    }
                    else
                    {
                        lblResultado.Text = "E-mail ou senha inválidos. <Br>Tente novamente ou entre em contato conosco.";
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        protected void cmdLogin_Click(object sender, EventArgs e)
        {
            // try
            //{
            if (Page.IsValid)
            {
                if (hdProfessor.Value.Equals("P"))
                {
                    ProfessorDTO dto = new ProfessorDTO();
                    dto.emailProfessor = txtEmail.Text;
                    dto.pwProfessor    = cript2.code.business.SimpleCripto.Encrypt(txtPassword.Text + txtEmail.Text.Substring(0, 2), System.Configuration.ConfigurationManager.AppSettings["cript2Hash"].ToString());

                    ProfessorBRL brl     = new ProfessorBRL();
                    DataTable    dtTable = brl.searchProfessor(dto);

                    if (dtTable != null && dtTable.Rows.Count > 0)
                    {
                        string _nome = HttpUtility.UrlEncode(dtTable.Rows[0]["NomeProfessor"].ToString(), Encoding.GetEncoding(28597)).Replace("+", " ");
                        CriarCookie(_nome,
                                    dtTable.Rows[0]["EmailProfessor"].ToString(),
                                    dtTable.Rows[0]["IdProfessor"].ToString(),
                                    "P",
                                    "");

                        Response.Redirect("Dados.aspx");
                    }
                    else
                    {
                        lblResultado.Text = "E-mail ou senha inválidos. <Br>Tente novamente ou entre em contato conosco.";
                    }
                }
                else if (hdProfessor.Value.Equals("A"))
                {
                    AlunoDTO dto = new AlunoDTO();
                    dto.email    = txtEmail.Text;
                    dto.password = cript2.code.business.SimpleCripto.Encrypt(txtPassword.Text + txtEmail.Text.Substring(0, 2), System.Configuration.ConfigurationManager.AppSettings["cript2Hash"].ToString());

                    AlunoBRL  brl     = new AlunoBRL();
                    DataTable dtTable = brl.searchUserLogin(dto);

                    if (dtTable != null && dtTable.Rows.Count > 0)
                    {
                        string _nome = HttpUtility.UrlEncode(dtTable.Rows[0]["Nome"].ToString(), Encoding.GetEncoding(28597)).Replace("+", " ");
                        CriarCookie(_nome,
                                    dtTable.Rows[0]["Email"].ToString(),
                                    dtTable.Rows[0]["IdAluno"].ToString(),
                                    "A",
                                    dtTable.Rows[0]["CPF"].ToString());

                        Response.Redirect("Dados.aspx");
                    }
                    else
                    {
                        lblResultado.Text = "E-mail ou senha inválidos. <Br>Tente novamente ou entre em contato conosco.";
                    }
                }
            }
            //}
            //catch (Exception ex)
            //{
            //    enviaEmailError(txtEmail.Text, ex.ToString() + ex.StackTrace.ToString());
            //}
        }