<!--#include file="setup.asp"-->
<!--#include file="plus/Ex_Stock/Exsm_Plus_Conn.asp"-->
<!--#include file="plus/Ex_Stock/Exsm_Plus_Const.asp"-->
<%
	'检查用户名和ＩＤ是否合法
	If Exsm.UserID="" or Exsm.UserID=0 or not isnumeric(Exsm.UserID) or Exsm.StockHolder="" Then
		Response.Redirect "Exsm_Plus_Gupiao.asp"
	Else
		set Rs=stock_conn.execute("select UserName,LockUser from Ex_User where ID="&Exsm.UserID&"")
		'是否存在用户
		If Rs.eof and Rs.bof Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'用户是否锁定
		Elseif Rs(1)>1 Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'是否已经登录
		Elseif not Exsm.Members Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'检查用户等级
		Elseif not Exsm.StockAdmin Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		'再次验证身份
		Elseif not Rs(0)=Exsm.StockHolder Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
		Else
			Dim NewStock_Info,NewTrade_Info
			NewTrade_Info=split(Exsm.Stock_Setting(2),",")
			NewStock_Info=Split(Exsm.Stock_Setting(4),"|")
			select case request("action")
				case "NewStock"
					call NewStock()
				case "search"
					call search()
				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 else
					call main()
			End select
		End if
	End if%>
<%
	Sub main()
		Exsm.Title 1,"股票管理"
