private void dgvTurmas_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgvTurmasCadastro.Columns[e.ColumnIndex].Name == "btnHorario") { frmHorarios frmHorario = new frmHorarios(Convert.ToInt32(dgvTurmasCadastro.Rows[dgvTurmasCadastro.CurrentRow.Index].Cells["ID_TURMA_CADASTRO"].Value.ToString()), dgvTurmasCadastro.Rows[dgvTurmasCadastro.CurrentRow.Index].Cells["NOME_MODALIDADE"].Value.ToString(), dgvTurmasCadastro.Rows[dgvTurmasCadastro.CurrentRow.Index].Cells["numeroTurmaCadastro"].Value.ToString()); frmHorario.ShowDialog(); } bloqueaCadastro(); }
private void dgvTurma_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvTurma.Columns[e.ColumnIndex].Name == "btnEditar") { txtCodigo.Text = dgvTurma.Rows[e.RowIndex].Cells["ID_TURMA"].Value.ToString(); txtAluno.Text = dgvTurma.Rows[e.RowIndex].Cells["MAXIMO_ALUNOS"].Value.ToString(); txtTurma.Text = dgvTurma.Rows[e.RowIndex].Cells["NUMERO_TURMA"].Value.ToString(); cbxModalidade.Text = dgvTurma.Rows[e.RowIndex].Cells["NOME_MODALIDADE"].Value.ToString(); } else { if (dgvTurma.Columns[e.ColumnIndex].Name == "btnExcluir" && MessageBox.Show("Deseja realmente excluir??", "Excluir", MessageBoxButtons.YesNo) == DialogResult.Yes) { novaTurma = new Turma(); novaTurma.excluir(Convert.ToInt32(dgvTurma.Rows[e.RowIndex].Cells["ID_TURMA"].Value.ToString())); MessageBox.Show("Excluido com sucesso!!"); listarTurma(); } else { //abrir o formulario de horarios if (dgvTurma.Columns[e.ColumnIndex].Name == "btnHorario" && MessageBox.Show("Deseja cadastrar Horario para essa turma?", "Cadastrar", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { frmHorarios frm = new frmHorarios(Convert.ToInt32(dgvTurma.Rows[e.RowIndex].Cells["ID_TURMA"].Value), dgvTurma.Rows[e.RowIndex].Cells["NOME_MODALIDADE"].Value.ToString(), dgvTurma.Rows[e.RowIndex].Cells["NUMERO_TURMA"].Value.ToString()); frm.ShowDialog(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }