Search in sources :

Example 6 with RelatorioDAO

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

the class ExcluiHotelServlet method doGet.

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

Example 7 with RelatorioDAO

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

the class ExcluiVooServlet method doGet.

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

Example 8 with RelatorioDAO

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

the class AlteraHotelServlet method doPost.

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    HotelService service = new HotelService();
    HotelDAO dao = new HotelDAO();
    RelatorioDAO relatorioDAO = new RelatorioDAO();
    RelatorioMudancas relatorio = new RelatorioMudancas();
    String nome_hotel = request.getParameter("nome_hotel");
    String data_entrada = request.getParameter("data_entrada");
    String data_saida = request.getParameter("data_saida");
    int quantidade_quartos = Integer.parseInt(request.getParameter("quantidade_quartos"));
    int quantidade_hospedes = Integer.parseInt(request.getParameter("quantidade_hospedes"));
    float preco = Float.parseFloat(request.getParameter("preco"));
    int id = Integer.parseInt(request.getParameter("identificacao"));
    request.setAttribute("erroNome_hotel", service.validaNome(nome_hotel));
    request.setAttribute("erroData_entrada", service.validaEntrada(data_entrada));
    request.setAttribute("erroData_saida", service.validaSaida(data_saida));
    request.setAttribute("erroQuantidade_quartos", service.validaQuantidade_quartos(quantidade_quartos));
    request.setAttribute("erroQuantidade_hospedes", service.validaQuantidade_hospedes(quantidade_hospedes));
    request.setAttribute("erroPreco", service.validaPreco(preco));
    Hotel hotel = new Hotel(nome_hotel.trim(), data_entrada.trim(), data_saida.trim(), quantidade_quartos, quantidade_hospedes, preco, true);
    hotel.setId(id);
    if (service.validaHotel(nome_hotel, quantidade_quartos, data_entrada, data_saida, quantidade_hospedes, preco)) {
        try {
            Hotel hoteis = dao.getHotelById(id);
            request.setAttribute("hoteis", hoteis);
        } catch (ClassNotFoundException | SQLException e) {
        }
        RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/EditarHotel.jsp");
        dispatcher.forward(request, response);
    } else {
        try {
            dao.alterar(hotel);
            HttpSession sessao = request.getSession();
            int identificacaoF = (int) sessao.getAttribute("id_func");
            relatorio.setId_func(identificacaoF);
            relatorio.setMudanca("Alteração de hotel efetuado!");
            relatorioDAO.inserir(relatorio);
            response.sendRedirect(request.getContextPath() + "/inicio");
        } catch (Exception ex) {
            Logger.getLogger(AlteraHotelServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : HotelService(br.senac.tads3.pi03b.gruposete.services.HotelService) HotelDAO(br.senac.tads3.pi03b.gruposete.dao.HotelDAO) 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) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) Hotel(br.senac.tads3.pi03b.gruposete.models.Hotel)

Example 9 with RelatorioDAO

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

the class BuscarRelatorioMudanca method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    RelatorioDAO relatorio = new RelatorioDAO();
    try {
        JSONArray jsonArray = new JSONArray();
        ArrayList<RelatorioMudancas> procurar = relatorio.procurarRelatorioMudanca();
        for (RelatorioMudancas procurarVenda : procurar) {
            JSONObject json = new JSONObject();
            json.put("mudanca", procurarVenda.getMudanca());
            json.put("data_m", procurarVenda.getData());
            json.put("nome", procurarVenda.getFuncionario());
            json.put("cargo", procurarVenda.getCargo());
            json.put("filial", procurarVenda.getFilial());
            jsonArray.add(json);
        }
        response.setCharacterEncoding("UTF-8");
        try (PrintWriter out = response.getWriter()) {
            out.println(jsonArray.toJSONString());
        }
    } catch (SQLException | ClassNotFoundException ex) {
        Logger.getLogger(BuscarRelatorioMudanca.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : JSONObject(org.json.simple.JSONObject) SQLException(java.sql.SQLException) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) JSONArray(org.json.simple.JSONArray) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) PrintWriter(java.io.PrintWriter)

Example 10 with RelatorioDAO

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

the class BuscarSLAServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    RelatorioDAO relatorio = new RelatorioDAO();
    try {
        JSONArray jsonArray = new JSONArray();
        ArrayList<RelatorioSLA> procurar = null;
        HttpSession sessao = request.getSession();
        String identificacaoF = (String) sessao.getAttribute("tipo");
        String filial = (String) sessao.getAttribute("filial");
        if (identificacaoF.equalsIgnoreCase("Master") || identificacaoF.equalsIgnoreCase("Gerente_Informatica")) {
            procurar = relatorio.procurarRelatorioSLA();
        } else {
            procurar = relatorio.procurarRelatorioSLA(filial);
        }
        for (RelatorioSLA procuraras : procurar) {
            JSONObject json = new JSONObject();
            json.put("id_sla", procuraras.getId_SLA());
            json.put("mensagem", procuraras.getMensagem());
            json.put("data_m", procuraras.getData());
            json.put("nome", procuraras.getFuncionario());
            json.put("cargo", procuraras.getCargo());
            json.put("filial", procuraras.getFilial());
            jsonArray.add(json);
        }
        response.setCharacterEncoding("UTF-8");
        try (PrintWriter out = response.getWriter()) {
            out.println(jsonArray.toJSONString());
        }
    } catch (SQLException | ClassNotFoundException ex) {
        Logger.getLogger(BuscarRelatorioMudanca.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : JSONObject(org.json.simple.JSONObject) SQLException(java.sql.SQLException) HttpSession(javax.servlet.http.HttpSession) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) JSONArray(org.json.simple.JSONArray) RelatorioSLA(br.senac.tads3.pi03b.gruposete.models.RelatorioSLA) PrintWriter(java.io.PrintWriter)

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