public static void Main(string[] args) { var vizu = new Aluno() { Nome = "Joao Vizu", Ra = "N300361", NotaB1 = 7.5M, NotaB2 = 10M }; var lais = new AlunoTecnologo() { Nome = "Lais Silva", Ra = "545454", NotaB1 = 7.5M, NotaB2 = 10M, NotaPim = 9M }; var dao = new AlunoDao(); dao.Adicionar(vizu); dao.Adicionar(lais); foreach (Aluno aluno in dao.Listar()) { WriteLine($"Nome: {aluno.Nome}\tNotaB1: {aluno.NotaB1}\tNotaB2: {aluno.NotaB2}\tMedia: {aluno.Media}"); } }
public ActionResult Index() { ViewBag.Alunos = AlunoDao.BuscaAlunosMaior16(); ViewBag.Professores = ProfessorDao.BuscaProfessorMedia15_17(); return(View()); }
// GET: Aluno public ActionResult Form(string professorId = "") { var professor = ProfessorDao.BuscaPorId(Convert.ToInt32(professorId)); if ((TempData["idAluno"] != null) && (!string.IsNullOrEmpty(TempData["idAluno"].ToString()))) { ViewBag.Aluno = AlunoDao.BuscaPorId(Convert.ToInt32(TempData["idAluno"].ToString())); } else { ViewBag.Aluno = new Aluno(professor); } if (TempData["mensagem"] != null) { ViewBag.Mensagem = TempData["mensagem"].ToString(); } else { ViewBag.Mensagem = string.Empty; } ViewBag.Alunos = AlunoDao.BuscaAlunosProfessor(Convert.ToInt32(professorId)); ViewBag.Professor = ProfessorDao.BuscaPorId(Convert.ToInt32(professorId)); return(View()); }
public ActionResult AlunoLinqCursoTurma(int idAluno, int idCurso, int idTurma, int idPlanoPagamento) { try { int id = idAluno; int curso = idCurso; int turma = idTurma; int planoPagamento = idPlanoPagamento; var erros = AlunoDao.validate(curso, turma); if (erros.Count == 0) { Aluno update = AlunoDao.Find(id); update.Curso = curso; update.Turma = turma; update.PlanoPagamento = planoPagamento; AlunoDao.SaveUpdateAll(); SessionHelper.AddMensagemToView("Aluno atualizado com sucesso"); return(RedirectToAction("Index", "Aluno")); } ViewBag.erros = erros; SessionHelper.AddMensagemToView("Revise os campos destacados", MensagemDTO.EnumTipoMensagem.info); return(View()); } catch (System.Exception) { throw; } }
public ActionResult AdicionarOuSalvar(Aluno aluno) { try { AlunoDao AlunoDao = new AlunoDao(); if (aluno.Id > 0) { AlunoDao.Atualizar(aluno); TempData["mensagem"] = "Registro alterado com sucesso"; } else { AlunoDao.Adicionar(aluno); TempData["mensagem"] = "Cadastrado com sucesso"; } return(RedirectToAction("Form", "Aluno", new { @professorId = aluno.ProfessorId.ToString() })); } catch (Exception e) { TempData.Add("mensagem", e.Message); return(RedirectToAction("Form", "Aluno", new { @professorId = aluno.ProfessorId.ToString() })); } }
public JsonResult DeleteAluno(long ID) { Aluno labUpdate = AlunoDao.FindAllByIDAluno(ID); AlunoDao.Delete(labUpdate); return(Json("Response from Delete")); }
public int ObterQtdeDeAlunos() { _alunoDao = new AlunoDao(); Int32 qtde_Alunos = _alunoDao.ConsultarQtdeDeAlunos(); return(qtde_Alunos); }
public JsonResult getAlunoDetails(int userId) { IList <Aluno> FoodList = new List <Aluno>(); FoodList = AlunoDao.FindAllByIDs(userId); return(Json(new { FoodList = FoodList }, JsonRequestBehavior.AllowGet)); }
private void btnBuscarMatricula_Click(object sender, RoutedEventArgs e) { var AlunoDao = new AlunoDao(); var pesquisa = AlunoDao.BuscaAluno(EntradaMatricula.Text); EscreveTela(pesquisa); }
public ActionResult Edit(int IdAluno) { Aluno aluno = AlunoDao.FindAllByIDAluno(IdAluno); ViewBag.ID = IdAluno; ViewBag.erros = new List <string>(); return(View(new AlunoDTO(aluno))); }
private void Btn_salvarmatricula_Click(object sender, EventArgs e) { EnderecoDao enDao = new EnderecoDao(); AlunoDao aluno = new AlunoDao(); ResponsavelDao resp = new ResponsavelDao(); TelefoneDao telDao = new TelefoneDao(); String responsavel = textBox_nomeResponsavel.Text; String telefone = mascara_telefone.Text; String cep = mascara_cep.Text; String rua = txt_rua.Text; String bairro = txt_bairro.Text; int numero = 0; if (textBox_numero.Text.Trim() != "") { numero = Convert.ToInt32(textBox_numero.Text); } String cidade = txt_cidade.Text; String uf = txt_estado.Text; String nome = txt_nome.Text; DateTime nascimento = dtBox_nascimento.Value; // String telefone = txt_telefone.Text; String genero = "M"; if (rd_btn_generoFem.Checked) { genero = "F"; } MemoryStream fot = new MemoryStream(); int countSucesso = 0; // checando idade de aluno ( 5 a 100 anos) int ano_nasc = dtBox_nascimento.Value.Year; int ano_atual = DateTime.Now.Year; if (LimitesCaracteresAceitos()) { if ((ano_atual - ano_nasc) < 5 || (ano_atual - ano_nasc) > 100) { MessageBox.Show("O aluno deve ter entre 5 e 100 anos", "Data de ascimento inválida", MessageBoxButtons.OK, MessageBoxIcon.Error); } else // adicionar aluno no banco if (VerificaCampoVazio()) { AdicionarAlunoControle adicionarAluno = new AdicionarAlunoControle(); adicionarAluno.SalvaMatricula(nome, nascimento, genero, fot, responsavel, cep, rua, bairro, numero, cidade, uf, telefone); } else { MessageBox.Show("Preencha todos os campos ", "Cadastro de aluno", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
/// <summary> /// Verifica se existe um aluno com o mesmo cpf /// </summary> /// <param name="cpf"></param> /// <returns></returns> public static bool ExisteAlunoComCPF(string cpf) { var existe = false; if (AlunoDao.FindByCpf(cpf) != null) { existe = true; } return(existe); }
private void Btn_procurarId_Click(object sender, EventArgs e) { if (txt_idAluno.Text.Trim() != "") { //buscar Aluno por id int idAluno = int.Parse(txt_idAluno.Text); try { AlunoDao aluno = new AlunoDao(); SqlCommand cmd = new SqlCommand("SELECT A.ID, A.NOME, A.NASCIMENTO, A.GENERO, A.FOTO FROM ALUNO A WHERE A.IDALUNO = " + idAluno); DataTable tabela = aluno.getAlunos(cmd); if (tabela.Rows.Count > 0) { txt_idAluno.Text = tabela.Rows[0]["IdAluno"].ToString(); txt_nome.Text = tabela.Rows[0]["Nome"].ToString(); dtBox_nascimento.Value = (DateTime)tabela.Rows[0]["Nascimento"]; if (tabela.Rows[0]["Genero"].ToString() == "F") { rd_btn_generoFem.Checked = true; } else { rd_btn_generoMasc.Checked = true; } // mascara_telefone.Text = tabela.Rows[0]["Telefone"].ToString(); byte[] foto = (byte[])tabela.Rows[0]["Foto"]; MemoryStream imagem = new MemoryStream(foto); pctb_foto.Image = Image.FromStream(imagem); // mascara_cep.Text = tabela.Rows[0]["Cep"].ToString(); /* txt_rua.Text = tabela.Rows[0]["Rua"].ToString(); * txt_bairro.Text = tabela.Rows[0]["Bairro"].ToString(); * textBox_numero.Text = tabela.Rows[0]["Numero"].ToString(); * txt_cidade.Text = tabela.Rows[0]["Cidade"].ToString(); * txt_estado.Text = tabela.Rows[0]["UF"].ToString();*/ } else { MessageBox.Show("O ID informado não existe no banco", "Erro ao Deletar aluno", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Erro ao consultar no banco de dados", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Informe ante um id", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void AlterarStatusAluno(int id, String status) { _alunoDao = new AlunoDao(); var linhasAfetadas = _alunoDao.AtualizaStatusAluno(id, status); if (linhasAfetadas == 0) { throw new AlunoNaoAtualizadoException(); } }
public void ExcluirAluno(int id) { _alunoDao = new AlunoDao(); var linhasAfetadas = _alunoDao.ExcluiAluno(id); if (linhasAfetadas == 0) { throw new AlunoNaoExcluidoException(); } }
public bool consultarAluno(Aluno aluno) { if (aluno.Id > 0) { AlunoDao alunoDao = new AlunoDao(); return(alunoDao.consultar(aluno)); } else { return(false); } }
public void InserirNovoAluno(Aluno aluno) { _alunoDao = new AlunoDao(); ValidarAluno(aluno); var linhasAfetadas = _alunoDao.InserirAluno(aluno); if (linhasAfetadas == 0) { throw new AlunoNaoCadastradoException(); } }
public AlunoController(AlunoDao alunoDao, LivroDAO livroDAO, ItemEmprestimoDao itemEmprestimoDao, FuncionarioDAO funcionarioDao, SignInManager <FuncionarioLogado> signInManager, UserManager <FuncionarioLogado> userManager) { _userManager = userManager; _signInManager = signInManager; _livroDAO = livroDAO; _alunoDao = alunoDao; _itemEmprestimoDao = itemEmprestimoDao; _funcionarioDAO = funcionarioDao; }
public ActionResult Alterar(string alunoId) { var aluno = AlunoDao.BuscaPorId(Convert.ToInt32(alunoId)); try { TempData["idAluno"] = alunoId; return(RedirectToAction("Form", "Aluno", new { @professorId = aluno.ProfessorId.ToString() })); } catch (Exception e) { TempData["mensagem"] = "Erro ao editar o professor" + e.Message; return(RedirectToAction("Form", "Aluno", new { @professorId = aluno.ProfessorId.ToString() })); } }
public DataTable Listar() { try { AlunoDao alunoDao = new AlunoDao(); DataTable dt = new DataTable(); dt = alunoDao.Listar(); return(dt); } catch (Exception) { throw; } }
public DataTable PesquisarNome(AlunoModel aluno) { try { AlunoDao alunoDao = new AlunoDao(); DataTable dt = new DataTable(); dt = alunoDao.BuscarNome(aluno); return(dt); } catch (Exception) { throw; } }
public void inserirAluno(Aluno aluno) { //Objeto alunoDao ira levar os dados do objeto aluno para a camada Modelo AlunoDao alunoDao = new AlunoDao(); if (alunoDao.inserir(aluno)) { MessageBox.Show("Aluno Cadastrado com Sucesso"); } else { MessageBox.Show("Aluno Não Cadastrada"); } alunoDao = null; }
public ActionResult Excluir(string alunoId) { var aluno = AlunoDao.BuscaPorId(Convert.ToInt32(alunoId)); try { var alunoDao = new AlunoDao(); alunoDao.ExcluirId(Int32.Parse(alunoId)); return(RedirectToAction("Form", "Aluno", new { @professorId = aluno.ProfessorId.ToString() })); } catch (Exception e) { TempData["mensagem"] = e.Message; return(RedirectToAction("Form", "Aluno", new { @professorId = aluno.ProfessorId.ToString() })); } }
public ActionResult Create(AlunoDTO aluno) { var erros = aluno.validate(); if (erros.Count == 0) { Aluno usuario = aluno.ParseToAluno(); AlunoDao.Save(usuario); SessionHelper.AddMensagemToView("Aluno criado com sucesso"); return(RedirectToAction("Index", "Aluno")); } ViewBag.erros = erros; SessionHelper.AddMensagemToView("Revise os campos destacados", MensagemDTO.EnumTipoMensagem.info); return(View(aluno)); }
public void excluirAluno(Aluno aluno) { if (aluno.Id > 0) { AlunoDao alunoDao = new AlunoDao(); if (alunoDao.excluir(aluno)) { MessageBox.Show("Dados exluidos com Sucesso"); } else { MessageBox.Show("Dados não excluidos"); } } else { MessageBox.Show("Dados invalidos"); } }
static void Main(string[] args) { var alunoDao = new AlunoDao(); var aluno1 = new Aluno(); //aluno1.Nome = "Paulo"; //aluno1.Nota1 = 9; //aluno1.Nota2 = 8; //aluno1.Nota3 = 7; //aluno1.Nota4 = 6; //aluno1.Media = (aluno1.Nota1 + aluno1.Nota2 + aluno1.Nota3 + aluno1.Nota4) / 4; //alunoDao.Insert(aluno1); aluno1.Id = 3; Console.WriteLine(alunoDao.Select(aluno1)); //aluno1.Nome = "Carlos"; //alunoDao.Update(aluno1); //aluno1.Id = 2; //alunoDao.Delete(aluno1); }
private void Btn_remover_Click(object sender, EventArgs e) { // deletar aluno try { int idAluno = Convert.ToInt32(txt_idAluno.Text); AlunoDao aluno = new AlunoDao(); if (MessageBox.Show("Você realmente deseja deletar a matrícula do aluno? ", "Deletar aluno", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (aluno.deletarAluno(idAluno)) { MessageBox.Show("Matrícula excluída", "Excluir matricula", MessageBoxButtons.OK, MessageBoxIcon.Information); //limpa textbox txt_idAluno.Clear(); txt_nome.Clear(); mascara_telefone.Clear(); dtBox_nascimento.Value = DateTime.Now; pctb_foto.Image = null; mascara_cep.Clear(); txt_rua.Clear(); txt_bairro.Clear(); textBox_numero.Clear(); txt_cidade.Clear(); txt_estado.Clear(); } else { MessageBox.Show("Insira um ID na caixa de texto!", "ID Inválido", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch { MessageBox.Show("Insira um ID na caixa de texto!", "Deletar matrícula", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// GET: Aluno public ActionResult Index() { return(View(AlunoDao.FindAll())); }
public void SalvaMatricula(String nome, DateTime nascimento, String genero, MemoryStream fot, String responsavel, String cep, String rua, String bairro, int numero, String cidade, String uf, String numTelefone) { AlunoDao alunoDao = new AlunoDao(); ResponsavelDao respDao = new ResponsavelDao(); EnderecoDao endDao = new EnderecoDao(); TelefoneDao telDao = new TelefoneDao(); int countSucesso = 0; if ((alunoDao.inserirAluno(nome, nascimento, genero, fot))) { countSucesso += 1; int idAluno = Convert.ToInt32(alunoDao.getIdAluno()); if (respDao.inserirResponsavel(responsavel, idAluno)) { countSucesso += 1; int idResponsavel = Convert.ToInt32(respDao.GetIdResponsavel()); if ((endDao.inserirEndereco(cep, rua, bairro, numero, cidade, uf))) { countSucesso += 1; int idEndereco = Convert.ToInt32(endDao.GetIdEndereco()); if (endDao.AssociaEnderResponsavel(idResponsavel, idEndereco)) { countSucesso += 1; int idTelefone = Convert.ToInt32(telDao.GetIdTelefone()); if (telDao.InserirTelefone(numTelefone)) { countSucesso += 1; if (telDao.AssociaTelefoneResponsavel(idResponsavel, idTelefone)) { countSucesso += 1; if (countSucesso == 6) { MessageBox.Show("Aluno cadastrado ", "Cadastro de aluno", MessageBoxButtons.OK, MessageBoxIcon.Information); LimpaCampos(); } } else { MessageBox.Show("Erro ao associar telefone ao responsavel", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Erro ao cadastrar telefone do responsavel", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Erro ao associar endereco ao responsavel", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Erro ao inserir endereco do responsavel", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Erro ao inserir responsavel ", "Cadastro de aluno", MessageBoxButtons.OK, MessageBoxIcon.Error); // Endereco endereco = new Endereco(); } } else { MessageBox.Show("Erro ao associar telefone ao responsavel", "erro", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <Aluno> ObterTodosOsAlunos(String pesquisa) { _alunoDao = new AlunoDao(); return(_alunoDao.ConsultarTodosOsAlunos(pesquisa)); }