Ejemplo n.º 1
0
        protected void btnGravar_Click(object sender, EventArgs e)
        {
            string IdAluno    = txtUsuId.Value;
            int    AlunoRA    = Convert.ToInt32(txtRA.Text);
            string Nome       = txtNome.Text;
            string Curso      = txtCurso.Text;
            string Sexo       = txtSexo.Text;
            string Email      = txtEmail.Text;
            string CPF        = txtCPF.Text;
            string Telefone   = txtTelefone.Text;
            string Nascimento = Convert.ToDateTime(txtNascimento.Text).ToString("yyyy-MM-dd");


            AlunoDAO alunoDAO = new AlunoDAO();

            if (IdAluno == "")
            {
                bool Validar = alunoDAO.ValidarEmail(Email);
                if (Validar)
                {
                    DivErro.InnerHtml = "Email já cadastrado para outro aluno";
                    return;
                }
                else
                {
                    alunoDAO.InserirAlunos(AlunoRA, Nome, Curso, Sexo, Email, CPF, Telefone, Nascimento);
                }
            }
            else
            {
                alunoDAO.AtualizarAlunos(Convert.ToInt32(IdAluno), AlunoRA, Nome, Curso, Sexo, Email, CPF, Telefone, Nascimento);
            }

            txtRA.Text         = "";
            txtNome.Text       = "";
            txtCurso.Text      = "";
            txtSexo.Text       = "";
            txtEmail.Text      = "";
            txtCPF.Text        = "";
            txtTelefone.Text   = "";
            txtNascimento.Text = "";


            MontarGrid();
            DivGrid.Visible = true;
            DivForm.Visible = false;

            return;
        }