public ActionResult Delete(int id)
        {
            MAluno mAluno = new MAluno();
            Aluno  aluno  = mAluno.BringOne(c => c.idAluno == id);

            TempData["Message"] = mAluno.Delete(aluno) ? "Aluno deletado com sucesso" : "Ação não foi realizada";
            return(RedirectToAction("Index", "ControleAlunos"));
        }
示例#2
0
 private void DeleteClick(object sender, RoutedEventArgs e)
 {
     if (grid.SelectedItem != null)
     {
         MAluno a = grid.SelectedItem as MAluno;
         n.ExcluirAluno(a);
         grid.ItemsSource = null;
         grid.ItemsSource = n.ListarAluno();
     }
 }
示例#3
0
        private void InsertClick(object sender, RoutedEventArgs e)
        {
            MAluno x = new MAluno();

            x.Nome       = txtn.Text;
            x.Email      = txte.Text;
            x.Foto       = foto;
            x.Nascimento = DateTime.Parse(txtnasci.Text);
            x.Senha      = txts.Text;
            n.InserirAluno(x);
        }
        public ActionResult ControleTurma(ICollection <int> alunos)
        {
            MAluno mAluno = new MAluno();

            foreach (var aluno in alunos)
            {
                //Console.WriteLine(aluno.nomeAluno);
                Console.WriteLine(mAluno.BringOne(c => c.idAluno == aluno).nomeAluno);
            }
            return(View());
        }
示例#5
0
        private void UpdateClick(object sender, RoutedEventArgs e)
        {
            MAluno x = new MAluno();

            x.Nome       = txtn.Text;
            x.Email      = txte.Text;
            x.Nascimento = DateTime.Parse(txtnasci.Text);
            x.Senha      = txts.Text;
            n.AtualizarAluno(x);
            grid.ItemsSource = null;
            grid.ItemsSource = n.ListarAluno();
        }
示例#6
0
        public void InserirAluno(MAluno x)
        {
            i = new PAluno();
            List <MAluno> a  = i.Open();
            int           id = 1;

            if (a.Count > 0)
            {
                id = a.Max(y => y.Id) + 1;
            }
            x.Id        = id;
            x.Matricula = "2019101111" + x.Id.ToString();
            a.Add(x);
            i.Save(a);
        }
示例#7
0
        public ActionResult Delete(int id)
        {
            MUsuario mUsuario  = new MUsuario();
            Aluno    aluno     = new MAluno().BringOne(c => c.idAluno == id);
            int      idUsuario = aluno.Usuario.FirstOrDefault().idUsuario;
            Usuario  usuario   = mUsuario.BringOne(c => c.idUsuario == idUsuario);

            usuario.Aluno.Remove(aluno);
            aluno.Usuario.Remove(usuario);
            mUsuario.Delete(usuario);
            MAluno mAluno = new MAluno();

            TempData["Message"] = mAluno.Delete(mAluno.BringOne(c => c.idAluno == aluno.idAluno)) ? "Aluno deletado com sucesso" : "Ação não foi realizada";
            return(RedirectToAction("Index", "ControleAlunos"));
        }
示例#8
0
        public void ExcluirAluno(MAluno x)
        {
            i = new PAluno();
            List <MAluno> a = i.Open();

            foreach (MAluno j in a)
            {
                if (j.Matricula == x.Matricula)
                {
                    a.Remove(j);
                    break;
                }
            }
            i.Save(a);
        }
示例#9
0
        public void AtualizarAluno(MAluno x)
        {
            i = new PAluno();
            List <MAluno> att = i.Open();

            for (int j = 0; j < att.Count; j++)
            {
                if (att[j].Id == x.Id)
                {
                    att.RemoveAt(j);
                    break;
                }
            }
            att.Add(x);
            i.Save(att);
        }
        public ActionResult AdicionarAlunosTurma(int idTurma)
        {
            AlunosTurmaViewModel viewModel    = new AlunosTurmaViewModel();
            MTurma          mTurma            = new MTurma();
            MInscricaoTurma mInscricaoTurma   = new MInscricaoTurma();
            MAluno          mAluno            = new MAluno();
            List <Aluno>    AlunosCadastrados = mInscricaoTurma.Bring(c => c.idTurma == idTurma).Select(c => c.Aluno).ToList();

            viewModel.AlunosCadastrados = AlunosCadastrados;
            List <Aluno> AlunosDisponiveis = mAluno.BringAll();

            AlunosDisponiveis.RemoveAll(c => AlunosCadastrados.Contains(c));
            viewModel.AlunosDisponiveis = AlunosDisponiveis;
            viewModel.turmaAtual        = mTurma.BringOne(c => c.idTurma == idTurma);
            //Teste(viewModel);
            return //PartialView("AdicionarAlunosTurma", viewModel);
                   (View("AdicionarAlunosTurma", viewModel));
        }
