<!--#include file="setup.asp"-->
<!--#include file="plus/Ex_Stock/Exsm_Plus_Conn.asp"-->
<!--#include file="plus/Ex_Stock/Exsm_Plus_Const.asp"-->
<%
	Dim Trade_Info,Person_Info,page
	Trade_Info=split(Exsm.Stock_Setting(2),",")
	Person_Info=split(Exsm.Stock_Setting(4),"|")
	select case request("action")
		case "NewStock"
			call NewStock()
		case "SaveUsSt"
			call SaveUsSt()
		case "UserStat"
			call UserStat()
		case "edit"
			call Edit()
		case "SaveEdit"
			call SaveEdit()
		case "DelEachStock"
			call DelEachStock()
		case else
			call main()
	End select
	Sub main()
		Exsm.Title 1,"个股上市列表"
		page=request("page")
		If page="" Or Not isnumeric(page) Then page=1
		Dim ExRs
		Response.Write "<script language=""JavaScript"" src =""plus/Ex_Stock/Exsm_Plus_EachStock.js""></script>"
		Response.Write "<Script Language=JavaScript>"
		Response.Write "var assignwidth='"&Exsm.AssignWidth&"';"
		Response.Write "var userid="&Exsm.UserID&";"
		If Exsm.StockAdmin Then
			Response.Write "useradmin=1;"
		End if
		Response.Write "ex_each_stock_top();"
		Response.Write "</Script>"
		sql= "select * from EX_OneselfStock"
		Set Rs=server.createobject("adodb.recordset")
		rs.open sql,stock_conn,1,1
		If not Rs.eof Then
			Rs.PageSize=CInt(Exsm.Setting_Info(15))
			If page+0>Rs.PageCount Then page=Rs.PageCount
			Rs.AbsolutePage=page
			ExRs=Rs.GetRows(Rs.PageSize)
			For i=0 To Ubound(ExRs,2)
				Response.Write "<Script Language=JavaScript>"
				Response.Write "ex_each_stock('"
				Response.Write Rs.PageSize*page+i-Rs.PageSize+1
				Response.Write "','"
				Response.Write ExRs(0,i)
				Response.Write "','"
				Response.Write ExRs(1,i)
				Response.Write "','"
				Response.Write Exsm.htmlencode(ExRs(2,i))
				Response.Write "','"
				Response.Write ExRs(3,i)
				Response.Write "','"
				Response.Write Exsm.htmlencode(ExRs(4,i))
				Response.Write "','"
				Response.Write ExRs(5,i)
				Response.Write "','"
				Response.Write ExRs(6,i)
				Response.Write "','"
				Response.Write ExRs(7,i)
				Response.Write "','"
				Response.Write ExRs(8,i)
				Response.Write "','"
				Response.Write Exsm.htmlencode(server.htmlencode(ExRs(9,i)))
				Response.Write "','"
				Response.Write ExRs(11,i)
				Response.Write "','"
				Response.Write ExRs(12,i)
				Response.Write "','"
				Response.Write ExRs(13,i)
				Response.Write "');"
				Response.Write "</Script>"
			Next
			Response.Write "<Script Language=JavaScript>"
			Response.Write "var assignwidth='"&Exsm.AssignWidth&"';"
			Response.Write "var page="&page&";"
			Response.Write "var recordcount="&Rs.RecordCount&";"
			Response.Write "var pagesize="&Rs.PageSize&";"
			Response.Write "var pagecount="&Rs.PageCount&";"
			Response.Write "ex_each_stock_root();"
			Response.Write "</Script>"
		Else
			Response.Write "<Script Language=JavaScript>"
			Response.Write "var assignwidth='"&Exsm.AssignWidth&"';"
			Response.Write "ex_each_stock_naught();"
			Response.Write "</Script>"
		End if
		Exsm.RootShow
	End Sub
	Sub NewStock()
		Dim MinPrice,MaxPrice
		If Not Exsm.Members Then
			Exsm.Errmess="<li>您还没有股票帐户，不能申请个股上市，请先开户。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Person_Info(0)=0 Then
			Exsm.Errmess="<li>个股上市申请暂时关闭，请等待开放。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Exsm.StockAdmin Then
			Exsm.Errmess="<li>管理员["&Exsm.StockHolder&"]您好，请到后台进行股票添加。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Cdbl(Exsm.UserCash)<cdbl(Person_Info(1)) Then
			Exsm.Errmess="<li>您现在的股票帐户可用资金不足["&Person_Info(1)&"]元，不能申请个股上市。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set Rs=stock_conn.execute("select top 1 ClosingPrice from EX_Stock order by ClosingPrice")
		If Rs.eof Then
			inPrice=Round(Trade_Info(5),2)
		Else
			If Rs(0)<Round(Trade_Info(5),2) Then
				MinPrice=Round(Trade_Info(5),2)
			Else
				MinPrice=Round(Rs(0),2)
			End if
		End if
		set Rs=stock_conn.execute("select top 1 ClosingPrice from EX_Stock order by ClosingPrice desc")
		If Rs.eof Then
			MaxPrice=100.00
		Else
			If Rs(0)<Round(Trade_Info(5),2) Then
				MaxPrice=100.00
			Else
				MaxPrice=Round(Rs(0),2)
			End if
		End if
		Exsm.Title 1,"申请个股上市"
			Response.Write "<script language=""JavaScript"" src =""plus/Ex_Stock/Exsm_Plus_MyDispose.js""></script>"
			Response.Write "<script language=""javascript"">var Filter='$,"&Person_Info(6)&"';</script>"
			Response.Write "<script language=""JavaScript"" src =""plus/Ex_Stock/Exsm_Plus_EachStock.js""></script>"
			Response.Write "<Script Language=JavaScript>"
			Response.Write "var assignwidth='"&Exsm.AssignWidth&"';"
			Response.Write "var userid="&Exsm.UserID&";"
			Response.Write "var username='"&Exsm.htmlencode(Exsm.StockHolder)&"';"
			Response.Write "var usercash='"&Exsm.UserCash&"';"
			Response.Write "var minprice='"&MinPrice&"';"
			Response.Write "var maxprice='"&MaxPrice&"';"
			Response.Write "var minstocknum="&Person_Info(2)&";"
			Response.Write "var minname="&Person_Info(3)&";"
			Response.Write "var maxname="&Person_Info(4)&";"
			Response.Write "var companyint="&Person_Info(5)&";"
			Response.Write "ex_each_stock_new();"
			Response.Write "</Script>"
		Exsm.RootShow
	End Sub
	Sub SaveUsSt()
		Dim GpCoDe,GpName,Gpprice,Gpnum,inigpnum,GpExplain,l_content
		GpCoDe=Request.form("gpcode")
		GpName=trim(replace(Request.form("gpname"),"'",""))
		GpName=Exsm.SiftName(GpName)
		Gpprice=Request.form("price")
		Gpnum=Request.form("gpnum")
		inigpnum=Request.form("inigpnum")
		GpExplain=trim(replace(Request.form("Explain"),"'",""))
		If Not Exsm.Members Then
			Exsm.Errmess="<li>您还没有登录不能进入，请先登录。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Person_Info(3)=0 Then
			Exsm.Errmess="<li>个股上市申请暂时关闭，请等待开放。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Exsm.StockAdmin Then
			Exsm.Errmess="<li>管理员["&Exsm.StockHolder&"]您好，请到后台进行股票添加。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Cdbl(Exsm.UserCash)<Cdbl(Person_Info(1)) Then
			Exsm.Errmess="<li>个股申请要求最低拥有["&cdbl(Person_Info(1))&"]元可用资金，您未能达到要求！"
			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="" or Exsm.Syllable(GpName)<Cint(Person_Info(3)) or Exsm.Syllable(GpName)>Cint(Person_Info(4)) Then
			Exsm.Errmess="<li>请正确输入上市公司的名称。名称长度不能小于["&Person_Info(3)&"]Byte或者超过["&Person_Info(4)&"]Byte，或您输入的名称含有仅用字符。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Gpprice="" Or not isnumeric(Gpprice) Then
			Exsm.Errmess="<li>请正确输入股票价格！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		Gpprice=Round(Gpprice,2)
		If Cdbl(Gpprice)<Cdbl(Request.form("MinPrice")) Or Cdbl(Gpprice)>Cdbl(Request.form("MaxPrice")) Then
			Exsm.Errmess="<li>请正确输入股票单价，单价范围：["&Request.form("MinPrice")&"]～["&Request.form("MaxPrice")&"]！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Gpnum="" or not isnumeric(Gpnum) or not InStr(Gpnum,".")=0 Then
			Exsm.Errmess="<li>请正确输入股票数量！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Gpnum+0<Round(Person_Info(2)) Then
			Exsm.Errmess="<li>股票数量必须大于["&Formatnumber(Person_Info(2),0,-1)&"]股。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If inigpnum="" or not isnumeric(inigpnum) or not InStr(inigpnum,".")=0 Then
			Exsm.Errmess="<li>请正确输入初始每日交易量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		Gpnum=replace(formatnumber(Gpnum,0,-1),",","")
		If Cdbl(Exsm.UserCash)/Cdbl(Gpprice)<Round(Person_Info(2)) Then
			Exsm.Errmess="<li>您输入的单价只能上市["&Formatnumber(Cdbl(Exsm.UserCash)/Cdbl(Gpprice),0,-1)&"]股，请降低输入的单价。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Round(inigpnum)>Round(Gpnum) Or Round(inigpnum)<100 Then
			Exsm.Errmess="<li>请正确输入初始每日交易量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If GpExplain="" Or Exsm.Syllable(GpExplain)>Cint(Person_Info(5)) Then
			Exsm.Errmess="<li>公司简介不能为空或超过["&Person_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 Company 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>您输入的上市公司已经存在。或您输入的名称含有仅用字符，请重新填写上市公司名称。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set rs=stock_conn.execute("select Company from EX_OneselfStock where Company='"&GpName&"'")
		If not rs.eof Then
			Exsm.Errmess="<li>您输入的上市公司已经存在。或您输入的名称含有仅用字符，请重新填写上市公司名称。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		on error resume next
		stock_conn.execute("insert into EX_OneselfStock (Code,Username,UserId,Company,Price,Stocknum,Explain,ApplyDate,States,TodayTradeSum) values('"&Gpcode&"','"&Exsm.StockHolder&"',"&Exsm.UserID&",'"&GpName&"',"&Round(Gpprice,2)&","&Gpnum&",'"&GpExplain&"',"&SqlSmNowString&",0,"&inigpnum&")")
		stock_conn.execute("update Ex_User set UserWealth=UserWealth-"&Round(Gpprice*Gpnum,2)&",UserAssets=UserAssets-"&Round(Gpprice*Gpnum,2)&" Where ID="&Exsm.UserID&"")
		If err.number=0 Then
			l_content=replace("用户操作：申请个股["&GpName&"]单格["&Gpprice&"]数量["&Gpnum&"] ","'","")
			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.StockHolder&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',5)")
			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,RsEdit
		Sid=request("sid")
		If Not Exsm.Members Then
			Exsm.Errmess="<li>您还没有登录不能进入，请先登录。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Sid="" or not isnumeric(Sid) Then
			Exsm.Errmess="<li>请正确输入股票ＩＤ！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set RsEdit=stock_conn.execute("select * from EX_OneselfStock Where Sid="&Sid)
		If RsEdit.eof and RsEdit.bof Then
			Exsm.Errmess="<li>没有找到指定的上市公司！"
			Call Exsm.Endinfo(1)
			Exit sub
		Elseif RsEdit("UserId")<>Exsm.UserID And not Exsm.StockAdmin Then
			Exsm.Errmess="<li>您不是该上市公司的大股东，没有执行本操作的权限！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		Exsm.Title 1,"编辑个股["&RsEdit("Company")&"]资料"
			Response.Write "<script language=""JavaScript"" src =""plus/Ex_Stock/Exsm_Plus_MyDispose.js""></script>"
			Response.Write "<script language=""javascript"">var Filter='$,"&Person_Info(6)&"';</script>"
			Response.Write "<script language=""JavaScript"" src =""plus/Ex_Stock/Exsm_Plus_EachStock.js""></script>"
			Response.Write "<Script Language=JavaScript>"
			Response.Write "var assignwidth='"&Exsm.AssignWidth&"';"
			Response.Write "var userid="&Exsm.UserID&";"
			Response.Write "var sid="&RsEdit("sid")&";"
			Response.Write "var company='"&RsEdit("Company")&"';"
			Response.Write "var stockcode='"&RsEdit("Code")&"';"
			Response.Write "var stockprice='"&RsEdit("Price")&"';"
			Response.Write "var stocknum='"&RsEdit("Stocknum")&"';"
			Response.Write "var todaytradesum='"&RsEdit("TodayTradeSum")&"';"
			Response.Write "var explain='"&Exsm.htmlencode(server.htmlencode(RsEdit("Explain")))&"';"
			Response.Write "var minname="&Person_Info(3)&";"
			Response.Write "var maxname="&Person_Info(4)&";"
			Response.Write "var companyint="&Person_Info(5)&";"
			Response.Write "ex_each_stock_edit();"
			Response.Write "</Script>"
		Exsm.RootShow
	End Sub
	Sub SaveEdit()
		Dim Gpsid,RsEdit,GpCoDe,GpName,GpCoDen,GpNamen,GpExplain,inigpnum,MessageE,l_content
		Gpsid=Request.form("sid")
		GpCoDe=Request.form("gpcode")
		GpName=trim(replace(Request.form("gpname"),"'",""))
		GpCoDen=Request.form("gpoldcode")
		GpNamen=trim(replace(Request.form("gpoldname"),"'",""))
		GpName=Exsm.SiftName(GpName)
		inigpnum=Request.form("inigpnum")
		GpExplain=trim(replace(Request.form("Explain"),"'",""))
		If Not Exsm.Members Then
			Exsm.Errmess="<li>您还没有登录不能进入，请先登录。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Gpsid="" or not isnumeric(Gpsid) Then
			Exsm.Errmess="<li>请正确输入股票ＩＤ！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set RsEdit=stock_conn.execute("select * from EX_OneselfStock where sid="&Gpsid&"")
		If RsEdit.eof and RsEdit.bof Then
			Exsm.Errmess="<li>没有找到指定的上市公司！"
			Call Exsm.Endinfo(1)
			Exit sub
		Elseif RsEdit("UserId")<>Exsm.UserID and not Exsm.StockAdmin 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="" or Exsm.Syllable(GpName)<Cint(Person_Info(3)) or Exsm.Syllable(GpName)>Cint(Person_Info(4)) Then
			Exsm.Errmess="<li>请正确输入上市公司的名称。名称长度不能小于["&Person_Info(3)&"]Byte或者超过["&Person_Info(4)&"]Byte，或您输入的名称含有仅用字符。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If inigpnum="" or not isnumeric(inigpnum) or not InStr(inigpnum,".")=0 Then
			Exsm.Errmess="<li>请正确输入初始每日交易量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Round(inigpnum)>Round(Request.form("Stocknum")) Or Round(inigpnum)<100 Then
			Exsm.Errmess="<li>请正确输入初始每日交易量。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If GpExplain="" or Exsm.Syllable(GpExplain)>Cint(Person_Info(5)) Then
			Exsm.Errmess="<li>公司简介不能为空或超过["&Person_Info(5)&"]Byte。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If GpCoDen<>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 Company 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 GpNamen<>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(1)
				Exit sub
			End if
			set rs=stock_conn.execute("select Company from EX_OneselfStock where Company='"&GpName&"'")
			If not rs.eof Then
				Exsm.Errmess="<li>您输入的上市公司已经存在。或您输入的名称含有仅用字符，请重新填写上市公司名称。"
				Call Exsm.Endinfo(1)
				Exit sub
			End if
		End if
		on error resume next
		If RsEdit("States")=0 Then
			stock_conn.execute("update EX_OneselfStock set Code='"&Gpcode&"',Company='"&GpName&"',Explain='"&GpExplain&"' where Sid="&Gpsid&"")
			MessageE="编辑上市公司["&GpName&"]成功！请等待证监会的审批。"
		Else
			stock_conn.execute("update EX_OneselfStock set Code='"&Gpcode&"',Company='"&GpName&"',Explain='"&GpExplain&"',States=2 where Sid="&Gpsid&"")
			MessageE="编辑上市公司["&GpName&"]成功！请等待证监会的批准，通过批准后上市股票将会被更新。"
		End if
		If err.number=0 then
			l_content=replace("用户操作：个股["&GpNamen&"]改为["&GpName&"]代码["&Gpcoden&"]改为["&Gpcode&"]分红类型["&Gpfenpei&"]分红量["&AllotAmount&"] ","'","")
			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.StockHolder&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',5)")
			Exsm.Sucmess="<li>"&MessageE&""
			Call Exsm.Endinfo(1)
		Else
			Exsm.Errmess="<li>出现错误，具体如下："&Err.Description&""
			Call Exsm.Endinfo(1)
		End if
	End Sub
	Sub DelEachStock()
		Dim Gpsid,RsDel
		Dim EachUserId,EachStName,EachPrice,EachStocknum,l_content
		Gpsid=request("Gpsid")
		If Not Exsm.Members Then
			Exsm.Errmess="<li>您还没有登录不能进入，请先登录。"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If Gpsid="" or not isnumeric(Gpsid) Then
			Exsm.Errmess="<li>请正确输入股票ＩＤ！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		set RsDel=stock_conn.execute("select * from EX_OneselfStock where States=0 and sid="&Gpsid&"")
		If RsDel.eof and RsDel.bof Then
			Exsm.Errmess="<li>没有找到指定的上市公司！可能已经正式上市。"
			Call Exsm.Endinfo(1)
			Exit sub
		Elseif RsDel("UserId")<>Exsm.UserID And Not Exsm.StockAdmin Then
			Exsm.Errmess="<li>您不是该上市公司的大股东，没有执行本操作的权限！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		EachUserId=RsDel("UserId")
		EachStName=RsDel("Company")
		EachPrice=RsDel("Price")
		EachStocknum=RsDel("Stocknum")
		stock_conn.execute("update Ex_User set UserWealth=UserWealth+"&Round(EachPrice*EachStocknum,2)&",UserAssets=UserAssets+"&Round(EachPrice*EachStocknum,2)&" where ID="&EachUserId&"")
		stock_conn.execute("delete from EX_OneselfStock where sid="&Gpsid&"")
		l_content=replace("用户操作：股民["&Exsm.StockHolder&"]撤销个股["&EachStName&"]申请 ","'","")
		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.StockHolder&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',5)")
		Exsm.Sucmess="<li>上市公司["&EachStName&"]个股注销成功。"
		Call Exsm.Endinfo(1)
	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
	Sub UserStat()
		Dim Sid,UserRs,Mycontent,l_content
		Randomize
		Sid=request("sid")
		If Exsm.UserID="" or Exsm.UserID=0 or not isnumeric(Exsm.UserID) or Exsm.StockHolder="" Then
			Response.Redirect "Exsm_Plus_Gupiao.asp"
			Exit sub
		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"
				Exit sub
			Elseif Rs(1)>1 Then
				Response.Redirect "Exsm_Plus_Gupiao.asp"
				Exit sub
			Elseif not Exsm.Members Then
				Response.Redirect "Exsm_Plus_Gupiao.asp"
				Exit sub
			Elseif not Exsm.StockAdmin Then
				Response.Redirect "Exsm_Plus_Gupiao.asp"
				Exit sub
			Elseif not Rs(0)=Exsm.StockHolder Then
				Response.Redirect "Exsm_Plus_Gupiao.asp"
				Exit sub
			End if
		End if
		If Sid="" or not isnumeric(Sid) Then
			Exsm.Errmess="<li>请正确输入批准股票ＩＤ！"
			Call Exsm.Endinfo(1)
			Exit sub
		End if
		If not request("stat")="Yes" And not request("stat")="No" And not request("stat")="OnceAgainYes" Then
			Exsm.Errmess="<li>非法进入，请输入执行参数！"
			Call Exsm.Endinfo(1)
			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="<li>未发现您指定的股票数据！"
			Call Exsm.Endinfo(1)
			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="<li>您指定的股票可能已经上市请不要重复提交！"
				Call Exsm.Endinfo(1)
				Exit sub
			End if
			set Rs=stock_conn.execute("select UserWealth from Ex_User where ID="&UserRs("UserId")&"")
			If Rs(0)<Cdbl(Person_Info(1)/2) Then
				Mycontent=replace("系统消息：股民["&UserRs("Username")&"]个股["&UserRs("Company")&"]由于资金低于["&cdbl(Person_Info(1)/2)&"]元，未能通过审批！","'","")
				stock_conn.execute("insert into EX_News (content,Color,addtime) values('"&Mycontent&"','"&Exsm.RndColor&"',"&SqlSmNowString&")")
				Exsm.DelStockCahe("Exsm_Imitate_News")
				Exsm.Errmess="<li>被审批股民帐户可用资金低于["&Cdbl(Person_Info(1)/2)&"]元，股民["&UserRs("Username")&"]当前资金为["&cdbl(Rs(0))&"]元，不能通过审批！"
				Call Exsm.Endinfo(1)
				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")&"','plus/img_gupiao/LtdImg/1.jpg','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")&"] ","'","")
			stock_conn.execute("insert into EX_Log (l_boardid,l_touser,l_username,l_content,l_addtime,l_ip,l_type) values('"&Exsm.UserID&"','"&UserRs("Username")&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',3)")
			Call Exsm.CalculateFund(UserRs("UserId"),0)
			ResetCid
			Exsm.DelStockCahe("Exsm_Imitate_News")
			Exsm.Sucmess="<li>股民["&UserRs("Username")&"]个股["&UserRs("Company")&"]提交成功。"
			Call Exsm.Endinfo(1)
		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="<li>您指定的股票还未上市不能进行再次批准！"
				Call Exsm.Endinfo(1)
				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")&"] ","'","")
				stock_conn.execute("insert into EX_Log (l_boardid,l_touser,l_username,l_content,l_addtime,l_ip,l_type) values('"&Exsm.UserID&"','"&UserRs("Username")&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',3)")
				stock_conn.execute("update EX_Stock set Code='"&UserRs("Code")&"',Company='"&UserRs("Company")&"',TodayTradeSum="&Round(UserRs("TodayTradeSum")/2,0)&",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
				l_content=replace("股票管理：提交编辑股民["&UserRs("Username")&"]个股，股票名称["&Rs("Company")&"]：初始每日交易量["&UserRs("TodayTradeSum")&"] ","'","")
				stock_conn.execute("insert into EX_Log (l_boardid,l_touser,l_username,l_content,l_addtime,l_ip,l_type) values('"&Exsm.UserID&"','"&UserRs("Username")&"','"&Exsm.StockHolder&"','"&l_content&"',"&SqlSmNowString&",'"&Exsm.UserIP&"',3)")
				stock_conn.execute("update EX_Stock set TodayTradeSum="&Round(UserRs("TodayTradeSum")/2,0)&",Explain='"&UserRs("Explain")&"' Where Sid="&UserRs("DecideId")&"")
			End if
			stock_conn.execute("update EX_OneselfStock set States=1 where sid="&Sid&"")
			Exsm.DelStockCahe("Exsm_Imitate_News")
			Exsm.Sucmess="<li>股民["&UserRs("Username")&"]个股["&UserRs("Company")&"]再次提交成功。"
			Call Exsm.Endinfo(1)
		End if
	End Sub
%>
