<!--#include file="../conn/zkconn.asp" -->
<link href="../css/css.css" rel="stylesheet" type="text/css">
<table width="170" height="120" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="20" align="center" valign="middle"><img src="/image/cart.gif" width="170" height="25"></td>
  </tr>
  <tr>
    <td valign="middle"> 
      <%
conn.execute("Delete ls_cart where datediff(n,sj,getdate())>200")
conn.execute("Delete ls_userid where datediff(n,sj,getdate())>200")
if session.sessionid="" then
Response.Write("<script>alert(""本网站购物系统需要cookies的支持，请先调整您的浏览器设置!"");history.back();</script>")
end if
if request("cpid")<>"" and session.sessionid<>"" then
set rs = conn.execute("select sessionid from ls_cart where sessionid="&session.sessionid&"")
if rs.eof then
Response.Write("<script language=JavaScript>window.open('/open.htm','hello','scrollbars=0,height=100,width=300,top=200,left=200');</script>")
rs.close
end if
set rs = conn.execute("select * from chanpin where id="&request("cpid")&"")
if not rs.eof then
mc=rs("mc")
userid=rs("userid")
jg1=rs("jg1")
jg2=rs("jg2")
rs.close
end if
set rs = conn.execute("select * from ls_cart where cpid="&request("cpid")&" and sessionid="&session.sessionid&"")
if rs.eof then
conn.execute("Insert into ls_cart(cpid,mc,jg1,jg2,userid,sessionid,sj)values("&request("cpid")&",'"&mc&"',"&jg1&","&jg2&","&userid&","&session.sessionid&",'"&now()&"')")
set rs1 = conn.execute("select * from ls_userid where userid="&userid&" and sessionid="&session.sessionid&"")
if rs1.eof then
conn.execute("Insert into ls_userid(userid,sessionid,sj)values("&userid&","&session.sessionid&",'"&now()&"')")
else
conn.execute("Update ls_userid set sj='"&now()&"' where  userid="&userid&" and sessionid="&session.sessionid&"")
end if
rs1.close
else
conn.execute("Update ls_cart set sl=sl+1,sj='"&now()&"' where  cpid="&request("cpid")&" and sessionid="&session.sessionid&"")
conn.execute("Update ls_userid set sj='"&now()&"' where  userid="&userid&" and sessionid="&session.sessionid&"")
end if
rs.close
end if
if session.sessionid<>"" then
set rs = conn.execute("select * from ls_cart where sessionid="&session.sessionid&"")
if rs.eof then
favocou=0
zj=0
else
For I = 1 To rs.RecordCount
favocou = favocou + rs("sl")
zj = zj + csng(rs("jg2")) * rs("sl")
rs.MoveNext
Next
rs.close
end if
else
favocou=0 
zj=0
end if
zj=FormatNumber(zj,2)
Response.Write("&nbsp;&nbsp;您的购物车有<font color=#ff3300>"&favocou&"</font>件商品<br>&nbsp;&nbsp;总金额：<font color=#ff3300>"&zj&"</font>元")%>
      <br>&nbsp;&nbsp;<a href="/cart.asp" target="_parent">查看购物车/结账&gt;&gt;</a>
<% huiyuan=session("huiyuan")
if huiyuan<>"" then
set rs = conn.execute("select * from shoucang where huiyuan='"& huiyuan&"'") 
cang=rs.recordcount 
rs.close
else
cang=0
end if
%><br>&nbsp;&nbsp;<a href="/huiyuan-2.asp" target="_parent">您的收藏夹有<font color="#FF0000"><%=cang%></font>件商品</a></td>
</tr>
</table>