Exemplo n.º 1
0
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            //Preencher o objeto da BLL com o conteudo da UI.
            aluno.Ra    = txtRa.Text;
            aluno.Nome  = txtNome.Text;
            aluno.Cpf   = txtCpf.Text;
            aluno.Idade = int.Parse(txtIdade.Text);

            if (atualizar)
            {
                alunoDAL.Atualizar(aluno);
                MessageBox.Show("Aluno cadastrado!");
                btnCadastrar.Text   = "Cadastrar";
                atualizar           = false;
                txtRa.ReadOnly      = false;
                btnCancelar.Visible = false;
            }

            else
            {
                //Enviar para o Cadastrar da camada DAL
                alunoDAL.Cadastrar(aluno);
                MessageBox.Show("Aluno cadastrado!");
            }


            txtRa.Clear();
            txtNome.Clear();
            txtCpf.Clear();
            txtIdade.Clear();
            txtRa.Focus();
        }
Exemplo n.º 2
0
        protected void btnAtualizar_Click(object sender, EventArgs e)
        {
            try
            {
                aluno.Ra   = Convert.ToInt32(txtRa.Text);
                aluno.Nome = txtNome.Text;
                aluno.Cpf  = txtCpf.Text;

                alunoDAL.Atualizar(aluno);

                txtRa.Text   = "";
                txtNome.Text = "";
                txtCpf.Text  = "";

                Response.Write("<script>alert('Atualizado')</script>");
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('Erro')</script>");
                Response.Write("<div>" + ex.Message + "</div>");
            }
        }
Exemplo n.º 3
0
        private void btnCadastrar_Click_1(object sender, EventArgs e)
        {
            alu.Nome           = txtNomeAlu.Text;
            alu.Cpf            = txtCpfAlu.Text;
            alu.Rg             = txtRgAlu.Text;
            alu.Email          = txtEmailAlu.Text;
            alu.DataNascimento = Convert.ToDateTime(mtxtDataNascimentoAlu.Text);

            if (editar == false)
            {
                aluDAL.Cadastrar(alu);
            }
            else
            {
                aluDAL.Atualizar(alu);
            }

            MessageBox.Show("Dados Gravados com Sucesso!");

            dgvConsulta.DataSource = aluDAL.ConsultarTodos();
            limpar();
        }