<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!--#include file="inc/ex_stock/ex_sm_conn.asp"-->
<!--#include file="inc/ex_stock/ex_sm_const.asp"-->
<%
	dim reg_info,user_info,trade_info
	reg_info=split(exsm.stockdata(9,0),",")
	user_info=split(exsm.stockdata(11,0),",")
	trade_info=split(exsm.stockdata(10,0),",")
	call connectiondatabase()
	select case request("action")
		case "newexuser"
			call newexuser()
		case "savenewexuser"
			call savenewexuser()
		case "userinfo"
			call userinfo()
		case "savemyinfo"
			call savemyinfo()
		case "reflashinfo"
			call reflashinfo()
		case "accountadopt"
			call accountadopt()
		case "accountdeposit"
			call accountdeposit()
		case "accounttransfer"
			call accounttransfer()
		case else
			call main()
	end select
	sub main()
		session("ex_sm")=0
		sql="select * from ex_user where id="&exsm.userid&" and lockuser=0"
		set rs=stock_conn.execute(sql)
		if rs.eof and rs.bof then
			call newexuser()
			exit sub
		else
		exsm.title 1,"股市帐户"
%>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
		<tr>
		<th colspan="11" height="25">-=> 持 股 情 况 <=-</th>
		</tr>
		<tr align="center">
		<td class="tablebody2"><b>代码</b></td>
		<td class="tablebody2"><b>股票名称</b></td>
		<td class="tablebody2"><b>拥有数量</b></td>
		<td class="tablebody2"><b>持股成本</b></td>
		<td class="tablebody2"><b>当前价</b></td>
		<td class="tablebody2"><b>持股价</b></td>
		<td class="tablebody2"><b>持股现值</b></td>
		<td class="tablebody2"><b>每股盈亏</b></td>
		<td class="tablebody2"><b>总盈亏</b></td>
		<td class="tablebody2"><b>盈亏率</b></td>
		<td class="tablebody2"><b>状态</b></td>
		</tr>
<%
		dim agvinprice,currentprice
		dim mygupiaonum,mygupiaovalue,mygupiaocost
		dim ykstr,totalgranrate
		dim currentpage,page_count,totalrec,pcount,color(0)
		dim bj,totalgain,granrate,meigukuisun,zongkuisun,yingkuilv,fudu,pricechange
		mygupiaonum=0 :	mygupiaovalue=0 :	mygupiaocost=0
		sql="select d.*,g.tradeprice,g.closingprice,g.management,g.managementid,g.lockstock from ex_customer d inner join ex_stock g on d.code=g.code where d.userid="&exsm.userid&" order by d.possessstocksum desc"
		set rs=stock_conn.execute(sql)
		if rs.eof and rs.bof then
			response.write "<tr><td class=""tablebody1"" colspan=""11"">您还没有股票。</tr></table>"
		end if
		currentpage=request("page")
		if currentpage="" or not isnumeric(currentpage) then
			currentpage=1
		end if
		set rs= server.createobject("adodb.recordset")
		rs.open sql,stock_conn,1,1
		if rs.eof and rs.bof then
		else
			rs.pagesize=cint(exsm.setting_info(15))
			rs.absolutepage=currentpage
			page_count=0
			totalrec=rs.recordcount
			do while (not rs.eof) and (not page_count = rs.pagesize)
				currentprice=round(rs("tradeprice"),2)
				agvinprice=round(rs("averageprice"),2)
				mygupiaonum=mygupiaonum+rs("possessstocksum")
				mygupiaovalue=mygupiaovalue+(rs("possessstocksum"))*currentprice
				mygupiaocost=mygupiaocost+(rs("possessstocksum"))*agvinprice
				bj=currentprice-agvinprice
				bj=round(bj,2)
				if bj>0 then
					meigukuisun="<font color=""#ff0000"">↑"&formatnumber(bj,2,true)&"</font>"
					color(0)="#ff0000"
				elseif bj<0 then
					meigukuisun="<font color=""#008800"">↓"&formatnumber(abs(bj),2,true)&"</font>"
					color(0)="#008800"
				elseif bj=0 then
					meigukuisun="<font color=""#000000"">→0.00</font>"
					color(0)="#000000"
				end if
				totalgain=bj*(rs("possessstocksum"))
				granrate=totalgain*100/mygupiaocost
				if totalgain>0 then
					zongkuisun="<font color=""#ff0000"">↑"&formatnumber(totalgain,2,true)&"</font>"
					yingkuilv="<font color=""#ff0000"">↑"&formatnumber(granrate,2,true)&"%</font>"
				elseif totalgain<0 then
					zongkuisun="<font color=""#008800"">↓"&formatnumber(-totalgain,2,true)&"</font>"
					yingkuilv="<font color=""#008800"">↓"&formatnumber(-granrate,2,true)&"%</font>"
				else
					zongkuisun="<font color=""#000000"">→0.00</font>"
					yingkuilv="<font color=""#000000"">→0.00%</font>"
				end if
				if mygupiaovalue-mygupiaocost>0 then
					ykstr="<font color=""#ff0000"">↑"&formatnumber(mygupiaovalue-mygupiaocost,2,true)
				elseif mygupiaovalue-mygupiaocost<0 then
					ykstr="<font color=""#008800"">↓"&formatnumber(mygupiaocost-mygupiaovalue,2,true)
				else
					ykstr="<font color=""#000000"">→0.00"
				end if
					ykstr=ykstr&"</font>"
				if mygupiaocost=0 then
					totalgranrate=0
				else
					totalgranrate=(mygupiaovalue-mygupiaocost)*100/mygupiaocost
				end if
%>
				<tr align="right">
				<td class="tablebody1" align="center"><font color="olive"><%=rs("code")%></font></td>
				<td class="tablebody1" align="center"><a href="ex_sm_dispcompare.asp?sid=<%=rs("sid")%>" onmouseover="cziemenu(event,'<div><a href=\'ex_sm_dispcompare.asp?sid=<%=rs("sid")%>\'>上市资讯</a></div><div><a href=\'ex_sm_exchange.asp?sid=<%=rs("sid")%>\'>进行交易</a></div>','',15)"><font color="<%=color(0)%>"><%=rs("company")%></font></a></td>
				<td class="tablebody1"><%=replace(formatnumber(rs("possessstocksum"),0,-1),",","")%></td>
				<td class="tablebody1"><%=formatnumber(agvinprice*(rs("possessstocksum")),2,-1)%></td>
				<td class="tablebody1"><%=formatnumber(currentprice,2,-1)%></td>
				<td class="tablebody1"><%=formatnumber(agvinprice,2,-1)%></td>
				<td class="tablebody1"><%=formatnumber(currentprice*(rs("possessstocksum")),2,-1)%></td>
				<td class="tablebody1"><%=meigukuisun%></td>
				<td class="tablebody1"><%=zongkuisun%></td>
				<td class="tablebody1"><%=yingkuilv%></td>
<%
					response.write "<td class=""tablebody1"" align=""center"">"
					response.write "<a style=""cursor:hand"" onmouseover=""cziemenu(event,'<div>"
					response.write "<a>股票状态："
					if rs("lockstock")=0 then
						pricechange=round(round(rs("tradeprice")-rs("closingprice"),2)/round(rs("closingprice"),2),4)
						if round(rs("tradeprice"),2)<round(trade_info(5),2) then
							response.write "<font color=\'navy\'>停牌</font>"
						elseif pricechange>=round(trade_info(3)/100,2) then
							response.write "<font color=\'#ff0000\'>涨停</font>"
						elseif pricechange<=-round(trade_info(4)/100,2) then
							response.write "<font color=\'#008800\'>跌停</font>"
						else
							response.write "开盘"
						end if
					else
						response.write "<font color=\'#ff0000\'>封盘</font>"
					end if
					response.write "</a></div>"
					if not exsm.stockadmin and split(exsm.stockdata(12,0),",")(0)=1 and rs("managementid")=exsm.userid then
						response.write "<div><a href=\'ex_sm_exchange.asp?action=userfh&sid="&rs("sid")&"\'>分红操作</a></div>"
					end if
					response.write "<div><a>今涨跌幅："&formatpercent(pricechange,2,-1)&"</a></div>"
					response.write "<div><a>买入时间："&rs("buytime")&"</a></div>"
					if datediff("n",rs("buytime"),now())<round(trade_info(14)) then
						response.write "<div><a>离再买入时间还差：<font color=\'#ff0000\'>"&trade_info(14)-datediff("n",rs("buytime"),now())&"分钟</font></a></div>"
					end if
					if datediff("n",rs("buytime"),now())<round(trade_info(7)) then
						response.write "<div><a>离可卖出时间还差：<font color=\'#ff0000\'>"&trade_info(7)-datediff("n",rs("buytime"),now())&"分钟</font></a></div>"
					else
						if datediff("n",rs("selltime"),now())<round(trade_info(15)) then
							response.write "<div><a>离再卖出时间还差：<font color=\'#ff0000\'>"&trade_info(15)-datediff("n",rs("selltime"),now())&"分钟</font></a></div>"
						end if
					end if
					response.write "','',0)"">其它</a>"
					response.write "</td></tr>"
				page_count=page_count+1
				rs.movenext
				loop
				pcount=rs.pagecount
				if totalgranrate>0 then
					fudu="<font color=""#ff0000"">↑"&formatnumber(totalgranrate,2,true)&"%</font>"
				elseif totalgranrate<0 then
					fudu="<font color=""#0000ff"">↓"&formatnumber(-totalgranrate,2,true)&"%</font>"
				else
					fudu="<font color=""#000000"">→0.00%</font>"
				end if
