-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodificarLibro.jsp
119 lines (105 loc) · 3.9 KB
/
modificarLibro.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<%@ page import ="operacions.*" %>
<%@ page import="java.sql.*" %>
<%@ page import ="java.util.*" %>
<%
String statCon="nada";
OperacionsBiblioLibro operacions=new OperacionsBiblioLibro();
statCon = operacions.abrirConexion();
try{
int numLibs = operacions.contarLibros();
Libro libroModificado=null;
%>
<html>
<head>
<link rel="stylesheet" type="text/css" href="estilos.css" media="screen" />
<title>Modificar Libro</title>
</head>
<body>
<!--Si recibe el parametro modificar,modificamos el libro -->
<%
if (request.getParameter("modificar")!=null){
libroModificado = new Libro(Integer.parseInt(request.getParameter("idLibro")),request.getParameter("isbn"),request.getParameter("titulo"),request.getParameter("autores"),Integer.parseInt(request.getParameter("ano")));
operacions.modificarLibro(libroModificado);
%>
<!--Mostramos un alert, y volvemos a la pagina correspondiente-->
<script type="text/javascript" >
alert("Se ha modificado el libro \n <%=libroModificado.getTitulo()%>");
location.href = "modificarLibro.jsp?id=<%=libroModificado.getIdLibro()%>";
</script>
<!--Si no recibe parametro, cargamos el libro que queriamos modificar-->
<%
}else{
libroModificado = operacions.consultarLibro(Integer.parseInt(request.getParameter("id")));
}
%>
<!--Barra de titulo-->
<div class="bar_titulo">
<table class="tabla_titulo">
<tr>
<td width="10%">
<a class="boton" href="index.jsp">Volver</a>
</td>
<td width="90%">
<h3>Modificar: <%=libroModificado.getTitulo()%></h3>
</td>
</tr>
</table>
</div>
<section><!--tabla -->
<div id="tabla">
<form class="formulario" action="modificarLibro.jsp" method="post">
<fieldset>
<legend>Datos</legend>
<input type="hidden" id="idLibro" name="idLibro" value="<%=libroModificado.getIdLibro()%>"/>
<label>
<span>ISBN :</span>
<input type="text" id="isbn" name="isbn" value="<%=libroModificado.getISBN()%>" placeholder="isbn" autofocus required/>
</label> <br/>
<label>
<span>Título :</span>
<input type="text" id="titulo" name="titulo" value="<%=libroModificado.getTitulo()%>" placeholder="titulo de la obra" maxlength="200" required/>
</label> <br/>
<label>
<span>Autores :</span>
<input type="text" id="autores" name="autores" value="<%=libroModificado.getAutores()%>" placeholder="autor/es del libro" maxlength="300" required/>
</label> <br/>
<label>
<span>Ano :</span>
<input type="date" id="ano" name="ano" value="<%=libroModificado.getAno()%>" placeholder="ano de edició" min="868" max="2030" maxlength="4" required/>
</label> <br/>
<input type="hidden" id="modificar" name="modificar" value="true"/>
<input type="submit" class="button" value="Enviar"/>
</fieldset>
</form>
<hr/>
<h3>Datos Libro Modificado</h3>
<table border="1" class="tabla_seleccion">
<tr><th scope="col">ID</th><th scope="col">ISBN</th><th scope="col">T$iacute;tulo</th><th scope="col">Autores</th><th scope="col">Ano</th><th scope="col">Accions</th></tr>
<tr>
<td><%=libroModificado.getIdLibro() %></td>
<td><%=libroModificado.getISBN()%></td>
<td><%=libroModificado.getTitulo()%></td>
<td><%=libroModificado.getAutores()%></td>
<td><%=libroModificado.getAno()%></td>
<td><a class="boton" href="consultarLibro.jsp?id=<%=libroModificado.getIdLibro()%>">Consultar</a>
</td>
<td><a class="boton boton_rojo" href="index.jsp?borrar=<%=libroModificado.getIdLibro()%>">Borrar</a>
</td>
</tr>
<%
operacions.cerrarConexion();
}catch(Exception e){
out.println("Error"+e.getMessage());
}
%>
</table>
</div>
</section><!--Fin tabla -->
</body>
<!--Muestro los errores con getErro en el pie de la pagina-->
<footer class="pie"><!--Pie-->
<div >
<span>JDBC version:<%=statCon%> ||</span><span style="color:#FF0000">Consola: <%=operacions.getErro()%></span>
</div>
</footer>
</html>