<!--#include file="conn.asp"-->
<%if request.cookies("bookshop")("username")="" then
response.write "<script language=javascript>alert('对不起，您还没有登陆！');history.go(-1);</script>"
response.End
end if%>
<!--#include file="webconfig.asp"-->

<html>
<head>
<title><%=webname%>--我要下订单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/css.css" rel="stylesheet" type="text/css">
<style>
td{font-size:9pt;line-height:120%;color:#353535} 
body{font-size:9pt;line-height:120%} 

a:link          { color: #000000; text-decoration: none }
a:visited       { color: #000000; text-decoration: none }
a:active        { color: #000000; text-decoration: none }
a:hover         { color: #336699; text-decoration: none; position: relative; right: 0px; top: 1px }
</style>
</head>
<body leftmargin="0" topmargin="5" marginwidth="0" marginheight="0">
<table width="96%" border="0" align="center" cellpadding="2" cellspacing="1">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<%dim bookid,action,i
action=request.QueryString("action")
if request.QueryString("id")="" then
bookid=request("bookid")
else
bookid=request.QueryString("id")
end if
if bookid="" then
response.write "<script language=javascript>alert('对不起，您没有选择商品！');history.go(-1);</script>"
response.End
end if
select case action
'//////////////////////////////////
case ""
set rs=server.CreateObject("adodb.recordset")
rs.open "select bookid,bookname,shichangjia,huiyuanjia,dazhe from shop_books where bookid in ("&bookid&") order by bookid",conn,1,1%>
<table width="98%" border="1" cellspacing="0" cellpadding="1" bordercolor="#75A3D0" align="center">
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td rowspan="2"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="12v">
              <tr> 
                <td class="12v" > 
                  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber3" height="0" width="100%">
                    <tr> 
                      <td> 
                        <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
                          <form name="form1" method="post" action="">
                            <tr> 
                              <td width="41%" bgcolor="#5F95D3"> <div align="center"><font color="#FFFFFF">商品名称</font></div></td>
                              <td width="16%" bgcolor="#5F95D3"> <div align="center"><font color="#FFFFFF">市场价</font></div></td>
                              <td width="8%" bgcolor="#5F95D3"> <div align="center"><font color="#FFFFFF">折扣</font></div></td>
                              <td width="9%" bgcolor="#5F95D3"> <div align="center"><font color="#FFFFFF">数量</font></div></td>
                              <td width="14%" bgcolor="#5F95D3"> <div align="center"><font color="#FFFFFF">小计</font></div></td>
                              <td width="12%" bgcolor="#5F95D3"> <div align="center"><font color="#FFFFFF">修改数量</font></div></td>
                            </tr>
                            <%dim iii '定义总价
	  
	  dim bookscount,books '定义判断有几个bookid 
	  bookscount=request.QueryString("id").count
	  do while not rs.eof
	dim quatity '判断input 名
	 Quatity = CInt( Request( "ckxp"&rs("bookid")) )
	If Quatity <=0 Then Quatity = 1
	%>
                            <tr> 
                              <td bgcolor="#EFF5FE" style='PADDING-LEFT: 5px'><%=trim(rs("bookname"))%> <input type=hidden name=bookname value=<%=trim(rs("bookname"))%>> 
                              </td>
                              <td bgcolor="#EFF5FE"> <div align="center"><%=formatnumber(rs("shichangjia"),2)&"点"%></div></td>
                              <input type=hidden name=huiyuanjia value=<%=rs("huiyuanjia")%>>
                              <td bgcolor="#EFF5FE"> <div align="center"><%=formatnumber(rs("dazhe")*100,2)&"%"%></div></td>
                              <td bgcolor="#EFF5FE"> <div align="center"> 
                                  <input name="<%="ckxp"& rs("bookid")%>" type="text" size="3" value="<%=Quatity%>" onKeyPress= "return regInput(this,	/^[0-9]*$/,	String.fromCharCode(event.keyCode))"onpaste	= "return regInput(this,/^[0-9]*$/, window.clipboardData.getData('Text'))"ondrop= "return regInput(this,/^[0-9]*$/,event.dataTransfer.getData('Text'))">
                                </div></td>
                              <td bgcolor="#EFF5FE"> <div align="center"> 
                                  <%if Quatity<=1 then
	  response.write formatnumber(rs("huiyuanjia")*1,2)&"点"
	  else
	  response.write formatnumber(rs("huiyuanjia")*Quatity,2)&"点"
	  end if
	  
	  iii=formatnumber(rs("huiyuanjia")*Quatity+iii,2 )
	  %>
                                </div></td>
                              <td bgcolor="#EFF5FE"> <div align="center"> 
                                  <input type="submit" name="Submit" value="修改"  onClick="this.form.action='shopping.asp?id=<%=bookid%>';this.form.submit()">
                                </div></td>
                            </tr>
                            <%if bookscount=1 then books=rs("bookid")
	rs.movenext
	loop
	rs.close
	  set rs=nothing%>
                            <tr bgcolor="#EFF5FE"> 
                              <td height="18" colspan="6" > <div align="right"><font color="#FF0000">总计会消耗：<%=iii%>点&nbsp;&nbsp;&nbsp;&nbsp;</font></div></td>
                      
				
						      </tr>
                            <tr bgcolor="#EFF5FE"> 
                              <td height="27" colspan="6" > <div align="center"> 
                                  <input type="submit" name="Submit2" style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"value="立即成交" onClick="this.form.action='shopping.asp?action=ckxp1&id=<%=bookid%>';this.form.submit()" >
                                  &nbsp;&nbsp; 
                                  <%if bookscount=1 then%>
                                  <input type="button" name="Submit22" style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"value="放入收藏架" onClick="location.href='shoucang.asp?id=<%=books%>&action=add'"><input name="num" type="hidden" value="<%=iii%>">
                                  <%end if%>
                                </div></td>
                            </tr>
                            <tr bgcolor="#EFF5FE">
                              <td height="28" colspan="6" >注意：请保护好您的密码谨慎交易，点击成交后立即从您的聊天室点中扣除相应的点！</td>
                            </tr>
                          </form>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%
'/////////////////////////////////////////
case "ckxp1"
'response.Write bookid
set rs=server.CreateObject("adodb.recordset")
rs.open "select username,exp_num from [user] where username='"&request.cookies("bookshop")("username")&"'",conn,1,1
dim userid
userid=rs("username")
dim test
test=request.form("num")
 if rs("exp_num")<clng(test)  then
 response.Write"对不起，您的经验值不足，不可以购买这个东西！"%>
 <%else%>

<table width="100%" border="1" cellspacing="0" cellpadding="1" bordercolor="#75A3D0" align="center">
  <tr> 
    <td height="100"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td rowspan="2"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="12v">
              <tr> 
                <td class="12v" > 
                  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber3" height="0" width="100%">
                    <tr> 
                      <td valign="top"> 
                        <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF">
                          <form name="shouhuoxx" method="post" action="shopping.asp?action=ok&id=<%=bookid%>&userid=<%=userid%>">
                            <b> 
                            <%dim rs2
 set rs2=server.CreateObject("adodb.recordset")
'付值某的数量
rs2.open "select bookid from shop_books where bookid in ("&bookid&") order by bookid",conn,1,1
do while not rs2.eof
%>
                            <input name="<%="ckxp"&rs2("bookid")%>" type="hidden" value="<%=cint(request("ckxp"&rs2("bookid")))%>">
                            <%
rs2.movenext
loop
rs2.close
set rs2=nothing%>
                            </b> 
                            <tr bgcolor="#EFF5FE"> 
                              <td colspan="2" style='PADDING-LEFT: 20px'> 
                                
                            <tr bgcolor="#EFF5FE"> 
                              <td height="32" colspan="2" style='PADDING-LEFT: 20px'> 
                                <div align="center"><b> 
                                 <% dim num2
								   num2=request.form("num")   
								%>
                                  <input name="num3" type="hidden" value=<%=num2%> >
                                  <input type="submit" name="Submit3" style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"value="您真的要成交吗？" onClick="return ssxx();">&nbsp;&nbsp;&nbsp;&nbsp;
                                  <input type="submit" name="Submit4" value="放弃交易" style="height:20; font:9pt; BORDER-BOTTOM: #cccccc 1px groove; BORDER-RIGHT: #cccccc 1px groove; BACKGROUND-COLOR: #eeeeee"  onClick=javascript:window.close()>
                                  </b></div></td>
                            </tr>
                          </form>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<% end if%>
<%
case "ok"
'/////////////////////////////////////////////////
function HTMLEncode2(fString)
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P>")
	fString = Replace(fString, CHR(10), "<BR>")
	HTMLEncode2 = fString
end function
'''''''此处用来更改经验值


dim sql 
dim exp_num

dim num3
num3=formatnumber(request.form("num3"))
set rs=server.CreateObject("adodb.recordset")
sql="select * from user where username='"&request.cookies("bookshop")("username")&"'"
rs.open sql,conn,1,3


rs("exp_num")=rs("exp_num")-num3
exp_num=rs("exp_num")
rs.Update
rs.close





if session("xiadan")<>minute(now) then
dim shijian,dingdan
shijian=now()
dingdan=year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
'response.write bookid
set rs2=server.CreateObject("adodb.recordset")
rs2.open "select bookid,bookname,shichangjia,huiyuanjia,dazhe from shop_books where bookid in ("&bookid&") order by bookid ",conn,1,1
dingdan=year(shijian)&month(shijian)&day(shijian)&hour(shijian)&minute(shijian)&second(shijian)
do while not rs2.eof
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from shop_action",conn,1,3
rs.addnew
rs("username")=trim(request.cookies("bookshop")("username"))
rs("bookid")=rs2("bookid")
rs("actiondate")=shijian
rs("bookcount")=CInt(Request("ckxp"&rs2("bookid")))
rs("zhuangtai")=1
rs("dingdan")=dingdan

rs.update
rs.close
set rs=nothing
conn.execute "delete from shop_action where username='"&request.cookies("bookshop")("username")&"' and bookid in ("&bookid&") and zhuangtai=6"
rs2.movenext
loop
rs2.close
set rs2=nothing
session("xiadan")=minute(now)
else
response.Write "<center>您不能重复提交！</center>"
response.End
end if
'/////////////HTML
set rs=server.CreateObject("adodb.recordset")
rs.open "select shop_books.bookid,shop_books.bookname,shop_books.shichangjia,shop_books.huiyuanjia,shop_action.shousex,shop_action.userzhenshiname,shop_action.shouhuoname,shop_action.dingdan,shop_action.youbian,shop_action.liuyan,shop_action.zhifufangshi,shop_action.songhuofangshi,shop_action.zonger,shop_action.bookcount from shop_books inner join shop_action on shop_books.bookid=shop_action.bookid where shop_action.username='"&request.Cookies("bookshop")("username")&"' and zhuangtai=1 and dingdan='"&dingdan&"' ",conn,1,1

%>
<table width="98%" border="1" cellspacing="0" cellpadding="1" bordercolor="#75A3D0" align="center">
  <tr> 
    <td> 
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td rowspan="2"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0" class="12v">
              <tr> 
                <td class="12v" > 
                  <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" id="AutoNumber3" height="0" width="100%">
                    <tr> 
                      <td> 
                        <table width="100%" border="0" align="center" cellpadding="2" cellspacing="1">
                          <tr> 
                            <td height="18" bgcolor="#EFF5FE"> <div align="center"><font color="#FF6600">恭喜，您已成功的进行了交易！我们将在你的经验值扣除<%=num3%>！还有<%=exp_num%>点经验值以下是你的订单号吗：</font></div></td>
                          </tr>
                          <tr> 
                            <td height="18" bgcolor="#EFF5FE" style='PADDING-LEFT: 100px'>订单号：<font color=#FF6600><%=rs("dingdan")%></font></td>
                          </tr>
                          <tr> 
                            <td bgcolor="#EFF5FE" style='PADDING-LEFT: 100px'>请牢记订单号！</td>
                          </tr>
                          <%if trim(request("liuyan"))<>"" then%>
                          <%end if%>
                          <tr> 
                            <td height="26" bgcolor="#EFF5FE" style='PADDING-LEFT: 100px'> 
                              <p>商品领取及咨询服务电话： 0411-4508363<font color=#666666> 
                                </font></p></td>
                          </tr>
                          <tr> 
                            <td height="18" bgcolor="#D0E2FD" style='PADDING-LEFT: 100px'> 
                              <div align="right"><a href="#" onClick=javascript:window.close()> 
                                关闭窗口</a><font color="#999999">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;订单完成 
                                创建时间：<%=shijian%>&nbsp;</font></div></td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<%set rs=server.CreateObject("adodb.recordset")
rs.open "select chengjiaocount from shop_books where bookid in ("&bookid&")" ,conn,1,3
do while not rs.eof
rs("chengjiaocount")=rs("chengjiaocount")+1
rs.update
rs.movenext
loop
rs.close
set rs=nothing
end select%>
</body>
</html>

<script language=javascript>
<!--
function regInput(obj, reg, inputStr)
{
	var docSel	= document.selection.createRange()
	if (docSel.parentElement().tagName != "INPUT")	return false
	oSel = docSel.duplicate()
	oSel.text = ""
	var srcRange	= obj.createTextRange()
	oSel.setEndPoint("StartToStart", srcRange)
	var str = oSel.text + inputStr + srcRange.text.substr(oSel.text.length)
	return reg.test(str)
}
function checkspace(checkstr) {
  var str = '';
  for(i = 0; i < checkstr.length; i++) {
    str = str + ' ';
  }
  return (str == checkstr);
}

   //-->
</script>