コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (Request.Params["id"] != null)
                {
                    CriptQuery.SecureQueryString qs = new SecureQueryString(Request["id"]);
                    string _email = qs["email"];

                    AlunoDTO dto = new AlunoDTO();
                    dto.situacao = "A";
                    dto.email    = _email;

                    AlunoBRL brl = new AlunoBRL();

                    DataTable dtAluno = brl.searchAlunoByEmail(dto);

                    if (dtAluno != null && dtAluno.Rows.Count > 0)
                    {
                        if (brl.updateAlunoSituacao(dto))
                        {
                            lblResultado.Text = "E-mail " + _email + " do aluno(a) ativado(a) com sucesso.";
                        }
                        else
                        {
                            lblResultado.Text = "Erro ao ativar e-mail. Tente novamente ou entre em contato conosco.";
                        }
                    }
                    else
                    {
                        lblResultado.Text = "Aluno(a) não existente. Entre em contato conosco pelo link Contato";
                    }
                }
            }
        }
コード例 #2
0
        protected void cmdCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                lblResultado.Text = "";
                if (Page.IsValid)
                {
                    if (BEPiD.Business.Util.Validacao.IsValidCPF(txtCPF.Text))
                    {
                        AlunoDTO dto = new AlunoDTO();
                        dto.agencia     = txtAgencia.Text;
                        dto.nome        = txtNome.Text;
                        dto.bancoNome   = txtNomeBanco.Text;
                        dto.bancoNumero = txtNrBanco.Text;
                        dto.celular     = txtCelular.Text;
                        dto.cidade      = txtCidade.Text;
                        dto.conta       = txtConta.Text;
                        dto.cpf         = txtCPF.Text;
                        //dto.dataNascimento = Convert.ToDateTime(txtDataNascimento.Text.Replace("/", "-"));
                        dto.email            = txtEmail.Text;
                        dto.endereco         = txtEndereco.Text;
                        dto.estado           = cmbEstado.Text;
                        dto.identidade       = txtIdentidade.Text;
                        dto.nome             = txtNome.Text;
                        dto.nomeUniversidade = txtUniversidade.Text;
                        dto.orgao            = txtOrgao.Text;
                        //dto.password = cript2.code.business.SimpleCripto.Encrypt(txtPassword.Text + txtEmail.Text.Substring(0, 2), System.Configuration.ConfigurationManager.AppSettings["cript2Hash"].ToString());
                        dto.telefone      = txtTelefone.Text;
                        dto.cep           = txtCEP.Text;
                        dto.estadoCivil   = cmbEstadoCivil.SelectedValue.ToString();
                        dto.nacionalidade = txtNacionalidade.Text;
                        //dto.dataDeExpedicao = Convert.ToDateTime(txtDataExpedicao.Text.Replace("/", "-"));

                        //pegando idaluno
                        //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];
                        dto.idAluno = int.Parse(Session["IAluno"].ToString());

                        AlunoBRL _brl = new AlunoBRL();
                        if (_brl.updateAluno(dto))
                        {
                            //enviando e-mail de cadastro
                            //enviadEmailAdministradores();

                            //enviado e-mail para o usuário
                            //enviadEmailAtivacao();

                            Response.Redirect("DadosPessoais?Situacao=1");
                        }
                    }
                    else
                    {
                        lblResultado.Text = "Digite um CPF válido.";
                    }
                }
            }
            catch (Exception ex)
            {
                lblResultado.Text = "Ops! Um erro aconteceu! - " + ex.Message.ToString() + "<Br>" + ex.StackTrace.ToString();
            }
        }
コード例 #3
0
        protected void cmdBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                AlunoDTO dto = new AlunoDTO();

                if (txtNome.Text.Length > 0)
                {
                    dto.nome = txtNome.Text;
                }

                if (txtAno.Text.Length > 0)
                {
                    dto.ano = int.Parse(txtAno.Text);
                }

                if (!cmbSituacao.SelectedValue.Equals(""))
                {
                    dto.situacao = cmbSituacao.SelectedValue.ToString();
                }

                AlunoBRL  brl = new AlunoBRL();
                DataTable dt  = brl.searchAlunosGeral(dto);
                grdAluno.DataSource = dt;
                grdAluno.DataBind();

                calculaTotal(dt);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #4
