<!--#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"-->
<%
if request("action")="reflash" then
	call reflash()
else
	call main()
end if
sub main()
	dim sqluser,title,username
	if request("action")="search" then
		username=trim(replace(request("username"),"'",""))
		if username="" then
			exsm.errmess="请输入查找关键字。"
			call exsm.endinfo("no")
			exit sub
		end if
			sqluser= "select * from ex_user where ranksecret=1 and username='"&username&"'"
			set rs=stock_conn.execute(sqluser)
		title="查找结果"
	else
		if request("paixu")="资产" then
			sqluser= "select * from ex_user order by userwealth desc"
			title="-=> 资 产 排 行 <=-"
		else
			title="-=> 总 资 产 排 行 <=-"
			sqluser= "select * from ex_user order by userassets desc"
		end if
	end if
	exsm.title 1,"详细排名"
%>
	<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<th height="25"><%=title%></th>
	</tr>
		<form name="form1" method="post" action="?action=search">
		<td class="tablebody1">查找股民：<input type="text" name="username" size="20" class="pageinput">&nbsp;<input type="submit" name="submit" class="pageinput" value="查询"></td>
		</form>
	</tr>
	</table>
	<br>
	<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
	<tr>
		<th height="25">名次</th>
		<th>帐户</th>
		<th id="tabletitlelink"><a href="?paixu=资产">资金</a></th>
		<th id="tabletitlelink"><a href="?">总资金</a></th>
		<th>持股种类</th>
		<th>今买入</th>
		<th>今卖出</th>
		<th>总买入</th>
		<th>总卖出</th>
		<th>最后交易日期</th>
		<th>状态</th>
	</tr>
<%
	dim currentpage,page_count,pcount
	dim totalrec,endpage
	currentpage=request("page")
	if currentpage="" or not isnumeric(currentpage) then
		currentpage=1
	end if
	set rs= server.createobject("adodb.recordset")
	rs.open sqluser,stock_conn,1,1
	if rs.eof and rs.bof then
		response.write "<tr><td class=""tablebody1"" colspan=""11"">没有找到任何股民</td></tr></table>"
	else
		rs.pagesize=cint(exsm.setting_info(16))
		totalrec=rs.recordcount
		if cdbl(currentpage)>=totalrec\cdbl(rs.pagesize)+1 then
			currentpage=totalrec\cdbl(rs.pagesize)+1
		else
			currentpage=cdbl(currentpage)
		end if
		if clng(currentpage)<1 then currentpage=1
		rs.absolutepage=currentpage
		page_count=0
		do while (not rs.eof) and (not page_count = rs.pagesize)
%>
			<tr align="right">
				<td class="tablebody1" align="center"><%if request("action")="search" then%>-<%else%><font color=red><%=rs.pagesize*(currentpage-1)+page_count+1%></font><%end if%></td>
				<td class="tablebody1" align="center">
					<%if rs("ranksecret")=1 or exsm.stockadmin or rs("id")=exsm.userid then%>
						<a href="ex_sm_dispu.asp?uid=<%=rs("id")%>"><%if rs("id")=exsm.userid then%><font color="blue">您自己</font><%else%><%=rs("username")%><%end if%></a>
					<%else%><a title="使用了用户名保护模式">***</a><%end if%>
				</td>
				<td class="tablebody1"><%=formatcurrency(rs("userwealth"),2,-1)%></td>
				<td class="tablebody1"><%=formatcurrency(rs("userassets"),2,-1)%></td>
				<td class="tablebody1"><%=rs("possesssort")%></td>
				<td class="tablebody1"><%=rs("todaybuy")%></td>
				<td class="tablebody1"><%=rs("todaysell")%></td>
				<td class="tablebody1"><%=rs("totalbuy")%></td>
				<td class="tablebody1"><%=rs("totalsell")%></td>
				<td class="tablebody1" align="center"><%=formatdatetime(rs("lasttradedate"),2)%></td>
				<td class="tablebody1" align="center"><%if rs("lockuser")=1 then%><font color="red">锁定<%else%>正常<%end if%></td>
			</tr>
			<%page_count = page_count + 1
			rs.movenext
		loop
		pcount=rs.pagecount
		response.write "</table>"
		call exsm.disppagenum(totalrec,page_count,currentpage,pcount,"?page=","?")
	end if
	rs.close
	set rs=nothing
	exsm.rootshow
end sub
sub reflash()
	if not datediff("n",session(exsm.placename&"exsmteuserid")(4),now())>=5 then
		exsm.errmess="您可能刚刚登录或已经刷新过排名，请["&cint(5-datediff("n",session(""&exsm.placename&"exsmteuserid")(4),now()))&"]分钟后再次刷新。"
		call exsm.endinfo("no")
		exit sub
	else
		call exsm.calculatefund(0,0)
		exsm.exsmuserinfo(4)=now()
		session(exsm.placename&"exsmteuserid")=exsm.exsmuserinfo
		exsm.delstockcahe("exsm_imitate_usersequence")
		response.redirect request.servervariables("http_referer")
	end if
end sub
%>