<!--#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"-->
<%'cnxk qq:29510683
	dim sid,tongjif,totalnum,usernum,currentprice,code,managementid,tongji,userid,username,ranksecret,pricechange
	dim aion,useron,trade_info
	dim gpscale(),tnum
	dim gupiaovaluerobot,gupiaocostrobot
	dim gupiaovalue,gupiaocost,currentpage,page_count,totalrec,pcount
	currentpage=request("page")
	if currentpage="" or not isnumeric(currentpage) then currentpage=1
	sid=request("sid")
	const vheight=200
	const vwidth=200
	if sid="" or not isnumeric(sid) then
		exsm.errmess="错误的参数，请指定正确的股票。"
		call exsm.endinfo("no")
	else
		set rs=stock_conn.execute("select * from ex_stock where sid="&sid&"")
		if rs.eof and rs.bof then
			exsm.errmess="没有找到指定的上市公司，可能该上市公司已经倒闭。"
			call exsm.endinfo("no")
		else
			exsm.title 1,""&rs("company")&"-资讯"
			aion=true:useron=true
			trade_info=split(exsm.stockdata(10,0),",")
			response.write "<script language=""javascript"" src=""inc/ex_stock/ex_sm_dispcompare.js""></script>"
			set rs=stock_conn.execute("select * from ex_stock where sid="&sid&"")
			code=rs("code")
			managementid=rs("managementid")
			currentprice=round(rs("tradeprice"),2)
			pricechange=round(round(rs("tradeprice")-rs("closingprice"),2)/round(rs("closingprice"),2),4)
			tongji=rs("statement")
			if tongji="" or isnull(tongji) then tongji="0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0"
			tongjif=tongji
			tongji=split(tongji,"|")
			tongjif=split(tongjif,"|")
			totalnum=stock_conn.execute("select sum(possessstocksum) from ex_customer where sid="&sid&"")(0)
			usernum=stock_conn.execute("select count(*) from ex_customer where userid>0 and sid="&sid&"")(0)
			if totalnum=0 or isnull(totalnum) then totalnum=1
			call formatvalue(vheight)
			tnum=stockscale(vwidth,usernum,totalnum)
%>
			<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
			<tr>
			<th colspan="5" height="25">-=> 第 <%=rs("code")%> 号 上 市 公 司 <%=rs("company")%> 资 讯 <=-</th>
			</tr>
			<tr> 
			<td class="tablebody2" width="20%" align="center" valign="middle" rowspan="11"><%if rs("ltdimg")<>"" and (not isnull(rs("ltdimg"))) then%><img style="filter: alpha(opacity=85);" border="0" src="<%=rs("ltdimg")%>" width="130" height="190"><%else%><font color=gray>无图片</font><%end if%></td>
			<td class="tablebody2" width="10%"><b>股票代码</b>：</td>
			<td class="tablebody1" width="30%"><%=rs("code")%></td>
			<td class="tablebody2" width="10%"><b>上市公司</b>：</td>
			<td class="tablebody1" width="30%"><%=rs("company")%></td>
			</tr>
			<tr>
			<td class="tablebody2"><b>经 营 者</b>：</td>
			<td class="tablebody1"><%if rs("management")<>"" then%><a href="ex_sm_dispu.asp?uid=<%=managementid%>"><%=rs("management")%></a><%else%>-<%end if%></td>
			<td class="tablebody2"><b>当前状态</b>：</td>
			<td class="tablebody1">
<%
				if rs("lockstock")=0 then
					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