0
        protected void cmdLogin_Click(object sender, EventArgs e)
        {
            try
            {
                AlunoDTO dto = new AlunoDTO();
                dto.password = cript2.code.business.SimpleCripto.Encrypt(txtPassword.Text + hdEmail.Value.Substring(0, 2), System.Configuration.ConfigurationManager.AppSettings["cript2Hash"].ToString());

                if (!String.IsNullOrEmpty(hdId.Value))
                {
                    dto.idAluno = int.Parse(hdId.Value);
                }

                dto.email    = hdEmail.Value;
                dto.situacao = "A";

                AlunoBRL brl = new AlunoBRL();
                if (brl.updateAlunoSenhaByEmaileId(dto))
                {
                    lblResultado.Text = "Senha alterada com sucesso. <br>Favor acessar o link <a href='Login'>Login</a> para entrar no sistema.";
                    desabilitaCampos();
                }
                else
                {
                    lblResultado.Text = "Erro ao tentar mudar a senha, entrar em contato com o administrador";
                }
            }
            catch (Exception ex)
            {
                lblResultado.Text = "Erro aconteceu. <br> " + ex.ToString();
            }
        }
コード例 #5
0
        public async Task <IActionResult> PutAluno(int id, AlunoDTO alunoDTO)
        {
            var aluno = await _context.Aluno.FindAsync(id);

            if (aluno == null)
            {
                return(NotFound());
            }

            aluno.Nome   = alunoDTO.Nome;
            aluno.Rua    = alunoDTO.Rua;
            aluno.Numero = alunoDTO.Numero;
            aluno.Bairro = alunoDTO.Bairro;
            aluno.Cidade = alunoDTO.Cidade;
            aluno.Estado = alunoDTO.Estado;
            aluno.Curso  = alunoDTO.Curso;

            _context.Entry(aluno).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException) when(!AlunoExists(id))
            {
                return(NotFound());
            }

            return(NoContent());
        }
コード例 #6
0
        public void Post(AlunoDTO aluno)
        {
            Validar(aluno);
            var alunoDTO = _mapper.Map <AlunoDTO, Aluno>(aluno);

            _aluno.Salvar(alunoDTO);
        }
コード例 #7
0
        public async Task <IActionResult> Put([FromBody] AlunoDTO aluno, int id)
        {
            var responseContent = new ResponseContent();

            if (id != aluno.IDAluno)
            {
                responseContent.Message = "Inconsistencia na informação enviada.";
                return(BadRequest(responseContent));
            }

            try
            {
                await _alunoBLL.UpdateAlunoAsync(new Aluno(IDAluno : aluno.IDAluno, NMAluno : aluno.NMAluno, Email : aluno.Email, Senha : aluno.Senha, SNEnviaEmail : aluno.SNEnviaEmail, SNAtivo : aluno.SNAtivo));

                responseContent.Message = "Cadastro do aluno alterado com sucesso!!";
                return(Ok(responseContent));
            }
            catch (BusinessException bex)
            {
                responseContent.Message = bex.Message;
                return(BadRequest(responseContent));
            }
            catch (Exception ex)
            {
                responseContent.Message = ex.Message;
                return(BadRequest(responseContent));
            }
        }
コード例 #8
0
 public Boolean verifyCPFAndEmail(AlunoDTO dto)
 {
     try
     {
         DataTable dtTotal = _alunoDAO.verifyCPFAndEmail(dto);
         if (dtTotal != null && dtTotal.Rows.Count > 0)
         {
             if (dtTotal.Rows[0][0].ToString().Equals("0"))
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         var metodo = this.GetType().FullName + "." + System.Reflection.MethodBase.GetCurrentMethod().Name.ToString();
         var classe = this.GetType().Name.ToString();
         throw new Exception("Atenção: aconteceu um erro na classe: " + classe + " e método: " + metodo + ", tente novamente. <Br> Erro: " + ex.Message.ToString() + ex.Source.ToString() + ex.StackTrace.ToString() + ex.Source.ToString(), ex.InnerException);
     }
 }
コード例 #9
0
        private void preencherGridAluno()
        {
            //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];
            if (Session != null && !Session["S"].Equals("P")) //0 é para os administradores
            {
                AlunoDTO dto = new AlunoDTO();
                dto.idAluno = int.Parse(Session["I"].ToString());

                AlunoBRL  brl = new AlunoBRL();
                DataTable dt  = brl.searchDadosPrincipais(dto);
                grdDadosAluno.DataSource = dt;
                grdDadosAluno.DataBind();

                if (dt != null && dt.Rows.Count > 0)
                {
                    //if (!String.IsNullOrEmpty(dt.Rows[0]["Numero"].ToString()))
                    txtNumero.Text = dt.Rows[0]["Numero"].ToString();
                    String imagem = dt.Rows[0]["Foto"].ToString();
                    if (!String.IsNullOrEmpty(imagem))
                    {
                        lblImagem.Text          = "<img src='http://s3.amazonaws.com/BEPiD/" + imagem + "' style='border-radius:20px; width:200px;'/>";
                        cmdEnviarImagem.Visible = false;
                    }
                }
            }
            else
            {
                //pnlAdministrativo.Visible = true;
                //this.MasterPageFile = "~/Adm.Master";
            }
        }
コード例 #10
0
        public RecuperaSenhaDTO EnviarEmailEsqueciSenha(string identificador, Aplicacoes aplicacao)
        {
            Cliente cliente = new Cliente();
            var filtro = new AlunoDTO();
            var recupera = new RecuperaSenhaDTO();
            recupera.Validacao = ValidaRecuperaSenha.Inexistente;

            if (Utilidades.IsValidEmail(identificador))
            {
                filtro.Email = identificador;
            }
            else
            {
                filtro.Register = identificador;
            }

            var aluno = _clienteDataRepository.GetAlunoPorFiltros(filtro);

            if (aluno != null && aluno.Id != default(int))
            {
                cliente.Register = aluno.Register;
                var result = _clienteDataRepository.UpdateEsqueciSenha(cliente, aplicacao);
                recupera.Validacao = result.Key > default(int) ? ValidaRecuperaSenha.EmailEnviado : ValidaRecuperaSenha.Inexistente;
            }

            return recupera;
        }
        protected void cmdVerificar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    AlunoDTO dto = new AlunoDTO();
                    dto.ano = DateTime.Now.Year + 1;
                    dto.cpf = txtCPF.Text.Replace(".", "").Replace("-", "");

                    AlunoBRL brl     = new AlunoBRL();
                    var      dtAluno = brl.searchAlunoByCPF(dto);

                    if (dtAluno != null && dtAluno.Rows.Count > 0)
                    {
                        lblResultado.ControlStyle.ForeColor = System.Drawing.Color.Blue;
                        lblResultado.Text = "PARABÉNS: Seu CPF está cadastrado no processo seletivo.";
                    }
                    else
                    {
                        lblResultado.ControlStyle.ForeColor = System.Drawing.Color.Red;
                        lblResultado.Text = "Seu CPF não está cadastrado no processo seletivo do ano " + dto.ano;
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    lblResultado.Visible = true;
                }
            }
        }
