private void alunosDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex == -1 || e.ColumnIndex == -1) { return; } if (e.ColumnIndex == adicionar_aulas.Index) { FormAdicionarAulas f4 = new FormAdicionarAulas(ref tableAdapterManager, ref alunosBindingSource, ref database_alunosDataSet, ref alunosTableAdapter, e.RowIndex, ref TravaAtualizacao); f4.ShowDialog(); } else if (e.ColumnIndex == editar.Index) { FormEditarAluno f3 = new FormEditarAluno(ref tableAdapterManager, ref alunosBindingSource, ref database_alunosDataSet, ref alunosTableAdapter, ref TravaAPI, ref TravaAtualizacao, e.RowIndex); f3.ShowDialog(); } else if (e.ColumnIndex == deletar.Index) { DataRowView aluno = (DataRowView)alunosBindingSource[e.RowIndex]; if (MessageBox.Show("Você tem certeza que deseja deletar todas as informações dess" + utilidades.adeq(aluno, utilidades.adeqSituacoes.ae) + " alun" + utilidades.adeq(aluno, utilidades.adeqSituacoes.ao) + "? Se apenas torná-lo inativo, suas informações não serão deletadas, mas também não poderá entrar na academia.", "Deseja deletar esse aluno?", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { lock (TravaAtualizacao) { alunosBindingSource.RemoveAt(e.RowIndex); this.Validate(); this.alunosBindingSource.EndEdit(); this.tableAdapterManager.UpdateAll(this.database_alunosDataSet); } } } }
private void botaoadicionar_Click(object sender, EventArgs e) { FormEditarAluno f2 = new FormEditarAluno(ref tableAdapterManager, ref alunosBindingSource, ref database_alunosDataSet, ref alunosTableAdapter, ref TravaAPI, ref TravaAtualizacao); f2.ShowDialog(); }