private void dgvAluno_CellContentClick(object sender, DataGridViewCellEventArgs e) { using (ControleAcademiaContexto contexto = new ControleAcademiaContexto()) { var row = rowsExibidas[e.RowIndex]; var id = Convert.ToInt32(row[row.Length - 1]); var aluno = contexto.Alunos.Include("Ciclos.Meses").FirstOrDefault(x => x.Id == id); if (e.ColumnIndex == 1) { var newAluno = new NewAluno(aluno.Id); newAluno.ShowDialog(); CarregarTabela(); AtualizarTabela(); } else if (e.ColumnIndex == 2) { var activateAluno = new ActivateAluno(aluno.Nome, aluno.Id); activateAluno.ShowDialog(); CarregarTabela(); AtualizarTabela(); } else { var meses = aluno.Ciclos.LastOrDefault().Meses.OrderByDescending(x => x.Data).ToList(); if (14 - (e.ColumnIndex) < meses.Count) { var mes = meses.ElementAt(14 - (e.ColumnIndex)); var confirmacaoPagamento = new ConfirmacaoPagamento(aluno.Nome, mes.Id); confirmacaoPagamento.ShowDialog(); CarregarTabela(); AtualizarTabela(); } } } }
private void btnNovo_Click(object sender, EventArgs e) { var newAluno = new NewAluno(); newAluno.ShowDialog(); CarregarTabela(); AtualizarTabela(); }