コード例 #12
0
        public void BuildResource(object resource, HttpRequestMessage request)
        {
            AlunoDTO dto = resource as AlunoDTO;

            if (dto == null)
            {
                throw new ArgumentException($"Era esperado um AlunoDTO, porém, foi enviado um {resource.GetType().Name}");
            }
            UrlHelper urlHelper     = new UrlHelper(request);
            string    alunoDTORoute = urlHelper.Link("DefaultApi", new { controller = "Alunos", id = dto.ID });

            dto.Links.Add(new RestLink
            {
                Rel  = "self",
                Href = alunoDTORoute
            });
            dto.Links.Add(new RestLink
            {
                Rel  = "edit",
                Href = alunoDTORoute
            });
            dto.Links.Add(new RestLink
            {
                Rel  = "delete",
                Href = alunoDTORoute
            });
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //HttpCookie Session = Request.Cookies["BEPiDUCB.Site"];

                if (Session == null || Session["I"].ToString().Equals("0"))
                {
                    Response.Redirect("Login");
                }
                else
                {
                    int idAluno = int.Parse(Session["I"].ToString());

                    AlunoDTO dto = new AlunoDTO();
                    dto.idAluno = idAluno;

                    BEPiD.Business.BRL.AlunoBRL alunoBRL = new Business.BRL.AlunoBRL();
                    DataTable dtAluno = alunoBRL.searchDadosPrincipais(dto);

                    if (dtAluno != null && dtAluno.Rows.Count > 0)
                    {
                        Session.Add("Endereco", dtAluno.Rows[0]["endereco"].ToString());
                        Session.Add("Cidade", dtAluno.Rows[0]["cidade"].ToString());
                        Session.Add("Estado", dtAluno.Rows[0]["Estado"].ToString());
                        Session.Add("CEP", dtAluno.Rows[0]["CEP"].ToString());
                        Session.Add("Identidade", dtAluno.Rows[0]["Identidade"].ToString());
                        Session.Add("Orgao", dtAluno.Rows[0]["orgao"].ToString());
                        Session.Add("Nacionalidade", dtAluno.Rows[0]["Nacionalidade"].ToString());
                        Session.Add("EstadoCivil", dtAluno.Rows[0]["EstadoCivil"].ToString());
                    }
                }
            }
        }
