public string ValidarAcceso() { string rpta = ""; string cabecera = Request.Headers["xhr"]; if (cabecera != null && cabecera.Equals("OSC")) { string user = Request.QueryString["usuario"]; string pass = Request.QueryString["pass"]; string dstb = Request.QueryString["dstb"]; string chk = Request.QueryString["rmbr"]; brLogin obrLogin = new brLogin(); beLogin lstLogin = obrLogin.ValidarLogin(user.ToLower(), pass, dstb.ToLower()); if (lstLogin != null) { if (lstLogin.exito != 0) { DateTime expira = DateTime.Now.AddMonths(1); HttpCookie usuario = new HttpCookie("Usuario", user); usuario.Expires = expira; Response.Cookies.Add(usuario); HttpCookie pu = new HttpCookie("PU", lstLogin.exito.ToString()); pu.Expires = expira; Response.Cookies.Add(pu); if (chk == "1") { HttpCookie rmbr = new HttpCookie("Chk", "1"); rmbr.Expires = expira; Response.Cookies.Add(rmbr); } rpta = CustomSerializer.Serializar(lstLogin.lstDstAbnd, '@', '_', false).ToString(); Session["validar"] = 1; } else { rpta = "0"; } } } return(rpta); }
protected void btnLogin_Click(object sender, EventArgs e) { try { brLogin brLogin = new brLogin(); List <beLogin> lLogin = brLogin.ValidarLogin(txtUsuario.Text, txtPassword.Text, txtDstb.Text); int exito = lLogin[0].exito; string sUserIden = lLogin[0].sUserIden.ToString(); int cPrflCode = lLogin[0].cPrflCode; string sdealercode = lLogin[0].dealercode.ToString(); string sdealername = lLogin[0].dealername.ToString(); if (exito == 1) { Session["sUserIden"] = sUserIden; Session["cPrflCode"] = cPrflCode; Session["dealercode"] = sdealercode; Session["dealername"] = sdealername; lblMensaje.Text = "Ingresando ..."; Response.Redirect("../General/Menu.aspx"); } else { lblMensaje.Text = "Usuario/Password incorrecto"; } } catch (Exception ex) { brLog brLog = new brLog(); brLog.InsertarLog(ex.HResult.ToString(), ex.Message, "Login", "btnLogin_Click"); } }