%>
				<tr align="right">
				<td class="tablebody2" align="center">总&nbsp;&nbsp;&nbsp;计</td>
				<td class="tablebody2" align="center">-</td>
				<td class="tablebody2"><%=replace(formatnumber(mygupiaonum,0,-1),",","")%></td>
				<td class="tablebody2"><%=formatnumber(mygupiaocost,2,-1)%></td>
				<td class="tablebody2" align="center">-</td>
				<td class="tablebody2" align="center">-</td>
				<td class="tablebody2"><%=formatnumber(mygupiaovalue,2,-1)%></td>
				<td class="tablebody2" align="center">-</td>
				<td class="tablebody2"><%=ykstr%></td>
				<td class="tablebody2"><%=fudu%></td>
				<td class="tablebody2" align="center">-</td>
				</tr>
				</table>
<%
				call exsm.disppagenum(totalrec,page_count,currentpage,pcount,"?page=","?")
			end if
			rs.close
			set rs=nothing
			set rsbbs=conn.execute("select userwealth from dv_user where userid="&exsm.bbsuserid&"")
%>
			<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0"><br>
			<tr><th height="25">-=> 资 金 管 理 <=-</th></tr>
			<tr><td align="center" valign="center" class="tablebody1"><br>您的论坛帐户中虚拟资金共“<font color="#0000ff"><%=formatnumber(rsbbs(0),2,-1)%></font>”元，股市帐户中虚拟资金共“<font color="#0000ff"><%=formatnumber(exsm.usercash,2,-1)%></font>”元。
			<%if user_info(0)=1 then%>
				<br><br><div><form method="post" action="?action=accountadopt" name="form1">从股票帐户提款：<input type="text" name="money" size="10" class="pageinput">&nbsp;<input type="submit" name="submit" class="pageinput" value="取款">&nbsp;取款手续费[<font color="red"><%if user_info(6)<0 then%>0.00<%else%><%=formatnumber(user_info(6),2,-1)%><%end if%>%</font>]</form></div>
			<%end if
			if user_info(1)=1 then%>
				<div><form method="post" action="?action=accountdeposit" name="form2">存款到股票帐户：<input type="text" name="money" size="10" class="pageinput">&nbsp;<input type="submit" name="submit" class="pageinput" value="存款">&nbsp;存款手续费[<font color="red"><%if user_info(7)<0 then%>0.00<%else%><%=formatnumber(user_info(7),2,-1)%><%end if%>%</font>]</form></div>
			<%end if
			if user_info(4)=1 then%>
				<div><form method="post" action="?action=accounttransfer" name="form3">过户：<input type="text" name="xianjin" size="10" class="pageinput">&nbsp;元 给：<input type="text" name="username" size="10" class="pageinput">&nbsp;<input type="submit" name="submit" class="pageinput" value="过户">&nbsp;过户手续费[<font color="red"><%if user_info(8)<0 then%>0.00<%else%><%=formatnumber(user_info(8),2,-1)%><%end if%>%</font>]</form></div>
			<%end if%>
			<font color="red">请注意:论坛帐户资金与股市虚拟资金的兑换比例为<b>1:<%if user_info(5)<0 then%>1.00<%else%><%=formatnumber(user_info(5),2,-1)%><%end if%></b></font><br><br></td></tr>
			</table>
