private void txtMatricula_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtMatricula.Text)) { try { int id = Convert.ToInt32(txtId.Text); Aluno aluno = new AlunosRepositorio().ObterPeloCodigo(id); if (aluno != null) { PreencherCampos(aluno); } else { MessageBox.Show("Registro não existe"); txtId.Focus(); txtId.SelectionStart = 0; txtId.SelectionLength = txtId.Text.Length; } } catch (NotFiniteNumberException ex) { MessageBox.Show("Digite um código válido"); txtId.Focus(); txtId.SelectionStart = 0; txtId.SelectionLength = txtId.Text.Length; } } }
private void CadastroDeAlunos_Load(object sender, EventArgs e) { double totalContas = new AlunosRepositorio().ObterMedia(codigo); label8.Text = Convert.ToString(totalContas); double frequenciaDoAluno = new AlunosRepositorio().ObterFrequencia(codigo); double MediaAux = 0; string situacaoAluno = string.Empty; if (frequenciaDoAluno <= 65) { situacaoAluno = "Reprovado por frequência"; } if (totalContas < 5) { MediaAux = totalContas; situacaoAluno = "Reprovado por média"; } else if (totalContas < 7) { MediaAux = totalContas; situacaoAluno = "Exame"; } else if (totalContas >= 7) { MediaAux = totalContas; situacaoAluno = "Aprovado"; } label10.Text = Convert.ToString(situacaoAluno); }
private void btnSalvar_Click(object sender, EventArgs e) { Aluno aluno = new Aluno(); aluno.Nome = txtNome.Text; aluno.Matricula = txtMatricula.Text; aluno.Nota1 = Convert.ToDouble(txtNota1.Text); aluno.Nota2 = Convert.ToDouble(txtNota2.Text); aluno.Nota3 = Convert.ToDouble(txtNota3.Text); if (string.IsNullOrEmpty(txtId.Text)) { int cadastrou = new AlunosRepositorio().Inserir(aluno); txtId.Text = Convert.ToString(cadastrou); MessageBox.Show("Registro cadastrado com sucesso"); } else { int id = Convert.ToInt32(txtId.Text); aluno.Id = id; bool alterou = new AlunosRepositorio().Alterear(aluno); if (alterou) { MessageBox.Show("Registro alterado com sucesso"); } else { MessageBox.Show("Não foi possível alterar"); } } }
public ActionResult Excluir(int id) { bool apagado = new AlunosRepositorio().Excluir(id); ViewBag.TituloPagina = "Aluno - Apagar"; return(null); }
private void btnCadastrar_Click(object sender, EventArgs e) { Alunos aluno = new Alunos(); aluno.Nome = txtNome.Text; aluno.Matricula = txtNumeroDaMatricula.Text; aluno.Nota_01 = Convert.ToDouble(txtNota1.Text); aluno.Nota_02 = Convert.ToDouble(txtNota2.Text); aluno.Nota_03 = Convert.ToDouble(txtNota3.Text); aluno.Frequencia = Convert.ToInt32(txtFrequencia.Text); if (string.IsNullOrEmpty(txtCodigo.Text)) { int id = new AlunosRepositorio().Inserir(aluno); txtCodigo.Text = Convert.ToString(id); MessageBox.Show("O aluno " + aluno.Nome + " foi cadastrado com sucesso"); } else { int id = Convert.ToInt32(txtCodigo.Text); aluno.Id = id; bool alterou = new AlunosRepositorio().Alterar(aluno); if (alterou) { MessageBox.Show("Registro alterado com sucesso"); } else { MessageBox.Show("Não foi possível alterar"); } } }
private void txtCodigo_Leave(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtCodigo.Text)) { try { int id = Convert.ToInt32(txtCodigo.Text); Alunos aluno = new AlunosRepositorio().ObterAlunosPorCodigo(id); if (aluno != null) { PreencherCampos(aluno); } else { MessageBox.Show("Código não é existente"); txtCodigo.Focus(); txtCodigo.SelectionStart = 0; txtCodigo.SelectionLength = txtCodigo.Text.Length; } } catch { MessageBox.Show("Digite um código válido"); txtCodigo.Focus(); } } }
private void button1_Click(object sender, EventArgs e) { Alunos alunos = new Alunos() { Nome = txtNome.Text, Matricula = txtMatricula.Text, Nota01 = Convert.ToDouble(txtNota01.Text), Nota02 = Convert.ToDouble(txtNota02.Text), Nota03 = Convert.ToDouble(txtNota03.Text), Frequencia = Convert.ToInt32(txtFrequencia.Text) }; if (string.IsNullOrWhiteSpace(txtCodigo.Text)) { int id = new AlunosRepositorio().Inserir(alunos); txtCodigo.Text = id.ToString(); MessageBox.Show("Registro cadastrado com sucesso."); } else { int id = Convert.ToInt32(txtCodigo.Text); alunos.Id = id; bool alterou = new AlunosRepositorio().Alterar(alunos); if (alterou) { MessageBox.Show("Registro alterado com sucesso"); LimparCampos(); } else { MessageBox.Show("Não foi possível alterar"); } } }
public CadastroAluno(int codigo) { InitializeComponent(); this.codigo = codigo; Aluno aluno = new AlunosRepositorio().ObterPeloCodigo(codigo); PreencherCampos(aluno); }
public ActionResult Editar(int id) { Alunos aluno = new AlunosRepositorio().ObterPeloID(id); ViewBag.Aluno = aluno; ViewBag.TituloPaginas = "Alunos - Editar"; return(View()); }
public ActionResult Index() { List <Alunos> alunos = new AlunosRepositorio().ObterTodos(); ViewBag.Alunos = alunos; ViewBag.TituloPaginas = "Alunos"; return(View()); }
public AlunosController( AlunosRepositorio alunosRepositorio, TurmasRepositorio turmasRepositorio, InscricoesRepositorio inscricoesRepositorio) { _alunosRepositorio = alunosRepositorio; _turmasRepositorio = turmasRepositorio; _inscricoesRepositorio = inscricoesRepositorio; }
private void atualizarLista() { string coluna = "nome"; if (rbNome.Checked) { coluna = "nome"; } else if (rbNota1.Checked) { coluna = "nota_1"; } else if (rbNota2.Checked) { coluna = "nota_2"; } else if (rbNota3.Checked) { coluna = "nota_3"; } string ordenacao = "ASC"; if (rbASC.Checked) { ordenacao = "ASC"; } else { ordenacao = "DESC"; } dataGridView1.Rows.Clear(); List <Aluno> alunos = new AlunosRepositorio().ObterTodos (txtPesquisa.Text, coluna, ordenacao); foreach (Aluno aluno in alunos) { dataGridView1.Rows.Add(new object[] { aluno.Id, aluno.Nome, aluno.Matricula, aluno.Nota1, aluno.Nota2, aluno.Nota3, aluno.Media }); } }
private void btnExcluir_Click(object sender, EventArgs e) { int linhaSelecionada = dataGridView1.CurrentRow.Index; int codigo = Convert.ToInt32(dataGridView1.Rows[linhaSelecionada].Cells[0].Value.ToString()); bool excluido = new AlunosRepositorio().Apagar(codigo); if (excluido) { dataGridView1.Rows.RemoveAt(linhaSelecionada); MessageBox.Show("Registro excluido com sucesso"); } else { MessageBox.Show("Não foi possível apagar"); } }
private void AtualizarLista() { dataGridView1.Rows.Clear(); string pesquisa = ""; List <Alunos> alunos = new AlunosRepositorio().ObterTodosOsAlunos(textBox1.Text); foreach (Alunos aluno in alunos) { dataGridView1.Rows.Add(new object[] { aluno.Id, aluno.Nome, aluno.Matricula, aluno.Nota_01, aluno.Nota_02, aluno.Nota_03 }); } }
public ActionResult Update(Alunos aluno) { bool alterado = new AlunosRepositorio().Alterar(aluno); return(null); }
public ActionResult Store(Alunos aluno) { int identificador = new AlunosRepositorio().Cadastrar(aluno); return(RedirectToAction("Index", new { id = identificador })); }