<%@language="vbscript"%>
<%response.buffer=true%>
<%response.expires=-1500%>
<%
dim dns
dim connessione
dim rs
dim sql
%>
<%
operazione=request("operazione")
quantita=request("txtquantita")
cod=request("codice")
utente=session("userlog")
dns="DRIVER=Microsoft Access Driver (*.mdb); dbq="& server.MapPath("DB.mdb")
set connessione=server.CreateObject("ADODB.Connection" )
connessione.open dns
set rs=server.CreateObject("ADODB.Recordset")
set rsOP=server.CreateObject("ADODB.Recordset")
set rsSC=server.CreateObject("ADODB.Recordset")
set rsp=server.CreateObject("ADODB.Recordset")
if operazione="" then
sql="SELECT * FROM Acquisti"
rsp.open sql,connessione
if rsp.bof=true and rsp.eof=true then
sqlSC="INSERT INTO Acquisti (cod,Marca,Prezzo) SELECT cod,Marca,Prezzo FROM Scarpe "
rsSC.open sqlSC,connessione,1,3
end if
end if
if operazione="aggiungi" then
sqlOP="SELECT * FROM Acquisti WHERE cod='"&cod&"';"
rsOP.open sqlOP,connessione,3,3
rsOP("Quantita")=quantita
rsOP("Utente")=utente
rsOP.update
end if
if operazione="elimina" then
sqlOP="SELECT * FROM Acquisti WHERE cod='"&cod&"';"
rsOP.open sqlOP,connessione,3,3
q=rsOP("Quantita")
qua=(q-quantita)
if qua>=0 then
rsOP("Quantita")=qua
if rsOP("Quantita")=0 then
rsOP("Utente")=""
end if
end if
rsOP.update
end if
sql="SELECT * FROM Acquisti"
rs.open sql,connessione
rs.movefirst
%>
<html>
<head>
<title>Armani</title>
</head>
<body >
<CENTER><font size="+2" color="#00CC00">CARRELLO</font></CENTER>
<font color="#00CC00">
<%if session("userlog")="" then
response.Redirect("login.html")
end if
%>
<table border="1" align="center">
<tr>
<td><font color="#00CC00">Codice</font></td>
<td><font color="#00CC00"> Prezzo</font></td>
</td>
<td><font color="#00CC00">Marca</font></td>
</td>
<td><font color="#00CC00">Quantita</font></td>
</td>
</tr>
<form method="post" action="">
<% somma=0
do until rs.eof%>
<tr>
<td><font color="#00CC00"><% response.write rs("cod")%></font></td>
<td><font color="#00CC00"> <% response.write rs("Prezzo")%></font></td><%prezzo=rs("Prezzo")%>
<td><font color="#00CC00"><% response.write rs("Marca")%></font></td>
<td><font color="#00CC00"><input type="text" value="<% response.write rs("Quantita")%>" name="txtquantita"></font></td><%numero=rs("Quantita")%>
<td><input type="submit" value="AGGIUNGI" onClick="this.form.action='carrello.asp?operazione =aggiungi&codice=<% response.write rs("cod")%>'"></td>
</td>
<td><input type="submit" value="ELIMINA" onClick="this.form.action='carrello.asp?operazione =elimina&codice=<% response.write rs("cod")%>'"></td>
</tr>
</form>
<%importo=numero*prezzo
somma=somma+importo
rs.movenext
loop
%>
<tr>
<td>TOTALE NEL CARRELLO:</td><td><%response.write somma%></td>
</td>
</table>
<%session("totale")=somma%>
</body>
</html>
<%
rs.close
connessione.close
set rs = nothing
set connessione = nothing
%>

Rispondi quotando
