<!--#include file="../Inc.asp"-->
<!--#include file="../ydzq.asp"-->
<!--#include file="conn.asp"-->
<%call head()
Call saycarda("我要下注")
Dim sss
randomize timer
sss=left(Int((9999)*Rnd +1000),3)
sss=abs(int(sss))
  set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select  hyin,winerin,bigzu,zucent,wincent,Isopen,zhunum,zhucent from winerAdmin where id=1",ydzqconn,1,1
if not rs.eof then
hyin=rs(0)
winerin=rs(1)
bigzu=rs(2)
zucent=rs(3)
wincent2=rs(4)
Isopen=rs(5)
zhunum=rs(6)
zhucent=rs(7)
end if
rs.close
set rs=nothing

dim id,paytype,TP


ID=request("ID")
paytype=request("paytype")
TP=request("TP")

if ID="" or Isnumeric(ID)=False then
  Call Error("ID无效！")
  end if

dim wincent,v_winnum,v_dinum
  set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select cent,winnum,dinum from winer where comeover=0 and id="&id,ydzqconn,1,1
if rs.eof then
call Error("不存在的记录或者已经开奖了！<br/>请<a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">进入下期</a>")
end if
wincent=rs("cent")
v_winnum=rs("winnum")
v_dinum=rs("dinum")
rs.close
set rs=nothing
'计算总投注数
dim v_dinumall,v_wincentall
v_dinumall=abs(int(v_dinum+paytype))
'计算总投注金额
v_wincentall=abs(int(wincent+paycent))


if TP="ok" then


if paytype<>"10" and paytype<>"50" and paytype<>"100" then
  Call Error("选择无效！")
  end if

paytype=abs(int(paytype))
dim paycent

paycent=abs(int(paytype*zucent))


 if myjb<paycent then
 Call Error("您的"&getcent&"不足！")
 end if
'-------------------------------------------------
'更新
ydzqconn.execute("update  winer set dinum=dinum+"&paytype&",cent='"&abs(int(wincent+paycent))&"' where ID="&ID)
conn.execute("update users Set myjb = myjb  - "&paycent&" where ID = " & myID)
  dim rs2
  set rs2=Server.CreateObject("ADODB.Recordset")
  rs2.open"select id,usid,votenum,votecent from winuslist where usid="&myid,ydzqconn,1,2
if not rs2.eof then
rs2("votenum")=rs2("votenum")+paytype
rs2("votecent")=abs(int(rs2("votecent")+paycent))
else
rs2.addnew
rs2("usid")=myid
rs2("votenum")=paytype
rs2("votecent")=paycent
end if
rs2.update
rs2.close
set rs2=nothing


for i=1 to paytype

Dim ss
randomize timer
ss=left(Int((9999)*Rnd +1000),3)
ss=abs(int(ss))

'-------------------------------------------------
set rssj=Server.CreateObject("ADODB.Recordset")
  rssj.open"select id from winerlist where vote="&ss,ydzqconn,1,1
  if not rssj.eof then
  'ss=left(Int((9999)*Rnd +1000),2)
  i=i-1
  else

'========================================


if Isopen=1 then
if v_dinumall>=zhunum then
ss=v_winnum
end if
if v_wincentall>=zhucent then
ss=v_winnum
end if
end if


if v_winnum=ss then
set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select id,winnum,winUsid,winUsname,comeover from winer where comeover=0 and ID="&ID,ydzqconn,1,2
  if rs.eof then
  Call Error("本轮投注已结束，请<a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">进入下期</a>")
  end if
 rs("winusid")=myid
 rs("winUsname")=myni
 rs("comeover")=1
 rs.update
rs.close
set rs=nothing
'奖励会员
  dim rs3
  set rs3=Server.CreateObject("ADODB.Recordset")
  rs3.open"select id,usid,votewinnum,votewincent from winuslist where usid="&myid,ydzqconn,1,2
if not rs3.eof then
rs3("votewinnum")=rs3("votewinnum")+1
rs3("votewincent")=abs(int(rs3("votewincent")+wincent*hyin*0.01))
end if
rs3.update
rs3.close
set rs3=nothing

set rsu=Server.CreateObject("ADODB.Recordset")
rsu.open"select * from guest",conn,1,2
rsu.addnew
rsu("fnr")="您好，您在第"&ID&"轮富翁投注中奖了！彩池奖金"&wincent&"，请到(url=/bbs/meng/index.asp?sid=[sid])富翁工厂(/url)继续投注哦！"
rsu("sid")=myid
rsu("fid")=0
rsu.update
rsu.close
set rsu=nothing

'开通下期
ydzqconn.execute("delete from winerlist")
ydzqconn.execute("insert into winer(winnum,cent)  values("&sss&",'"&abs(int((wincent+paycent)*winerin*0.01+wincent2))&"')")

conn.execute("update users set myjb=myjb+"&abs(int((wincent+paycent)*hyin*0.01))&" where ID="&myid)
Response.write "恭喜恭喜！本次投注抽中("&ss&")号码！得到彩池奖金:"&abs(int((wincent+paycent)*hyin*0.01))&""
response.write"<br/><a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">>>进入下期</a><br/>"
Call head1()
response.end
end if
'========================================

if v_dinumall>=abs(int(bigzu)) then

set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select comeover from winer where comeover=0 and ID="&ID,ydzqconn,1,2
  if rs.eof then
  Call Error("本轮投注已结束，请<a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">进入下期</a>")
  end if
 rs("comeover")=1
 rs.update
rs.close
set rs=nothing

'开通下期
ydzqconn.execute("delete from winerlist")
ydzqconn.execute("insert into winer(winnum,cent)  values("&sss&",'"&abs(int(wincent+paycent+wincent2))&"')")
Response.write "下注成功，还未中奖哦！<br/>"
Response.write "本轮投注已达"&bigzu&"注，彩池奖金:"&abs(int(wincent+paycent))&"全部转到下轮投注中"
response.write"<br/><a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">>>进入下期</a><br/>"
Call head1()
response.end
end if

set rs=Server.CreateObject("ADODB.Recordset")
  rs.open"select id,vote,usid from winerlist",ydzqconn,1,2
rs.addnew
rs("vote")=ss
rs("usid")=myid
rs.update
rs.close
set rs=nothing
'-------------------------
  end if 
  rssj.close
  set rssj=nothing
next

Response.write "下注成功，还未中奖哦！"

else




Response.write "您目前共有"&myjb&"金币<br/>"
Response.write "第"&ID&"轮下注站,每注"&zucent&getcent&"<br/>"
Response.write "你可以一次:<br/>"
call xlanlj("put.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&"")
if saytk>0 then
call xltjlj("paytype","10")
call xltjlj("tp","ok")
call xlanlj1("投10注")
else
response.write "<anchor>投10注"
response.write "<go href=""put.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&""" method=""post"" accept-charset=""utf-8"">"
response.write "<postfield name=""paytype"" value=""10""/>"
response.write "<postfield name=""TP"" value=""ok""/>"
response.write "</go></anchor>,"
end if
call xlanlj("put.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&"")
if saytk>0 then
call xltjlj("paytype","50")
call xltjlj("tp","ok")
call xlanlj1("投50注")
else
response.write "<anchor>投50注"
response.write "<go href=""put.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&""" method=""post"" accept-charset=""utf-8"">"
response.write "<postfield name=""paytype"" value=""50""/>"
response.write "<postfield name=""TP"" value=""ok""/>"
response.write "</go></anchor>,"
end if
call xlanlj("put.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&"")
if saytk>0 then
call xltjlj("paytype","100")
call xltjlj("tp","ok")
call xlanlj1("投100注")
else
response.write "<anchor>投100注"
response.write "<go href=""put.asp?ID="&ID&"&amp;sid="&sid&"&amp;saytk="&saytk&""" method=""post"" accept-charset=""utf-8"">"
response.write "<postfield name=""paytype"" value=""100""/>"
response.write "<postfield name=""TP"" value=""ok""/>"
response.write "</go></anchor>"
end if
response.write "<br/>彩池奖金:"&wincent
response.write"<br/><a href=""mywinlist.asp?sid="&sid&"&amp;saytk="&saytk&""">>>查看我的号码</a><br/>"
end if
conn.close
set conn=nothing
ydzqconn.close
set ydzqconn=nothing
%>
<!--#include file="fanhui.asp"-->
<%Call headsay()%>  