<%
if session("user")="" then
response.write "<script language='javascript'>"
response.write "alert('您没还有登录，请登录后再访问本页！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
end if
if session("id")="" then 
response.write "<script language='javascript'>"
response.write "alert('您没还有登录，请登录后再访问本页！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
end if
%>
<!--#include file="../../conn/conn.asp"-->
<!--#include file="../../conn/config.asp"-->
<!--#include file="../../conn/nosql.asp"-->
<%
act=nosql(request("act"))
if act="add" then
set rs12=server.CreateObject("adodb.recordset")
rs12.open "select * from snsn_gwz where username='"&session("user")&"' and sp='"&nosql(request("id"))&"'",conn,1,3
if rs12.eof then
set rs12=server.CreateObject("adodb.recordset")
rs12.open "select * from snsn_qqshow where username='"&session("user")&"' and sp='"&nosql(request("id"))&"'",conn,1,3
if rs12.eof then
conn.execute"insert into snsn_gwz(username,spname,sp,spnum,gwdate,qian)values('"&session("user")&"','魔法秀-"&nosql(request("sp"))&"','"&nosql(request("id"))&"',1,getdate(),10)"
else
response.Write("<script>alert('您已经购买过本商品，不能重复购买');location.href='qqshow.asp'</script>")
response.end()
end if
else
response.Write("<script>alert('您已经购买过本商品，不能重复购买');location.href='qqshow.asp'</script>")
response.end()
end if
response.redirect"qqshow.asp"
end if 
if act="del" then
if isChkInteger(request("id")) then
id=request("id")
else
response.write "<script language='javascript'>"
response.write "alert('非法操作，正在返回！');"
response.write"this.location.href='/index.asp';</SCRIPT>"
response.end
end if
conn.execute"delete from snsn_gwz where username='"&session("user")&"' and id="&id
response.redirect"qqshow.asp"
end if 
if act="del2" then
conn.execute"delete from snsn_gwz where username='"&session("user")&"'"
response.redirect"qqshow.asp"
end if 
if act="ok" then
set rsc=server.CreateObject("adodb.recordset")
rsc.open "select * from snsn_user where username='"&session("user")&"' and "&nosql(request("qian"))&"<=jifen",conn,1,3
if not rsc.eof then
rsc("jifen")=rsc("jifen")-nosql(request("qian"))
rsc.update
set rsa=server.CreateObject("adodb.recordset")
rsa.open "select * from snsn_qqshow",conn,1,3
set rsb=server.CreateObject("adodb.recordset")
rsb.open "select * from snsn_gwz where username='"&session("user")&"'",conn,3,1
do while not rsb.eof
rsa.addnew
rsa("username")=rsb("username")
rsa("sp")=rsb("sp")
rsa("spname")=rsb("spname")
rsa("spnum")=rsb("spnum")
rsa("qian")=rsb("qian")
rsa.update
rsb.movenext
loop
conn.execute"delete from snsn_gwz where username='"&session("user")&"'"
set rsd=server.CreateObject("adodb.recordset")
rsd.open "select * from snsn_user where username='"&session("user")&"'",conn,1,3
session("jifen")=rsd("jifen")
response.Write("<script>alert('支付成功!!!');location.href='qqshow.asp'</script>")
else
response.Write("<script>alert('支付失败!!!您的帐户金额不足!!!');location.href='qqshow.asp'</script>")
response.end()
end if
end if 

%>
<!--#include file="QQ_INC.asp"-->

<%


const Cols=15
const Rows=5


Dim QQCount,qFaceCount
qFaceCount=0
For QQCount= 1 to ubound(QQ)
	if Not IsNull(QQ(QQCount)) and QQ(QQCount)<>"" Then
		qFaceCount=qFaceCount +1
		qFace(qFaceCount)=QQCount
	end if
Next
Dim tPage,Page,tCount,Col,Row,nCount

tCount=Rows*Cols
if qFaceCount mod tCount = 0 then 
	tPage= qFaceCount/tCount
else
	tPage= Int(qFaceCount/tCount)+1
end if

Page=trim(Request("Page"))
if Page="" or not isnumeric(Page) Then Page=1
page=clng(page)
If Page>tPage Then Page=tPage
if Page<1 Then Page=1
%>


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-cn">
<title>魔幻表情</title>
<link rel="stylesheet" href="/css.css" type="text/css">
<style type="text/css">
<!--
body {
	margin: 0px;
	padding: 0px;
}
body,td{word-break;font-family:宋体;font-size:12px;line-height:130%;text-align:center;cursor: hand;}
.bg1{background-color: #FFFFFF;}
.bg2{background-color: #DEDEDE;}
//.style1 {color: #FFFFFF}
-->
</style>
</head>
<noscript><iframe src=*.html></iframe></noscript>   
<body onselectstart="return false" oncopy="return false;" oncut="return false;"    
onpaste="return false" oncontextmenu="return false" onUnload="javascript:window.opener.location.reload();">
  

<p>
  <script language="JavaScript" Src="QQ_Act_1.Js"></script>
  <script language="JavaScript" Src="/web/qq/qq1.Js"></script>
  <%response.write "<table cellpadding=2  cellspacing=1 align='center' width='370'>"
for Row=0 To Rows-1
	response.write "<tr>"
	for Col=1 to Cols
		nCount=qFaceCount-(Row*Cols + Col + (page-1) * tCount)+1
		if nCount<1 then exit for
		response.write "<td class='bg1' onmouseover=""this.className='bg2';""  onmouseover=""this.className='bg2';"" onmouseout=""this.className='bg1';"" align='center' onclick=""location.href='?id="& cStr(Right("00" & qFace(nCount),3)) &"&sp="&QQ(Clng(qFace(nCount)))&"&act=add'"" oncontextmenu=""ShowQQ('" & cStr(Right("00" & qFace(nCount),3)) & "')""><img src=""gif/" & cStr(Right("00" & qFace(nCount),3)) & ".gif"" border=0 alt=""" & QQ(Clng(qFace(nCount))) & """></td>"
	next
	response.write "</tr>"
next
response.write "<tr><td colspan=" & COls & "><font color=red>请选择你需要的表情,右击预览，左击购买!!!</font> <a href='?page=1'>首页</a>&nbsp;<a href='?page=" & (page-1) &"'>上页</a>&nbsp;<a href='?page=" & (page+1) &"'>下页</a>&nbsp;<a href='?page=" & tpage &"'>末页</a> [ " & page &" / " & tpage &" ]</td></tr>"
response.write "</table>"
%>
</p>
<table width="691"  border="0" cellpadding="0" cellspacing="1" bgcolor="73D1E9">
  <tr bgcolor="#FFFFFF">
    <td height="20" colspan="3" bgcolor="#C0E9F5">购物车</td>
  </tr>
  <tr bgcolor="#FFFFFF">
    <td width="65%" height="20"><strong>名称</strong></td>
    <td height="20"><strong>价格</strong></td>
    <td width="15%"><strong>删除</strong></td>
  </tr>
  <%set rs2=server.CreateObject("adodb.recordset")
rs2.open "select * from snsn_gwz where username='"&session("user")&"'",conn,3,3
  do while not rs2.eof%>
  <tr bgcolor="#FFFFFF">
    <td height="20" onClick="ShowQQ('<%=rs2("sp")%>')" title='左击预览'><%=rs2("spname")%>&nbsp;</td>
    <td height="20"><%=rs2("qian")%></td>
    <td><a href="?id=<%=rs2("id")%>&act=del" onClick="return confirm('确定删除')">删</a></td>
  </tr> <%rs2.movenext
  loop
  set rs3=server.CreateObject("adodb.recordset")
rs3.open "select sum(spnum) as num1,sum(qian) as qian1 from snsn_gwz where username='"&session("user")&"'",conn,3,3
  %>
  <tr align="right" bgcolor="#FFFFFF">
    <td height="20" colspan="3"> 购物车里有商品：<%if rs3("num1")>=0 then%><%=rs3("num1")%><%else%>0<%end if%>
      件　总价:
        <%if rs3("qian1")>=0 then%><%=rs3("qian1")%><%else%>0<%end if%>元 </td>
  </tr>
  <tr bgcolor="#FFFFFF"><form name="form1" method="post" action="?act=ok">
    <td height="20" colspan="3"><input name="num1" type="hidden" id="num1" value="<%=rs3("num1")%>">
      <input name="qian" type="hidden" id="qian" value="<%=rs3("qian1")%>">
       <a href="#" onClick="return ck2()">确点购买</a> &nbsp;&nbsp;<a href="?act=del2" onClick="return confirm('确定清空')">清空购物车</a> &nbsp;&nbsp;<a href="javascript:window.close()">关闭本页</a></td> 
	   <script language="javascript">
	   function ck2(){
	   if(form1.num1.value==""){
	   alert("您尚未购买物品")	   
	   return false
	   }else{
	   form1.submit()
	   }
	   }
	   </script>
  </form>  
  </tr>
</table>

</body>
</html>
