示例#1
0
 public ActionResult Delete(int?Matricula)
 {
     if (Convert.ToInt32(Session["NivelDeAcesso"]) == 3)
     {
         if (Matricula == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         alunos alunos = db.alunos.Find(Matricula);
         if (alunos == null)
         {
             return(HttpNotFound());
         }
         return(View(alunos));
     }
     else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 2)
     {
         return(RedirectToAction("Details", "Professores_Turmas"));
     }
     else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 1)
     {
         return(RedirectToAction("Details", "alunos"));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
示例#2
0
        public ActionResult Create([Bind(Include = "Nome,Matricula,Nascimento,Email")] alunos alunos)
        {
            if (Convert.ToInt32(Session["NivelDeAcesso"]) == 3)
            {
                alunos.Matricula = Convert.ToInt32(Convert.ToString(DateTime.Now.Year) + alunos.Matricula);
                if (ModelState.IsValid)
                {
                    db.alunos.Add(alunos);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }

                return(View(alunos));
            }
            else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 2)
            {
                return(RedirectToAction("Details", "Professores_Turmas"));
            }
            else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 1)
            {
                return(RedirectToAction("Details", "alunos"));
            }
            else
            {
                return(RedirectToAction("Login", "Login"));
            }
        }
示例#3
0
 public ActionResult Editar([Bind(Include = "Nome,Matricula,Nascimento,Email")] alunos alunos)
 {
     if (Convert.ToInt32(Session["NivelDeAcesso"]) == 3)
     {
         if (ModelState.IsValid)
         {
             db.Entry(alunos).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         return(View(alunos));
     }
     else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 2)
     {
         return(RedirectToAction("Details", "Professores_Turmas"));
     }
     else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 1)
     {
         return(RedirectToAction("Details", "alunos"));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
示例#4
0
        public HttpResponseMessage Put(int id, alunos aluno)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            if (id != aluno.id)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }

            _bd.Entry(aluno).State = EntityState.Modified;

            try
            {
                _bd.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
        private bool verifica_cpf(string cpf)
        {
            int count = 0;

            try
            {
                using (var db = new dbEscala())
                {
                    if (db.alunos.Count() != 0)
                    {
                        int prima  = db.alunos.First().ID - 1;
                        int caluno = db.alunos.Count();
                        for (int op = 1; op < caluno + 1; op++)
                        {
                            int    ID = prima + op;
                            alunos al = db.alunos.Find(ID);
                            if (cpf == al.CPF)
                            {
                                count++;
                            }
                        }
                    }
                }
            }catch (Exception err)
            {
            }
            if (count != 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#6
0
        public ActionResult Login(string Usuario, string Senha)
        {
            Usuario usuario    = new Usuario();
            int     Autenticar = usuario.AutenticarUsuario(Usuario, Senha);

            if (Autenticar == 1)
            {
                Session["NivelDeAcesso"] = usuario.NA;
                Session["Nome"]          = usuario.Nome;
                return(RedirectToAction("Index", "alunos"));
            }
            else if (Autenticar == 2)
            {
                Session["NivelDeAcesso"] = usuario.NA;
                Session["Nome"]          = usuario.Nome;
                Session["id"]            = usuario.Senha;
                alunos aluno = db.alunos.Find(Convert.ToInt32(Senha));
                return(RedirectToAction("Details", "alunos", aluno));
            }
            else if (Autenticar == 3)
            {
                Session["NivelDeAcesso"] = usuario.NA;
                Session["Nome"]          = usuario.Nome;
                Session["id"]            = usuario.Senha;
                professores professor = db.professores.Find(Senha);
                return(RedirectToAction("Details", "Professores_Turmas", professor));
            }
            else
            {
                ViewBag.Error   = "alert alert-danger text-danger";
                ViewBag.Message = "Usuario ou Senha Invalido !!";
                return(View());
            }
        }
示例#7
0
        //public ActionResult Index()
        //{
        //    return View(db.Alunos_Turmas.ToList());
        //}

        // GET: Notas_Alunos_Turmas_Materias/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            alunos aluno = db.alunos.Find(id);

            if (aluno == null)
            {
                return(HttpNotFound());
            }
            return(View(aluno));
        }
示例#8
0
        public JsonResult IncluirAlunos(alunos novoAluno)
        {
            ModeloDados2 e = new ModeloDados2();

            /* alunos aluno = new alunos();
             * aluno.nome = novoAluno.nome;
             * aluno.matricula = novoAluno.matricula;*/

            e.alunos.Add(novoAluno);
            e.SaveChanges();

            var alunoss = e.alunos.ToList();

            return(Json(alunoss, JsonRequestBehavior.AllowGet));
        }
示例#9
0
 public ActionResult Details(alunos alunos)
 {
     if (Convert.ToInt32(Session["NivelDeAcesso"]) == 1)
     {
         if (alunos == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         if (alunos == null)
         {
             return(HttpNotFound());
         }
         return(View(alunos));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
示例#10
0
        public JsonResult ExcluirAluno(alunos excluirAluno)
        {
            ModeloDados2 e = new ModeloDados2();


            /* //essa maneira tb funciona para remover do db
             * var idAluno = e.alunos.Find(excluirAluno.Id);
             * e.alunos.Remove(idAluno);
             * e.SaveChanges();*/


            alunos alunoExcluir = e.alunos.Where(x => x.Id == excluirAluno.Id).First();

            e.Set <alunos>().Remove(alunoExcluir);
            e.SaveChanges();

            var alunoss = e.alunos.ToList();

            return(Json(alunoss, JsonRequestBehavior.AllowGet));
        }
示例#11
0
 public ActionResult DeleteConfirmed(int Matricula)
 {
     if (Convert.ToInt32(Session["NivelDeAcesso"]) == 3)
     {
         alunos alunos = db.alunos.Find(Matricula);
         db.alunos.Remove(alunos);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 2)
     {
         return(RedirectToAction("Details", "Professores_Turmas"));
     }
     else if (Convert.ToInt32(Session["NivelDeAcesso"]) == 1)
     {
         return(RedirectToAction("Details", "alunos"));
     }
     else
     {
         return(RedirectToAction("Login", "Login"));
     }
 }
示例#12
0
        public HttpResponseMessage Delete(int id)
        {
            alunos aluno = _bd.alunos.Find(id);

            if (aluno == null)
            {
                return(Request.CreateResponse(HttpStatusCode.NotFound));
            }

            _bd.alunos.Remove(aluno);

            try
            {
                _bd.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, ex));
            }

            return(Request.CreateResponse(HttpStatusCode.OK, aluno));
        }
示例#13
0
        private static alunos CriaAluno(IReadOnlyList <string> arrStrings)
        {
            alunos aluno = new alunos()
            {
                inep_escola                   = Convert.ToInt64(arrStrings[1]),
                inep_aluno                    = Convert.ToInt64(arrStrings[2]),
                codigo_aluno                  = arrStrings[3],
                nome_aluno                    = arrStrings[4],
                data_nasc_aluno               = Convert.ToDateTime(arrStrings[5]),
                sexo_aluno                    = arrStrings[6].Equals("1"),
                cor_raca_aluno                = (int?)Convert.ToInt64(arrStrings[7]),
                possui_filiacao_aluno         = arrStrings[8].Equals("1"),
                filiacao1_aluno               = arrStrings[9],
                filiacao2_aluno               = arrStrings[10],
                nacionalidade_aluno           = (int?)Convert.ToInt64(arrStrings[11]),
                pais_origem_aluno             = (int?)Convert.ToInt64(arrStrings[12]),
                uf_nasc_aluno                 = (int?)Convert.ToInt64(arrStrings[13]),
                municipio_nasc_aluno          = (int?)Convert.ToInt64(arrStrings[14]),
                possui_deficiencia_aluno      = arrStrings[15].Equals("1"),
                defic_cegueira_aluno          = arrStrings[16].Equals("1"),
                defic_baixa_visao_aluno       = arrStrings[17].Equals("1"),
                defic_surdez_aluno            = arrStrings[18].Equals("1"),
                defic_defic_auditiva_aluno    = arrStrings[19].Equals("1"),
                defic_surdocegueira_aluno     = arrStrings[20].Equals("1"),
                defic_defic_fisica_aluno      = arrStrings[21].Equals("1"),
                defic_defic_intelectual_aluno = arrStrings[22].Equals("1"),
                defic_defic_multipla_aluno    = arrStrings[23].Equals("1"),
                defic_autismo_aluno           = arrStrings[24].Equals("1"),
                defic_asperger_aluno          = arrStrings[25].Equals("1"),
                defic_rett_aluno              = arrStrings[26].Equals("1"),
                defic_superdotacao_aluno      = arrStrings[27].Equals("1"),
                auxilio_ledor_aluno           = arrStrings[28].Equals("1"),
                auxilio_transcricao           = arrStrings[29].Equals("1"),
                guia_interprete               = arrStrings[30].Equals("1"),
                interprete_libras             = arrStrings[31].Equals("1"),
            };

            return(aluno);
        }
示例#14
0
        public JsonResult AlterarAluno(alunos alterarAluno)
        {
            ModeloDados2 e = new ModeloDados2();


            /* //essa maneira tb funciona para remover do db
             * var idAluno = e.alunos.Find(excluirAluno.Id);
             * e.alunos.Remove(idAluno);
             * e.SaveChanges();*/


            alunos alunoAlterar = e.alunos.Where(x => x.Id == alterarAluno.Id).First();

            alunoAlterar.nome  = alterarAluno.nome;
            alunoAlterar.email = alterarAluno.email;
            alunoAlterar.sexo  = alterarAluno.sexo;

            e.SaveChanges();

            var alunoss = e.alunos.ToList();

            return(Json(alunoss, JsonRequestBehavior.AllowGet));
        }
示例#15
0
        public HttpResponseMessage Post(int id, alunos aluno)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    _bd.alunos.Add(aluno);
                    _bd.SaveChanges();

                    HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, aluno);
                    response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = aluno.id }));
                    return(response);
                }
                else
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#16
0
 private void btCadastrar_Click(object sender, EventArgs e)
 {
     if (dgvAlunos.RowCount > 1)
     {
         DateTime hoje = DateTime.Now.Date;
         try
         {
             using (var db = new dbEscala())
             {
                 for (int op = 0; op < dgvAlunos.RowCount - 1; op++)
                 {
                     string cpf   = Convert.ToString(dgvAlunos.Rows[op].Cells[1].Value);
                     int    prima = db.alunos.Where(d => d.CPF == cpf).Count();
                     if (prima != 0)
                     {
                         int       idaluno = db.alunos.Where(d => d.CPF == cpf).FirstOrDefault().ID;
                         alunos    al      = db.alunos.Find(idaluno);
                         sal_aluno sa      = new sal_aluno();
                         sa.IDALUNO         = al.ID;
                         sa.IDSALA          = Convert.ToInt32(dgvAlunos.Rows[op].Cells[4].Value);
                         db.Entry(sa).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                         escala es = new escala();
                         es.IDSAL_ALUNO     = sa.ID;
                         es.DT_INICIO       = hoje;
                         es.DT_FINAL        = hoje;
                         db.Entry(es).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                     }
                     else
                     {
                         alunos al = new alunos();
                         al.NOME            = Convert.ToString(dgvAlunos.Rows[op].Cells[0].Value);
                         al.CPF             = Convert.ToString(dgvAlunos.Rows[op].Cells[1].Value);
                         al.DT_INICIO       = Convert.ToDateTime(dgvAlunos.Rows[op].Cells[2].Value);
                         al.DT_FINAL        = Convert.ToDateTime(dgvAlunos.Rows[op].Cells[3].Value);
                         al.ATIVO           = 1;
                         al.DELETADO        = 0;
                         db.Entry(al).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                         sal_aluno sa = new sal_aluno();
                         sa.IDALUNO         = al.ID;
                         sa.IDSALA          = Convert.ToInt32(dgvAlunos.Rows[op].Cells[4].Value);
                         db.Entry(sa).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                         escala es = new escala();
                         es.IDSAL_ALUNO     = sa.ID;
                         es.DT_INICIO       = hoje;
                         es.DT_FINAL        = hoje;
                         db.Entry(es).State = System.Data.Entity.EntityState.Added;
                         db.SaveChanges();
                     }
                 }
                 dgvAlunos.Rows.Clear();
                 MessageBox.Show("Aluno cadastrado com sucesso!!! ", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 txtNome.Focus();
             }
         }
         catch (Exception err)
         {
             MessageBox.Show("Erro " + err, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Nenhum Aluno cadastrado!! ", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
     }
 }