Search in sources :

Example 16 with RelatorioDAO

use of br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO in project Loja_Agencia_De_Viagens by ArtCouSan.

the class AlteraClienteServlet method doPost.

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    ClienteService service = new ClienteService();
    ClienteDAO dao = new ClienteDAO();
    RelatorioDAO relatorioDAO = new RelatorioDAO();
    RelatorioMudancas relatorio = new RelatorioMudancas();
    String nome = request.getParameter("nome");
    String sexo = request.getParameter("sexo");
    String data_nasc = request.getParameter("nascimento");
    String telefone = request.getParameter("telefone");
    String celular = request.getParameter("celular");
    String email = request.getParameter("email");
    int numero = Integer.parseInt(request.getParameter("numero"));
    String cep = request.getParameter("cep");
    String rua = request.getParameter("rua");
    String estado = request.getParameter("estado");
    String cidade = request.getParameter("cidade");
    String complemento = request.getParameter("complemento");
    int id = Integer.parseInt(request.getParameter("identificacao"));
    request.setAttribute("erroNome", service.validaNome(nome));
    request.setAttribute("erroNascimento", service.validaNascimento(data_nasc));
    request.setAttribute("erroRua", service.validaRua(rua));
    request.setAttribute("erroNumero", service.validaNumero(numero));
    request.setAttribute("erroCep", service.validaCep(cep));
    request.setAttribute("erroCidade", service.validaCidade(cidade));
    request.setAttribute("erroEmail", service.validaEmail(email));
    Cliente cliente = new Cliente(nome.trim(), sexo.trim(), data_nasc.trim(), numero, cep.trim(), rua.trim(), estado.trim(), cidade.trim(), complemento.trim(), celular.trim(), telefone.trim(), email.trim(), true);
    cliente.setId(id);
    try {
        if (service.validaCliente(nome, sexo, rua, numero, cep, cidade, email)) {
            try {
                Cliente clientes = dao.getClienteById(id);
                request.setAttribute("clientes", clientes);
            } catch (ClassNotFoundException | SQLException e) {
            }
            RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/EditarCliente.jsp");
            dispatcher.forward(request, response);
        } else {
            try {
                dao.alterar(cliente);
                HttpSession sessao = request.getSession();
                int identificacaoF = (int) sessao.getAttribute("id_func");
                relatorio.setId_func(identificacaoF);
                relatorio.setMudanca("Alteração de cliente efetuada!");
                relatorioDAO.inserir(relatorio);
                response.sendRedirect(request.getContextPath() + "/inicio");
            } catch (Exception ex) {
                Logger.getLogger(AlteraClienteServlet.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    } catch (SQLException | ClassNotFoundException ex) {
        Logger.getLogger(AlteraClienteServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : SQLException(java.sql.SQLException) HttpSession(javax.servlet.http.HttpSession) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SQLException(java.sql.SQLException) ClienteService(br.senac.tads3.pi03b.gruposete.services.ClienteService) ClienteDAO(br.senac.tads3.pi03b.gruposete.dao.ClienteDAO) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) Cliente(br.senac.tads3.pi03b.gruposete.models.Cliente)

Example 17 with RelatorioDAO

use of br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO in project Loja_Agencia_De_Viagens by ArtCouSan.

the class CadastroVooServlet method doPost.

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    VooService service = new VooService();
    VooDAO dao = new VooDAO();
    RelatorioDAO relatorioDAO = new RelatorioDAO();
    RelatorioMudancas relatorio = new RelatorioMudancas();
    String origem = request.getParameter("origem");
    String destino = request.getParameter("destino");
    String data_ida = request.getParameter("data_ida");
    String data_volta = request.getParameter("data_volta");
    int quantidade_passagens = Integer.parseInt(request.getParameter("quantidade_passagens"));
    float preco = Float.parseFloat(request.getParameter("preco"));
    request.setAttribute("erroOrigem", service.validaOrigem(origem));
    request.setAttribute("erroDestino", service.validaDestino(destino));
    request.setAttribute("erroData_ida", service.validaIda(data_ida));
    request.setAttribute("erroData_volta", service.validaVolta(data_volta));
    request.setAttribute("erroQuantidade_passagens", service.validaQuantidade_passagens(quantidade_passagens));
    request.setAttribute("erroPreco", service.validaPreco(preco));
    Voo voo = new Voo(data_ida, data_volta, destino, origem, quantidade_passagens, preco, true);
    if (service.validaVoo(origem.trim(), destino.trim(), data_ida.trim(), data_volta.trim(), quantidade_passagens, preco)) {
        RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/CadastroVoo.jsp");
        dispatcher.forward(request, response);
    } else {
        try {
            dao.inserir(voo);
            HttpSession sessao = request.getSession();
            int identificacaoF = (int) sessao.getAttribute("id_func");
            relatorio.setId_func(identificacaoF);
            relatorio.setMudanca("Cadastro de vôo efetuado!");
            relatorioDAO.inserir(relatorio);
            response.sendRedirect(request.getContextPath() + "/inicio");
        } catch (Exception ex) {
            Logger.getLogger(CadastroVooServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) Voo(br.senac.tads3.pi03b.gruposete.models.Voo) VooService(br.senac.tads3.pi03b.gruposete.services.VooService) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) VooDAO(br.senac.tads3.pi03b.gruposete.dao.VooDAO) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 18 with RelatorioDAO

use of br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO in project Loja_Agencia_De_Viagens by ArtCouSan.

the class ExcluiClienteServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String action = request.getParameter("action");
    ClienteDAO daoCliente = new ClienteDAO();
    RelatorioDAO relatorioDAO = new RelatorioDAO();
    RelatorioMudancas relatorio = new RelatorioMudancas();
    if ("delete".equalsIgnoreCase(action)) {
        int id = Integer.parseInt(request.getParameter("id"));
        try {
            daoCliente.excluir(id);
            HttpSession sessao = request.getSession();
            int identificacaoF = (int) sessao.getAttribute("id_func");
            relatorio.setId_func(identificacaoF);
            relatorio.setMudanca("Exclusão de cliente efetuada!");
            relatorioDAO.inserir(relatorio);
            RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/BuscaCliente.jsp");
            dispatcher.forward(request, response);
        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(ExcluiClienteServlet.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(ExcluiClienteServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : SQLException(java.sql.SQLException) ClienteDAO(br.senac.tads3.pi03b.gruposete.dao.ClienteDAO) HttpSession(javax.servlet.http.HttpSession) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SQLException(java.sql.SQLException)

Aggregations

RelatorioDAO (br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO)18 IOException (java.io.IOException)16 ServletException (javax.servlet.ServletException)16 HttpSession (javax.servlet.http.HttpSession)16 RelatorioMudancas (br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas)15 SQLException (java.sql.SQLException)14 RequestDispatcher (javax.servlet.RequestDispatcher)13 ClienteDAO (br.senac.tads3.pi03b.gruposete.dao.ClienteDAO)4 HotelDAO (br.senac.tads3.pi03b.gruposete.dao.HotelDAO)4 VooDAO (br.senac.tads3.pi03b.gruposete.dao.VooDAO)4 FuncionarioDAO (br.senac.tads3.pi03b.gruposete.dao.FuncionarioDAO)3 Cliente (br.senac.tads3.pi03b.gruposete.models.Cliente)3 Hotel (br.senac.tads3.pi03b.gruposete.models.Hotel)3 RelatorioSLA (br.senac.tads3.pi03b.gruposete.models.RelatorioSLA)3 Voo (br.senac.tads3.pi03b.gruposete.models.Voo)3 PrintWriter (java.io.PrintWriter)3 JSONArray (org.json.simple.JSONArray)3 JSONObject (org.json.simple.JSONObject)3 Funcionario (br.senac.tads3.pi03b.gruposete.models.Funcionario)2 ClienteService (br.senac.tads3.pi03b.gruposete.services.ClienteService)2