Ver Mensaje Individual
  #5 (permalink)  
Antiguo 03/12/2014, 08:38
hugelig
 
Fecha de Ingreso: noviembre-2014
Mensajes: 8
Antigüedad: 9 años, 6 meses
Puntos: 0
Respuesta: Obtener facturas por mes seleccionado

En mi primera pagina (estado.asp) obtengo el año

<%@language="vbscript"%>
<% option explicit%>
<html>
<head>
<title>consultas</title>
<center>
<font color=blue size=+6 face="arial">
<b>comprobaciones
</b><hr>
</font>
</head>
<body bgcolor=#f3e2a3><p>
<table align=center cellspacing="6" cellpadding="2" border=0>
<tr>
<td>
<font color="red" size=+3 face="arial">datos
</font>
</td>
</tr>
</table><br>
<% dim conex,sqltext,rs,a
a=request.form("ano")
set conex=server.createobject("adodb.connection")
conex.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath ("./bd/contabilidad.mdb")%>
<form name="idano" method="post" action="respuesta.asp">
<table width=10% border=0>
<tr align=center>
<th>
<font size="+2" face="times new roman">a&ntilde;o
</font>
</th>
</tr>
<tr align=center>
<td>
<% sqltext= "select ano from lugar group by ano ;"
set rs=conex.execute(sqltext)%>
<select name="ano" style="font:16px verdana;border-radius:6px;">
<% do while not rs.eof%>
<option>
<% =rs("ano")%>
</option>
<% rs.movenext
loop %>
</select>
</td>
</tr>
</table><br>
<table width=22% border=0><br>
<tr align=center>
<td>
<button type="submit" style="width:auto;height:36px;font-size:10pt;background:#c0c0c0;border-radius:8px; "onclick="location.href='respuesta.asp'">
<img src="ok.png" align="absmiddle" hspace='4'/> aceptar
</button>
</td>
<td>
<button type="reset" style="width:auto;height:36px;font-size:10pt;background:#c0c0c0;border-radius:8px;"onclick="borrar();">
<img src="cancel2.png" align="absmiddle" hspace='4'/> deshacer
</button>
</td>
</tr>
</table><br>
<table align=center cellspacing="4" cellpadding="8" border=0>
<tr align=center>
<td>
<button type="reset" style="width:auto;height:36px;font-size:10pt;background:#c0c0c0;border-radius:8px;"onclick="location.href='estado2.html'" >
<img src="atras.png" align="absmiddle" hspace='4'/> atras
</button>
</td>
</tr>
</table>
</form>
</body>
</html>





En la segunda respuesta.asp obtengo los meses que tienen facturas

<%@language="vbscript"%>
<% option explicit
response.buffer %>
<html>
<head>
<title>contabilidad de gastos</title>
<style type="text/css" media="print">
#imprime {display:none}
</style>
<center>
<font color=blue size=+5>
<b>informe de gastos</b>
</font>
</center>
</head><hr><br>
<center>
<body bgcolor="#f3e2a3">
<table border=0>
<tr>
<td>
<% dim m,a,f,conex,rs,sqltext
m=request.form("mes")
a=request.form("ano")
f=request.form("n_factura")
set conex=server.createobject("adodb.connection")
conex.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("./bd/contabilidad.mdb") %>

<table align=center border=0>
<tr>
<td>
<font size=+3><b>consulta </b>
</font>
</td>
</tr>
</table><br>

<% set rs=server.createobject("adodb.recordset")
sqltext="select ano, count(n_factura) as facturas, lugar.mes from meses inner join lugar on meses.mes = lugar.mes where ano='"&a&"' group by lugar.mes, ano, meses.numeromes order by meses.numeromes;"
set rs=conex.execute(sqltext)
if not rs.eof then %>

