Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="list" class="row">
- <div class="table-responsive col-md-12">
- <form method="POST" action="ControleProjeto"/>
- <table class="table table-striped" cellspacing="0" cellpadding="0">
- <thead>
- <tr>
- <th>ID</th>
- <th>Nome do projeto</th>
- <th>Nome da empresa</th>
- <th>Nome do Responsável</th>
- <th class="actions">Ações</th>
- </tr>
- </thead>
- <%
- for(Projetos p: listaprojetos){
- %>
- <tbody>
- <tr>
- <td><%=p.getID()%></td>
- <td><%=p.getNome()%></td>
- <td><%=p.getEmpresa()%></td>
- <td><%=p.getResponsavel()%></td>
- <td class="actions">
- <input type="submit" name="acao" value="Editar" class="btn btn-danger btn-xs" />
- </td>
- </tr>
- </tbody>
- <%}%>
- </table>
- </form>
- </div>
- </div>
- Projetos p = new Projetos();
- if("Editar".equals(acao)){
- if(p.getID() != 0){
- try{
- int id = p.getID();
- Projetos pj = new ProjetoDAO().get(id);
- RequestDispatcher rd = request.getRequestDispatcher("editarProjeto.jsp");
- request.setAttribute("projeto", pj);
- rd.forward(request, response);
- return ;
- }catch(Exception e){
- }
- }
- }
- public Projetos get(int id) throws ServletException {
- Projetos p = new Projetos();
- try{
- sql = "SELECT * FROM projeto WHERE idProjeto = ?;";
- con = Connect.conectar();
- ps = con.prepareStatement(sql);
- ps.setInt(1, id);
- rs = ps.executeQuery();
- if(rs.next()){
- p.setID(rs.getInt("idProjeto"));
- p.setEmpresa(rs.getString("empresa"));
- p.setNome(rs.getString("nome"));
- p.setResponsavel(rs.getString("responsavel"));
- }
- } catch (ClassNotFoundException | SQLException ex) {
- Logger.getLogger(ProjetoDAO.class.getName()).log(Level.SEVERE, null, ex);
- return null;
- }finally {
- try {
- Connect.fechar();
- } catch (Exception sqlex) {
- }
- }
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement