Example #1
0
 private void Btn_remover_Click(object sender, EventArgs e)
 {
     // deletar aluno
     try
     {
         int      idAluno = Convert.ToInt32(txt_idAluno.Text);
         AlunoDao aluno   = new AlunoDao();
         if (MessageBox.Show("Você realmente deseja deletar a matrícula do aluno? ", "Deletar aluno", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             if (aluno.deletarAluno(idAluno))
             {
                 MessageBox.Show("Matrícula excluída", "Excluir matricula", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 //limpa textbox
                 txt_idAluno.Clear();
                 txt_nome.Clear();
                 mascara_telefone.Clear();
                 dtBox_nascimento.Value = DateTime.Now;
                 pctb_foto.Image        = null;
                 mascara_cep.Clear();
                 txt_rua.Clear();
                 txt_bairro.Clear();
                 textBox_numero.Clear();
                 txt_cidade.Clear();
                 txt_estado.Clear();
             }
             else
             {
                 MessageBox.Show("Insira um ID na caixa de texto!", "ID Inválido", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     catch
     {
         MessageBox.Show("Insira um ID na caixa de texto!", "Deletar matrícula", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }