Пример #1
0
        protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            AutenticacionTableAdapter authTBLA  = new AutenticacionTableAdapter();
            AutenticacionDataTable    datosAuth = authTBLA.GetDataById(this.Login1.UserName);



            //var entity = new Database1Entities();
            //var a = entity.DatosAutenticacion(this.Login1.UserName).ToArray();
            if (datosAuth.Rows.Count == 0)
            {
                //Usuario no existe
            }
            else if (datosAuth.Rows.Count == 1)
            {
                var datosUsuario = (AutenticacionRow)datosAuth.Rows[0];
                if (datosUsuario["Role"].ToString() == "profesor" && datosUsuario["Clave"].ToString() == this.Login1.Password)
                {
                    this.Login1.Visible          = false;
                    this.webcontentLogin.Visible = false;

                    Session["IdProf"] = datosUsuario["Id"].ToString();
                    Session["Role"]   = "profesor";
                    ProfesoresTableAdapter profesoresTableAdapter = new ProfesoresTableAdapter();
                    Session["NomProf"] = profesoresTableAdapter.GetProfName(Session["IdProf"].ToString()).ToString();

                    this.idProf.Text  = Session["IdProf"].ToString();
                    this.nomProf.Text = Session["NomProf"].ToString();
                    //this.SqlDataSource1.SelectParameters["Id"].DefaultValue = datosUsuario["Id"].ToString();
                    //this.SqlDataSource2.SelectParameters["IdEst"].DefaultValue = Id;



                    this.webcontentProfesor.Visible = true;
                }
                else
                {
                    //Negar acceso
                }
            }
            else
            {
                //Negar acceso
            }
        }
Пример #2
0
        protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            AutenticacionTableAdapter authTBLA  = new AutenticacionTableAdapter();
            AutenticacionDataTable    datosAuth = authTBLA.GetDataById(this.Login1.UserName);

            if (datosAuth.Rows.Count == 1)
            {
                var datosUsuario = (AutenticacionRow)datosAuth.Rows[0];
                if (datosUsuario["Role"].ToString() == "administrador" && datosUsuario["Clave"].ToString() == this.Login1.Password)
                {
                    this.webcontentLogin.Visible = false;

                    Session["IdAdmin"] = datosUsuario["Id"].ToString();
                    Session["Role"]    = "administrador";
                    AdministradoresTableAdapter atministradoresTableAdapter = new AdministradoresTableAdapter();
                    Session["NomAdmin"] = atministradoresTableAdapter.GetAdminName(Session["IdAdmin"].ToString());

                    this.idAdmin.Text            = Session["IdAdmin"].ToString();
                    this.nomAdmin.Text           = Session["NomAdmin"].ToString();
                    this.webcontentAdmin.Visible = true;
                }
            }
        }