protected void BtProf_Click(object sender, EventArgs e)
        {
            AutenticacionTableAdapter autenticacion = new AutenticacionTableAdapter();
            ProfesoresTableAdapter    profesores    = new ProfesoresTableAdapter();

            RadioButtonList1.Items.Clear();
            foreach (AutenticacionRow datos in autenticacion.GetData().Rows)
            {
                if (DropDownList1.SelectedValue == "Inhabilitar")
                {
                    LblTipoDato.Text = "Profesores disponibles para Inhabilitar:";
                    if (datos["Role"].ToString() == "profesor")
                    {
                        RadioButtonList1.Items.Add(new ListItem(datos["Id"].ToString() + " - " + profesores.GetProfName(datos["Id"].ToString()).ToString(), datos["Id"].ToString()));
                    }
                }
                else if (DropDownList1.SelectedValue == "Habilitar")
                {
                    LblTipoDato.Text = "Profesores disponibles para Habilitar:";
                    if (datos["Role"].ToString() == "profesor$")
                    {
                        RadioButtonList1.Items.Add(new ListItem(datos["Id"].ToString() + " - " + profesores.GetProfName(datos["Id"].ToString()).ToString(), datos["Id"].ToString()));
                    }
                }
            }

            wcOpciones.Visible = false;
            wcLista.Visible    = true;
        }
        private void FlipRole(string id)
        {
            AutenticacionTableAdapter autenticacion = new AutenticacionTableAdapter();
            string role = autenticacion.ScalarQueryGetRoleById(id);

            if (role.Contains("$"))
            {
                role = role.Remove(role.Length - 1);
            }
            else
            {
                role += "$";
            }
            autenticacion.UpdateQueryForRoleDisable(role, id);
        }
Exemplo n.º 3
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
            }
        }
Exemplo n.º 4
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;
                }
            }
        }
        protected void btnSeguroAgregar_Click(object sender, EventArgs e)
        {
            this.btnVolverEditar.Visible        = false;
            this.btnSeguroAgregar.Visible       = false;
            this.btnVolverMenuPrincipal.Visible = true;
            this.lblEntidadAgregada.Visible     = true;
            if ((bool)ViewState["agrEst"] == true)
            {
                //this.btnAgregar.Visible = true;
                estudiantes   = new EstudiantesTableAdapter();
                autenticacion = new AutenticacionTableAdapter();
                if (nombreEst != null && contraEst != null)
                {
                    string id = dataUpdate.GetID();
                    //this.btnAgregar.Visible = true;
                    estudiantes.Insert(id, nombreEst.Text.ToUpper(), ListCarreras.SelectedValue, "0.00", 0, "Sin Honor", 0);
                    autenticacion.Insert(id, contraEst.Text, null, "estudiante");
                    lblEntidadAgregada.Text = "Estudiante agregado";
                }
                else
                {
                    lblEntidadAgregada.Text = "No se ha podido agregar el estudiante";
                }
                //divEst.Visible = false;
                //div1.Visible = true;
            }
            else if ((bool)ViewState["agrProf"] == true)
            {
                profesores    = new ProfesoresTableAdapter();
                autenticacion = new AutenticacionTableAdapter();
                if (nombreProf != null && contraProf != null)
                {
                    string id = dataUpdate.GetID();
                    //this.btnAgregar.Visible = true;
                    profesores.Insert(id, nombreProf.Text.ToUpper());
                    autenticacion.Insert(id, contraProf.Text, null, "profesor");
                }
                else
                {
                    lblEntidadAgregada.Text = "No se ha podido agregar el profesor";
                }
                //divProf.Visible = false;
                //div1.Visible = true;
            }
            else if ((bool)ViewState["agrAsig"] == true)
            {
                asignaturas = new AsignaturasTableAdapter();
                if (claveAsig != null && nombreAsig != null && creditosAsig != null && Regex.IsMatch(creditosAsig.Text, @"^\d+$"))
                {
                    //this.btnAgregar.Visible = true;
                    asignaturas.Insert(claveAsig.Text.ToUpper(), nombreAsig.Text.ToUpper(), int.Parse(creditosAsig.Text));
                }
                else
                {
                    lblEntidadAgregada.Text = "No se ha podido agregar la asignatura";
                }
                //lblError.Text = "No se ha podido agregar la asignatura";
                //lblError.Visible = true;
                //btnVolverEditar.Visible = true;

                //divAsig.Visible = false;
                //div1.Visible = true;
            }
        }