%>
		<table class=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr>
				<td align=center height=25 class=a1>-=> 股 票 管 理 <=-</td>
			</tr>
			<tr> 
				<form name="form1" method="post" action="?action=search">
					<td class=a3 colspan=8 height=20>查找：<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=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr align=center height=25 class=a1>
				<td>代码</td>
				<td>股票名称</td>
				<td>总股份</td>
				<td>昨日收盘</td>
				<td>目前成交</td>
				<td>成交量</td>
				<td>状态</td>
				<td>管理</td>
			</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 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=a3 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=a3 align=center><%=rs("Code")%></td>
				<td class=a3 align=center><a href=?action=edit&sid=<%=Rs("Sid")%>><%=rs("Company")%></a></td>
				<td class=a3 align=right><%=formatnumber(rs("StockSum"),0,-1)%></td>
				<td class=a3 align=right><%=formatnumber(rs("ClosingPrice"),2,-1)%></td>
				<td class=a3 align=right><%=formatnumber(rs("TradePrice"),2,-1)%></td>
				<td class=a3 align=right><%=Replace(Formatnumber(Rs("TodayAdTradeSum"),0,-1),",","")%></td>
				<td class=a3 align=center><%If Rs("LockStock")=0 Then%>开<%Else%><Font color="#FF0000">封</Font><%End if%></Font></td>
				<td class=a3 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=Exsm_Plus_Admin_Cutamelon.asp?sid=<%=rs("sid")%>>分红</a></div><div><a href=?action=edit&sid=<%=rs("sid")%>>编辑</a></div><div><a href=Exsm_Plus_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%>
		</table>
		<table width=<%=Exsm.AssignWidth%> cellspacing=0 cellpadding=1 align=center border=0>
			<tr>
				<td align=left>共 <font color=blue><%=totalrec%></font> 支股票，每页 <font color=blue><%=rs.PageSize%></font> 支，第 <font color=red><%=currentpage%></font> 页 / 共 <font color=blue><%=Pcount%></font> 页</td>
				<td align=right>分页：<%call Exsm.DispPageNum(currentpage,Pcount,"""?page=","""")%></td>
			</tr>
		</table>
		<script language="JavaScript">
		function DelUser(str,url)
		{
			{
			if(confirm(str))
			{
				location.href=url;
				return true;
			}
//			return false;
			}
		}
		</script>
<%
		End if
		rs.close
		set rs=nothing
	Exsm.RootShowA
	End Sub
	Sub NewStock()
		Exsm.Title 1,"新股上市"
		Randomize
%>
		<script language="JavaScript" src ="plus/Ex_Stock/Exsm_Plus_MyDispose.js"></script>
		<script language="javascript">var Filter="$,<%=NewStock_Info(6)%>";</script>
		<table class=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr>
				<td colspan=2 align=center height=25 class=a1>-=> 新 股 上 市 <=-</td>
			</tr>
			<form method=post action="?action=SaveNew" name="form1">
			<tr>
				<td class=a3 width="50%"><u>股票代码</u><br>必须填写股市代码方便以后查询</td>
				<td class=a3 width="50%">&nbsp;<input type=text name=gpcode value=""></td>
			</tr>
			<tr>
				<td class=a4><u>公司名称</u><br>即股票名，最长[<%=NewStock_Info(4)%>]Byte，最短[<%=NewStock_Info(3)%>]Byte</td>
				<td class=a4>&nbsp;<input type=text name=gpname value="">&nbsp;<input type=button value="检测股票代码和名称" name=button onclick=ExCheckData(1)></td>
			</tr>
			<tr>
				<td class=a3><u>总 股 份</u><br>上市公司股票总数量</td> 
				<td class=a3>&nbsp;<input type=text name=StockNum value="200000000">&nbsp;股</td>
			</tr>
			<tr>
				<td class=a4><u>每日初始交易量</u><br>每天允许的最大交易量</td>
				<td class=a4>&nbsp;<input type=text name=IniStockNum  value="20000000">&nbsp;股</td>
			</tr>
			<tr>
				<td class=a3><u>股票单价</u><br>单价范围：每股[<%=Round(NewTrade_Info(5),2)%>]元以上！</td>
				<td class=a3>&nbsp;<input type=text name=nowprice value="">&nbsp;元</td>
			</tr>
			<tr>
				<td class=a4><u>状　　态</u></td>
				<td class=a4><input type=radio name=state value=0 checked>开&nbsp;<input type=radio name=state value=1>封</td>
			</tr>
			<tr>
				<td class=a3><u>公司图片</u><br>(150*190)如果图片路径是相对路径，则当前目录是股票的根目录<br>图片也可以是网上的图片连接</td>
				<td class=a3>&nbsp;<input type=text name=LtdImg size="39" value="plus/Ex_Stock/Ex_img/Inc_img/1.jpg"></td> 
			</tr>
			<tr>
				<td class=a4 valign="top"><u>公司简介</u><br>上市公司介绍<br>公司简介不能超过[<%=NewStock_Info(5)%>]Byte</td>
				<td class=a4>&nbsp;<textarea cols="39" name="Explain" rows="5">暂无公司简介！</textarea></td>
			</tr>
			<tr>
				<td class=a3 colspan="2" align="center"><input type="submit" name="submit" value="提交">&nbsp;&nbsp;<input type="reset" name="submit" value="重填"></td>
			</tr>
			</form>
		</table>
<%
		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 GpCoDe="" or not isnumeric(GpCoDe) or not len(GpCoDe)=6 Then
			Exsm.Errmess="<li>请正确输入股票代码[六位数字]。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If GpName="" Then
			Exsm.Errmess="<li>请输入上市股票的名称。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If Exsm.Syllable(GpName)<Cint(NewStock_Info(3)) or Exsm.Syllable(GpName)>Cint(NewStock_Info(4)) Then
			Exsm.Errmess="<li>上市股票名称字节不能小于["&NewStock_Info(3)&"]byte或大于["&NewStock_Info(4)&"]byte。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If StockNum="" or not isnumeric(StockNum) or not InStr(StockNum,".")=0 Then
			Exsm.Errmess="<li>请正确输入股票数量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If StockNum+0<NewStock_Info(2)+0 Then
			Exsm.Errmess="<li>股票数量必须大于["&Formatnumber(NewStock_Info(2),0,-1)&"]股。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If IniStockNum="" or not isnumeric(IniStockNum)or not InStr(IniStockNum,".")=0 Then
			Exsm.Errmess="<li>请正确输入每日初始交易量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If IniStockNum>StockNum Then
			Exsm.Errmess="<li>每日初始交易量不能大于股票数量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Gpprice="" Then
			Exsm.Errmess="<li>请正确输入股票价格。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If not isnumeric(Gpprice) Then
			Exsm.Errmess="<li>请正确输入股票价格。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		Gpprice=Round(Gpprice,2)
		If Gpprice<Round(NewTrade_Info(5),2) Then
			Exsm.Errmess="<li>股票价格必须大于["&Round(NewTrade_Info(5),2)&"]元。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If LtdImg="" Then
			Exsm.Errmess="<li>公司图片不能为空，请认真指定路径。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Explain="" or Exsm.Syllable(Explain)>cint(NewStock_Info(5)) Then
			Exsm.Errmess="<li>公司简介不能为空或超过["&NewStock_Info(5)&"]Byte。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set rs=stock_conn.execute("select code from EX_Stock Where Code='"&GpCoDe&"'")
		If not rs.eof Then
			Exsm.Errmess="<li>您输入的股市代码已经使用了，请重新填写上市公司代码。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set rs=stock_conn.execute("select Code from EX_OneselfStock Where Code='"&GpCoDe&"'")
		If not rs.eof Then
			Exsm.Errmess="<li>您输入的股市代码已经使用了，请重新填写上市公司代码。"
			Call Exsm.Endinfo(1)
			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>您输入的上市公司已经存在。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
			Call Exsm.Endinfo(1)
			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>您输入的上市公司已经上市了。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
			Call Exsm.Endinfo(1)
			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=Exsm_Plus_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&"] ","'","")
			stock_conn.execute("insert into EX_Log (l_boardid,l_touser,l_username,l_content,l_addtime,l_ip,l_type) values('"&Exsm.UserID&"','"&Exsm.ScriptName&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserExsmIP&"',3)")
			ResetCid
			Exsm.DelStockCahe("Exsm_Imitate_News")
			Exsm.Sucmess="<li>恭喜，新股["&GpName&"]成功上市。"
			Call Exsm.Endinfo(1)
		Else
			Exsm.Errmess="<li>出现错误，具体如下："&Err.Description&""
			Call Exsm.Endinfo(1)
		End if
	End Sub
	Sub Edit()
		Dim Sid
		Sid=request("sid")
		If Sid="" Or Not isnumeric(Sid) Then
			Exsm.Errmess="<li>参数错误，请指定相关股票。"
			Call Exsm.Endinfo(1)
			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="<li>参数错误，没有找到该股票。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		Exsm.Title 1,"编辑"&Rs("Code")&"号股票-"&Rs("Company")&""
		Set Rs=stock_conn.execute("select * from EX_Stock Where Sid="&Sid)
%>
		<script language="JavaScript" src ="plus/Ex_Stock/Exsm_Plus_MyDispose.js"></script>
		<script language="javascript">var Filter="$,<%=NewStock_Info(6)%>";</script>
		<table class=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr>
				<td colspan="2" align=center height=25 class=a1>-=> 编 辑 <%=Rs("Code")%> 号 股 票 - <%=Rs("Company")%> <=-</td>
			</tr>
			<form method=post action="?action=EditStock" name="form1">
			<tr>
				<td class=a3 width="50%"><u>Ｉ　　Ｄ</u></td>
				<td class=a3 width="50%">&nbsp;<input type=text readonly name=sid value="<%=Rs("sid")%>" style="background-color: #EEEEEE"></td>
			</tr>
			<tr>
				<td class=a4 width="50%"><u>股票代码</u><br>必须正确填写股市查询代码</td>
				<td class=a4 width="50%">&nbsp;<input type=text name=gpcode value="<%=Rs("Code")%>"><input type=hidden name=gpoldcode value="<%=Rs("Code")%>"></td>
			</tr>
			<tr>
				<td class=a3><u>公司名称</u><br>即股票名，最长[<%=NewStock_Info(4)%>]Byte，最短[<%=NewStock_Info(3)%>]Byte</td>
				<td class=a3>&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=a4><u>总 股 份</u></td>
				<td class=a4>&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=a3><u>剩余股份</u></td>
				<td class=a3>&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=a4><u>每日初始交易量</u><br>每天允许的最大交易量</td>
				<td class=a4>&nbsp;<input type=text name=IniStockNum value="<%=Replace(Formatnumber(rs("TodayPermitTradeSum"),0,-1),",","")%>">&nbsp;股</td>
			</tr>
			<tr>
				<td class=a3><u>收盘价格</u><br></td>
				<td class=a3>&nbsp;<input type=text name=NowCPrice value="<%=formatnumber(Rs("ClosingPrice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class=a4><u>当前价格</u><br></td>
				<td class=a4>&nbsp;<input type=text name=nowsprice value="<%=formatnumber(Rs("TradePrice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class=a3><u>最 高 价</u></td>
				<td class=a3>&nbsp;<input type=text name=ztall value="<%=formatnumber(Rs("HighestPrice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class=a4><u>最 低 价</u></td>
				<td class=a4>&nbsp;<input type=text name=zlow value="<%=formatnumber(Rs("LowestPrice"),2,-1)%>"></td>
			</tr>
			<tr>
				<td class=a3><u>上市日期</u></td>
				<td class=a3>&nbsp;<input type=text name=gpdate value="<%=Rs("ListedDate")%>">&nbsp;格式1900-1-31</td>
			</tr>
			<tr>
				<td class=a4><u>状　　态</u></td>
				<td class=a4>&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=a3><u>公司图片</u>(150*190)<br>如果图片路径是相对路径，则当前目录是股票的根目录<br>图片也可以是网上的图片连接</td>
				<td class=a3>&nbsp;<input type=text name=LtdImg size="39" value="<%=Rs("LtdImg")%>"></td> 
			</tr>	
			<tr>
				<td class=a4 valign="top"><u>版面说明</u><br>上市公司简绍<br>公司简介不能超过[<%=NewStock_Info(5)%>]Byte</td>   
				<td class=a4>&nbsp;<textarea cols="39" name="Explain" rows="5"><%=server.htmlencode(Rs("Explain"))%></textarea></td>  
			</tr>
			<tr>
				<td class=a3 colspan="2" align="center"><input type=submit name=submit value=执行修改></td>
			</form>
		</table>
<%
		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"),"'",""))
		set Rs=stock_conn.execute("select TodayPermitTradeSum from EX_Stock Where Sid="&sid&"")
		If Rs.eof Then
			Exsm.Errmess="<li>错误的参数，请指定正确的股票。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If gpcode="" or not isnumeric(gpcode) or not len(gpcode)=6 Then
			Exsm.Errmess="<li>请正确输入股票代码[六位数字]！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If GpName="" Then
			Exsm.Errmess="<li>请输入上市股票的名称。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If Exsm.Syllable(GpName)<Cint(NewStock_Info(3)) or Exsm.Syllable(GpName)>Cint(NewStock_Info(4)) Then
			Exsm.Errmess="<li>上市股票名称字节不能小于["&NewStock_Info(3)&"]byte或大于["&NewStock_Info(4)&"]byte。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(nowsprice) Then
			Exsm.Errmess="<li>当前价格必须输入数字。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(NowCPrice) Then
			Exsm.Errmess="<li>收盘价格必须输入数字。"
			Call Exsm.Endinfo(1)
			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="<li>收盘价格必须大于["&Round(NewTrade_Info(5),2)&"]元。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If nowsprice<Round(NewTrade_Info(5),2) Then
			Exsm.Errmess="<li>当前价格必须大于["&Round(NewTrade_Info(5),2)&"]元。"
			Call Exsm.Endinfo(1)
			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="<li>当前价格和收盘价格比例请控制在收盘价格正["&Round(NewTrade_Info(3),2)&"%]负["&Round(NewTrade_Info(4),2)&"%]之间。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(ztall) Then
			Exsm.Errmess="<li>最高价格必须输入数字。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(zlow) Then
			Exsm.Errmess="<li>最低价格必须输入数字。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(StockNum) or not InStr(StockNum,".")=0 Then
			Exsm.Errmess="<li>总股份必须输入数字。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(RemainStockNum) or not InStr(RemainStockNum,".")=0 Then
			Exsm.Errmess="<li>剩余股份必须输入数字。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isnumeric(IniStockNum) or not InStr(IniStockNum,".")=0 Then
			Exsm.Errmess="<li>每日初始交易量必须输入数字。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If StockNum<>TotalStockNum Then
			If StockNum>TotalStockNum Then
				RemainStockNum=Replace(Formatnumber(RemainStockNum+(StockNum-TotalStockNum),0,-1),",","")
			Elseif StockNum<TotalStockNum Then
				RemainStockNum=Replace(Formatnumber(RemainStockNum-(TotalStockNum-StockNum),0,-1),",","")
			End if
		End if
		If RemainStockNumA<>OldRemainStockNum Then
			If RemainStockNum>OldRemainStockNum Then
				StockNum=Replace(Formatnumber(StockNum+(RemainStockNum-OldRemainStockNum),0,-1),",","")
			Elseif RemainStockNum<OldRemainStockNum Then
				StockNum=Replace(Formatnumber(StockNum-(OldRemainStockNum-RemainStockNum),0,-1),",","")
			End if
		End if
		If StockNum<=0 Then
			Exsm.Errmess="<li>总股份不能等于或小于[0]！请重新填写。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If RemainStockNum<0 Then
			Exsm.Errmess="<li>剩余股份不能小于[0]！请重新填写。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If RemainStockNum+0>StockNum+0 Then
			Exsm.Errmess="<li>总股份低于剩余股票！请重新填写。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If IniStockNum+0>RemainStockNum+0 Or IniStockNum+0>StockNum+0 Then
			Exsm.Errmess="<li>每日初始交易量不能大于总股份或剩余股份。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If not isdate(gpdate) Then
			Exsm.Errmess="<li>上市日期格式错误请重新填写。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If LtdImg="" Then
			Exsm.Errmess="<li>公司图片不能为空，请认真指定路径。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Exsm.Syllable(Explain)>Cint(NewStock_Info(5)) Then
			Exsm.Errmess="<li>上市股票公司简介不能大于["&NewStock_Info(5)&"]byte。"
			Call Exsm.Endinfo(1)
			Exit Sub
		End if
		If RemainStockNum+0<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="<li>您输入的股市代码已经使用了，请重新填写上市公司代码。"
				Call Exsm.Endinfo(1)
				Exit sub
			End if
			set rs=stock_conn.execute("select Code from EX_OneselfStock Where Code='"&gpcode&"'")
			If not rs.eof Then
				Exsm.Errmess="<li>您输入的股市代码已经使用了，请重新填写上市公司代码。"
				Call Exsm.Endinfo(1)
				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>您输入的上市公司已经存在。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
				Call Exsm.Endinfo(1)
				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>您输入的上市公司已经上市了。<li>或您输入的名称含有仅用字符，请重新填写上市公司名称。"
				Call Exsm.Endinfo(1)
				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&"] ","'","")
			stock_conn.execute("insert into EX_Log (l_boardid,l_touser,l_username,l_content,l_addtime,l_ip,l_type) values('"&Exsm.UserID&"','"&Exsm.ScriptName&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserExsmIP&"',3)")
			Exsm.Sucmess="<li>["&GpName&"]股票信息已经修改完毕！"
			Call Exsm.Endinfo(1)
		Else
			Exsm.Errmess="<li>出现错误，具体如下："&Err.Description&""
			Call Exsm.Endinfo(1)
		End if
	End sub
	Sub search()
		Dim GupiaoName
		GupiaoName=trim(replace(request("gname"),"'",""))
		If GupiaoName="" Then
			Exsm.Errmess="<li>请输入查找关键字。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		Exsm.Title 1,"股票搜索结果"
		If request("usernamechk")="yes" Then
			sql="select * from EX_Stock where Company='"&GupiaoName&"'"
		Else
			sql="select * from EX_Stock where Company like '%"&GupiaoName&"%'"
		End if
%>
		<table class=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr>
				<td align=center height=25 class=a1>-=> 搜 索 结 果 <=-</td>
			</tr>
			<tr> 
				<form name="form1" method="post" action="?action=search">
					<td class=a3 colspan=8 height=20>查找：<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=a2 width=<%=Exsm.AssignWidth%> cellspacing=1 cellpadding=3 align=center border=0>
			<tr align=center height=25 class=a1>
				<td>代码</td>
				<td>股票名称</td>
				<td>总股份</td>
				<td>昨日收盘</td>
				<td>目前成交</td>
				<td>成交量</td>
				<td>状态</td>
				<td>管理</td>
			</tr>
<%
		Set Rs=stock_conn.execute(sql)
		If Rs.eof Then
			response.Write "<tr><td class=a3 colspan=8>没有找到任何股票</td></tr>"
		Else
			Do while not rs.eof
%>
			<tr> 
				<td class=a3 align=center><%=rs("Code")%></td>
				<td class=a3 align=center><a href=?action=edit&sid=<%=Rs("Sid")%>><%=rs("Company")%></a></td>
				<td class=a3 align=right><%=formatnumber(rs("StockSum"),0,-1)%></td>
				<td class=a3 align=right><%=formatnumber(rs("ClosingPrice"),2,-1)%></td>
				<td class=a3 align=right><%=formatnumber(rs("TradePrice"),2,-1)%></td>
				<td class=a3 align=right><%=Replace(Formatnumber(Rs("TodayTradeSum")-Rs("TodayPermitTradeSum"),0,-1),",","")%></td>
				<td class=a3 align=center><%If Rs("LockStock")=0 Then%>开<%Else%><Font color="#FF0000">封</Font><%End if%></Font></td>
				<td class=a3 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=Exsm_Plus_Admin_Cutamelon.asp?sid=<%=rs("sid")%>>分红</a></div><div><a href=?action=edit&sid=<%=rs("sid")%>>编辑</a></div><div><a href=Exsm_Plus_Admin_Intervene.asp?sid=<%=rs("sid")%>>干预</a></div><div><a href=?action=DelStock&Sid=<%=rs("Sid")%>>删除</a></div>','',0)">操作</a></td>
			</tr>