示例#11
0
        public ActionResult AdicionarAlunosTurmaAction(int idTurma)
        {
            var                   alunos          = Request.Form["alunos[]"].Split(',');
            List <Aluno>          listAlunos      = new List <Aluno>();
            MAluno                mAluno          = new MAluno();
            Turma                 turma           = new MTurma().BringOne(c => c.idTurma == idTurma);
            MInscricaoTurma       mInscricaoTurma = new MInscricaoTurma();
            List <InscricaoTurma> alunosInscritos = mInscricaoTurma.Bring(c => c.idTurma == turma.idTurma);
            List <InscricaoTurma> alunosInscrever = new List <InscricaoTurma>();
            MControleNotas        mControleNotas  = new MControleNotas();

            foreach (var item in alunos)
            {
                InscricaoTurma novo = new InscricaoTurma();
                novo.idAluno = Convert.ToInt32(item);
                novo.idTurma = turma.idTurma;
                alunosInscrever.Add(novo);
            }
            foreach (var item in alunosInscritos)
            {
                if (alunosInscrever.SingleOrDefault(c => c.idAluno == item.idAluno) == null)
                {
                    mInscricaoTurma.Delete(item);
                }
            }
            foreach (var item in alunosInscrever)
            {
                if (alunosInscritos.SingleOrDefault(c => (c.idAluno == item.idAluno) && (c.idTurma == idTurma)) != null)
                {
                    continue;
                }
                mInscricaoTurma.Add(item);
                foreach (var modulo in turma.Med.Semestre.Modulo)
                {
                    ControleNotas controleNotas = new ControleNotas();
                    controleNotas.idInscricaoTurma = item.idInscricaoTurma;
                    controleNotas.idModulo         = modulo.idModulo;
                    mControleNotas.Add(controleNotas);
                }
            }
            return(RedirectToAction("GerenciarTurmas", new { idMed = turma.idMed }));
        }
示例#12
0
        public ActionResult Create(string nomeAluno, string cpfAluno, string matriculaAluno, string email)
        {
            Aluno aluno = new Aluno();

            aluno.nomeAluno      = nomeAluno;
            aluno.cpfAluno       = cpfAluno;
            aluno.matriculaAluno = matriculaAluno;
            aluno.ativo          = true;
            Usuario novo = new Usuario();

            novo.login         = aluno.cpfAluno;
            novo.senha         = aluno.cpfAluno;
            novo.email         = email;
            novo.idTipoUsuario = (int)Enumeradores.TipoUsuario.Aluno;
            aluno.Usuario.Add(novo);
            MAluno mAluno = new MAluno();

            mAluno.Add(aluno);
            return(RedirectToAction("Index"));
        }
        public static bool VerificarSenha(ref int p, string n, string s, ref MAluno u, ref MProfessor a)
        {
            bool r = false;

            if (n == "Admin")
            {
                r = s == "admin";
                p = 0;
            }
            if (r == false)
            {
                NProfessor        f   = new NProfessor();
                List <MProfessor> lis = f.ListarProfessor();
                foreach (MProfessor x in lis)
                {
                    if (x.Matricula == n && s == x.Senha)
                    {
                        r = true;
                        p = 2;
                        a = x;
                        break;
                    }
                }
            }
            if (r == false)
            {
                NAluno        e = new NAluno();
                List <MAluno> b = e.ListarAluno();
                foreach (MAluno x in b)
                {
                    if (x.Matricula == n && s == x.Senha)
                    {
                        r = true;
                        p = 1;
                        u = x;
                        break;
                    }
                }
            }
            return(r);
        }
        private void BtnEntrar(object sender, RoutedEventArgs e)
        {
            bool       logou = false;
            MAluno     u     = new MAluno();
            MProfessor a     = new MProfessor();
            int        i     = 0;

            do
            {
                logou = VerificarSenha(ref i, txtUsuario.Text, txtSenha.Password, ref u, ref a);
                if (!logou)
                {
                    MessageBox.Show("Usuário ou senha inválidos");
                }
                else
                {
                    break;
                }
            } while (logou);
            if (logou)
            {
                if (i == 0)
                {
                    Window janela = new Administrador();
                    Close();
                    janela.ShowDialog();
                }
                else if (i == 1)
                {
                    Window janela = new Aluno(u);
                    Close();
                    janela.ShowDialog();
                }
                else if (i == 2)
                {
                    Window janela = new Professor(a);
                    Close();
                    janela.ShowDialog();
                }
            }
        }
        public ActionResult Create(string nomeAluno, string cpfAluno, string matriculaAluno)
        {
            Aluno aluno = new Aluno();

            aluno.nomeAluno      = nomeAluno;
            aluno.cpfAluno       = cpfAluno;
            aluno.matriculaAluno = matriculaAluno;
            aluno.ativo          = true;
            MAluno mAluno = new MAluno();

            if (mAluno.Add(aluno))
            {
                Usuario novo = new Usuario();
                novo.login         = aluno.cpfAluno;
                novo.senha         = aluno.cpfAluno;
                novo.idTipoUsuario = 3;
                new MUsuario().Add(novo);
                TempData["Message"] = new MUsuarioAluno().Add(novo.idUsuario, aluno.idAluno) ? "Aluno cadastrado" : "Ação não foi realizada";
            }
            return(RedirectToAction("Create"));
        }
示例#16
0
        public Aluno(MAluno a)
        {
            InitializeComponent();
            txtN.Text     = a.Nome;
            txtE.Text     = a.Email;
            txtM.Text     = a.Matricula;
            txtS.Text     = a.Senha;
            txtNasci.Text = a.Nascimento.ToString();

            OpenFileDialog w = new OpenFileDialog();

            w.Filter = "Arquivos jpg|*.jpg";
            byte[] b = Convert.FromBase64String(a.Foto);

            BitmapImage bi = new BitmapImage();

            bi.BeginInit();
            bi.StreamSource = new MemoryStream(b);
            bi.EndInit();

            img.Source = bi;
        }
        public ActionResult Update(int id)
        {
            MAluno mAluno = new MAluno();

            return(View(mAluno.BringOne(c => c.idAluno == id)));
        }