Ejemplo n.º 1
0
        private void btnAcceder_Click(object sender, EventArgs e)
        {

            if (txtUser.Text == "USUARIO" || txtPassword.Text == "CONTRASEÑA") {
                msgError("Ingrese un usuario y/o contraseña valida.");
                return;
            }

            intentos = controller.getNAttemptsByUserName(txtUser.Text);
            if (intentos > 6)
            {
                MessageBox.Show("Ha excedido el numero de intentos posibles. Su cuenta ha sido bloqueada", "IMPORTANTE!");
                contador = 100;
                btnAcceder.Enabled = false;
                
                timer1.Enabled = true;
            }

            int []tipo = new int[6] { 0, 0, 0, 0, 0 ,0 };
            
            //VALIDACION DE ROLES
            /*user = txtUser.Text;
            password = txtPassword.Text;
            if (user == "admin" && password == "123") { tipo[0] = 1; Validacion = true; }
            else if (user == "secretario" && password == "123") { tipo[1] = 1; Validacion = true; }
            else if (user == "profesor" && password == "123") { tipo[2] = 1; Validacion = true; }
            else if (user == "auxiliar" && password == "123") { tipo[3] = 1; Validacion = true; }
            else if (user == "apoderado" && password == "123") { tipo[4] = 1; Validacion = true; }
            else if (user == "alumno" && password == "123") { tipo[5] = 1; Validacion = true; }
            else if (user == "profesor_apoderado" && password == "123") { tipo[2] = 1; tipo[4] = 1; Validacion = true; }
            else if (user == "auxiliar_apoderado" && password == "123") { tipo[3] = 1; tipo[4] = 1; Validacion = true; }
            else if (user == "secretario_apoderado" && password == "123") { tipo[1] = 1; tipo[4] = 1; Validacion = true; }
            else
            {
                this.Intentos++;
                msgError("Ingrese un usuario y/o contraseña valida.");
            }

            if (Validacion == true)
            {
                int contador = 0;
                for (int i = 0; i < tipo.Length; i++)
                    if (tipo[i] == 1) contador++;
                if (contador > 1)
                {
                    frmIniciarTipoUsuario frmTipo = new frmIniciarTipoUsuario();
                    frmTipo.Permisos = tipo;
                    frmTipo.FormClosed += Logout;
                    frmTipo.Show();                    
                }
                else
                {
                    if (tipo[0] == 1)
                    {
                        frmMenuPrincipalAdministrador menu = new frmMenuPrincipalAdministrador();
                        menu.FormClosed += Logout;
                        menu.Show();
                    }
                    else if (tipo[1] == 1)
                    {
                        frmMenuPrincipalSecretario menu = new frmMenuPrincipalSecretario();
                        menu.FormClosed += Logout;
                        menu.Show();
                    }
                    else if (tipo[2] == 1)
                    {
                        frmMenuPrincipalProfesor menu = new frmMenuPrincipalProfesor();
                        menu.FormClosed += Logout;
                        menu.Show();
                    }
                    else if (tipo[3] == 1)
                    {
                        frmMenuPrincipalAuxiliar menu = new frmMenuPrincipalAuxiliar();
                        menu.FormClosed += Logout;
                        menu.Show();
                    }
                    else if (tipo[4] == 1)
                    {
                        frmMenuPrincipalApoderado menu = new frmMenuPrincipalApoderado();
                        menu.FormClosed += Logout;
                        menu.Show();
                    }
                    else if (tipo[5] == 1)
                    {
                        frmMenuPrincipalAlumno menu = new frmMenuPrincipalAlumno();
                        menu.FormClosed += Logout;
                        menu.Show();
                    }*/
                }