Beispiel #1
0
        //public ActionResult Create([Bind(Include = "COD_ALUNO,NOME,RM,DATA_NASCIENTO,SEXO")] TB_ALUNO tB_ALUNO)
        public ActionResult Create(MatriculaAluno matricula)//vai pegar os dados que estão inseridos na classe MatriculaAluno
        {
            TB_ALUNO tB_ALUNO = matricula.TB_ALUNO;

            if (ModelState.IsValid)
            {
                db.TB_ALUNO.Add(tB_ALUNO);
                db.SaveChanges();

                TB_TURMA       tB_TURMA       = db.TB_TURMA.Find(matricula.COD_TURMA);
                TB_ALUNO_TURMA tB_ALUNO_TURMA = new TB_ALUNO_TURMA
                {
                    ANO       = DateTime.Today.Year + "",
                    COD_ALUNO = tB_ALUNO.COD_ALUNO,
                    COD_TURMA = tB_TURMA.COD_TURMA,
                    SEMESTRE  = "1", //obs: Precisa ver de onde vai tirar essa informacao.
                    //Acredito que o semestre deveria estar acessível através da turma,
                    //mas turma não tem essa informação, entao, acho que está faltando...
                };
                db.TB_ALUNO_TURMA.Add(tB_ALUNO_TURMA);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tB_ALUNO));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     TB_ALUNO tB_ALUNO = db.TB_ALUNO.Find(id);
     db.TB_ALUNO.Remove(tB_ALUNO);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
Beispiel #3
0
        public int AdicionaTopico(TB_ALUNO aluno, string nomeTopico)
        {
            using (var conexao = new SIGMAEntities())
            {
                //var alunoNovo = conexao.TB_ALUNO.Single(x => x.ID_ALUNO == aluno.IdAluno);

                //verificar se o topico já existe, adiciono na tabela Topico uma linha

                var idTopicoProcurado = ExisteTopico(aluno.ID_ALUNO, nomeTopico);
                if (idTopicoProcurado == 0)
                {
                    var novoTopico = new TB_TOPICO();

                    novoTopico.ID_ALUNO   = aluno.ID_ALUNO;
                    novoTopico.NOM_TOPICO = nomeTopico;

                    conexao.TB_TOPICO.Add(novoTopico);
                    conexao.SaveChanges();

                    return(novoTopico.ID_TOPICO);
                }
                else
                {
                    return(idTopicoProcurado);
                }
            }
        }
Beispiel #4
0
 public ActionResult Edit([Bind(Include = "COD_ALUNO,NOME,RM,DATA_NASCIMENTO,SEXO")] TB_ALUNO tB_ALUNO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tB_ALUNO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tB_ALUNO));
 }
        public ActionResult DeleteConfirmed(int id)
        {
            TB_ALUNO tB_ALUNO = db.TB_ALUNO.Find(id);

            tB_ALUNO.TB_ALUNO_TURMA.Clear();  //esse comando autoriza excluir um aluno pois sem esse comando
                                              //não estava conseguindo por causa da FK_aluno3 na tabela Aluno_Turma não estava permitindo
            db.TB_ALUNO.Remove(tB_ALUNO);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "COD_ALUNO,NOME,RM,DATA_NASCIENTO,SEXO")] TB_ALUNO tB_ALUNO)
        {
            if (ModelState.IsValid)
            {
                db.TB_ALUNO.Add(tB_ALUNO);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(tB_ALUNO);
        }
 // GET: TB_ALUNO/Delete/5
 public ActionResult Delete(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     TB_ALUNO tB_ALUNO = db.TB_ALUNO.Find(id);
     if (tB_ALUNO == null)
     {
         return HttpNotFound();
     }
     return View(tB_ALUNO);
 }
Beispiel #8
0
        // GET: Aluno/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TB_ALUNO tB_ALUNO = db.TB_ALUNO.Find(id);

            if (tB_ALUNO == null)
            {
                return(HttpNotFound());
            }
            return(View(tB_ALUNO));
        }
Beispiel #9
0
        public void Cadastrar(Aluno dadosTela)
        {
            using (var conexao = new SIGMAEntities())
            {
                var novoAluno = new TB_ALUNO();

                novoAluno.NOM_ALUNO = dadosTela.Nome;
                //IdTopico
                novoAluno.NUM_CPF        = dadosTela.CPF;
                novoAluno.DES_EMAIL      = dadosTela.Email;
                novoAluno.DAT_NASCIMENTO = dadosTela.DataNascimento;
                novoAluno.NOM_LOGIN      = dadosTela.Usuário;
                novoAluno.DES_SENHA      = dadosTela.Senha;

                conexao.TB_ALUNO.Add(novoAluno);
                conexao.SaveChanges();
            }
        }
Beispiel #10
0
        public ActionResult BuscarRM(TB_ALUNO tB_ALUNO)
        {
            //   if (rm == null)

            //   {

            //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            // }

            var aluno = db.TB_ALUNO.Where(a => a.RM == tB_ALUNO.RM).FirstOrDefault();

            if (aluno == null)

            {
                return(HttpNotFound());
            }

            return(Json(new { nome = aluno.NOME }, JsonRequestBehavior.AllowGet));
        }