<!--#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 page,uid,username,usercash,userfund
	dim stocktype,todaybuy,todaysale,totalbuy,totalsale
	dim currentpage,page_count,totalrec,pcount
	uid=request("uid")
	if uid="" or not isnumeric(uid) then
		exsm.errmess="错误的参数，请指定正确的用户id。"
		call exsm.endinfo("no")
	else
		set rs=stock_conn.execute("select * from ex_user where id="&uid&"")
		if rs.eof and rs.bof then
			exsm.errmess="指定的用户不存在，请确认传递的参数是否正确。"
			call exsm.endinfo("no")
		else
			call exsm.calculatefund(uid,0)
			username="***"
			if rs("ranksecret")=1 or exsm.stockadmin or rs("id")=uid then username=exsm.htmlencode(rs("username"))
			usercash=rs("userwealth")
			userfund=rs("userassets")
			stocktype=rs("possesssort")
			todaybuy=rs("todaybuy")
			todaysale=rs("todaysell")
			totalbuy=rs("totalbuy")
			totalsale=rs("totalsell")
			exsm.title 1,""&username&"-用户资料"
			call main()
		end if
	end if
	sub main()
%>
	<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
		<tr>
			<th colspan="10" height="25">-=> 股 民 <%=username%> 持 股 一 览 <=-</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> 
		</tr>
<%
		dim mygupiaonum,mygupiaovalue,mygupiaocost,id
		dim totalgranrate,bj,meigukuisun,totalgain,granrate,color(0)
		mygupiaonum=0 :	mygupiaovalue=0 :	mygupiaocost=0:		totalgranrate=0
		sql="select d.*,g.tradeprice,g.management,g.managementid from ex_customer d inner join ex_stock g on d.sid=g.sid where d.userid="&uid&" 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=""10"">指定的用户没有股票。</tr></table>"
		end if
			dim rst,currentprice,agvinprice
			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))
				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)
				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>↑"&formatcurrency(bj,2,-1)&"</font>"
					color(0)="#ff0000"
				elseif bj<0 then
					meigukuisun="<font color=#008800>↓"&formatcurrency(abs(bj),2,-1)&"</font>"
					color(0)="#008800"
				elseif bj=0 then
					meigukuisun="<font color=#000000>→￥0.00</font>"
					color(0)="#000000"
				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"><%=formatcurrency(agvinprice*(rs("possessstocksum")),2,-1)%></td>
			<td class="tablebody1"><%=formatcurrency(currentprice,2,-1)%></td>
			<td class="tablebody1"><%=formatcurrency(agvinprice,2,-1)%></td>
			<td class="tablebody1"><%=formatcurrency(currentprice*(rs("possessstocksum")),2,-1)%></td>
			<td class="tablebody1"><%=meigukuisun%></td>
			<td class="tablebody1"><%
				totalgain=bj*(rs("possessstocksum"))
				granrate=totalgain*100/mygupiaocost
				if totalgain>0 then
					response.write "<font color=""#ff0000"">↑"&formatcurrency(totalgain,2,-1)&"</font></td>" 
					response.write "<td class=""tablebody1"" align=""right""><font color=""#ff0000"">↑"&formatnumber(granrate,2,-1)&"%</font>"
				elseif totalgain<0 then
					response.write "<font color=""#008800"">↓"&formatcurrency(-totalgain,2,-1)&"</font></td>"
					response.write "<td class=""tablebody1"" align=""right""><font color=""#008800"">↓"&formatnumber(-granrate,2,-1)&"%</font>" 
				else
					response.write "<font color=""#000000"">→￥0.00</font></td>"
					response.write "<td class=""tablebody1"" align=""right""><font color=""#000000"">→0.00%</font>"	
				end if
%>			</td>
		</tr>
		<%page_count = page_count + 1
		rs.movenext
		loop
		pcount=rs.pagecount
		if mygupiaocost=0 then
			totalgranrate=0
		else
			totalgranrate=(mygupiaovalue-mygupiaocost)*100/mygupiaocost
		end if%>
		<tr align="center">
		<td class="tablebody2">合计</td>
		<td class="tablebody2">-</td>
		<td class="tablebody2" align="right"><%=replace(formatnumber(mygupiaonum,0,-1),",","")%></td>
		<td class="tablebody2" align="right"><%=formatcurrency(mygupiaocost,2,-1)%></td>
		<td class="tablebody2">-</td>
		<td class="tablebody2">-</td>
		<td class="tablebody2" align="right"><%=formatcurrency(mygupiaovalue,2,-1)%></td>
		<td class="tablebody2">-</td>
		<td class="tablebody2" align="right"><%if mygupiaovalue-mygupiaocost>0 then%>↑<%else%>↓<%end if%><%=formatcurrency((mygupiaovalue-mygupiaocost),2,-1)%></td> 
		<td class="tablebody2" align="right"><%if totalgranrate>0 then%>↑<%else%>↓<%end if%><%=formatcurrency(totalgranrate,2,-1)%>%</td>
		</tr>
	</table>
<%
			call exsm.disppagenum(totalrec,page_count,currentpage,pcount,"?uid="&uid&"&page=","?uid="&uid&"")
		end if
		rs.close
		set rs=nothing
%>
	<br>
	<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
		<tr height="25">
		<th>股民</th>
		<th>总资产</th>
		<th>资金</th>
		<th>持股总价值</th>
		<th>持股种类</th>
		<th>今日买入</th>
		<th>今日卖出</th>
		<th>总买入</th>
		<th>总卖出</th>
		</tr>
		<tr align="right">
		<td class="tablebody1" align="center"><%=username%></td>
		<td class="tablebody1"><%=formatcurrency(userfund,2,-1)%></td>
		<td class="tablebody1"><%=formatcurrency(usercash,2,-1)%></td>
		<td class="tablebody1"><%=formatcurrency(mygupiaovalue,2,-1)%></td>
		<td class="tablebody1"><%=stocktype%></td>
		<td class="tablebody1"><%=todaybuy%></td>
		<td class="tablebody1"><%=todaysale%></td>
		<td class="tablebody1"><%=totalbuy%></td>
		<td class="tablebody1"><%=totalsale%></td>
		</tr>
		<tr>
		<td class="tablebody2" align="center" colspan="9"><a href="ex_sm_topuser.asp"><< 返回排行榜</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="ex_sm_index.asp"><< 返回股市大厅</b></a></td>
		</tr>
	</table>
<%
		exsm.rootshow
	end sub
%>