Exemple #1
0
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        if ((ComboBases.Text != "") && (edusuario.Text != "") && (edsenha.Text != ""))
        {
            SreDblib.connectionString    = SreDblib.GetConnString(Convert.ToString(ComboBases.Value));
            SreDblib.connectionStringcep = SreDblib.GetConnString(Convert.ToString("SRE_SqlServerCep"));

            edusuario.Text = edusuario.Text.ToUpper();
            edsenha.Text   = edsenha.Text.ToUpper();
            edusuario.Text = edusuario.Text.Trim();
            edsenha.Text   = edsenha.Text.Trim();

            if (LogarUsuario(edusuario.Text, edsenha.Text) == "")
            {
                //Codigos Originais
                string bd     = ComboBases.Text.ToUpper();
                int    ptraco = bd.IndexOf("-");
                bd = bd.Substring(ptraco + 2, bd.Length - (ptraco + 2));
                Session.Add("CodBaseSql", bd);
                DM.Banco = bd;
                Session.Add("CodUsuario", edusuario.Text.ToUpper());
                Session.Add("BaseCorrente", ComboBases.Text.ToUpper());
                // Codigos duplicados
                Session.Add("usuario", edusuario.Text.ToUpper());
                Session.Add("connectionstring", SreDblib.connectionString);
                Session.Add("connectionstringcep", SreDblib.connectionStringcep);
                //
                AtualizaCss();
                //
                Response.Redirect("Principal.aspx");
            }
        }
        else
        {
            lbmsg.Text = "ATENÇÃO: Preencha Todos os Dados!";
            ScriptManager.RegisterStartupScript(this.Page, typeof(Page), Guid.NewGuid().ToString(),
                                                "toastr.error('Preencha Todos os Dados!', 'Atenção!')", true);
        }
    }