codice:
/******************************************
Menu item creation:
myCoolMenu.makeMenu(name, parent_name, text, link, target, width, height, regImage, overImage, regClass, overClass , align, rows, nolink, onclick, onmouseover, onmouseout)
*************************************/
<%
'*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'ASP CODE START - READING ITEMS FROM THE DATABASE
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Sub readItemsFromDatabase
'The path to your database:
Dim db,q,rs,rsarr(4,1000),menuID,mName,mLink,parent,cols,max
db ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../mdb-database/ecom.mdb")
q = "SELECT ID,Scategoria from Scategorie ORDER BY ID ASC"
Set rs=Server.CreateObject("ADODB.Recordset")
rs.CacheSize = 25 ' Cache data fetching
rs.CursorType = 3
rs.LockType = 3
'Opening database --- --
rs.Open q,db
'Now using getRows because that's so sexy :}
if NOT rs.EOF then
max = rs.recordcount - 1
rs.movefirst
for i = 0 to max
rsarr(0,i) = rs("id")
rsarr(1,i) = rs("SCategoria")
rsarr(2,i) = "catalogo.asp?scat=" & rsarr(0,i)
rsarr(3,i) = 0
rs.movenext
next
else
max = 0
end if
rs.close()
q = "SELECT ID,Categoria,SCategoria from Categorie ORDER BY ID ASC"
rs.Open q,db
if NOT rs.EOF then
dim maxold
maxold = max + 1
max = max + rs.recordcount
rs.movefirst
for i = maxold to max
rsarr(0,i) = rs("id") + maxold
rsarr(1,i) = rs("Categoria")
rsarr(2,i) = "catalogo.asp?scat=" & rs("Scategoria") & "&cat=" & rs("id")
rsarr(3,i) = rs("Scategoria")
rs.movenext
next
end if
'Closing database, we don't need it anymore - we have the info in the array
rs.close()
Set rs = Nothing
dim row
row=0
do while(row<=max) 'Looping rows
'Setting variables
menuID = "m" & rsarr(0,row)
mName = rsarr(1,row)
mLink = rsarr(2,row)
if(mLink="null") then mLink=""
parent = rsarr(3,row)
if(parent<>0) then
parent = "m" & parent
else
parent=""
end if
'Making menu item
Response.write("oCMenu.makeMenu('" & menuID & "','" &parent & "','" & mName & "','" & mLink & "')" & vbcrlf)
row = row + 1
loop
end sub
Sub readItemsFromDatabase2
'The path to your database:
Dim db,q,rs,rsarr(4,1000),menuID,mName,mLink,parent,cols,max
db ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../mdb-database/ecom.mdb")
'RICAVO I DATI PER IL CARRELLO
q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
Set rs=Server.CreateObject("ADODB.Recordset")
rs.CacheSize = 25 ' Cache data fetching
rs.CursorType = 3
rs.LockType = 3
'Opening database --- --
rs.Open q,db
'Now using getRows because that's so sexy :}
rsarr(0,0) = 1000
rsarr(1,0) = "Riepilogo carrello"
rsarr(2,0) = "carrello.asp"
rsarr(3,0) = 0
if NOT rs.EOF then
max = rs.recordcount
rs.movefirst
for i = 1 to max
rsarr(0,i) = i
rsarr(1,i) = rs("Prodotto")
rsarr(2,i) = "scheda.asp?id=" & rs("idprodotto")
rsarr(3,i) = 1000
rs.movenext
next
else
max = 0
end if
rs.close()
q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
rs.Open q,db
if NOT rs.EOF then
dim maxold
maxold = max + 1
max = max *2
rs.movefirst
for i = maxold to max
rsarr(0,i) = i
rsarr(1,i) = "Quantità: " & rs("quantita")
rsarr(2,i) = ""
rsarr(3,i) = i-maxold+1
rs.movenext
next
end if
rs.close()
q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
rs.Open q,db
if NOT rs.EOF then
dim maxold2
maxold2 = max + 1
max = max + rs.recordcount
rs.movefirst
TotaleCart = 0
for i = maxold2 to max
If Session("Rivenditore") Then PrezzoProdotto = RS("RPrezzo") Else PrezzoProdotto = RS("CPrezzo")
PrezzoTotaleProdotto = (UtilizzaPrezzo(PrezzoProdotto) * RS("Quantita"))
rsarr(0,i) = i
rsarr(1,i) = "Prezzo Tot.: " & VisualizzaPrezzo(PrezzoTotaleProdotto) & IvaNonCompresaBreve
rsarr(2,i) = ""
rsarr(3,i) = i-maxold2+1
TotaleCart = TotaleCart + PrezzoTotaleProdotto
rs.movenext
next
end if
rs.close()
q = "SELECT * FROM Carrello WHERE IDSessione = '"& SessionID &"'"
rs.Open q,db
if NOT rs.EOF then
dim maxold3
maxold3 = max + 1
max = max + rs.recordcount
rs.movefirst
for i = maxold3 to max
rsarr(0,i) = i
rsarr(1,i) = "Cancella"
rsarr(2,i) = "prod_cancella.asp?id=" & RScart("IDProdotto") & "&idtipologia=" & RSCart("IDTipologia")
rsarr(3,i) = i-maxold3+1
rs.movenext
next
end if
max = max+1
rsarr(0,max) = 2000
rsarr(1,max) = "TOTALE: " & SimboloValuta & " " & VisualizzaPrezzo(TotaleCart) & IvaNonCompresaBreve
rsarr(2,max) = ""
rsarr(3,max) = 1000
max = max+1
rsarr(0,max) = 3000
rsarr(1,max) = "ORDINA"
rsarr(2,max) = "carrello.asp"
rsarr(3,max) = 1000
'Closing database, we don't need it anymore - we have the info in the array
rs.close()
Set rs = Nothing
dim row
row=0
do while(row<=max) 'Looping rows
'Setting variables
menuID = "m" & rsarr(0,row)
mName = rsarr(1,row)
mLink = rsarr(2,row)
if(mLink="null") then mLink=""
parent = rsarr(3,row)
if(parent<>0) then
parent = "m" & parent
else
parent=""
end if
'Making menu item
if mName = "Cancella" then
Response.write("oCMenu2.makeMenu('" & menuID & "','" &parent & "','" & mName & "','" & mLink & "',"""","""","""","""","""","""",""clLevel2over"")" & vbcrlf)
else
Response.write("oCMenu2.makeMenu('" & menuID & "','" &parent & "','" & mName & "','" & mLink & "')" & vbcrlf)
end if
row = row + 1
loop
End Sub
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'ASP CODE END - READING ITEMS FROM THE DATABASE
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%>
<%
call readItemsFromDatabase
%>
//Leave this line - it constructs the menu
oCMenu.construct()
<%
call readItemsFromDatabase2
%>
oCMenu2.construct()
</script>
</body>
</html>