📄 buy.asp
字号:
<%@ language=vbscript%>
<%
if Session.Contents("UserName")="" then
%>
<script language="vbscript">
MsgBox "不能进入,你还没有登录"
location.href = "../index.htm"
</script>
<%
else
sid=Request.Form ("sid")
ushare=abs(Request.Form ("ushare"))
dim username
username=Session.Contents("UserName")
set conn=server.createobject("adodb.connection")
DBPath = Server.MapPath("stock.asp")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
set uconn=server.createobject("adodb.connection")
DBPath = Server.MapPath("../../data/members.asp")
uconn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
set rs_s=conn.execute ("select sshare,sprice_y,sprice_t from stock where sid="&sid)
set rs_u1=conn.execute ("select username,inprice from ustock where sid="&sid)
set rs_c=uconn.execute ("select * from users where name='"&username&"'")
if CSng(rs_s("sprice_t"))/CSng(rs_s("sprice_y"))>1.1 then
response.write "<link rel='stylesheet' type='text/css' href='../style1.css'><table border=0 width='100%' bgcolor=#FBE651 cellspacing=0 cellpadding=0><tr><td width='100%' height=20><p align=center>股票涨停不能进行交易</td></tr></table><dl><dd align='center'><p align='center'><a href=index.asp>返回股票交易大厅</a></p></dd></dl>"
else
dsshare=rs_s("sshare")-ushare
sql="select cash from users where name='"&username&"'"
set rs=server.createobject("adodb.recordset")
rs.cursorlocation=3
rs.open sql,uconn
nowmoney=rs("cash")
rs.close
set rs=nothing
if nowmoney>=ushare*rs_s("sprice_t") and dsshare>=0 then
delmoney=ushare*rs_s("sprice_t")
'dtumoney=session("bmoney")+session("umoney")-ushare*rs_s("sprice_t")
'dumoney=session("umoney")-ushare*rs_s("sprice_t")
'if dsshare>=0 and dtumoney>=0 then
if rs_u1.eof then
sprice=((dsshare+ushare)/dsshare)*rs_s("sprice_t")
conn.execute "update stock set sprice_t="&sprice&", sshare="&dsshare&",s_amount=s_amount+"&ushare&" where sid="&sid
conn.execute "insert into ustock (username,sid,indate,inprice,ushare,lastcount) values ('"&username&"','"&sid&"','"&date()&"','"&rs_s("sprice_t")&"','"&ushare&"','"&ushare&"')"
uconn.execute "update users set cash=cash-"&delmoney&" where name='"&username&"'"
'session("umoney")=dumoney
else
set rs_u=conn.execute ("select ushare,inprice from ustock where sid="&sid&" and username='"&username&"'")
if rs_u.eof then
sprice=((dsshare+ushare)/dsshare)*rs_s("sprice_t")
conn.execute "update stock set sprice_t="&sprice&", sshare="&dsshare&",s_amount=s_amount+"&ushare&" where sid="&sid
conn.execute "insert into ustock (username,sid,indate,inprice,ushare,lastcount) values ('"&username&"',"&sid&",'"&date()&"',"&rs_s("sprice_t")&","&ushare&","&ushare&")"
uconn.execute "update users set cash=cash-"&delmoney&" where name='"&username&"'"
'session("umoney")=dumoney
else
inprice=rs_u1("inprice")
sprice=((dsshare+ushare)/dsshare)*rs_s("sprice_t")
uprice=(rs_s("sprice_t")+rs_u1("inprice"))/2
conn.execute "update stock set sprice_t="&sprice&",sshare="&dsshare&",s_amount=s_amount+"&ushare&" where sid="&sid
conn.execute "update ustock set indate='"&date()&"',inprice="&uprice&",ushare="&rs_u("ushare")&"+"&ushare&",lastcount="&ushare&" where username='"&username&"' and sid="&sid
uconn.execute "update users set cash=cash-"&delmoney&" where name='"&username&"'"
'session("umoney")=dumoney
end if
end if
elseif dsshare<0 then
Response.Redirect ("serror.html")
else
Response.Redirect ("uerror.html")
end if
%>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 3.0">
<link rel="stylesheet" type="text/css" href="../style1.css">
<script ID="clientEventHandlersJS" LANGUAGE="javascript">
<!--
function button1_onclick() {
window.history.go(-2);
}
//-->
</script>
<title>股票交易成功</title>
<link rel="stylesheet" href="../../CSS/STYLE.CSS">
</head>
<body bgcolor="#FFFEF4">
<table border="0" width="100%" bgcolor="#FBE651" cellspacing="0" cellpadding="0">
<tr bgcolor="#FFFAE1">
<td width="100%" height="20">
<p align="center"><span class="p"><font color="#006633">购买成功!</font></span>
</td>
</tr>
</table>
<dl>
<dd align="center"><p align="center"><a href="index.asp">返回股票交易大厅</a></p>
</dd>
</dl>
</body>
</html>
<%end if
end if
%>
<%conn.close
set conn=nothing
uconn.close
set uconn=nothing
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -