Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. <div id="list" class="row">
  2. <div class="table-responsive col-md-12">
  3. <form method="POST" action="ControleProjeto"/>
  4. <table class="table table-striped" cellspacing="0" cellpadding="0">
  5. <thead>
  6. <tr>
  7. <th>ID</th>
  8. <th>Nome do projeto</th>
  9. <th>Nome da empresa</th>
  10. <th>Nome do Responsável</th>
  11. <th class="actions">Ações</th>
  12. </tr>
  13. </thead>
  14. <%
  15. for(Projetos p: listaprojetos){
  16. %>
  17. <tbody>
  18. <tr>
  19. <td><%=p.getID()%></td>
  20. <td><%=p.getNome()%></td>
  21. <td><%=p.getEmpresa()%></td>
  22. <td><%=p.getResponsavel()%></td>
  23. <td class="actions">
  24. <input type="submit" name="acao" value="Editar" class="btn btn-danger btn-xs" />
  25. </td>
  26. </tr>
  27. </tbody>
  28. <%}%>
  29. </table>
  30. </form>
  31. </div>
  32. </div>
  33.  
  34. Projetos p = new Projetos();
  35.  
  36. if("Editar".equals(acao)){
  37. if(p.getID() != 0){
  38. try{
  39. int id = p.getID();
  40. Projetos pj = new ProjetoDAO().get(id);
  41.  
  42. RequestDispatcher rd = request.getRequestDispatcher("editarProjeto.jsp");
  43. request.setAttribute("projeto", pj);
  44. rd.forward(request, response);
  45. return ;
  46. }catch(Exception e){
  47.  
  48. }
  49. }
  50. }
  51.  
  52. public Projetos get(int id) throws ServletException {
  53. Projetos p = new Projetos();
  54. try{
  55. sql = "SELECT * FROM projeto WHERE idProjeto = ?;";
  56. con = Connect.conectar();
  57. ps = con.prepareStatement(sql);
  58.  
  59. ps.setInt(1, id);
  60.  
  61. rs = ps.executeQuery();
  62.  
  63. if(rs.next()){
  64. p.setID(rs.getInt("idProjeto"));
  65. p.setEmpresa(rs.getString("empresa"));
  66. p.setNome(rs.getString("nome"));
  67. p.setResponsavel(rs.getString("responsavel"));
  68. }
  69. } catch (ClassNotFoundException | SQLException ex) {
  70. Logger.getLogger(ProjetoDAO.class.getName()).log(Level.SEVERE, null, ex);
  71. return null;
  72. }finally {
  73. try {
  74. Connect.fechar();
  75. } catch (Exception sqlex) {
  76. }
  77. }
  78. return p;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement