Search in sources :

Example 1 with RelatorioMudancas

use of br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas in project Loja_Agencia_De_Viagens by ArtCouSan.

the class ExcluiFuncionarioServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String action = request.getParameter("action");
    FuncionarioDAO query = new FuncionarioDAO();
    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 funcionario efetuada!");
            relatorioDAO.inserir(relatorio);
            RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/BuscaFuncionario.jsp");
            dispatcher.forward(request, response);
        } catch (ClassNotFoundException | SQLException ex) {
            Logger.getLogger(ExcluiFuncionarioServlet.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(ExcluiFuncionarioServlet.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) FuncionarioDAO(br.senac.tads3.pi03b.gruposete.dao.FuncionarioDAO) RequestDispatcher(javax.servlet.RequestDispatcher) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SQLException(java.sql.SQLException)

Example 2 with RelatorioMudancas

use of br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas in project Loja_Agencia_De_Viagens by ArtCouSan.

the class ExcluiSLAServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    try {
        int id = Integer.parseInt(request.getParameter("id"));
        RelatorioDAO relatorioDAO = new RelatorioDAO();
        RelatorioMudancas relatorio = new RelatorioMudancas();
        RelatorioSLA relatorios = new RelatorioSLA();
        relatorioDAO.excluirSLA(id);
        HttpSession sessao = request.getSession();
        int identificacaoF = (int) sessao.getAttribute("id_func");
        relatorio.setId_func(identificacaoF);
        relatorio.setMudanca("Exclusão de chamado efetuado!");
        relatorioDAO.inserir(relatorio);
        response.sendRedirect(request.getContextPath() + "/inicio");
    } catch (SQLException | ClassNotFoundException ex) {
        Logger.getLogger(ExcluiSLAServlet.class.getName()).log(Level.SEVERE, null, ex);
    } catch (Exception ex) {
        Logger.getLogger(ExcluiSLAServlet.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) RelatorioSLA(br.senac.tads3.pi03b.gruposete.models.RelatorioSLA) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) SQLException(java.sql.SQLException)

Example 3 with RelatorioMudancas

use of br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas in project Loja_Agencia_De_Viagens by ArtCouSan.

the class VendaServlet method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, FileNotFoundException {
    double totalP = Double.parseDouble(request.getParameter("totalP"));
    if (totalP != 0) {
        String cpf = request.getParameter("cpf");
        ClienteDAO clienteData = new ClienteDAO();
        Cliente cliente = null;
        try {
            cliente = clienteData.getClienteByCPF(cpf);
        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(VendaServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        HttpSession sessao = request.getSession();
        int identificacaoF = (int) sessao.getAttribute("id_func");
        Venda venda = new Venda(cliente.getId(), identificacaoF, totalP);
        VendaDAO vendaData = new VendaDAO();
        try {
            vendaData.inserir(venda);
            RelatorioDAO relatorioDAO = new RelatorioDAO();
            RelatorioMudancas relatorio = new RelatorioMudancas();
            relatorio.setId_func(identificacaoF);
            relatorio.setMudanca("Venda efetuada!");
            relatorioDAO.inserir(relatorio);
        } catch (SQLException | ClassNotFoundException | ParseException ex) {
            Logger.getLogger(VendaServlet.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(VendaServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        int idLista = 0;
        try {
            idLista = vendaData.maiorIdVenda();
        } catch (SQLException | ClassNotFoundException ex) {
            Logger.getLogger(VendaServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        String idsVoos = request.getParameter("idsVoos");
        String idsHoteis = request.getParameter("idsHoteis");
        String precosVoos = request.getParameter("precosVoos");
        String precosHoteis = request.getParameter("precosHoteis");
        String quantidadeVoos = request.getParameter("quantidadeVoos");
        String quantidadeHoteis = request.getParameter("quantidadeHoteis");
        if (idsVoos.length() != 0) {
            String[] idsV = idsVoos.split(",");
            String[] precosV = precosVoos.split(",");
            String[] quantidadesV = quantidadeVoos.split(",");
            for (int i = 0; i < idsV.length; i++) {
                try {
                    VooDAO voo = new VooDAO();
                    int idV = Integer.parseInt(idsV[i]);
                    Voo vooEncontrado = voo.getVooById(idV);
                    int qtd_encontradaV = vooEncontrado.getQuantidade_passagens();
                    int quantidadeV = Integer.parseInt(quantidadesV[i]);
                    float precoV = Float.parseFloat(precosV[i]);
                    int novaQtdVoo = qtd_encontradaV - quantidadeV;
                    vendaData.inserirLista(idV, quantidadeV, precoV, idLista, "V");
                    vendaData.removerEstoqueVoo(idV, novaQtdVoo);
                } catch (SQLException | ClassNotFoundException ex) {
                    Logger.getLogger(VendaServlet.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        if (idsHoteis.length() != 0) {
            String[] idsH = idsHoteis.split(",");
            String[] precosH = precosHoteis.split(",");
            String[] quantidadesH = quantidadeHoteis.split(",");
            for (int i = 0; i < idsH.length; i++) {
                try {
                    HotelDAO hotel = new HotelDAO();
                    int idH = Integer.parseInt(idsH[i]);
                    Hotel hotelEncontrado = hotel.getHotelById(idH);
                    int qtd_encontradaH = hotelEncontrado.getQuantidade_quartos();
                    int quantidadeH = Integer.parseInt(quantidadesH[i]);
                    float precoH = Float.parseFloat(precosH[i]);
                    int novaQtdHotel = qtd_encontradaH - quantidadeH;
                    vendaData.inserirLista(idH, quantidadeH, precoH, idLista, "H");
                    vendaData.removerEstoqueHotel(idH, novaQtdHotel);
                } catch (SQLException | ClassNotFoundException ex) {
                    Logger.getLogger(VendaServlet.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
        response.sendRedirect(request.getContextPath() + "/inicio");
    } else {
        response.sendRedirect(request.getContextPath() + "/inicio");
    }
}
Also used : SQLException(java.sql.SQLException) HotelDAO(br.senac.tads3.pi03b.gruposete.dao.HotelDAO) HttpSession(javax.servlet.http.HttpSession) VendaDAO(br.senac.tads3.pi03b.gruposete.dao.VendaDAO) VooDAO(br.senac.tads3.pi03b.gruposete.dao.VooDAO) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) SQLException(java.sql.SQLException) ParseException(java.text.ParseException) ClienteDAO(br.senac.tads3.pi03b.gruposete.dao.ClienteDAO) Venda(br.senac.tads3.pi03b.gruposete.models.Venda) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) Voo(br.senac.tads3.pi03b.gruposete.models.Voo) RelatorioMudancas(br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas) ParseException(java.text.ParseException) Cliente(br.senac.tads3.pi03b.gruposete.models.Cliente) Hotel(br.senac.tads3.pi03b.gruposete.models.Hotel)

Example 4 with RelatorioMudancas

use of br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas 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 5 with RelatorioMudancas

use of br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas 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)

Aggregations

RelatorioMudancas (br.senac.tads3.pi03b.gruposete.models.RelatorioMudancas)16 RelatorioDAO (br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO)15 IOException (java.io.IOException)14 ServletException (javax.servlet.ServletException)14 HttpSession (javax.servlet.http.HttpSession)14 SQLException (java.sql.SQLException)13 RequestDispatcher (javax.servlet.RequestDispatcher)12 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 Voo (br.senac.tads3.pi03b.gruposete.models.Voo)3 Funcionario (br.senac.tads3.pi03b.gruposete.models.Funcionario)2 ClienteService (br.senac.tads3.pi03b.gruposete.services.ClienteService)2 FuncionarioService (br.senac.tads3.pi03b.gruposete.services.FuncionarioService)2 HotelService (br.senac.tads3.pi03b.gruposete.services.HotelService)2 VooService (br.senac.tads3.pi03b.gruposete.services.VooService)2 VendaDAO (br.senac.tads3.pi03b.gruposete.dao.VendaDAO)1