コード例 #14
0
ファイル: AlunoDAO.cs プロジェクト: robsonalves87/WebApp
        public void AtualizarAlunoDB(AlunoDTO aluno)
        {
            try
            {
                IDbCommand updateCmd = conexao.CreateCommand();
                updateCmd.CommandText = "update Alunos set Nome = @Nome, Sobrenome = @Sobrenome, Telefone = @Telefone, RA = @RA where Id = @Id";

                IDbDataParameter paramId        = new SqlParameter("Id", aluno.Id);
                IDbDataParameter paramNome      = new SqlParameter("Nome", aluno.Nome);
                IDbDataParameter paramSobrenome = new SqlParameter("Sobrenome", aluno.Sobrenome);
                IDbDataParameter paramTelefone  = new SqlParameter("Telefone", aluno.Telefone);
                IDbDataParameter paramRA        = new SqlParameter("RA", aluno.RA);

                updateCmd.Parameters.Add(paramId);
                updateCmd.Parameters.Add(paramNome);
                updateCmd.Parameters.Add(paramSobrenome);
                updateCmd.Parameters.Add(paramTelefone);
                updateCmd.Parameters.Add(paramRA);

                updateCmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
コード例 #15
0
        // PUT: api/Aluno/5
        public IHttpActionResult Put(int id, [FromBody] AlunoDTO value)
        {
            value.Id = id;
            _alunoService.Update(value);

            return(Ok());
        }
コード例 #16
0
        public IHttpActionResult Atualizar(int id, [FromBody] AlunoDTO aluno)
        {
            try
            {
                AlunoModel _aluno = new AlunoModel();

                var alunoExiste = _aluno.ListarAlunos().FirstOrDefault(a => a.id == id);

                if (alunoExiste == null)
                {
                    return(NotFound());
                }
                else
                {
                    aluno.id = id;
                    _aluno.Atualizar(aluno);

                    return(Ok(_aluno.ListarAlunos(id)));
                }
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
コード例 #17
0
ファイル: AlunoDAO.cs プロジェクト: robsonalves87/WebApp
        public void InserirAlunoDB(AlunoDTO aluno)
        {
            try
            {
                IDbCommand insertCmd = conexao.CreateCommand();
                insertCmd.CommandText = "insert into Alunos (Nome, Sobrenome, Telefone, RA) values (@Nome, @Sobrenome, @Telefone, @RA)";

                IDbDataParameter paramNome      = new SqlParameter("Nome", aluno.Nome);
                IDbDataParameter paramSobrenome = new SqlParameter("Sobrenome", aluno.Sobrenome);
                IDbDataParameter paramTelefone  = new SqlParameter("Telefone", aluno.Telefone);
                IDbDataParameter paramRA        = new SqlParameter("RA", aluno.RA);

                insertCmd.Parameters.Add(paramNome);
                insertCmd.Parameters.Add(paramSobrenome);
                insertCmd.Parameters.Add(paramTelefone);
                insertCmd.Parameters.Add(paramRA);

                insertCmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
コード例 #18
0
        public void AtualizarAlunoDB(AlunoDTO aluno)
        {
            try
            {
                IDbCommand updateCmd = conexao.CreateCommand();
                updateCmd.CommandText = "UPDATE Alunos SET nome = @nome, sobrenome = @sobrenome, telefone = @telefone, registro = @registro WHERE id = @id";

                // Referenciando os parametros
                IDbDataParameter paramId = new SqlParameter("id", aluno.id);
                updateCmd.Parameters.Add(paramId);

                IDbDataParameter paramNome = new SqlParameter("nome", aluno.nome);
                updateCmd.Parameters.Add(paramNome);

                IDbDataParameter paramSobronome = new SqlParameter("sobrenome", aluno.sobrenome);
                updateCmd.Parameters.Add(paramSobronome);

                IDbDataParameter paramTelefone = new SqlParameter("telefone", aluno.telefone);
                updateCmd.Parameters.Add(paramTelefone);

                IDbDataParameter paramRegistro = new SqlParameter("registro", aluno.registro);
                updateCmd.Parameters.Add(paramRegistro);

                updateCmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
コード例 #19
0
        private void preencherGridAluno()
        {
            if (Session["SAluno"] != null)
            {
                if (Session["SAluno"].Equals("A"))
                {
                    AlunoDTO dto = new AlunoDTO();
                    dto.idAluno = int.Parse(Session["IAluno"].ToString());

                    AlunoBRL  brl = new AlunoBRL();
                    DataTable dt  = brl.searchDadosPrincipais(dto);
                    grdDadosAluno.DataSource = dt;
                    grdDadosAluno.DataBind();

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        //if (!String.IsNullOrEmpty(dt.Rows[0]["Numero"].ToString()))
                        txtNumero.Text = dt.Rows[0]["Numero"].ToString();
                        String imagem = dt.Rows[0]["Foto"].ToString();
                        if (!String.IsNullOrEmpty(imagem))
                        {
                            lblImagem.Text          = "<img src='http://s3.amazonaws.com/BEPiD/" + imagem + "' style='border-radius:20px; width:200px;'/>";
                            cmdEnviarImagem.Visible = false;
                        }
                    }
                }
            }
        }
コード例 #20
0
        public void AtualizarAlunoBD(AlunoDTO aluno)
        {
            try
            {
                IDbCommand updateCMD = conexao.CreateCommand();
                updateCMD.CommandText = "update Alunos set nome = @nome, sobrenome = @sobrenome, telefone = @telefone, ra = @ra where Id=@ID";

                IDbDataParameter parmNome      = new SqlParameter("nome", aluno.Nome);
                IDbDataParameter parmSobreNome = new SqlParameter("sobrenome", aluno.Sobrenome);
                IDbDataParameter parmTelefone  = new SqlParameter("telefone", aluno.Telefone);
                IDbDataParameter parmRa        = new SqlParameter("ra", aluno.Ra);

                updateCMD.Parameters.Add(parmNome);
                updateCMD.Parameters.Add(parmSobreNome);
                updateCMD.Parameters.Add(parmTelefone);
                updateCMD.Parameters.Add(parmRa);

                IDbDataParameter parmID = new SqlParameter("ID", aluno.Id);
                updateCMD.Parameters.Add(parmID);

                updateCMD.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
コード例 #21
0
        public void AtualizarAlunoDB(AlunoDTO aluno)
        {
            try
            {
                IDbCommand update = conexao.CreateCommand();
                update.CommandText = "update Alunos set nome = @nome, sobrenome = @sobrenome, telefone = @telefone, ra = @ra where id = @id";

                IDbDataParameter paramNome = new SqlParameter("nome", aluno.nome);
                update.Parameters.Add(paramNome);

                IDbDataParameter paramSobrenome = new SqlParameter("Sobrenome", aluno.sobrenome);
                update.Parameters.Add(paramSobrenome);

                IDbDataParameter paramTelefone = new SqlParameter("telefone", aluno.telefone);
                update.Parameters.Add(paramTelefone);

                IDbDataParameter paramRa = new SqlParameter("ra", aluno.ra);
                update.Parameters.Add(paramRa);


                IDbDataParameter paramId = new SqlParameter("id", aluno.id);
                update.Parameters.Add(paramId);

                update.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
コード例 #22
0
        public async Task <IActionResult> PutAtivo([FromBody] AlunoDTO aluno, int id)
        {
            var responseContent = new ResponseContent();

            if (id != aluno.IDAluno)
            {
                responseContent.Message = "Inconsistencia na informação enviada.";
                return(BadRequest(responseContent));
            }

            try
            {
                var msg = await _alunoBLL.UpdateStatusAlunoAsync(aluno.IDAluno, aluno.SNAtivo);

                if (!msg.Equals(""))
                {
                    responseContent.Message = msg;
                    return(BadRequest(responseContent));
                }

                responseContent.Message = "Cadastro do aluno alterado com sucesso!!";
                return(Ok(responseContent));
            }
            catch (BusinessException bex)
            {
                responseContent.Message = bex.Message;
                return(BadRequest(responseContent));
            }
            catch (Exception ex)
            {
                responseContent.Message = ex.Message;
                return(BadRequest(responseContent));
            }
        }
コード例 #23
0
        public void InserirAlunoDB(AlunoDTO aluno)
        {
            try
            {
                IDbCommand insert = conexao.CreateCommand();
                insert.CommandText = "insert into Alunos (nome,sobrenome, telefone, ra) values (@nome,@sobrenome,@telefone,@ra)";

                IDbDataParameter paramNome = new SqlParameter("nome", aluno.nome);
                insert.Parameters.Add(paramNome);

                IDbDataParameter paramSobrenome = new SqlParameter("Sobrenome", aluno.sobrenome);
                insert.Parameters.Add(paramSobrenome);

                IDbDataParameter paramTelefone = new SqlParameter("telefone", aluno.telefone);
                insert.Parameters.Add(paramTelefone);

                IDbDataParameter paramRa = new SqlParameter("ra", aluno.ra);
                insert.Parameters.Add(paramRa);

                insert.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                conexao.Close();
            }
        }
コード例 #24
0
        public void BuildResouce(object resource, HttpRequestMessage request)
        {
            AlunoDTO alunoDTO = resource as AlunoDTO;

            if (alunoDTO == null)   //Tenta fazer o cash - Não consegue lidar com esse DTO
            {
                throw new ArgumentException($"Era esperado um AlunoDTO, foi enviado um {resource.GetType().Name}");
            }

            UrlHelper urlHelper     = new UrlHelper(request);
            string    alunoDTORoute = urlHelper.Link("DefaultApi", new { Controller = "Alunos", id = alunoDTO.id }); //Basear na rota nomeada como 'DefaultApi'

            alunoDTO.Links.Add(new RestLink {
                Rel  = "self", //Recuperar o próprio DTO
                Href = alunoDTORoute
            });
            alunoDTO.Links.Add(new RestLink {
                Rel  = "edit",
                Href = alunoDTORoute
            });
            alunoDTO.Links.Add(new RestLink {
                Rel  = "delete",
                Href = alunoDTORoute
            });
        }
コード例 #25
0
ファイル: AlunoDAO.cs プロジェクト: tiagorockman/MVC-ASP-NET
        public void InserirAlunoDB(AlunoDTO aluno)
        {
            try
            {
                IDbCommand insertdbCommand = connection.CreateCommand();
                insertdbCommand.CommandText = "Insert into TB_ALUNOS (nome, sobrenome, telefone, data, RA) values (@nome, @sobrenome, @telefone, @data, @RA)";

                IDbDataParameter parameterNome = new SqlParameter("nome", aluno.nome);
                insertdbCommand.Parameters.Add(parameterNome);
                IDbDataParameter parameterSobrenome = new SqlParameter("sobrenome", aluno.sobrenome);
                insertdbCommand.Parameters.Add(parameterSobrenome);
                IDbDataParameter parameterTel = new SqlParameter("telefone", aluno.telefone);
                insertdbCommand.Parameters.Add(parameterTel);
                IDbDataParameter parameterData = new SqlParameter("data", aluno.data);
                insertdbCommand.Parameters.Add(parameterData);
                IDbDataParameter parameterRA = new SqlParameter("RA", aluno.RA);
                insertdbCommand.Parameters.Add(parameterRA);

                insertdbCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                connection.Close();
                connection.Dispose();
            }
        }
コード例 #26
0
        public void Excluir(AlunoDTO dto)
        {
            dal.Conectar();

            string query = "Delete from Turma where id = " + dto.Id;

            dal.ExecutarComandoSQL(query);
        }
コード例 #27
0
        public AlunoDTO GetAluno()
        {
            AlunoDTO alunoSelecionado = listAlunos.SelectedItem as AlunoDTO;

            alunoSelecionado = _alunoService.GetById(alunoSelecionado.Id);

            return(alunoSelecionado);
        }
コード例 #28
0
        public List <AlunoDTO> consultarAlunosporMateria(MateriaDTO objDTO)
        {
            //Abrir conexão
            abrirConexao();

            //Parâmetros de comando
            SqlCommand objComandoSQL = new SqlCommand();

            objComandoSQL.Connection = obterConexao();

            objComandoSQL.CommandType = CommandType.Text;
            string strComando;

            strComando = "SELECT Aluno.idAluno, Aluno.nomeAluno, AlunoMateria.semestre FROM ";
            strComando = strComando + "Aluno INNER JOIN AlunoMateria ON Aluno.idAluno = AlunoMateria.idAluno ";
            //strComando = strComando + "WHERE AlunoMateria.idMateria = ";

            if (objDTO != null)
            {
                strComando = strComando + "WHERE AlunoMateria.idMateria = " + objDTO.idMateria;
            }
            strComando = strComando + " ORDER BY Aluno.nomeAluno ";
            objComandoSQL.CommandText = strComando;

            SqlDataReader objLeitorConsulta = objComandoSQL.ExecuteReader();

            List <AlunoDTO> listaRetorno;

            if (objLeitorConsulta.HasRows)
            {
                listaRetorno = new List <AlunoDTO>();
                AlunoDTO objLinhaRegistroDTO;

                //Fazer o loop nos resultados da consulta
                while (objLeitorConsulta.Read())
                {
                    objLinhaRegistroDTO           = new AlunoDTO();
                    objLinhaRegistroDTO.idAluno   = int.Parse(objLeitorConsulta["idAluno"].ToString());
                    objLinhaRegistroDTO.nomeAluno = objLeitorConsulta["nomeAluno"].ToString();
                    objLinhaRegistroDTO.semestre  = objLeitorConsulta["semestre"].ToString();

                    listaRetorno.Add(objLinhaRegistroDTO);
                }
                //Console.WriteLine(objLeitorConsulta["usuario"]);
                //Console.WriteLine(objLeitorConsulta["senha"]);
                //retorno = true;
            }
            else
            {
                //Retornar vazio
                listaRetorno = null;
            }

            //Fechar conexão
            fecharConexao();

            return(listaRetorno);
        }
コード例 #29
0
        protected void lnkEsqueceuASenha_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                try
                {
                    if (!String.IsNullOrEmpty(txtUsuario.Text))
                    {
                        AlunoDTO dto = new AlunoDTO();
                        dto.email    = txtUsuario.Text;
                        dto.situacao = "A";

                        AlunoBRL  brl     = new AlunoBRL();
                        DataTable dtEmail = brl.searchAlunoByEmail(dto);

                        if (dtEmail != null && dtEmail.Rows.Count > 0)
                        {
                            CriptQuery.SecureQueryString qs = new SecureQueryString();
                            qs["Email"] = txtUsuario.Text;
                            qs["Id"]    = dtEmail.Rows[0]["IdAluno"].ToString();
                            //qs["Tipo"] = "Professor";


                            string[] emails = new string[1];
                            emails[0] = txtUsuario.Text;

                            //string _pw = cript2.code.business.SimpleCripto.Decrypt(dtEmail.Rows[0]["PWProfessor"].ToString(), System.Configuration.ConfigurationManager.AppSettings["cript2Hash"].ToString());

                            StringBuilder str = new StringBuilder();
                            str.Append(@" Segue o link abaixo para alterar a senha solicitada através do sistema BEPiD UCB. <br>
                                      Lembre-se de nunca passar a sua senha para ninguém, toda senha 
                                        é confidencial e intransferível. ");

                            str.Append(@" <Br><Br> Acesse o link ou copie cole no browser: http://aluno.bepiducb.com.br/LoginAlterarSenha?e=" + qs.ToString() + " <br> e digite nova senha.");
                            str.Append(@" <Br><Br> Em caso de dúvidas, entre em contato conosco pelo menu Contato");

                            BEPiD.Business.Util.EmailEnvio.enviaEmail(emails, "E-mail automático de senha - aluno.bepiducb.com.br", str.ToString());

                            lblResultado.Text = "Foi enviado para seu e-mail.";
                        }
                        else
                        {
                            lblResultado.Text = "O e-mail não está cadastrado, entrar em contato com o administrador.";
                        }
                    }
                    else
                    {
                        lblResultado.Text = "Favor, digite o seu e-mail no campo de e-mail para verificação!";
                        txtUsuario.Focus();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
コード例 #30
0
ファイル: AlunoService.cs プロジェクト: Artbraga/api-ctep
        public AlunoDTO SalvarAluno(AlunoDTO alunoDto)
        {
            var transaction = this.alunoRepository.GetTransaction();

            try
            {
                Aluno aluno;
                if (alunoDto.Id.HasValue)
                {
                    aluno                = alunoRepository.GetById(alunoDto.Id.Value);
                    aluno.Nome           = alunoDto.Nome;
                    aluno.RG             = alunoDto.RG;
                    aluno.CPF            = alunoDto.CPF;
                    aluno.OrgaoEmissor   = alunoDto.OrgaoEmissor;
                    aluno.Sexo           = alunoDto.Sexo;
                    aluno.Naturalidade   = alunoDto.Naturalidade;
                    aluno.Naturalidade   = alunoDto.Naturalidade;
                    aluno.NomePai        = alunoDto.NomePai;
                    aluno.NomeMae        = alunoDto.NomeMae;
                    aluno.Endereco       = alunoDto.Endereco;
                    aluno.CEP            = alunoDto.CEP;
                    aluno.Bairro         = alunoDto.Bairro;
                    aluno.Cidade         = alunoDto.Cidade;
                    aluno.Complemento    = alunoDto.Complemento;
                    aluno.DataMatricula  = alunoDto.DataMatricula;
                    aluno.DataNascimento = alunoDto.DataNascimento;
                    aluno.DataValidade   = alunoDto.DataValidade;
                    aluno.Telefone       = alunoDto.Telefone;
                    aluno.Celular        = alunoDto.Celular;
                    aluno.Email          = alunoDto.Email;
                    aluno.CursoAnterior  = alunoDto.CursoAnterior;
                }
                else
                {
                    aluno             = alunoDto.ToEntity();
                    aluno.TurmasAluno = new List <TurmaAluno>();
                    alunoRepository.Add(aluno);
                }
                alunoRepository.SaveChanges();

                transaction.Commit();
                transaction.Dispose();

                return(new AlunoDTO(alunoRepository.GetById(aluno.Id)));
            }
            catch (Exception ex)
            {
                transaction.Rollback();
                transaction.Dispose();
                if (ex.InnerException.Message.Contains("cpf_UNIQUE"))
                {
                    throw new BusinessException("Já existe um aluno com o CPF cadastrado.");
                }
                log.Error("Erro ao salvar aluno.", ex);
                throw new BusinessException("Erro desconhecido ao salvar aluno.");
            }
        }