<table align=center border=1>
<tr><%do while not rs.eof%>
<th align=center width="120" bgcolor="#00aaaa">
<font size=+3>a&ntilde;o
</font>
</th>
<td align=center width="120">
<font size=+3><%response.write rs("ano")%>
</font>
</td>
</tr>
</table><br><br>
<table align=center border=1>
<tr>
<th colspan="2" bgcolor="#00aaaa">
<font size=+2>mes
</font>
</th>
</tr>
<tr><%do while not rs.eof%>
<td width="120" align=center>
<%response.write ucase(rs("mes"))%>
</td>
<td align=center>
<button type="submit" style="width:auto;height:36px;font-size:10pt;background:#c0c0c0;border-radius:8px;" onclick="location.href='editar.asp?action=editar&n_factura= <%= rs("mes")%>'"<%= rs("facturas")%>>
<img src='editar3.png' align='absmiddle' hspace='4'/>consultar
</button>
</td>
</tr><% rs.movenext
loop %>
</table><br>
<table align=center cellspacing="4" cellpadding="8" border=0>
<tr>
<td>
<button type="submit" id="imprime" style="width:auto;height:36px;font-size:10pt;background:#c0c0c0;border-radius:8px; "onclick="location.href='mensual.html'">
<img src="ok.png" align="absmiddle" hspace='4'/> aceptar
</button>
</td>
</tr>
</table>
<% loop
end if
rs.close
conex.close
set rs=nothing
set conex=nothing %>

</td>
</tr>
</table>
</body>
</center>
</html>




Y en la tercera editar.asp obtener las facturas del mes que desee con sus detalles (nº factura, concepto, importe e importe total de todas las facturas de ese mes)

<%@language="vbscript"%>
<% option explicit %>
<html>
<head>
<title>contabilidad</title>
<table align=center width=40% bgcolor=#f1f1f1 cellpadding="0" cellspacing="0" border=3>
<tr align=center>
<td>
<font color=black size=+5 face="verdana">
gastos
</font>
</td>
</tr>
</table><p>
</head><hr>
<body>
<table align=center border=0>
<tr>
<td>
<% dim conex,sqltext,rs,m,a
a=request.form("ano")
m=request.form("mes")
set conex=server.createobject("adodb.connection")
conex.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath ("./bd/contabilidad.mdb")%>
<table align=center cellspacing="6" cellpadding="2" border=0>
<tr align=center>
<td align=left><font color=blue size=+3 face="verdana"><u>datos obtenidos</u></font>
</td>
</tr>
</table><br>
<% set rs=server.createobject("adodb.recordset")
sqltext="select * from lugar where mes='"&request("n_factura")&"' ;"
set rs=conex.execute(sqltext) %>
<table align=center border=1>
<tr><%do while not rs.eof%>
<th width="100" bgcolor="#00ccdde">
<font size=+2>aÑo
</font>
</th>
<td width="140" align=center>
<font size=+2><%response.write rs("ano")%>
</font>
</td>
</tr>
<tr>
<th bgcolor="#00ccdde">
<font size=+2>mes
</font>
</th>
<td align=center>
<font size=+2><%response.write rs("mes")%>
</font>
</td>
</tr>
</table><br>
<table align=center border=1 >
<tr align=center bgcolor="#00ccdd">
<th width="150">nº factura
</th>
<th width="140">concepto
</th>
<th width="100">importe
</th>
</tr>
<tr><% do while not rs.eof %>
<td align=center><%response.write rs("n_factura")%>
</td>
<td align=center><%response.write ucase(rs("concepto"))%>
</td>
<td align=center><%response.write formatnumber(rs("importe"),2)%> €
</td>
</tr><%rs.movenext
loop%>
</table><br>
<table align=right border=1>
<% set conex=server.createobject("adodb.connection")
conex.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("./bd/contabilidad.mdb")
set rs=server.createobject("adodb.recordset")
sqltext="select sum(importe) as total from lugar where mes='"&request("n_factura")&"' ;"
set rs=conex.execute(sqltext) %>
<tr><%do While not rs.eof%>
<td align=center width="100" bgcolor="#ff2222">
<font size=+2>total
</font>
</td>
<td align=center width="100">
<font size=+2><%response.write formatnumber(rs("total"),2)%> €
</font>
</td>
</tr><% rs.movenext
loop %>
</table><br><br><br>
<form method="get" action="mensual.html" >
<table align=center cellspacing="6" cellpadding="2" border=0>
<tr>
<td>
<button type="submit" style="width:auto;height:36px;font-size:10pt;background:#c0c0c0;border-radius:8px; "onclick="location.href='mensual.html'">
<img src="ok.png" align="absmiddle" hspace='4'/> aceptar
</button>
</td>
</tr>
</table><br>
<% loop
conex.close
set conex=nothing %>
</form>
</td>
</tr>
</table>
</body>
</html>

No se si el problema puede estar en el filtro que hago en respuesta.asp o que la sentencia sql de editar.asp no es la correcta.

Un saludo y muchas gracias por la ayuda.