<%
		end if
		exsm.rootshow
	end sub
	sub userinfo()
		if not exsm.members then
			exsm.errmess="您还没有股票帐户，请先开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		exsm.title 1,"帐户设置"
		session("ex_sm")=0
		exsm.reloadon=0
		set rs=stock_conn.execute("select id,transfersecret,ranksecret,tradesecret,autoupname from ex_user where id="&exsm.userid&"")
		if not rs.eof then
%>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
		<tr><th colspan="2" height="25">-=> 帐 户 设 置 <=-</th></tr>
		<form method="post" action="?action=savemyinfo">
		<tr><td class="tablebody1" width="50%"><u>过户设置</u><br>是否接收其他股民过户</td>
		<td class="tablebody1">&nbsp;<input type="radio" name="transfersecret" value="1" <%if rs(1)=1 then%>checked<%end if%>>是&nbsp;<input type="radio" name="transfersecret" value="0" <%if rs(1)=0 then%>checked<%end if%>>否</td></tr>
		<tr><td class="tablebody2"><u>股市帐户名称保护</u><br>如果可能是否取得经营权，股市首页为不显示您的名称其它页面为星号代替</td>
		<td class="tablebody2">&nbsp;<input type="radio" name="ranksecret" value="1" <%if rs(2)=1 then%>checked<%end if%>>是&nbsp;<input type="radio" name="ranksecret" value="0" <%if rs(2)=0 then%>checked<%end if%>>否</td></tr>
		<tr><td class="tablebody1"><u>交易保密默认设置</u><br>默认交易时是否显示您的名称</td>
		<td class="tablebody1">&nbsp;<input type="radio" name="tradesecret" value="1" <%if rs(3)=1 then%>checked<%end if%>>是&nbsp;<input type="radio" name="tradesecret" value="0" <%if rs(3)=0 then%>checked<%end if%>>否</td></tr>
		<tr><td class="tablebody2"><u>自动跟踪用户名</u><br>是否自动跟踪论坛中的用户名称（使用论坛道具中心的“转生之炎”）</td>
		<td class="tablebody2">&nbsp;<input type="radio" name="autoupname" value="1" <%if rs(4)=1 then%>checked<%end if%>>是&nbsp;<input type="radio" name="autoupname" value="0" <%if rs(4)=0 then%>checked<%end if%>>否</td></tr>
		<tr><td colspan="2" class="tablebody1" align="center"><input type="submit" name="submit" value="提交">&nbsp;&nbsp;<input type="reset" name="submit" value="重填"></td></tr>
		</form>
		</table>
