示例#1
0
        private void dgvDisciplinas_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 3)
                {
                    DiciplinaModel diciplina = dgvDisciplinas.CurrentRow.DataBoundItem as DiciplinaModel;
                    frmInicial.Current.OpenScreen(new frmDisciplinasCadastrar(diciplina));
                    Hide();
                }
                if (e.ColumnIndex == 4)
                {
                    DialogResult resposta = MessageBox.Show("Deseja realmente remover essa informação?", "NSF",
                                                            MessageBoxButtons.YesNo,
                                                            MessageBoxIcon.Question);

                    if (resposta == DialogResult.Yes)
                    {
                        DiciplinaModel diciplina = dgvDisciplinas.CurrentRow.DataBoundItem as DiciplinaModel;
                        API.Remover(diciplina.IdDisciplina);
                        dgvDisciplinas.DataSource = API.ListarTudo();
                        MessageBox.Show("Disciplina removida!", "NSF", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message, "NSF", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception)
            {
                MessageBox.Show("Ocorreu um erro. Entre em contato com o administrador.", "NSF", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
 public frmDisciplinasConsultar()
 {
     InitializeComponent();
     API = new API.Client.DisciplinaAPI();
     dgvDisciplinas.AutoGenerateColumns = false;
     dgvDisciplinas.DataSource          = API.ListarTudo();
 }