<!--#include file="conn.asp"-->
<% 
if session("uname")="" then
response.redirect "../login.asp"
response.end
else
sid=Request.QueryString ("sid")
dim uname
uname=session("uname")
%>
<%
sql="select 资金 from 客户 where 帐号='"&uname&"'"
set rs=conn.execute(sql)

   if rs.eof or rs.bof then
call endinfo("你还没有股票帐户，不能炒股，请先开户")
else
   nowmoney=rs("资金")
   if nowmoney=0 then
   call endinfo("你的股票帐户里没有钱，不能炒股，请先存些钱进去")
end if
   rs.close
   set rs=nothing
   sql="select * from 股票 where sid="&sid
   set rss=conn.execute(sql)
   if rss("状态")="封" then
 call endinfo("今天股市还没开盘或者已经封盘，不能进行交易")
   else
   
   sql="select 持股数 from 大户 where sid="&sid&" and 帐号='"&uname&"'"
   set rs=conn.execute(sql)
   if rs.eof then 
   sushare=0
   else
   sushare=rs("持股数")
   end if
%>

<html>

<head>
<title>股票交易</title>
</head>

<body oncontextmenu=self.event.returnValue=false; bgcolor="#FFFEF4" style="font-size:9pt;">
<form name="form1" method="post" action="buy.asp" >
  <input type="hidden" name="sid" value="<%=sid%>">
  <div align="center"> 
    <center>
      <p class="fnt9"><font color="#006633">股票代号：<%=sid%> 股票数量： 
        <%nowtt=rss("流通股票")%>
        <%=rss("流通股票")%> 当前价格：<%=formatnumber(rss("当前价格"),3)%></font></p>
    </center>
  </div>
  <div align="center"> 
    <center>
      <p class="fnt9"><font color="#006633">您的股票帐户里现有资金： 
        <% 
	  if nowmoney=0 then
	  response.write "０"
	  else
	  response.write (formatnumber(nowmoney,0))
	  end if
	  %>
        元,</font></p>
    </center>
  </div>
  <div align="center"> 
    <center>
      <p class="fnt9"><font color="#006633">购买数量： 
        <input name="ushare"
  size="20" class="smallinput">
        <input type="submit" value="购买" name="B1"class="buttonface">
        <input  type="reset" value="取消" name="B2" class="buttonface">
        <br>
        <font color="#990000">扣除 0.1% 的手续费后，你最多可以购买 
       <%	if (formatnumber(nowmoney,0))=0  then'1%>
        <%="0" %> 
        <% else %>
        <% if nowtt<(int((formatnumber(nowmoney,0)/formatnumber(rss("当前价格"),3))*0.999)) and nowmoney>=nowtt*rss("当前价格")*1.01 then %>
        <%=nowtt%> 
        <%else %>
        <%=int((formatnumber(nowmoney,0)/formatnumber(rss("当前价格"),3))*0.999) %> 
        <%end if %>
        <% 		 end if '1 %>
        股</font></font></p>
    </center>
  </div>
</form>
<form name="form2" method="post" action="sale.asp"  >
  <span class="fnt9"><font color="#006633"> 
  <input type="hidden" name="sid" value="<%=sid%>">
  </font> </span> 
  <div align="center"> 
    <center>
      <font color="#006633">卖出数量： 
        <input
  name="ushare2" size="20" class="smallinput">
        <input type="submit" value="卖出" name="B3" class="buttonface">
        <input
  type="reset" value="取消" name="B2" class="buttonface">
        </font>
    </center>
  </div>
  <div align="center" class="fnt9"><font color="#990000">你拥有这种股票数：</font><font color="#006633"><%=sushare%><font color="#990000"> 
    股</font></font> </div>
</form>
<div align="center" class="fnt9"><font color="#006633"> 
  <%end if %>
  <a href="gupiao.asp"><font color="#0000FF">返回股票交易大厅</font></a></font> </div>
</body>
</html>
<%
end if
end if

 sub endinfo(message) 
'-------------------------------信息提示-------------------------------
%>
<table width="<%=TableWidth%>" border=0 cellspacing=1 cellpadding=3 align=center bgcolor="<%=Tablebackcolor%>"><tr bgcolor="<%=Tabletitlecolor%>" ><td align=center height=26 bgcolor="<%=Tabletitlecolor%>"><b>信息提示</b></td></tr><tr><td align=center height=70 bgcolor="<%=aTabletitlecolor%>"><%=message%><br></td></tr><tr><td align=center height=26 bgcolor="<%=Tabletitlecolor%>"><a href="gupiao.asp">返回</a></td></tr></table>
<%end sub%>