Search in sources :

Example 1 with RelatorioDAO

use of br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO 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 RelatorioDAO

use of br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO 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 RelatorioDAO

use of br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO 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 RelatorioDAO

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

the class BuscarRelatorioVendas method doGet.

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    RelatorioDAO relatorio = new RelatorioDAO();
    try {
        JSONArray jsonArray = new JSONArray();
        ArrayList<RelatorioValores> procurar = relatorio.procurarRelatorioAno();
        ArrayList<RelatorioValores> procurar2 = relatorio.procurarRelatorioMes();
        for (RelatorioValores procurarR : procurar) {
            JSONObject json = new JSONObject();
            json.put("data_vendaANO", procurarR.getData());
            json.put("filialANO", procurarR.getFilial());
            json.put("valorANO", procurarR.getValor());
            jsonArray.add(json);
        }
        for (RelatorioValores procurarR : procurar2) {
            JSONObject json = new JSONObject();
            json.put("data_vendaMES", procurarR.getData());
            json.put("filialMES", procurarR.getFilial());
            json.put("valorMES", procurarR.getValor());
            jsonArray.add(json);
        }
        response.setCharacterEncoding("UTF-8");
        try (PrintWriter out = response.getWriter()) {
            out.println(jsonArray.toJSONString());
        }
    } catch (Exception e) {
    }
}
Also used : JSONObject(org.json.simple.JSONObject) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) JSONArray(org.json.simple.JSONArray) RelatorioValores(br.senac.tads3.pi03b.gruposete.models.RelatorioValores) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) PrintWriter(java.io.PrintWriter)

Example 5 with RelatorioDAO

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

the class CadastrarSLAServlet method doPost.

@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    String mensagem = request.getParameter("mensagem");
    if (mensagem != null) {
        RelatorioSLA sla = new RelatorioSLA();
        HttpSession sessao = request.getSession();
        int identificacaoF = (int) sessao.getAttribute("id_func");
        sla.setId_func(identificacaoF);
        sla.setMensagem(mensagem);
        RelatorioDAO dao = new RelatorioDAO();
        try {
            dao.sla(sla);
        } catch (Exception ex) {
            Logger.getLogger(CadastrarSLAServlet.class.getName()).log(Level.SEVERE, null, ex);
        }
        RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/index.jsp");
        dispatcher.forward(request, response);
    } else {
        RequestDispatcher dispatcher = request.getRequestDispatcher("WEB-INF/jsp/SLA.jsp");
        dispatcher.forward(request, response);
    }
}
Also used : HttpSession(javax.servlet.http.HttpSession) RelatorioDAO(br.senac.tads3.pi03b.gruposete.dao.RelatorioDAO) RelatorioSLA(br.senac.tads3.pi03b.gruposete.models.RelatorioSLA) ServletException(javax.servlet.ServletException) IOException(java.io.IOException) RequestDispatcher(javax.servlet.RequestDispatcher)

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