<%
		end if
		exsm.rootshow
	end sub
	sub newexuser()
		dim exwarn,se_setting
		se_setting=split(exsm.stockdata(13,0),",")
		if exsm.stockholder="" then
			exsm.errmess="您是游客，不能开设股票帐户！请注册后在来。"
			call exsm.endinfo("no")
			exit sub
		end if
		if exsm.members then
			exsm.errmess="您已经有股票帐户了，怎么还来开户？"
			call exsm.endinfo("no")
			exit sub
		end if
		if cint(reg_info(0))=0 then
			exsm.errmess="股市暂停开户，请与管理员联系。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rsbbs=conn.execute("select userpost,usercp,userep,userwealth from dv_user where userid="&exsm.bbsuserid&"")
		if rsbbs(0)<cint(reg_info(1)) then
			exsm.errmess="本股市已限制了开户最少发帖数为["&reg_info(1)&"]，您现在不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rsbbs(1)<cint(reg_info(2)) then
			exsm.errmess="本股市已限制了开户最少魅力值为["&reg_info(2)&"]，您不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rsbbs(2)<cint(reg_info(3)) then
			exsm.errmess="本股市已限制了开户最少经验值为["&reg_info(3)&"]，您不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rsbbs(3)<cdbl(reg_info(4)) then
			exsm.errmess="本股市已限制了开户最少现金值为["&reg_info(4)&"]，您不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		rsbbs.close
		set rsbbs=nothing
		set rs=stock_conn.execute("select username from ex_user where username='"&exsm.stockholder&"'")
		if not rs.eof then
			exwarn="<font color=""#ff0000"">您的用户名已经存在！您必须重新填写用户名</font>"
		else
			exwarn="您可以直接开户或填写新名字进行开户"
		end if
		exsm.title 1,"股市开户"
		session("ex_sm")=0
		exsm.reloadon=0
		response.write "<table class=""tableborder1"" cellspacing=""1"" cellpadding=""3"" align=""center"" border=""0"">"
		response.write "<tr><th height=""25"">-=> 新 股 民 开 户 <=-</th></tr>"
		response.write "<form method=""post"" name=""form"" action=""?action=savenewexuser"">"
		response.write "<tr><td class=""tablebody1"" align=""center"">"
		response.write "<br>*请文明用语！如发现恶意文字您的帐户将被锁定<br><br>请填写您在股市中的名字：&nbsp;"
		response.write "<input type=""text"" name=""username"" maxlength="""&reg_info(7)&""" value="""&exsm.stockholder&""">&nbsp;<input type=""submit"" name=""submit"" value=""开户"">"
		response.write "<br><br>"&exwarn&"<br><br>"
		if round(se_setting(9),2)>0 then response.write "您开户后仍然可以修改自己在股市中的名字，每次修改需要：[<font color=""#ff0000"">"&formatnumber(se_setting(9),2,-1)&"</font>]元<br><br>"
		response.write "</td></tr></form>"
		response.write "</table>"
		exsm.rootshow
	end sub
	sub savenewexuser()
		dim mycontent,newexusername
		newexusername=trim(replace(request.form("username"),"'",""))
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.stockholder="" then
			exsm.errmess="您是游客，不能开设股票帐户！请注册后在来。"
			call exsm.endinfo("no")
			exit sub
		end if
		if exsm.members then
			exsm.errmess="您已经有股票帐户了，怎么还来开户？"
			call exsm.endinfo("no")
			exit sub
		end if
		if cint(reg_info(0))=0 then
			exsm.errmess="股市暂停开户，请与管理员联系。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rsbbs=conn.execute("select userpost,usercp,userep,userwealth from dv_user where userid="&exsm.bbsuserid&"")
		if rsbbs(0)<cint(reg_info(1)) then
			exsm.errmess="本股市已限制了开户最少发帖数为["&reg_info(1)&"]，您现在不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rsbbs(1)<cint(reg_info(2)) then
			exsm.errmess="本股市已限制了开户最少魅力值为["&reg_info(2)&"]，您不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rsbbs(2)<cint(reg_info(3)) then
			exsm.errmess="本股市已限制了开户最少经验值为["&reg_info(3)&"]，您不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rsbbs(3)<cdbl(reg_info(4)) then
			exsm.errmess="本股市已限制了开户最少现金值为["&reg_info(4)&"]，您不符合本要求，暂时不能开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		rsbbs.close
		set rsbbs=nothing
		if newexusername="" or len(newexusername)>cint(reg_info(7)) then
			exsm.errmess="请正确输入用户名。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select username from ex_user where username='"&newexusername&"'")
		if not rs.eof then
			exsm.errmess="您输入的用户名已经存在。<li>或您输入的用户名含有仅用字符，请重新填写用户名。"
			call exsm.endinfo("no")
			exit sub
		end if
		sql="insert into ex_user (userbbsid,username,userwealth,userassets) values("&exsm.bbsuserid&",'"&newexusername&"',"&reg_info(5)&","&reg_info(5)&")"
		stock_conn.execute (sql)
		set rs=stock_conn.execute("select top 1 id from ex_user order by id desc")
		mycontent=replace("欢迎新股民[<a href=ex_sm_dispu.asp?uid="&rs(0)&"><font color=#3366ff>"&newexusername&"</font></a>]进入["&exsm.setting_info(0)&"]！","'","")
		stock_conn.execute("insert into ex_news (content,color,addtime) values('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
		exsm.delstockcahe("exsm_imitate_news")
		exsm.delstockcahe("exsm_imitate_usersequence")
		session("ex_sm")=1
		exsm.rurl=reg_info(6)
		exsm.definerurl="<a href=ex_sm_help.asp>查看股市帮助</a>"
		exsm.sucmess="股票帐户申请成功！["&exsm.setting_info(0)&"]欢迎您的到来！并赠送给您["&reg_info(5)&"]元股市虚拟资金。"
		call exsm.endinfo("ok")
	end sub
	sub accountadopt()
		dim money(3),bbscash,l_content
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if not exsm.members then
			exsm.errmess="您还没有股票帐户，请先开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cint(user_info(0))=0 then
			exsm.errmess="帐户提款暂时关闭不能进行操作。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rsbbs=conn.execute("select userwealth from dv_user where userid="&exsm.bbsuserid&"")
		bbscash=rsbbs("userwealth")
		if bbscash>1000000000 then
			exsm.errmess="错误您的论坛帐户中资金大于[10]亿不能进行取款操作。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(request.form("money")) then
			exsm.errmess="您没有输入提款金额或者输入的不是数字！"
			call exsm.endinfo("no")
			exit sub
		elseif request.form("money")<=0 then
			exsm.errmess="您输入的提款金额不能小于等于零。"
			call exsm.endinfo("no")
			exit sub
		elseif request.form("money")>=1000000000 then
			exsm.errmess="错误每次您取钱不能大于[10]亿。"
			call exsm.endinfo("no")
			exit sub
		end if
		money(0)=round(request.form("money"),0)
		money(3)=round(money(0)*(user_info(6)/100),2)
		if cdbl(user_info(5))<=0 then
			money(2)=1
		else
			money(2)=cdbl(user_info(5))
		end if
		money(1)=round(money(0)/money(2),2)
		if cdbl(exsm.usercash-(money(0)+money(3)))<cdbl(reg_info(5)) then
			exsm.errmess="本股市规定：股票帐户基本资金不得低于["&formatnumber(reg_info(5),2,-1)&"]元。"
			call exsm.endinfo("no")
			exit sub
		elseif cdbl(money(0))>cdbl(user_info(2)) and cdbl(user_info(2))>0 then
			exsm.errmess="对不起！您每次提款不能超过["&formatnumber(user_info(2),2,-1)&"]元。"
			call exsm.endinfo("no")
			exit sub
		elseif cdbl(money(0)+money(3))>cdbl(exsm.usercash) then
			exsm.errmess="对不起！您的取款数额大于帐户资金（取款数额["&formatnumber(money(0),2,-1)&"]手续费["&formatnumber(money(3),2,-1)&"]元），请重新填写。"
			call exsm.endinfo("no")
			exit sub
		else
			stock_conn.execute("update ex_user set userwealth=userwealth-"&round(money(0)+money(3),2)&",userassets=userassets-"&round(money(0)+money(3),2)&" where id="&exsm.userid&"")
			conn.execute("update [dv_user] set userwealth=userwealth+"&round(money(1),2)&" where userid="&exsm.bbsuserid&"")
			call dvbbsmoney(round(bbscash+money(1),2))
			l_content=replace("资金流向：用户["&exsm.stockholder&"]，把股市资金["&money(0)&"]元（手续费["&money(3)&"]元），折合论坛帐户资金["&money(1)&"]元，提取到论坛帐号 ","'","")
			call exsm.savelog(exsm.scriptname,l_content,6)
			session("ex_sm")=1
			exsm.sucmess="你提取股市虚拟资金["&formatnumber(money(0),2,-1)&"]元（手续费["&formatnumber(money(3),2,-1)&"]元），折合论坛帐户资金["&formatnumber(money(1),2,-1)&"]元，请妥善保管。"
			call exsm.endinfo("ok")
		end if
	end sub
	sub accountdeposit()
		dim money(3),bbscash,l_content
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if not exsm.members then
			exsm.errmess="您还没有股票帐户，请先开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cint(user_info(1))=0 then
			exsm.errmess="帐户存钱暂时关闭不能进行操作。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(request.form("money")) then
			exsm.errmess="您没有输入提款金额或者输入的不是数字！"
			call exsm.endinfo("no")
			exit sub
		end if
		money(0)=round(request.form("money"),0)
		if cdbl(money(0))<=0 then
			exsm.errmess="您输入的提款金额不能小于等于零。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(user_info(5))<=0 then
			money(2)=1
		else
			money(2)=cdbl(user_info(5))
		end if
		money(1)=round(money(0)*money(2),2)
		money(3)=round(money(0)*(user_info(7)/100),2)
		if cdbl(money(1))>cdbl(user_info(3)) and cdbl(user_info(3))>0 then
			exsm.errmess="存钱操作每次最多只能存入["&formatnumber(user_info(3),2,-1)&"]元。"
			call exsm.endinfo("no")
			exit sub
		end if	
		if round(exsm.usercash+round(money(0)+money(3),2),2)>round(9999999999999.99,2) then
			exsm.rurl="ex_sm_mymanage.asp"
			exsm.errmess="您帐户中资金大于["&formatnumber(9999999999999.99,2,-1)&"]元，不能进行存入。"
			call exsm.endinfo("no")
		end if
		set rsbbs=conn.execute("select * from dv_user where userid="&exsm.bbsuserid&"")
		bbscash=rsbbs("userwealth")
		if cdbl(money(0)+money(3))>cdbl(bbscash) then
			exsm.errmess="对不起！您在论坛中没有足够的资金（存款数额["&formatnumber(money(0),2,-1)&"]手续费["&formatnumber(money(3),2,-1)&"]元）。"
			call exsm.endinfo("no")
			exit sub
		else
			conn.execute("update [dv_user] set userwealth=userwealth-"&round(money(0)+money(3),2)&" where userid="&exsm.bbsuserid&"")
			stock_conn.execute("update ex_user set userwealth=userwealth+"&round(money(1),2)&",userassets=userassets+"&round(money(1),2)&" where id="&exsm.userid&"")
			call dvbbsmoney(round(bbscash-round(money(0)+money(3),2),2))
			l_content=replace("资金流向：用户["&exsm.stockholder&"]，把论坛帐户资金["&money(0)+money(3)&"]元（手续费["&money(3)&"]元），折合股市资金["&money(1)&"]元，存入了股市帐号 ","'","")
			call exsm.savelog(exsm.scriptname,l_content,6)
			session("ex_sm")=1
			exsm.sucmess="你已经把论坛帐户资金["&formatnumber(money(0)+money(3),2,-1)&"]元（手续费["&formatnumber(money(3),2,-1)&"]元），折合股市虚拟资金["&formatnumber(money(1),2,-1)&"]元，存进了你的股票帐户。"
			call exsm.endinfo("ok")
		end if
	end sub
	sub accounttransfer()
		dim mingcheng,money(1),jisuan,zijin,mycontent,l_content
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if not exsm.members then
			exsm.errmess="您还没有股票帐户，请先开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		mingcheng=trim(replace(request.form("username"),"'",""))
		if cint(user_info(4))=0 then
			exsm.errmess="股市过户功能暂时关闭，请等待开放。"
			call exsm.endinfo("no")
			exit sub
		end if
		if round(exsm.usercash,2)>round(9999999999999.99,2) then
			exsm.errmess="您帐户中资金大于["&formatnumber(9999999999999.99,2,-1)&"]元，不能使用过户功能。"
			call exsm.endinfo("no")
		end if
		money(0)=request.form("xianjin")
		if money(0)="" or not isnumeric(money(0)) then
			exsm.errmess="请输入正确的过户资金。"
			call exsm.endinfo("no")
			exit sub
		end if
		money(0)=round(money(0),2)
		money(1)=round(money(0)*(user_info(8)/100),2)
		if cdbl(money(0))<=0 then
			exsm.errmess="请输入正确的过户资金。"
			call exsm.endinfo("no")
			exit sub
		end if
		jisuan=cdbl(exsm.usercash-(money(0)+money(1)))
		if jisuan=<1 then
			exsm.errmess="您的现有股市虚拟资金不足（过户数额["&formatnumber(money(0)-money(1),2,-1)&"]手续费["&formatnumber(money(1),2,-1)&"]元）。"
			call exsm.endinfo("no")
			exit sub
		end if
		if mingcheng="" then
			exsm.errmess="请输入收取人名称！"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select * from ex_user where username='"&mingcheng&"'")
		if rs.eof then
			exsm.errmess="股市中没有找到该用户！他可能不存在或没开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if mingcheng=exsm.stockholder then
			exsm.errmess="股市虚拟资金不能自己送给自己。"
			call exsm.endinfo("no")
			exit sub
		end if
		if rs("transfersecret")=0 then
			exsm.errmess="股市中没有找到该用户！他可能不存在或没开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(exsm.usercash-(money(0)+money(1)))<cdbl(reg_info(5)) then	
			exsm.errmess="本股市规定：股票帐户基本资金不得低于["&formatnumber(reg_info(5),2,-1)&"]元（过户数额["&formatnumber(money(0),2,-1)&"]手续费["&formatnumber(money(1),2,-1)&"]元）。"
			call exsm.endinfo("no")
			exit sub
		end if
		if round(rs("userwealth")+round(money(0),2),2)>round(9999999999999.99,2) then
			exsm.errmess="对方帐户中资金大于["&formatnumber(9999999999999.99,2,-1)&"]元，不能进行过户。"
			call exsm.endinfo("no")
		end if
		stock_conn.execute("update ex_user set userwealth=userwealth-"&round(money(0)+money(1),2)&",userassets=userassets-"&round(money(0)+money(1),2)&" where id="&exsm.userid&"")
		stock_conn.execute("update ex_user set userwealth=userwealth+"&round(money(0)-money(1),2)&",userassets=userassets+"&round(money(0)-money(1),2)&" where username='"&mingcheng&"'")
		mycontent=replace("股民[<a href=ex_sm_dispu.asp?uid="&exsm.userid&"><font color="&exsm.rndcolor&">"&exsm.stockholder&"</font></a>]过户给[<a href=ex_sm_dispu.asp?uid="&rs("id")&"><font color="&exsm.rndcolor&">"&rs("username")&"</font></a>]股民["&money(0)&"]元虚拟资金！请注意查收。","'","")
		stock_conn.execute("insert into ex_news(content,color,addtime) values ('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
		l_content=replace("资金流向：用户["&exsm.stockholder&"]，过户给["&rs("username")&"]["&money(0)&"]元（手续费["&money(1)&"]元）虚拟资金 ","'","")
		call exsm.savelog(rs("username"),l_content,6)
		session("ex_sm")=1
		exsm.sucmess="您的虚拟资金["&formatnumber(money(0),2,-1)&"]元（手续费["&formatnumber(money(1),2,-1)&"]）已经成功送出。"
		call exsm.endinfo("ok")
	end sub
	sub savemyinfo()
		dim ranksecret,tradesecret,transfersecret,autoupname
		if exsm.outsiderefer() then
			exsm.errmess="请不要从外部提交数据。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if exsm.repeatrefer() then
			exsm.errmess="您提交的数据已经保存，请不要重复提交。"
			call exsm.endinfo("stop.gif")
			exit sub
		end if
		if not exsm.members then
			exsm.errmess="您还没有股票帐户，请先开户。"
			call exsm.endinfo("no")
			exit sub
		end if
		ranksecret=request.form("ranksecret")
		tradesecret=request.form("tradesecret")
		transfersecret=request.form("transfersecret")
		autoupname=request.form("autoupname")
		if ranksecret="" or tradesecret="" or transfersecret="" or autoupname="" or not isnumeric(ranksecret) or not isnumeric(tradesecret) or not isnumeric(transfersecret) or not isnumeric(autoupname) then
			exsm.errmess="非法参数！请返回。"
			call exsm.endinfo("no")
			exit sub
		end if
		stock_conn.execute("update ex_user set ranksecret="&ranksecret&",tradesecret="&tradesecret&",transfersecret="&transfersecret&",autoupname="&autoupname&" where id="&exsm.userid&"")
		exsm.delstockcahe("exsm_imitate_usersequence")
		session("ex_sm")=1
		exsm.sucmess="帐户设置成功。"
		call exsm.endinfo("ok")
	end sub
	sub reflashinfo()
		if not datediff("n",session(exsm.placename&"exsmteuserid")(6),now())>=10 then
			exsm.errmess="您可能刚刚登录或已经刷新过个人情况总揽，请["&cint(10-datediff("n",session(""&exsm.placename&"exsmteuserid")(6),now()))&"]分钟后再次刷新。"
			call exsm.endinfo("no")
			exit sub
		else
			call exsm.calculatefund(exsm.userid,0)
			exsm.exsmuserinfo(6)=now()
			session(exsm.placename&"exsmteuserid")=exsm.exsmuserinfo
			response.redirect request.servervariables("http_referer")
		end if
	end sub
	sub dvbbsmoney(money)
		dim bbsuserinfo
		bbsuserinfo=session(exsm.placename&"UserID")
		bbsuserinfo(21)=round(money,2)
		session(exsm.placename&"UserID")=bbsuserinfo
	end sub
%>