Beispiel #1
0
 private void btnExcluir_Click(object sender, EventArgs e)
 {
     if (tbAluno.SelectedIndex == 0)
     {
         tbAluno.SelectTab(1);
     }
     if (MessageBox.Show("Confirma exclusão?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
     {
         Aluno RegAluno = new Aluno();
         RegAluno.RaAluno        = Convert.ToInt32(txtRA.Text);
         RegAluno.NomeAluno      = txtNome.Text;
         RegAluno.CidadeIdcidade = Convert.ToInt16(cbAlunoCidade.SelectedValue);
         if (RegAluno.Excluir() > 0)
         {
             MessageBox.Show("Aluno excluído com sucesso!");
             Aluno R = new Aluno();
             dsAluno.Tables.Clear();
             dsAluno.Tables.Add(R.Listar());
             bnAluno.DataSource = dsAluno.Tables["TBALUNO"];
         }
         else
         {
             MessageBox.Show("Erro ao excluir aluno!");
         }
     }
 }
Beispiel #2
0
        private void btnExcluir_Click_1(object sender, EventArgs e)
        {
            if (tabControlAluno.SelectedIndex == 0)
            {
                tabControlAluno.SelectTab(1);
            }


            if (MessageBox.Show("Confirma exclusão?", "Yes or No", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                Aluno RegAlu = new Aluno();

                RegAlu.RaAluno   = Convert.ToInt16(txtRa.Text);
                RegAlu.NomeAluno = txtNomeAluno.Text;
                MessageBox.Show(cbxCidade.SelectedItem.ToString());
                RegAlu.CidadeIdCidade = Convert.ToInt16(cbxCidade.SelectedValue);

                if (RegAlu.Excluir() > 0)
                {
                    MessageBox.Show("Aluno excluído com sucesso!");
                    Cidade R = new Cidade();
                    dsAluno.Tables.Clear();
                    dsAluno.Tables.Add(R.Listar());
                    bnAluno.DataSource = dsAluno.Tables["TBAluno"];
                }
                else
                {
                    MessageBox.Show("Erro ao excluir aluno!");
                }
            }
        }