%></td>
			</tr>
			<tr>
			<td class="tablebody2"><b>上市日期</b>：</td>
			<td class="tablebody1"><%=rs("listeddate")%></td>
			<td class="tablebody2"><b>上市价格</b>：</td>
			<td class="tablebody1"><%=formatnumber(rs("issueprice"),2,-1)%></td>
			</tr>
			<tr>
			<td class="tablebody2"><b>总 股 份</b>：</td>
			<td class="tablebody1"><%=replace(formatnumber(rs("stocksum"),0,-1),",","")%>&nbsp;股</td>
			<td class="tablebody2"><b>剩余股份</b>：</td>
			<td class="tablebody1"><%=replace(formatnumber(rs("surplusshare"),0,-1),",","")%>&nbsp;股</td>
			</tr>
			<tr>
			<td class="tablebody2"><b>今可交易</b>：</td>
			<td class="tablebody1"><%if rs("todaypermittradesum")>0 then%><%=replace(formatnumber(rs("todaypermittradesum"),0,-1),",","")%>&nbsp;股</font><%else%>-<%end if%></td> 
			<td class="tablebody2"><b>今成交量</b>：</td> 
			<td class="tablebody1"><%if rs("todayadtradesum")>0 then%><%=replace(formatnumber(rs("todayadtradesum"),0,-1),",","")%>&nbsp;股</font><%else%>-<%end if%></td>
			</tr>
			<tr>
			<td class="tablebody2"><b>开盘价格</b>：</td>
			<td class="tablebody1"><%=formatnumber(rs("oqprice"),2,-1)%>&nbsp;元</td>
			<td class="tablebody2"><b>当前价格</b>：</td>
			<td class="tablebody1"><%=formatnumber(rs("tradeprice"),2,-1)%>&nbsp;元</td>
			</tr>
			<tr>
			<td class="tablebody2"><b>今日涨跌</b>：</td>
			<td class="tablebody1"><%=formatnumber(rs("tradeprice")-rs("closingprice"),2,-1)%>&nbsp;元</td> 
			<td class="tablebody2"><b>今涨跌幅</b>：</td>
			<td class="tablebody1"><%=formatpercent(pricechange,2,-1)%></td>
			</tr>
			<tr>
			<td class="tablebody2"><b>最高价格</b>：</td>
			<td class="tablebody1"><%=formatnumber(rs("highestprice"),2,-1)%>&nbsp;元</td> 
			<td class="tablebody2"><b>最低价格</b>：</td> 
			<td class="tablebody1"><%=formatnumber(rs("lowestprice"),2,-1)%>&nbsp;元</td>  
			</tr>
			<tr>
			<td class="tablebody2"><b>今日指数</b>：</td>
			<td class="tablebody1"><%=formatnumber(rs("todaywave"),2,-1)%>&nbsp;点</td> 
			<td class="tablebody2"><b>综合指数</b>：</td> 
			<td class="tablebody1"><%=formatnumber(rs("totalwave"),2,-1)%>&nbsp;点</td>  
			</tr>
			<tr>
			<td class="tablebody2"><b>买入笔数</b>：</td>
			<td class="tablebody1"><%=rs("todaybuynumber")%>&nbsp;笔</td>
			<td class="tablebody2"><b>卖出笔数</b>：</td>
			<td class="tablebody1"><%=rs("todaysellnumber")%>&nbsp;笔</td>
			</tr>
			<tr valign="middle"> 
			<td class="tablebody2"><b>版面说明</b>：</td>
			<td class="tablebody1" colspan="4"><%=rs("explain")%></td>
			</tr>
			<tr>
			<td class="tablebody1" colspan="5" align="center">
<%
			if rs("lockstock")=0 and round(rs("tradeprice"),2)=>round(trade_info(5),2) then
				set rs=stock_conn.execute("select * from ex_customer where userid="&exsm.userid&" and sid="&sid&"")
				if not rs.eof then
					response.write "<a href=""ex_sm_exchange.asp?sid="&sid&""" onmouseover=""cziemenu(event,'<div><a>持股信息：</a></div>"
					if not exsm.stockadmin and split(exsm.stockdata(12,0),",")(0)=1 and 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>买入时间："&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>"
				else
					response.write "<a href=""ex_sm_exchange.asp?sid="&sid&""">进行交易</a>"
				end if
			else
				response.write "<a title=""该股票已经封盘或停牌，不能进行交易。""><font color=""gray"">进行交易</font></a>"
			end if
%>			&nbsp;&nbsp;&nbsp;&nbsp;<a href="ex_sm_index.asp"><< 返回股市大厅</a></td>
			</tr>
			</table>
			<br>
			<table class="tableborder1" cellspacing="1" cellpadding="1" align="center" border="0">
			<tr>
			<th height="25" width="50%">-=> 最 近 30 天 走 势 图 <=-</th>
			<th height="25" width="50%">-=> 十 大 股 东 持 股 比 例 图 <=-</th>
			</tr>
			<tr>
			<td class="tablebody1" width="50%">
				<table cellspacing="0" cellpadding="0" align="center" border="0">
					<tr>
						<td align="center" valign="bottom" height="<%=vheight+20%>" width="100%">
						<%for i=0 to ubound(tongji)%>
						<img src="inc/ex_stock/ex_img/bar.gif" width="6" height="<%=tongjif(i)+5%>" title="当日收盘价：<%=formatnumber(tongji(i),2,-1)%> 元">
						<%next%></td>
					</tr>
				</table>
			</td>
			<td class="tablebody1" valign="top" height="<%=vheight+20%>">
				<table cellspacing="0" cellpadding="0" align="center" border="0" width="100%" height="100%">
					<%if usernum<=0 then
						response.write "<tr valign=""middle"" align=""center""><td><font color=""gray"">暂时没有人购买该股票</font></td></tr>"
					else
						for i=0 to tnum%>
					<tr>
						<td width="90"><%=gpscale(i,5)%></td>
						<td><img src="inc/ex_stock/ex_img/baru.gif" height=10 width="<%=gpscale(i,4)+5%>" alt="持股手数：<%=gpscale(i,2)%>股 持股手数百分比：<%=formatnumber(gpscale(i,3)*100,2,-1)%>%"></td>
					</tr>
					<%next
					end if%>
				</table>
			</td>
			</tr>
			</table>
			<br>
			<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0">
<%
			response.write "<tr align=""center""><th height=""25"">代码</th><th>股东</th><th>持股数量</th><th>持股比例</th><th>当前价格</th><th>持股价格</th><th>持股现值</th><th>持股成本</th><th>总盈亏</th><th>盈亏率</th></tr>"
			set rs=stock_conn.execute("select * from ex_customer where sid="&sid&" and userid=-1")
			if not rs.eof then
				gupiaovaluerobot=currentprice*rs("possessstocksum")
				gupiaocostrobot=rs("averageprice")*rs("possessstocksum")
				aion=false
				response.write "<tr align=""right"">"
				response.write "<td class=""tablebody1"" align=""center""><font color=""olive"">"&rs("code")&"</font></td>"
				response.write "<td class=""tablebody1"" align=""center""><font color=""red"">"&rs("username")&"</font></td>"
				response.write "<td class=""tablebody1"">"&replace(formatnumber(rs("possessstocksum"),0,-1),",","")&"</td>"
				response.write "<td class=""tablebody1"">"&formatnumber(rs("possessstocksum")*100/totalnum,2,-1)&"%</td>"
				response.write "<td class=""tablebody1"">"&formatcurrency(currentprice,2,-1)&"</td>"
				response.write "<td class=""tablebody1"">"&formatcurrency(rs("averageprice"),2,-1)&"</td>"
				response.write "<td class=""tablebody1"">"&formatcurrency(gupiaovaluerobot,2,-1)&"</td>"
				response.write "<td class=""tablebody1"">"&formatcurrency(gupiaocostrobot,2,-1)&"</td>"
				response.write "<td class=""tablebody1"">"&formatcurrency(gupiaovaluerobot-gupiaocostrobot,2,-1)&"</td>"
				response.write "<td class=""tablebody1"">"
				if gupiaocostrobot=0 then
					response.write "0.00"
				else
					response.write ""&formatnumber((gupiaovaluerobot-gupiaocostrobot)*100/gupiaocostrobot,2,-1)&""
				end if
				response.write "%</td>"
				response.write "</tr>"
			end if
			sql="select d.*,u.ranksecret from ex_customer d inner join ex_user u on d.userid=u.id where d.userid>0 and d.sid="&sid&" order by d.possessstocksum desc"
			set rs= server.createobject("adodb.recordset")
			rs.open sql,stock_conn,1,1
			if not rs.eof then
				useron=false
				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)
				gupiaovalue=currentprice*rs("possessstocksum")
				gupiaocost =round(rs("averageprice"),2)*rs("possessstocksum")
