示例#1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            ClsUsuario ObjUsuario = new ClsUsuarioN().Login("icp", "1234");

            if (ObjUsuario != null)
            {
                Label1.Text = "conectado";
            }
            else
            {
                Label1.Text = "desconectado";
            }
        }
示例#2
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["Id"] != null)
                {
                    Response.Write("<script language=javascript>alert('xxx');</script>"); //Ya a iniciado sessión, se borrará los datos de la sesión par iniciar nuevamente
                    Session.RemoveAll();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            if (Page.IsValid)
            {
                try
                {
                    ClsUsuario ObjUsuario = new ClsUsuarioN().Login(txtUsuario.Text, TxtClave.Text);
                    if (ObjUsuario != null)
                    {
                        Session["Usuario"] = ObjUsuario.Usuario;
                        Session["Id"]      = ObjUsuario.ID_usuario;
                        Session["Estado"]  = ObjUsuario.Estado;
                        Session.Timeout    = 20;

                        Response.Redirect("Inicio.aspx");
                    }
                    else
                    {
                        Response.Write("<script language=javascript>alert('Usuario o Clave incorrecta');</script>");
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }