Esempio n. 1
0
        protected void btnSesion_Click(object sender, EventArgs e)
        {
            Usuario us          = new Usuario();
            string  TipoUsuario = "";
            string  UsuarioId   = "";

            if (CheckColaborador.Checked == true)
            {
                TipoUsuario = "UsuarioCo";
                UsuarioId   = "UsuarioCoId";
            }
            else
            if (CheckAdm.Checked == true)
            {
                TipoUsuario = "Usuario";
                UsuarioId   = "UsuarioId";
            }

            if (CheckAdm.Checked == false && CheckColaborador.Checked == false)
            {
                Utilitario.ShowToastr(this, "SELECCIONE UN TIPO DE USUARIO", "Mensaje", "error");
            }
            else
            {
                if (us.ValidarLog(tbxCorreo.Text, tbxContrasena.Text, TipoUsuario, UsuarioId))
                {
                    if (TipoUsuario == "Usuario")
                    {
                        Session["UserName"]  = us.Nombre;
                        Session["UsuarioId"] = us.UsuarioId;



                        us.ActualizarEstadoSubscripcion(us.UsuarioId);
                        if (us.Estado == 3)
                        {
                            Label lbl = this.Master.FindControl("lblExpiracionPrueba") as Label;
                            lbl.Visible = true;


                            ScriptManager.RegisterStartupScript(this, this.GetType(), "LaunchServerSide", "$(function() { LoginFail(); });", true);
                        }
                        else
                        {
                            Response.Redirect("~/Consulta/MenuAdm.aspx");
                        }
                    }
                    else
                    {
                        Session["UserName"]    = us.Nombre;
                        Session["UsuarioCoId"] = us.UsuarioCoId;

                        Response.Redirect("~/Consulta/Menu.aspx");
                    }
                    lblNoEncontrado.Visible = false;
                }
                else
                {
                    Utilitario.ShowToastr(this, "Contraseña o correo incorrecto.!", "Mensaje", "error");
                    lblNoEncontrado.Visible = true;
                }
            }
        }