%>
				<tr align="right">
				<td class="tablebody1" align="center"><font color="olive"><%=rs("code")%></font></td>
				<td class="tablebody1" align="center">
					<%if rs("ranksecret")=1 or exsm.stockadmin or rs("userid")=exsm.userid then%>
						<a href="ex_sm_dispu.asp?uid=<%=rs("userid")%>"><%if rs("userid")=exsm.userid then%><font color="blue">您自己</font><%else%><%=rs("username")%><%end if%></a>
					<%else%><a title="使用了用户名保护模式">***</a><%end if%>
				</td>
				<td class="tablebody1"><%=replace(formatnumber(rs("possessstocksum"),0,-1),",","")%></td>
				<td class="tablebody1"><%=formatnumber(rs("possessstocksum")*100/totalnum,2,-1)%>%</td>
				<td class="tablebody1"><%=formatcurrency(currentprice,2,-1)%></td>
				<td class="tablebody1"><%=formatcurrency(rs("averageprice"),2,-1)%></td>
				<td class="tablebody1"><%=formatcurrency(gupiaovalue,2,-1)%></td>
				<td class="tablebody1"><%=formatcurrency(gupiaocost,2,-1)%></td>
				<td class="tablebody1"><%=formatcurrency(gupiaovalue-gupiaocost,2,-1)%></td>
				<td class="tablebody1"><%=formatnumber((gupiaovalue-gupiaocost)*100/gupiaocost,2,-1)%>%</td>
				</tr>
<%
				page_count = page_count + 1
				rs.movenext
				loop
				pcount=rs.pagecount
				response.write "</table>"
				call exsm.disppagenum(totalrec,page_count,currentpage,pcount,"?sid="&sid&"&page=","?sid="&sid&"")
			end if
			if aion and useron then
				response.write "<tr><td class=""tablebody1"" colspan=""10"">暂时没有人购买这只股票</td></tr></table>"
			else
				response.write "</table>"
			end if
		end if
	end if
	function formatvalue(stdvalue)
		dim max,ii
		max=tongji(0)
		for ii=1 to ubound(tongji)
			if csng(max)<csng(tongji(ii)) then max=tongji(ii)
		next
		if max=0 then max=1
		for ii=0 to ubound(tongji)
		 	tongjif(ii)=int(tongji(ii)*stdvalue/max)
		next
	end function
	function stockscale(stdwidth,topnum,totaln)
		dim other,num
		other=false
		stockscale=0
		num=topnum 
		if num<=0 then
			exit function
		elseif num>10 then
			num=9
			other=true
		end if	
		redim gpscale(num,5)
		dim rst,ii
		set rst=stock_conn.execute("select top "&num&" d.userid,d.username,d.possessstocksum,u.ranksecret from ex_customer d inner join ex_user u on d.userid=u.id where d.userid>0 and d.sid="&sid&" order by d.possessstocksum desc")
		for ii=0 to num-1
			gpscale(ii,0)=rst(0)
			gpscale(ii,1)=exsm.htmlencode(rst(1))
			gpscale(ii,2)=rst(2)
			gpscale(ii,3)=rst(2)/totaln
			gpscale(ii,4)=int(gpscale(ii,3)*stdwidth)
			stockscale=stockscale+gpscale(ii,2)
			if rst(3)=1 or rst(0)=exsm.userid or exsm.stockadmin then
				gpscale(ii,5)="<a href=""ex_sm_dispu.asp?uid="&gpscale(ii,0)&""">"&gpscale(ii,1)&"</a>"
			else
				gpscale(ii,5)="<a title=""使用了用户名保护模式"">***</a>"
			end if
			rst.movenext 
		next 
		rst.close
		set rst=nothing
		if other then   
			gpscale(9,5)="<font color=""gray"">其他股东</font>"
			gpscale(9,2)=totaln-stockscale
			gpscale(9,3)=gpscale(9,2)/totaln
			gpscale(9,4)=int(gpscale(9,3)*stdwidth)
		end if
		if topnum>10 then
			stockscale=9
		else
			stockscale=topnum-1
		end if
	end function
	exsm.rootshow
%>