<!--#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"-->
<!--#include file="inc/ex_stock/ex_admin/ex_admin_index.asp"-->
<%
	if not exsm.stockadmin then
		exsm.errmess="您没有管理权限！请返回。"
		call exsm.endinfo("no")
	else
		dim newstock_info,newtrade_info
		newtrade_info=split(exsm.stockdata(10,0),",")
		newstock_info=split(exsm.stockdata(8,0),"|")
		select case request("action")
			case "newstock"
				call newstock()
			case "edit"
				call edit()
			case "savenew"
				call savenew()
			case "editstock"
				call editstock()
			case "changstat"
				call changstat()
			case "delstock"
				call delstock()
			case "savedelstock"
				call savedelstock()
			case "userstat"
				call userstat()
			case else
				call main()
		end select
	end if
	sub main()
		dim gupiaoname
		if request("search")="yes" then
			gupiaoname=trim(replace(request("gname"),"'",""))
			if gupiaoname="" then
				exsm.errmess="请输入查找关键字或代码。"
				call exsm.endinfo("no")
				exit sub
			end if
		end if
		adminmenutop "股票管理"
		if request("search")="yes" and request("usernamechk")="yes" then
			if isnumeric(gupiaoname) then
		     		sql="where code='"&gupiaoname&"'"
			else
		     		sql="where company='"&gupiaoname&"'"
			end if
		elseif request("search")="yes" then
			if isnumeric(gupiaoname) then
		     		sql="where code like '%"&gupiaoname&"%'"
			else
		     		sql="where company like '%"&gupiaoname&"%'"
			end if
		else
			sql=""
		end if
		session("ex_sm")=0
%>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr>
				<th height="25">-=> 股 票 管 理 <=-</th>
			</tr>
			<tr> 
				<form name="form1" method="post" action="?search=yes">
					<td class="tablebody1" colspan="8">查找：<input type="text" name="gname" size="12"><input type="checkbox" name="usernamechk" value="yes" checked> 名称完全匹配 <input type="submit" name="submit" value="查询"></td>
				</form>
			</tr>
		</table>
		<br>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr height="25">
				<th>代码</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
		sql="select * from ex_stock "&sql&" order by sid"
		set rs= server.createobject("adodb.recordset")
		rs.open sql,stock_conn,1,1
		if rs.eof and rs.bof then
			response.write "<tr><td class=""tablebody1"" colspan=""8"">没有找到任何股票</td></tr></table>"
		else
			rs.pagesize=cint(exsm.setting_info(16))
			rs.absolutepage=currentpage
			page_count=0
			totalrec=rs.recordcount
			do while (not rs.eof) and (not page_count = rs.pagesize)%>
			<tr> 
				<td class="tablebody1" align="center"><%=rs("code")%></td>
				<td class="tablebody1" align="center"><a href=?action=edit&sid=<%=rs("sid")%>><%=rs("company")%></a></td>
				<td class="tablebody1" align="right"><%=formatnumber(rs("stocksum"),0,-1)%></td>
				<td class="tablebody1" align="right"><%=formatnumber(rs("closingprice"),2,-1)%></td>
				<td class="tablebody1" align="right"><%=formatnumber(rs("tradeprice"),2,-1)%></td>
				<td class="tablebody1" align="right"><%=replace(formatnumber(rs("todayadtradesum"),0,-1),",","")%></td>
				<td class="tablebody1" align="center"><%if rs("lockstock")=0 then%>开<%else%><font color="#ff0000">封</font><%end if%></font></td>
				<td class="tablebody1" align="center"><a style="cursor:hand" onmouseover="cziemenu(event,'<div><%if rs("lockstock")=0 then%><a href=?action=changstat&stat=closethis&sid=<%=rs("sid")%>>封盘</a><%else%><a href=?action=changstat&stat=openthis&sid=<%=rs("sid")%>>开市</a><%end if%></div><div><a href=ex_sm_admin_cutamelon.asp?sid=<%=rs("sid")%>>分红</a></div><div><a href=?action=edit&sid=<%=rs("sid")%>>编辑</a></div><div><a href=ex_sm_admin_intervene.asp?sid=<%=rs("sid")%>>干预</a></div><div><a href=?action=delstock&sid=<%=rs("sid")%>>删除</a></div>','',0)">操作</a></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
		adminmenubottom
		exsm.rootshowa
	end sub
	sub newstock()
		adminmenutop "新股上市"
		session("ex_sm")=0
		exsm.rurl=request.servervariables("http_referer")
		randomize
%>
		<script language="javascript" src ="inc/ex_stock/ex_sm_mydispose.js"></script>
		<script language="javascript">var filter="$,<%=newstock_info(6)%>";</script>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr>
				<th colspan=2 height=25>-=> 新 股 上 市 <=-</th>
			</tr>
			<form method=post action="?action=savenew" name="form1">
			<tr>
				<td class="tablebody1" width="50%"><u>股票代码</u><br>必须填写股市代码方便以后查询</td>
				<td class="tablebody1" width="50%">&nbsp;<input type="text" name="gpcode" value=""></td>
			</tr>
			<tr>
				<td class="tablebody2"><u>公司名称</u><br>即股票名，最长[<%=newstock_info(4)%>]byte，最短[<%=newstock_info(3)%>]byte</td>
				<td class="tablebody2">&nbsp;<input type="text" name="gpname" value="">&nbsp;<input type="button" value="检测股票代码和名称" name="button" onclick="excheckdata(1)"></td>
			</tr>
			<tr>
				<td class="tablebody1"><u>总 股 份</u><br>上市公司股票总数量</td> 
				<td class="tablebody1">&nbsp;<input type="text" name="stocknum" value="200000000">&nbsp;股</td>
			</tr>
			<tr>
				<td class="tablebody2"><u>每日初始交易量</u><br>每天允许的最大交易量</td>
				<td class="tablebody2">&nbsp;<input type="text" name="inistocknum" value="20000000">&nbsp;股</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>股票单价</u><br>单价范围：每股[<%=round(newtrade_info(5),2)%>]元以上！</td>
				<td class="tablebody1">&nbsp;<input type="text" name="nowprice" value="">&nbsp;元</td>
			</tr>
			<tr>
				<td class="tablebody2"><u>状　　态</u></td>
				<td class="tablebody2"><input type="radio" name="state" value="0" checked>开&nbsp;<input type="radio" name="state" value="1">封</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>公司图片</u><br>(130*190)如果图片路径是相对路径则当前目录是股票的根目录<br>图片也可以是网上的图片连接</td>
				<td class="tablebody1">&nbsp;<input type="text" name="ltdimg" size="39" value="inc/ex_stock/ex_img/inc_img/1.jpg"></td> 
			</tr>
			<tr>
				<td class="tablebody2" valign="top"><u>公司简介</u><br>上市公司介绍<br>公司简介不能超过[<%=newstock_info(5)%>]byte</td>
				<td class="tablebody2">&nbsp;<textarea cols="39" name="explain" rows="5">暂无公司简介！</textarea></td>
			</tr>
			<input type="hidden" name="rurl" value="<%=exsm.rurl%>">
			<tr>
				<td class="tablebody1" colspan="2" align="center"><input type="submit" name="submit" value="提交">&nbsp;&nbsp;<input type="reset" name="submit" value="重填"></td>
			</tr>
			</form>
		</table>
<%
		adminmenubottom
		exsm.rootshowa
	end sub
	sub savenew()
		dim gpcode,gpname,stocknum,inistocknum,gpprice,stid,gpstate,ltdimg,explain,mycontent,l_content
		gpcode=trim(request.form("gpcode"))
		gpname=trim(replace(request.form("gpname"),"'",""))
		gpname=exsm.siftname(gpname)
		stocknum=trim(request.form("stocknum"))
		inistocknum=trim(request.form("inistocknum"))
		gpprice=trim(request.form("nowprice"))
		gpstate=trim(request.form("state"))
		ltdimg=trim(replace(request.form("ltdimg"),"'",""))
		explain=trim(replace(request.form("explain"),"'",""))
		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 gpcode="" or not isnumeric(gpcode) or not len(gpcode)=6 then
			exsm.errmess="请正确输入股票代码[六位数字]。"
			call exsm.endinfo("no")
			exit sub
		end if
		if gpname="" then
			exsm.errmess="请输入上市股票的名称。"
			call exsm.endinfo("no")
			exit sub
		end if
		if exsm.syllable(gpname)<cint(newstock_info(3)) or exsm.syllable(gpname)>cint(newstock_info(4)) then
			exsm.errmess="上市股票名称字节不能小于["&newstock_info(3)&"]byte或大于["&newstock_info(4)&"]byte。"
			call exsm.endinfo("no")
			exit sub
		end if
		if stocknum="" or not isnumeric(stocknum) or not instr(stocknum,".")=0 then
			exsm.errmess="请正确输入股票数量。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(stocknum)<cdbl(newstock_info(2)) then
			exsm.errmess="股票数量必须大于["&formatnumber(newstock_info(2),0,-1)&"]股。"
			call exsm.endinfo("no")
			exit sub
		end if
		if inistocknum="" or not isnumeric(inistocknum) or not instr(inistocknum,".")=0 then
			exsm.errmess="请正确输入每日初始交易量。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(inistocknum)>cdbl(stocknum) then
			exsm.errmess="每日初始交易量不能大于股票数量。"
			call exsm.endinfo("no")
			exit sub
		end if
		if gpprice="" then
			exsm.errmess="请正确输入股票价格。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(gpprice) then
			exsm.errmess="请正确输入股票价格。"
			call exsm.endinfo("no")
			exit sub
		end if
		gpprice=round(gpprice,2)
		if round(gpprice,2)<round(newtrade_info(5),2) then
			exsm.errmess="股票价格必须大于["&round(newtrade_info(5),2)&"]元。"
			call exsm.endinfo("no")
			exit sub
		end if
		if ltdimg="" then
			exsm.errmess="公司图片不能为空，请认真指定路径。"
			call exsm.endinfo("no")
			exit sub
		end if
		if explain="" or exsm.syllable(explain)>cint(newstock_info(5)) then
			exsm.errmess="公司简介不能为空或超过["&newstock_info(5)&"]byte。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select code from ex_stock where code='"&gpcode&"'")
		if not rs.eof then
			exsm.errmess="您输入的股市代码已经使用了，请重新填写上市公司代码。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select code from ex_oneselfstock where code='"&gpcode&"'")
		if not rs.eof then
			exsm.errmess="您输入的股市代码已经使用了，请重新填写上市公司代码。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select sid from ex_stock where company='"&gpname&"'")
		if not rs.eof then
			exsm.errmess="您输入的上市公司已经存在。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select code from ex_oneselfstock where company='"&gpname&"'")
		if not rs.eof then
			exsm.errmess="您输入的上市公司已经上市了。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
			call exsm.endinfo("no")
			exit sub
		end if
		on error resume next
		stock_conn.execute("insert into ex_stock (code,company,tradeprice,closingprice,oqprice,lowestprice,highestprice,stocksum,surplusshare,todaytradesum,todaypermittradesum,issueprice,lockstock,ltdimg,statement,explain) values ('"&gpcode&"','"&gpname&"',"&round(gpprice,2)&","&round(gpprice,2)&","&round(gpprice,2)&","&round(gpprice,2)&","&round(gpprice,2)&","&stocknum&","&stocknum&","&inistocknum&","&inistocknum&","&gpprice&","&request.form("state")&",'"&ltdimg&"','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','"&explain&"')")
		if err.number=0 then
			set rs=stock_conn.execute("select top 1 sid from ex_stock order by sid desc")
			mycontent=replace("系统消息：新股[<a href=ex_sm_dispcompare.asp?sid="&rs(0)&"><font color="&exsm.rndcolor&">"&gpname&"</font></a>]代码["&gpcode&"]上市。","'","")
			stock_conn.execute("insert into ex_news (content,color,addtime) values('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
			l_content=replace("股票管理：新股上市，股票名称["&gpname&"] ","'","")
			call exsm.savelog(exsm.scriptname,l_content,3)
			resetcid
			exsm.delstockcahe("exsm_imitate_news")
			session("ex_sm")=1
			exsm.rurl=request("rurl")
			exsm.sucmess="恭喜，新股["&gpname&"]成功上市。"
			call exsm.endinfo("ok")
		else
			exsm.errmess="出现错误，具体如下："&err.description&""
			call exsm.endinfo("no")
		end if
	end sub
	sub edit()
		dim sid
		sid=request("sid")
		if sid="" or not isnumeric(sid) then
			exsm.errmess="参数错误，请指定相关股票。"
			call exsm.endinfo("no")
			exit sub
		end if
		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")
			exit sub
		end if
		adminmenutop "编辑"&rs("code")&"号股票-"&rs("company")&""
		session("ex_sm")=0
		exsm.rurl=request.servervariables("http_referer")
		set rs=stock_conn.execute("select * from ex_stock where sid="&sid)
%>
		<script language="javascript" src ="inc/ex_stock/ex_sm_mydispose.js"></script>
		<script language="javascript">var filter="$,<%=newstock_info(6)%>";</script>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr>
				<th colspan=2 height=25>-=> 编 辑 <%=rs("code")%> 号 股 票 <%=rs("company")%> <=-</th>
			</tr>
			<form method=post action="?action=editstock" name="form1">
			<tr>
				<td class="tablebody1" width="50%"><u>ｉ　　ｄ</u></td>
				<td class="tablebody1" width="50%">&nbsp;<input type="text" readonly name="sid" value="<%=rs("sid")%>" style="background-color: #eeeeee"></td>
			</tr>
			<tr>
				<td class="tablebody2"><u>股票代码</u><br>必须正确填写股市查询代码</td>
				<td class="tablebody2">&nbsp;<input type="text" name="gpcode" value="<%=rs("code")%>"><input type="hidden" name="gpoldcode" value="<%=rs("code")%>"></td>
			</tr>
			<tr>
				<td class="tablebody1"><u>公司名称</u><br>即股票名，最长[<%=newstock_info(4)%>]byte，最短[<%=newstock_info(3)%>]byte</td>
				<td class="tablebody1">&nbsp;<input type="text" name="gpname" value="<%=rs("company")%>"><input type="hidden" name="gpoldname" value="<%=rs("company")%>">&nbsp;<input type="button" value="检测股票代码和名称" name="button" onclick="excheckdata(0)"></td>
			</tr>
			<tr>
				<td class="tablebody2"><u>总 股 份</u></td>
				<td class="tablebody2">&nbsp;<input type="text" name="stocknum" value="<%=replace(formatnumber(rs("stocksum"),0,-1),",","")%>"><input type="hidden" name="totalstocknum" value="<%=replace(formatnumber(rs("stocksum"),0,-1),",","")%>">&nbsp;股</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>剩余股份</u></td>
				<td class="tablebody1">&nbsp;<input type="text" name="remainstocknum" value="<%=replace(formatnumber(rs("surplusshare"),0,-1),",","")%>"><input type="hidden" name="oldremainstocknum" value="<%=replace(formatnumber(rs("surplusshare"),0,-1),",","")%>">&nbsp;<font color="red">建议不要修改！</font></td> 
			</tr>
			<tr>
				<td class="tablebody2"><u>每日初始交易量</u><br>每天允许的最大交易量</td>
				<td class="tablebody2">&nbsp;<input type="text" name="inistocknum" value="<%=replace(formatnumber(rs("todaypermittradesum"),0,-1),",","")%>">&nbsp;股</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>收盘价格</u><br></td>
				<td class="tablebody1">&nbsp;<input type="text" name="nowcprice" value="<%=formatnumber(rs("closingprice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class="tablebody2"><u>当前价格</u><br></td>
				<td class="tablebody2">&nbsp;<input type="text" name="nowsprice" value="<%=formatnumber(rs("tradeprice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class="tablebody1"><u>最 高 价</u></td>
				<td class="tablebody1">&nbsp;<input type="text" name="ztall" value="<%=formatnumber(rs("highestprice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class="tablebody2"><u>最 低 价</u></td>
				<td class="tablebody2">&nbsp;<input type="text" name="zlow" value="<%=formatnumber(rs("lowestprice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class="tablebody1"><u>上市日期</u></td>
				<td class="tablebody1">&nbsp;<input type="text" name="gpdate" value="<%=rs("listeddate")%>">&nbsp;格式1900-1-31</td>
			</tr>
			<tr>
				<td class="tablebody2"><u>状　　态</u></td>
				<td class="tablebody2">&nbsp;<input type="radio" name="state" value="0" <%if rs("lockstock")=0 then%> checked <%end if%>>开&nbsp;<input type="radio" name="state" value="1" <%if rs("lockstock")=1 then%> checked <%end if%>>封</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>公司图片</u>(130*190)<br>如果图片路径是相对路径，则当前目录是股票的根目录<br>图片也可以是网上的图片连接</td>
				<td class="tablebody1">&nbsp;<input type="text" name="ltdimg" size="39" value="<%=rs("ltdimg")%>"></td> 
			</tr>	
			<tr>
				<td class="tablebody2" valign="top"><u>版面说明</u><br>上市公司简绍<br>公司简介不能超过[<%=newstock_info(5)%>]byte</td>   
				<td class="tablebody2">&nbsp;<textarea cols="39" name="explain" rows="5"><%=server.htmlencode(rs("explain"))%></textarea></td>  
			</tr>
			<input type="hidden" name="rurl" value="<%=exsm.rurl%>">
			<tr>
				<td class="tablebody1" colspan="2" align="center"><input type="submit" name="submit" value="执行修改"></td>
			</form>
		</table>
<%
		adminmenubottom
		exsm.rootshowa
	end sub
	sub editstock()
		dim sid,gpcode,gpoldcode,gpname,nowcprice,nowsprice,stocknum,totalstocknum,remainstocknum,remainstocknuma,oldremainstocknum,inistocknum,ztall,zlow
		dim todaypermittradesum,gpdate,ltdimg,explain,gpoldname,l_content
		sid=request("sid")
		gpcode=trim(request.form("gpcode"))
		gpoldcode=trim(request.form("gpoldcode"))
		gpname=trim(replace(request.form("gpname"),"'",""))
		gpname=exsm.siftname(gpname)
		gpoldname=trim(replace(request.form("gpoldname"),"'",""))
		stocknum=trim(request.form("stocknum"))
		totalstocknum=trim(request.form("totalstocknum"))
		remainstocknum=trim(request.form("remainstocknum"))
		remainstocknuma=trim(request.form("remainstocknum"))
		oldremainstocknum=trim(request.form("oldremainstocknum"))
		inistocknum=trim(request.form("inistocknum"))
		nowcprice=trim(request.form("nowcprice"))
		nowsprice=trim(request.form("nowsprice"))
		ztall=trim(request.form("ztall"))
		zlow=trim(request.form("zlow"))
		gpdate=trim(request.form("gpdate"))
		ltdimg=trim(request.form("ltdimg"))
		explain=trim(replace(request.form("explain"),"'",""))
		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
		set rs=stock_conn.execute("select todaypermittradesum from ex_stock where sid="&sid&"")
		if rs.eof then
			exsm.errmess="错误的参数，请指定正确的股票。"
			call exsm.endinfo("no")
			exit sub
		end if
		if gpcode="" or not isnumeric(gpcode) or not len(gpcode)=6 then
			exsm.errmess="请正确输入股票代码[六位数字]！"
			call exsm.endinfo("no")
			exit sub
		end if
		if gpname="" then
			exsm.errmess="请输入上市股票的名称。"
			call exsm.endinfo("no")
			exit sub
		end if
		if exsm.syllable(gpname)<cint(newstock_info(3)) or exsm.syllable(gpname)>cint(newstock_info(4)) then
			exsm.errmess="上市股票名称字节不能小于["&newstock_info(3)&"]byte或大于["&newstock_info(4)&"]byte。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(nowsprice) then
			exsm.errmess="当前价格必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(nowcprice) then
			exsm.errmess="收盘价格必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		zlow=round(zlow,2)
		ztall=round(ztall,2)
		nowcprice=round(nowcprice,2)
		nowsprice=round(nowsprice,2)
		if nowcprice<round(newtrade_info(5),2) then
			exsm.errmess="收盘价格必须大于["&round(newtrade_info(5),2)&"]元。"
			call exsm.endinfo("no")
			exit sub
		end if
		if nowsprice<round(newtrade_info(5),2) then
			exsm.errmess="当前价格必须大于["&round(newtrade_info(5),2)&"]元。"
			call exsm.endinfo("no")
			exit sub
		end if
		if (nowsprice-nowcprice)/nowcprice>round(newtrade_info(3)/100,2) or (nowsprice-nowcprice)/nowcprice<round(-newtrade_info(4)/100,2) then
			exsm.errmess="当前价格和收盘价格比例请控制在收盘价格正["&round(newtrade_info(3),2)&"%]负["&round(newtrade_info(4),2)&"%]之间。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(ztall) then
			exsm.errmess="最高价格必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(zlow) then
			exsm.errmess="最低价格必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(stocknum) or not instr(stocknum,".")=0 then
			exsm.errmess="总股份必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(remainstocknum) or not instr(remainstocknum,".")=0 then
			exsm.errmess="剩余股份必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isnumeric(inistocknum) or not instr(inistocknum,".")=0 then
			exsm.errmess="每日初始交易量必须输入数字。"
			call exsm.endinfo("no")
			exit sub
		end if
		if stocknum<>totalstocknum then
			if cdbl(stocknum)>cdbl(totalstocknum) then
				remainstocknum=round(remainstocknum+(stocknum-totalstocknum),0)
			elseif cdbl(stocknum)<cdbl(totalstocknum) then
				remainstocknum=round(remainstocknum-(totalstocknum-stocknum),0)
			end if
		end if
		if remainstocknuma<>oldremainstocknum then
			if cdbl(remainstocknum)>cdbl(oldremainstocknum) then
				stocknum=round(stocknum+(remainstocknum-oldremainstocknum),0)
			elseif cdbl(remainstocknum)<cdbl(oldremainstocknum) then
				stocknum=round(stocknum-(oldremainstocknum-remainstocknum),0)
			end if
		end if
		if cdbl(stocknum)<=0 then
			exsm.errmess="总股份不能等于或小于[0]！请重新填写。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(remainstocknum)<0 then
			exsm.errmess="剩余股份不能小于[0]！请重新填写。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(remainstocknum)>cdbl(stocknum) then
			exsm.errmess="总股份低于剩余股票！请重新填写。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(inistocknum)>cdbl(remainstocknum) or cdbl(inistocknum)>cdbl(stocknum) then
			exsm.errmess="每日初始交易量不能大于总股份或剩余股份。"
			call exsm.endinfo("no")
			exit sub
		end if
		if not isdate(gpdate) then
			exsm.errmess="上市日期格式错误请重新填写。"
			call exsm.endinfo("no")
			exit sub
		end if
		if ltdimg="" then
			exsm.errmess="公司图片不能为空，请认真指定路径。"
			call exsm.endinfo("no")
			exit sub
		end if
		if exsm.syllable(explain)>cint(newstock_info(5)) then
			exsm.errmess="上市股票公司简介不能大于["&newstock_info(5)&"]byte。"
			call exsm.endinfo("no")
			exit sub
		end if
		if cdbl(remainstocknum)<cdbl(rs(0)) then
			todaypermittradesum="todaypermittradesum="&remainstocknum&","
		end if
		if gpoldcode<>gpcode then
			set rs=stock_conn.execute("select code from ex_stock where code='"&gpcode&"'")
			if not rs.eof then
				exsm.errmess="您输入的股市代码已经使用了，请重新填写上市公司代码。"
				call exsm.endinfo("no")
				exit sub
			end if
			set rs=stock_conn.execute("select code from ex_oneselfstock where code='"&gpcode&"'")
			if not rs.eof then
				exsm.errmess="您输入的股市代码已经使用了，请重新填写上市公司代码。"
				call exsm.endinfo("no")
				exit sub
			end if
		end if
		if gpoldname<>gpname then
			set rs=stock_conn.execute("select sid from ex_stock where company='"&gpname&"'")
			if not rs.eof then
				exsm.errmess="您输入的上市公司已经存在。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
				call exsm.endinfo("no")
				exit sub
			end if
			set rs=stock_conn.execute("select code from ex_oneselfstock where company='"&gpname&"'")
			if not rs.eof then
				exsm.errmess="您输入的上市公司已经上市了。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
				call exsm.endinfo("no")
				exit sub
			end if
		end if
		if explain="" then explain="暂无"
		on error resume next
		stock_conn.execute("update ex_stock set code='"&gpcode&"',company='"&gpname&"',stocksum="&stocknum&",tradeprice="&nowsprice&",closingprice="&nowcprice&",highestprice="&ztall&",lowestprice="&zlow&",todaytradesum="&inistocknum&",surplusshare="&remainstocknum&","&todaypermittradesum&"listeddate='"&gpdate&"',lockstock="&request.form("state")&",ltdimg='"&ltdimg&"',explain='"&explain&"' where sid="&sid&"")
		stock_conn.execute("update ex_oneselfstock set todaytradesum="&round(inistocknum*2,0)&" where decideid="&sid&"")
		if gpoldcode<>gpcode or gpoldname<>gpname then
			stock_conn.execute("update ex_customer set code='"&gpcode&"',company='"&gpname&"' where sid="&sid&"")
			stock_conn.execute("update ex_oneselfstock set code='"&gpcode&"',company='"&gpname&"',todaytradesum="&round(inistocknum*2,0)&" where decideid="&sid&"")
		end if
		if err.number=0 then
			l_content=replace("股票管理：编辑股票信息，股票名称["&gpname&"] ","'","")
			call exsm.savelog(exsm.scriptname,l_content,3)
			session("ex_sm")=1
			exsm.rurl=request("rurl")
			exsm.sucmess="["&gpname&"]股票信息已经修改完毕！"
			call exsm.endinfo("ok")
		else
			exsm.errmess="出现错误，具体如下："&err.description&""
			call exsm.endinfo("no")
		end if
	end sub
	sub delstock()
		dim sid,rst,nowprice,gpname,addmoney,mycontent
		sid=request("sid")
		if sid="" or not isnumeric(sid) then
			exsm.errmess="没有输入参数或参数非法。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rst=stock_conn.execute("select tradeprice,company from ex_stock where sid="&sid&"")
		if rst.eof and rst.bof then
			exsm.errmess="股票数据表中没有找到你要删除的股票。"
			call exsm.endinfo("no")
			exit sub
		else
		adminmenutop "股票管理"
		session("ex_sm")=0
		exsm.rurl=request.servervariables("http_referer")
%>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" style="width:100%">
			<tr>
				<th height="25">-=> 股 票 管 理 - 删 除 股 票 <%=rst(1)%> <=-</th>
			</tr>
			<form method="post" action="?action=savedelstock">
			<tr>
				<td class="tablebody1"><u>操作理由</u>&nbsp;<input name="logtxt" size="70">&nbsp;*</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>资金流向</u>&nbsp;<input type=radio name="userwealth" value=1 checked>抛出所有股票&nbsp;<input type=radio name="userwealth" value=0>注销股票（不建议选择。）</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>信息发布</u>&nbsp;<input name="messagetxt" size="70" value="股票[<%=rst(1)%>]被删除！">&nbsp;<input type="checkbox" name="use" value=1>使用</td>
			</tr>
			<tr>
				<td class="tablebody1"><u>管理说明</u><br>①注销股票后持股者股票被删除后不会得到抛出资金！<br>②如果使用了信息发布，系统将发布即时信息以便通知股民。</td>
			</tr>
			<input type="hidden" name="delstockid" value="<%=sid%>">
			<input type="hidden" name="rurl" value="<%=exsm.rurl%>">
			<tr>
				<td class="tablebody2" align="center"><input type="submit" name="b1" value="确定">&nbsp;&nbsp;<input type="reset" name="b2" value="重填"></td>
			</tr>
			</form>
		</table>
<%
		adminmenubottom
		exsm.rootshowa
		end if
	end sub
	sub savedelstock()
		dim sid,logtxt,delstock,messagetxt,rst,nowprice,gpname,addmoney
		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
		sid=request.form("delstockid")
		logtxt=trim(replace(request.form("logtxt"),"'",""))
		messagetxt=trim(replace(request.form("messagetxt"),"'",""))
		if sid="" or not isnumeric(sid) then
			exsm.errmess="没有输入参数或参数非法。"
			call exsm.endinfo("no")
			exit sub
		end if
		set rs=stock_conn.execute("select tradeprice,company from ex_stock where sid="&sid&"")
		if rs.eof and rs.bof then
			exsm.errmess="股票数据表中没有找到你要删除的股票。"
			call exsm.endinfo("no")
			exit sub
		else
			nowprice=rs(0)
			gpname=rs(1)
			if logtxt="" or exsm.syllable(logtxt)>250 then
				exsm.errmess="操作理由不能为空。"
				call exsm.endinfo("no")
				exit sub
			else
				delstock="注销股票"
				if request.form("stocksum")=1 then delstock="抛出所有股票"
				logtxt="用户操作：删除股票["&gpname&"] "&delstock&" 操作理由："&logtxt&""
			end if
			if request.form("use")=1 and messagetxt="" or exsm.syllable(messagetxt)>250 then
				exsm.errmess="您选择了使用信息发布功能请填写信息内容。"
				call exsm.endinfo("no")
				exit sub
			end if
			if request.form("userwealth")=1 then
				set rst=stock_conn.execute("select possessstocksum,userid from ex_customer where sid="&sid&"")
				do while not rst.eof
					addmoney=rst(0)*nowprice
					stock_conn.execute "update ex_user set userwealth=userwealth+"&round(addmoney,2)&",userassets=userassets-"&round(addmoney,2)&",possesssort=possesssort-1 where id="&rst(1)&""
				rst.movenext
				loop
			end if
			stock_conn.execute("delete from ex_customer where sid="&sid&"")
			stock_conn.execute("delete from ex_stock where sid="&sid&"")
			stock_conn.execute("delete from ex_oneselfstock where decideid="&sid&"")
			if request.form("use")=1 then
				stock_conn.execute("insert into ex_news (content,color,addtime) values('"&messagetxt&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
				exsm.delstockcahe("exsm_imitate_news")
			end if
			call exsm.savelog(exsm.scriptname,logtxt,3)
			resetcid
			session("ex_sm")=1
			exsm.rurl=request("rurl")
			exsm.sucmess="股票["&gpname&"]删除成功。"
			call exsm.endinfo("ok")
		end if
	end sub
	sub changstat()
		if request("stat")="closethis" then
			stock_conn.execute("update ex_stock set lockstock=1 where sid="&request("sid"))
			stock_conn.execute("update ex_oneselfstock set lockstock=1 where decideid="&request("sid"))
		elseif request("stat")="openthis" then
			stock_conn.execute("update ex_stock set lockstock=0 where sid="&request("sid"))
			stock_conn.execute("update ex_oneselfstock set lockstock=0 where decideid="&request("sid"))
		end if
		if request.servervariables("http_referer")<>"" then
			response.redirect request.servervariables("http_referer")
		else
			response.write "<script language=javascript>javascript:history.go(-1)</script>"
			response.write "<script language=javascript>settimeout(""window.close()"",1000)</script>"
		end if
	end sub
	sub userstat()
		dim person_info,sid,userrs,mycontent,l_content
		randomize
		sid=request("sid")
		person_info=split(exsm.stockdata(8,0),"|")
		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 sid="" or not isnumeric(sid) then
			exsm.errmess="请正确输入批准股票ｉｄ！"
			call exsm.endinfo("no")
			exit sub
		end if
		if not request("stat")="yes" and not request("stat")="no" and not request("stat")="onceagainyes" then
			exsm.errmess="非法进入，请输入执行参数！"
			call exsm.endinfo("no")
			exit sub
		end if
		set userrs=stock_conn.execute("select * from ex_oneselfstock where sid="&sid&"")
		if userrs.eof and userrs.bof then
			exsm.errmess="未发现您指定的股票数据！"
			call exsm.endinfo("no")
			exit sub
		end if
		if request("stat")="yes" then
			set rs=stock_conn.execute("select * from ex_oneselfstock where decideid=0 and sid="&sid&"")
			if rs.eof and rs.bof then
				exsm.errmess="您指定的股票可能已经上市请不要重复提交！"
				call exsm.endinfo("no")
				exit sub
			end if
			set rs=stock_conn.execute("select userwealth from ex_user where id="&userrs("userid")&"")
			if not rs.eof then
				if round(rs(0),2)<round(person_info(1)/2,2) then
					mycontent=replace("系统消息：股民["&userrs("username")&"]个股["&userrs("company")&"]由于资金低于["&formatnumber(person_info(1)/2,2,-1)&"]元，未能通过审批！","'","")
					stock_conn.execute("insert into ex_news (content,color,addtime) values('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
					exsm.delstockcahe("exsm_imitate_news")
					exsm.errmess="被审批股民帐户资金低于["&cdbl(person_info(1)/2)&"]元，股民["&userrs("username")&"]当前资金为["&formatnumber(rs(0),2,-1)&"]元，不能通过审批！"
					call exsm.endinfo("no")
					exit sub
				end if
				if round(rs(0),2)>round(9999999999999.99,2) then
					mycontent=replace("系统消息：股民["&userrs("username")&"]个股["&userrs("company")&"]由于资金大于["&formatnumber(9999999999999.99,2,-1)&"]元，未能通过审批！","'","")
					stock_conn.execute("insert into ex_news (content,color,addtime) values('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
					exsm.delstockcahe("exsm_imitate_news")
					exsm.errmess="被审批股民帐户资金大于["&formatnumber(9999999999999.99,2,-1)&"]元，股民["&userrs("username")&"]当前资金为["&formatnumber(rs(0),2,-1)&"]元，不能通过审批！"
					call exsm.endinfo("no")
					exit sub
				end if
			else
				exsm.errmess="未找到该个股申请人信息！他可能没有开户或被删除。"
				call exsm.endinfo("no")
				exit sub
			end if
			stock_conn.execute("insert into ex_stock (code,company,management,managementid,issueprice,closingprice,oqprice,tradeprice,lowestprice,highestprice,stocksum,surplusshare,todaytradesum,todaypermittradesum,listeddate,lockstock,explain,ltdimg,statement) values ('"&userrs("code")&"','"&userrs("company")&"','"&userrs("username")&"',"&userrs("userid")&","&round(userrs("price"),2)&","&round(userrs("price"),2)&","&round(userrs("price"),2)&","&round(userrs("price"),2)&","&round(userrs("price"),2)&","&round(userrs("price"),2)&","&round(userrs("stocknum")/2,0)&","&round(userrs("stocknum")/2,0)&","&round(userrs("todaytradesum")/2,0)&","&round(userrs("todaytradesum")/2,0)&",'"&date()&"',0,'"&userrs("explain")&"','"&userrs("ltdimg")&"','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')")
			set rs=stock_conn.execute("select top 1 sid,company from ex_stock order by sid desc")
			stock_conn.execute("insert into ex_customer (username,userid,code,company,sid,buyprice,possessstocksum,averageprice) values ('"&userrs("username")&"',"&userrs("userid")&",'"&userrs("code")&"','"&userrs("company")&"',"&rs(0)&","&round(userrs("price"),2)&","&round(userrs("stocknum")/2,0)&","&round(userrs("price"),2)&")")
			stock_conn.execute("update ex_user set userwealth=userwealth+"&round(round(userrs("stocknum")/2,0)*userrs("price"),2)&" where id="&userrs("userid")&"")
			stock_conn.execute("update ex_oneselfstock set states=1,decideid="&rs(0)&" where sid="&sid&"")
			mycontent=replace("系统消息：股民["&userrs("username")&"]个股["&userrs("company")&"]通过证监会审批正式上市。","'","")
			stock_conn.execute("insert into ex_news (content,color,addtime) values('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
			l_content=replace("股票管理：提交股民["&userrs("username")&"]个股，股票名称["&userrs("company")&"]代码["&userrs("code")&"] ","'","")
			call exsm.savelog(userrs("username"),l_content,3)
			call exsm.calculatefund(userrs("userid"),0)
			call resetcid()
			exsm.delstockcahe("exsm_imitate_news")
			session("ex_sm")=1
			exsm.sucmess="股民["&userrs("username")&"]个股["&userrs("company")&"]提交成功。"
			call exsm.endinfo("ok")
		end if
		if request("stat")="no" then
			stock_conn.execute("update ex_oneselfstock set states=3 where sid="&sid&"")
			if request.servervariables("http_referer")<>"" then
				response.redirect request.servervariables("http_referer")
			else
				response.write "<script language=javascript>javascript:history.go(-1)</script>"
				response.write "<script language=javascript>settimeout(""window.close()"",1000)</script>"
			end if
		end if
		if request("stat")="onceagainyes" then
			set rs=stock_conn.execute("select * from ex_oneselfstock where decideid=0 and sid="&sid&"")
			if not rs.eof then
				exsm.errmess="您指定的股票还未上市不能进行再次批准！"
				call exsm.endinfo("no")
				exit sub
			end if
			set rs=stock_conn.execute("select * from ex_stock where sid="&userrs("decideid")&"")
			if rs("code")<>userrs("code") or rs("company")<>userrs("company") then
				mycontent=replace("系统消息：股民["&userrs("username")&"]对个股["&rs("company")&"]进行修改，更新后名称["&userrs("company")&"]代码["&rs("code")&"]修改为["&userrs("code")&"]。","'","")
				stock_conn.execute("insert into ex_news (content,color,addtime) values('"&mycontent&"','"&exsm.rndcolor&"',"&sqlsmnowstring&")")
				l_content=replace("股票管理：提交编辑股民["&userrs("username")&"]个股，股票名称["&rs("company")&"]修改为["&userrs("company")&"]代码["&rs("code")&"]修改为["&userrs("code")&"] ","'","")
				call exsm.savelog(userrs("username"),l_content,3)
				stock_conn.execute("update ex_stock set code='"&userrs("code")&"',company='"&userrs("company")&"',todaytradesum="&round(userrs("todaytradesum")/2,0)&",ltdimg='"&userrs("ltdimg")&"',explain='"&userrs("explain")&"' where sid="&userrs("decideid")&"")
				stock_conn.execute("update ex_customer set code='"&userrs("code")&"',company='"&userrs("company")&"' where sid="&userrs("decideid")&"")
			else
				stock_conn.execute("update ex_stock set todaytradesum="&round(userrs("todaytradesum")/2,0)&",ltdimg='"&userrs("ltdimg")&"',explain='"&userrs("explain")&"' where sid="&userrs("decideid")&"")
				l_content=replace("股票管理：提交编辑股民["&userrs("username")&"]个股，股票名称["&rs("company")&"]：初始每日交易量["&userrs("todaytradesum")&"] ","'","")
				call exsm.savelog(userrs("username"),l_content,3)
			end if
			stock_conn.execute("update ex_oneselfstock set states=1 where sid="&sid&"")
			exsm.delstockcahe("exsm_imitate_news")
			session("ex_sm")=1
			exsm.sucmess="股民["&userrs("username")&"]个股["&userrs("company")&"]再次提交成功。"
			call exsm.endinfo("ok")
		end if
	end sub
	sub resetcid()
		dim cid
		set rs=stock_conn.execute("select sid from ex_stock order by sid")
		if not rs.eof then
			cid=1
			do while not rs.eof
				stock_conn.execute("update ex_stock set cid="&cid&" where sid="&rs(0))
				cid=cid+1
			rs.movenext
			loop
		end if
	end sub
%>