verdetalle.aspx
Código:
<% @Page Language = VB %>
<% @Import Namespace = "System.Data" %>
<% @Import Namespace = "System.Data.OleDb" %>
<html>
<head>
<title>Catálogo on-line</title>
<script language="javascript">
//script por Tunait
var ventana
var cont=0
var titulopordefecto = "Imagen" //texto por defecto a mostrar en la barra de título en caso de omitir el argumento titulo
function afoto(cual,titulo)
{
if(cont==1){ventana.close();ventana=null}
if(titulo==null){titulo=titulopordefecto}
ventana=window.open('','ventana','resizable=yes,sc rollbars=no')
ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><img src="imagenes/' + cual + '" onLoad="opener.redimensionar(this.width, this.height)">')
ventana.document.close()
cont++
}
function redimensionar(ancho,alto)
{
ventana.resizeTo(ancho+12,alto+28)
ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2) //centra la ventana. Eliminar si no se quiere centrar el popup
}
</script>
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body>
<%
'Declarar Variables
Dim Conn As OleDbConnection
Dim cmd As OleDbDataAdapter
Dim dt, dtp As DataTable
Dim i, n, p, s As Integer
Dim sql_categorias As String
Dim sql_productos As String
Dim categoria, producto, contador As Integer
Dim findefila As String
'Rescate de valores por URL
categoria = Request.Querystring("cat")
producto = Request.Querystring("pro")
sql_categorias = "Select * From Categorias;"
Conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("catalogo.mdb") & ";")
' Crear el comando
cmd = New OleDbDataAdapter(sql_categorias, Conn)
' Llenar el DataTable
dt = New DataTable
cmd.Fill(dt)
n = dt.Rows.Count
%>
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="25%" valign="top">
<table border="1" width="60%" bordercolor="#DFE8FF" cellspacing="0" cellpadding="0" align="center">
<tr>
<td wisth="100%" bgcolor="#DFE8FF" align="center" class="text"><b>Categorías</b></td>
</tr>
<tr>
<td width="100%">
<table border="0" width="100%" bgcolor="#EFEFEF" cellspacing="0" cellpadding="0">
<%
If n = 0 then
%>
<tr>
<td width="100%" class="text" align="center">No hay categorías</td>
</tr>
<%
Else
For i = 0 To n - 1
Dim id_categoria
Dim nombre_categoria
Dim total_productos
id_categoria = dt.Rows(i).Item("id_categoria")
nombre_categoria = dt.Rows(i).Item("nombre_categoria")
total_productos = dt.Rows(i).Item("total_productos")
'Condición
If clng(categoria) = id_categoria Then
%>
<tr>
<td width="100%"><b><a href="catalogo.aspx?cat=<% = id_categoria %>"><% = nombre_categoria %></a></b> (<% = total_productos %>)</td>
</tr>
<% Else %>
<tr>
<td width="100%"><a href="catalogo.aspx?cat=<% = id_categoria %>"><% = nombre_categoria %></a> (<% = total_productos %>)</td>
</tr>
<%
End If
Next
End If
%>
</table>
</td>
</tr>
</table>
</td>
<td width="80%" valign="top">
<table border="1" bordercolor="#DFE8FF" width="60%" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td class="text" bgcolor="#DFE8FF">Detalle del Producto</td>
<td bgcolor="#DFE8FF"> </td>
</tr>
<%
'Creación de la sentencia SQL correspondiente
sql_productos = "Select * From productos Where id_producto = " & producto & ""
' Crear el comando
cmd = New OleDbDataAdapter(sql_productos, Conn)
' Llenar el DataTable
dtp = New DataTable
cmd.Fill(dtp)
s = dt.Rows.Count
If Not s = 0 Then
Dim id_producto
Dim imagen
Dim descripcion
Dim productop
Dim precio
id_producto = dtp.Rows(0).Item("id_producto")
imagen = dtp.Rows(0).Item("imagen")
productop = dtp.Rows(0).Item("producto")
descripcion = dtp.Rows(0).Item("descripcion")
precio = dtp.Rows(0).Item("precio")
%>
<tr>
<td width="84%" bgcolor="#EFEFEF"><% = productop %></td>
<td width="16%" bgcolor="#EFEFEF" align="right">Precio: $<% = precio %></td>
</tr>
<tr>
<td width="84%" bgcolor="#EFEFEF"><p> </p><% = descripcion %>
<p align="center">La empresa se responsabiliza por la información contenida en su catálogo y no por cambios que el fabricante pueda tener en su página web ya que pueden cambiar sin previo aviso.</p>
</td>
<td width="16%" bgcolor="#EFEFEF" align="right"><a href="#" onClick="afoto('<% = imagen %>','<% = productop %>');return false"><img src="imagenes/<% = imagen %>" alt="Pulsa para ampliar" width="75" height="75" border="0"></a></td>
</tr>
<% End If %>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Y por último la estructura de las tablas de la BD
tabla categorias:
id_categoria (autonumerico)
nombre_categoria (texto)
total_productos (numerico)
tabla productos:
id_producto (autonumerico)
categoria (numerico)
imagen (texto)
ancho (numerico) --->ancho de la imagen
alto (numerico) --->alto de la imagen
marca (texto)
modelo (texto)
descripcion (texto)
precio (texto)
Bueno espero que les sea de utilidad y ojala que me den sugerencias de como mejorarlo.... eso pues saludos y gracias a todos