<%
			Rs.movenext
			loop
		Rs.close
		End if
%>
		</table>
<%
		Exsm.RootShowA
	End sub
	Sub DelStock()
		Dim Sid,Rst,NowPrice,GpName,AddMoney,Mycontent
		Sid=request("Sid")
		If Sid="" Or Not isnumeric(Sid) Then
			Exsm.Errmess="<li>没有输入参数或参数非法。"
			Call Exsm.Endinfo(1)
			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="<li>股票数据表中没有找到你要删除的股票。"
			Call Exsm.Endinfo(1)
			Exit Sub
		Else
		Exsm.Title 1,"股票管理"
%>
		<table class="tableborder1" cellspacing="1" cellpadding="3" align="center" border="0" id="Ex">
			<tr>
				<td align=center height=25 class=a1>-=> 股 票 管 理 - 删 除 股 票 [<%=Rst(1)%>] <=-</td>
			</tr>
			<form method="post" action="?action=SaveDelStock">
			<tr>
				<td class=a3><u>操作理由</u>&nbsp;<input name="logtxt" size="70">&nbsp;*</td>
			</tr>
			<tr>
				<td class=a3><u>资金流向</u>&nbsp;<input type=radio name="UserWealth" value=1 checked>抛出所有股票&nbsp;<input type=radio name="UserWealth" value=0>注销股票（不建议选择。）</td>
			</tr>
			<tr>
				<td class=a3><u>信息发布</u>&nbsp;<input name="messagetxt" size="70" value="股票[<%=Rst(1)%>]被删除！">&nbsp;<input type="checkbox" name="use" value=1>使用</td>
			</tr>
			<tr>
				<td class=a3><u>管理说明</u><br>①注销股票后持股者股票被删除后不会得到抛出资金！<br>②如果使用了信息发布，系统将发布即时信息以便通知股民。</td>
			</tr>
			<input type=hidden name=DelStockId value="<%=Sid%>">
			<tr>
				<td class=a4 align="center"><input type="submit" value="确定" name="b1">&nbsp;&nbsp;<input type="reset" value="重填" name="b2"></td>
			</tr>
			</form>
		</table>
		<script language="JavaScript">setTimeout("winwidth()",1000)</script>
<%
		Exsm.RootShowA
		End if
	End Sub
	Sub SaveDelStock()
		Dim Sid,LogTxt,DelStock,MessageTxt,Rst,NowPrice,GpName,AddMoney
		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="<li>没有输入参数或参数非法。"
			Call Exsm.Endinfo(1)
			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="<li>股票数据表中没有找到你要删除的股票。"
			Call Exsm.Endinfo(1)
			Exit Sub
		Else
			NowPrice=Rs(0)
			GpName=Rs(1)
			If LogTxt="" Or Exsm.Syllable(LogTxt)>250 Then
				Exsm.Errmess="<li>操作理由不能为空。"
				Call Exsm.Endinfo(1)
				Exit sub
			Else
				DelStock="注销股票"
				If Request.form("StockSum")=1 Then DelStock="抛出所有股票"
				LogTxt="用户操作：删除股票["&GpName&"] "&LogTxt&" "&DelStock&""
			End if
			If Request.form("use")=1 And MessageTxt="" Or Exsm.Syllable(MessageTxt)>250 Then
				Exsm.Errmess="<li>您选择了使用信息发布功能请填写信息内容。"
				Call Exsm.Endinfo(1)
				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
			stock_conn.execute("insert into EX_Log (l_boardid,l_touser,l_username,l_content,l_addtime,l_ip,l_type) values('"&Exsm.UserID&"','"&Exsm.ScriptName&"','"&Exsm.StockHolder&"','"&LogTxt&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',3)")
			ResetCid
			Exsm.Sucmess="<li>股票["&GpName&"]删除成功。"
			Call Exsm.Endinfo(1)
		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 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
%>