Esempio n. 1
0
 private void buttonCadastrar_Click(object sender, EventArgs e)
 {
     try
     {
         Aluno a = new Aluno();
         a.Matricula = Int32.Parse(textBoxMatricula.Text.Trim());
         a.Nome      = textBoxNome.Text;
         AlunoBD dados = new AlunoBD();
         dados.Insert(a);
         MessageBox.Show("Aluno cadastrado com sucesso");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         AlunoBD dados = new AlunoBD();
         Aluno   a     = new Aluno()
         {
             Matricula = Int32.Parse(textBoxMatricula.Text),
             Nome      = textBoxNome.Text
         };
         dados.Insert(a);
         MessageBox.Show("Aluno cadastrado com sucesso");
     }
     catch (Exception ex)
     {
     }
 }
Esempio n. 3
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         AlunoBD dados = new AlunoBD();
         this.retorno = dados.Select(new Aluno());
         //limpar o listView
         listView1.Items.Clear();
         foreach (Aluno a in this.retorno)
         {
             //valor para a primeira coluna
             ListViewItem item = listView1.Items.Add(a.Matricula.ToString());
             item.SubItems.Add(a.Nome);
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Esempio n. 4
0
 private void buttonListar_Click(object sender, EventArgs e)
 {
     try
     {
         AlunoBD dados  = new AlunoBD();
         Aluno   filtro = new Aluno();
         if (textBoxMatricula.Text.Trim().Equals("") == false)
         {
             filtro.Matricula = Int32.Parse(textBoxMatricula.Text.Trim());
         }
         filtro.Nome = textBoxNome.Text;
         listaAlunos = dados.Select(filtro);
         listViewAlunos.Items.Clear();
         foreach (Aluno a in listaAlunos)
         {
             ListViewItem linha = listViewAlunos.Items.Add(a.Matricula.ToString());
             linha.SubItems.Add(a.Nome);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }