<%
Function BarraDeNavegacion(PaginasTotales, PaginaActual, MisCondiciones)
'Modificar el contenido de las constantes para cambiar el aspecto de la barra de navegación
const EstiloDeLaTabla = "border: 1px solid #D6AD6B; font-family: Arial, Helvetica, sans-serif; font-size: 12px;"
const EstiloCeldaPaginaXdeY = "color: white; background-color: black;"
const LinkDelEnlace = "link1"
const EstiloDeLaCeldaPaginaActual = "background-color:#EFD6AD; font-weight:bold;"
const EstiloDeLaCeldaPaginaConLink = "background-color:#F7E7C6"
MisCondiciones = "&v1="&v1&"&codigo="&codigo&"&descrip1="&descrip&"&familia="&familia&"&stock="&stock&""
if PaginasTotales > 1 then
if PaginasTotales > 5 then MostrarUltima = true
TablaConBarraDeNavegacion = "<table border=""0"" cellpadding=""2"" cellspacing=""1"" style=""" & EstiloDeLaTabla & """><tr><td style=""" & EstiloCeldaPaginaXdeY & """> Página " & PaginaActual & " de " & PaginasTotales & " </td>"
if PaginaActual >= 4 then
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=1" & MisCondiciones &""" class=""" & LinkDelEnlace & """><strong>«</strong> Primera</a></td>"
CantidadAMostrarDeAnterioresYPosteriores = 2
'Indicamos la celda central como activa, y sin link
'(la 3ª, de las 5 mostradas), y el resto con link
for i = 1 to 5
'No mostramos link si estamos en la 3ª celda de las 5 mostradas
if i = 3 then
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style=""" & EstiloDeLaCeldaPaginaActual & """>" & PaginaActual & "</td>"
else
'Mostramos el link si estamos en las celdas distintas de la 3ª (la central)
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style=""" & EstiloDeLaCeldaPaginaConLink & """><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & PaginaActual - CantidadAMostrarDeAnterioresYPosteriores & MisCondiciones & """ class=""" & LinkDelEnlace & """>" & PaginaActual - CantidadAMostrarDeAnterioresYPosteriores & "</a></td>"
end if
if PaginaActual - CantidadAMostrarDeAnterioresYPosteriores = PaginasTotales then
MostrarUltima = False
Exit For
end if
CantidadAMostrarDeAnterioresYPosteriores = CantidadAMostrarDeAnterioresYPosteriores - 1
next
else
if PaginasTotales < 5 then
for i = 1 to PaginasTotales
if i <> PaginaActual then
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & i & MisCondiciones & """ class=""" & LinkDelEnlace & """>" & i & "</a></td>"
else
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaActual &""">" & i & "</td>"
end if
next
else
For i = 1 to 5
if i <> PaginaActual then
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & i & MisCondiciones &""" class=""" & LinkDelEnlace & """>" & i & "</a></td>"
else
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td width=""15"" align=""center"" style="""& EstiloDeLaCeldaPaginaActual &""">" & i & "</td>"
end if
next
end if
end if
if MostrarUltima = true then TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "<td style="""& EstiloDeLaCeldaPaginaConLink &"""><a href="""& PaginaActualBarraDeNavegacion & "?pagina=" & PaginasTotales & MisCondiciones &""" class=""" & LinkDelEnlace & """>Última <strong>»</strong></a></td>"
TablaConBarraDeNavegacion = TablaConBarraDeNavegacion & "</tr></table>"
BarraDeNavegacion = TablaConBarraDeNavegacion
end if
end Function
Dim Cnn, RS, SQLQuery1
Dim PaginaActual ' en qué pagina estamos
Dim PaginasTotales ' cuántas páginas tenemos
Dim TamPagina ' cuantos registros por pagina
Dim CuantosRegistros ' para imprimir solo el nº de registro por pagina que queramos
TamPagina = 13
dim dbCnn
'aca recibo los campos que voy a realizar la busqueda
On Error Resume next
'Leemos qué página mostrar. La primera vez será la inicial
if Request.Querystring( "pagina" ) = "" then
PaginaActual = 1
else
PaginaActual = CInt(Request.Querystring( "pagina" ))
end if
codigo = Request("codigo")
familia = Request("familia")
descrip = Request("descrip1")
stock = Request("stock")
if Not IsEmpty(Request.Form("codigo")) then
codigo = Request.Form("codigo")
end if
if Not IsEmpty(Request.Form("familia")) then
familia = Request.Form("familia")
end if
if Not IsEmpty(Request.Form("descrip1")) then
descrip =Request.Form("descrip1")
end if
if Not IsEmpty(Request.Form("stock")) then
stock = replace(Request.Form("stock")," ","_" )
end if
Set Cnn = Server.CreateObject( "ADODB.Connection" )
Set rs = Server.CreateObject( "ADODB.Recordset" )
Cnn.Open Session("cnx")
strSQL1= "select CODI_FAMILIA from FAMILIAS where FAMILIA = '"&familia&"' "
set rs1 = Cnn.Execute(strSQL1)
If Not rs1.EOF then
codi_fami = rs1.fields ("CODI_FAMILIA")
end if
strSQL6= "select substring ('"&codigo&"', 2,2) as codigo_familia "
set rs6 = Cnn.Execute(strSQL6)
strSQL = " select codprod,descrip,costo,stock from PRODUCTO "
se_encuentra = False
if stock = "Solo_con_Stock" then
if se_encuentra then
strSQL=strSQL & " AND stock > 0"
else
strSQL=strSQL & " WHERE stock > 0"
se_encuentra=True
end if
end if
if stock = "Sin_Stock" then
if se_encuentra then
strSQL=strSQL & " AND stock = 0"
else
strSQL=strSQL & " WHERE stock = 0"
se_encuentra=True
end if
end if
if codi_fami <> "" then
if se_encuentra then
strSQL=strSQL & " AND substring (codprod, 2,2)='"&codi_fami&"'"
else
strSQL=strSQL & " where substring (codprod, 2,2)='"&codi_fami&"'"
se_encuentra=True
end if
end if
if codigo <> "" then
if se_encuentra then
strSQL=strSQL & " AND codprod LIKE '%"&codigo&"'"
else
strSQL=strSQL & " WHERE codprod LIKE '%"&codigo&"'"
se_encuentra=True
end if
end if
if descrip <> "" then
if se_encuentra then
strSQL=strSQL & " AND descrip LIKE '"&descrip&"%'"
else
strSQL=strSQL & " WHERE descrip LIKE '"&descrip&"%'"
se_encuentra=True
end if
end if
' Defino el tamaño de las páginas
RS.PageSize = TamPagina
RS.CacheSize = TamPagina
' Abro el recordset
RS.Open strSQL, Cnn, 1, 1
'Cuento las páginas
PaginasTotales = Rs.PageCount
'Compruebo que la pagina actual está en el rango
if PaginaActual < 1 then
PaginaActual = 1
end if
if PaginaActual > PaginasTotales then
PaginaActual = PaginasTotales
end if
if PaginasTotales = 0 then
Response.Redirect("../error/no_search.asp")
ELSE
session("codigo") = rs.fields ("CODPROD")
'Vamos a paginar
Rs.AbsolutePage = PaginaActual
%>
<html>
<head>
<script src="sorttable.js"></script>
<title>Resultado Busqueda</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-image: url(../images/01182_glassorbs_1024x768.jpg);
}
a:link {
color: #000000;
}
a:visited {
color: #000000;
}
body,td,th {
color: #FFFFFF;
}
-->
</style></head>
<body>
<p align="center">
<font face="Bookman Old Style"><em>Número de Repuestos Encontrados:</em></font> <b><%=RS.RecordCount%></b>
<p align="left"><%=BarraDeNavegacion(PaginasTotales, PaginaActual, MisCondiciones)%>
<div align="center">
<table class="sortable" width="834" height="71" border="1" cellpadding="2" cellspacing="2">
<tr>
<td height="39"> Código </td>
<td> Descripcion: </td>
<td> Precio: </td>
<td> Stock: </td>
</tr>
<%
CuantosRegistros = 0
Do while not RS.EOF and CuantosRegistros < TamPagina
i = i + 1
%>
<tr>
<td width="243" height="26" >
<ahref="../pir.asp?codigo=<%=RS.Fields("codprod")%>"><%=RS.Fields("codprod")%>
</td>
<td width="571"><%=RS.Fields("descrip")%></td>
<td width="571"><%if session("codigo") <>0 then%> <%=formatCurrency(rs.fields("COSTO"),0) %><%end if%></td>
<td width="571"><%=RS.Fields("STOCK")%></td>
</tr>
<%
CuantosRegistros = CuantosRegistros + 1
RS.MoveNext
loop
%>
</table>
<div align="left">
<%
end if
RS.Close
Cnn.Close
set RS = nothing
set Cnn = nothing
%>
</div>
</div>
</body>
</html>