Example #1
0
        private void Incluir_Click(object sender, EventArgs e)
        {
            if (Incluir.Text.Equals("Incluir"))
            {
                Incluir.Text = "Salvar";
                LimpaFormulario();
                txtID.Enabled = false;
                txtNome.Focus();
            }
            else if (Incluir.Text.Equals("Salvar"))
            {
                Incluir.Text  = "Incluir";
                txtID.Enabled = true;
                try
                {
                    Aluno aluno = new Aluno();

                    aluno.Nome     = txtNome.Text;
                    aluno.Endereco = txtEndereco.Text;
                    aluno.Email    = txtEmail.Text;
                    aluno.Telefone = txtTelefone.Text;
                    aluno.Status   = txtStatus.Text;
                    aluno.Turma    = txtStatus.Text;

                    DalHelper.Add(aluno);
                    CarregaDados();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Erro : " + ex.Message);
                }
            }
        }
Example #2
0
 private void CarregaDados()
 {
     cboAlunos.DataSource    = DalHelper.GetAlunos();
     cboAlunos.ValueMember   = "AlunoId";
     cboAlunos.DisplayMember = "Nome";
     cboAlunos.Text          = "selecione o aluno";
     LimpaFormulario();
 }
Example #3
0
        private void cboAlunos_SelectedIndexChanged(object sender, EventArgs e)
        {
            Aluno aluno = new Aluno();

            codigoAluno = Convert.ToInt32(((DataRowView)cboAlunos.SelectedItem)["AlunoId"]);

            aluno = DalHelper.GetAluno(codigoAluno);
            PreencheDados(aluno);
        }
Example #4
0
 private void Deletar_Click(object sender, EventArgs e)
 {
     try
     {
         DalHelper.Delete(codigoAluno);
         CarregaDados();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Erro : " + ex.Message);
     }
 }
Example #5
0
        private void Alterar_Click(object sender, EventArgs e)
        {
            try
            {
                Aluno aluno = new Aluno();

                aluno.AlunoId  = Convert.ToInt32(txtID.Text);
                aluno.Nome     = txtNome.Text;
                aluno.Endereco = txtEndereco.Text;
                aluno.Email    = txtEmail.Text;
                aluno.Telefone = txtTelefone.Text;
                aluno.Status   = txtStatus.Text;
                aluno.Turma    = txtTurma.Text;

                DalHelper.Update(aluno);
                CarregaDados();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro : " + ex.Message);
            }
        }