<!--#include file="../Inc.asp"-->
<!--#include file="../ydzq.asp"-->
<!--#include file="conn.asp"-->

<%'=============================
call head()
Call cardgame("球类投注中心",yanse12)
%>您目前共有<%=myjb%><%=getcent%><br/><%
dim id
id=request("id")
if id="" or IsNumeric(id)=False then
call error("ID无效！")
end if
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from YD_voteid where Active=1 and usid="&myid&" and id="&id&"  and ballj=0 order by ID desc"

rs.open sql,ydzqconn,1,1
If rs.eof	Then
call error("不存在或者尚未开奖！")
end if
   set rs1=Server.CreateObject("ADODB.Recordset")
   rs1.open"select * from YD_vote where id="&rs("ballid")&" order by ID desc",ydzqconn,1,1
if rs1.eof then
call error("不存在或者尚未开奖！")
end if

if rs("balltype")=1 then

	if rs("vote")=1 then
	if rs1("ballvote")="(让平手)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))=0 then


	elseif rs1("ballvote")="(让一球)" and abs(rs1("ballresult1"))+abs(rs1("ballresult2"))=1 then


	elseif rs1("ballvote")="(让二球)" and abs(rs1("ballresult1"))+abs(rs1("ballresult2"))=2 then


	elseif rs1("ballvote")="(让一球)" and abs(abs(rs1("ballresult1"))-abs(rs1("ballresult2")))=1 then


	elseif rs1("ballvote")="(让二球)" and abs(abs(rs1("ballresult1"))-abs(rs1("ballresult2")))=2 then

	elseif rs1("ballvote")="(让半球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=1 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让半球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<1 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)
  
    elseif rs1("ballvote")="(让平手)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=1 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让平手)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<1 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让一球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=2 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让一球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<2 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让一球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=2 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让一球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<2 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让一球半)" and abs(rs1("ballresult2"))-abs(rs1("ballresult1"))>=0 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)


    elseif rs1("ballvote")="(让二球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=3 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让二球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<3 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让二球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=3 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让二球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<3 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让二球半)" and abs(rs1("ballresult2"))-abs(rs1("ballresult1"))>=0 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让平手/半球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))=0 and rs("typeID")=2 then
dim paycent1,paycent2
paycent1=rs("paycent")*rs1("ballvotelu2")-rs("paycent")
paycent2=paycent1/2
V_votenum=0.5
V_jbnum=rs("paycent")+paycent2
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让平手/半球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=1 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让平手/半球)" and abs(rs1("ballresult2"))-abs(rs1("ballresult1"))>=0 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让半球/一球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))=1 and rs("typeID")=1 then
dim paycent3,paycent4
paycent3=rs("paycent")*rs1("ballvotelu1")-rs("paycent")
paycent4=paycent3/2
V_votenum=0.5
V_jbnum=rs("paycent")+paycent4
call addlist(V_votenum,V_jbnum)
    elseif rs1("ballvote")="(让半球/一球)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=2 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
  
    elseif rs1("ballvote")="(让半球/一球)" and abs(rs1("ballresult2"))-abs(rs1("ballresult1"))>=0 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让一球/球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))=1 and rs("typeID")=1 then
dim paycent5,paycent6
paycent5=rs("paycent")*rs1("ballvotelu1")-rs("paycent")
paycent6=paycent5/2
V_votenum=0.5
V_jbnum=rs("paycent")+paycent6
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让一球/球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=2 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum) 
    
    elseif rs1("ballvote")="(让一球/球半)" and abs(rs1("ballresult2"))-abs(rs1("ballresult1"))>=0 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让两球/两球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))=2 and rs("typeID")=1 then
dim paycent7,paycent8
paycent7=rs("paycent")*rs1("ballvotelu1")-rs("paycent")
paycent8=paycent7/2
V_votenum=0.5
V_jbnum=rs("paycent")+paycent8
call addlist(V_votenum,V_jbnum)

    elseif rs1("ballvote")="(让两球/两球半)" and abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>=3 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)
    
    elseif rs1("ballvote")="(让两球/两球半)" and abs(rs1("ballresult2"))-abs(rs1("ballresult1"))>=0 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

	end if
	
elseif rs("vote")=2  then
if abs(rs1("ballresult2"))+abs(rs1("ballresult1"))<abs(rs1("balldx")) and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldxlu1")
call addlist(V_votenum,V_jbnum)
    
	elseif abs(rs1("ballresult2"))+abs(rs1("ballresult1"))>abs(rs1("balldx")) and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldxlu2")
call addlist(V_votenum,V_jbnum)
   end if
   
elseif rs("vote")=3 then
    dim ballresult
    ballresult=abs(rs1("ballresult2"))+abs(rs1("ballresult1"))
    if ballresult mod 2 =1 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldslu1")
call addlist(V_votenum,V_jbnum)

    elseif ballresult mod 2 <>1 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldslu2")
call addlist(V_votenum,V_jbnum)
   end if
      end if
 
   '---------------------------------------------
ELSE
if rs("vote")=1  then

      if abs(rs1("ballresult1"))+abs(rs1("ballresult2")) = abs(rs1("ballvote")) then


      elseif abs(abs(rs1("ballresult1"))-abs(rs1("ballresult2"))) = abs(rs1("ballvote")) then
   
         elseif abs(rs1("ballresult1"))-abs(rs1("ballresult2"))>abs(rs1("ballvote")) and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu1")
call addlist(V_votenum,V_jbnum)

    elseif abs(rs1("ballresult1"))-abs(rs1("ballresult2"))<abs(rs1("ballvote")) and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)

    elseif abs(rs1("ballresult1"))-abs(rs1("ballresult2"))=abs(rs1("ballvote")) and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("ballvotelu2")
call addlist(V_votenum,V_jbnum)
end if

elseif rs("vote")=2  then
if abs(rs1("ballresult2"))+abs(rs1("ballresult1"))<abs(rs1("balldx")) and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldxlu1")
call addlist(V_votenum,V_jbnum)
    
	elseif abs(rs1("ballresult2"))+abs(rs1("ballresult1"))>abs(rs1("balldx")) and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldxlu2")
call addlist(V_votenum,V_jbnum)
   end if
   
elseif rs("vote")=3 then

    ballresult=abs(rs1("ballresult2"))+abs(rs1("ballresult1"))
    if ballresult mod 2 =1 and rs("typeID")=1 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldslu1")
call addlist(V_votenum,V_jbnum)

    elseif ballresult mod 2 <>1 and rs("typeID")=2 then
V_votenum=1
V_jbnum=rs("paycent")*rs1("balldslu2")
call addlist(V_votenum,V_jbnum)
   end if
end if
end if
'------------------------------------------------

    rs1.close
set rs1=nothing
rs.close
set rs=nothing
conn.close
set conn=nothing
ydzqconn.close
set ydzqconn=nothing
body="恭喜,兑奖成功！"
response.write body
Response.write "<br/>----------------<br/>"
response.write "<a href=""ball_f.asp?sid="&sid&"&amp;saytk="&saytk&""">返回继续兑奖</a><br/>"
response.write "<a href=""index.asp?sid="&sid&"&amp;saytk="&saytk&""">返回球类投注首页</a>"
Function addlist(V_votenum,V_jbnum)
ydzqconn.Execute("update YD_voteid set ballj=1 Where id=" & id)  
conn.Execute("update users set myjb=myjb+"&V_jbnum&" Where id=" & myid)
dim rs2 
set rs2=Server.CreateObject("ADODB.Recordset")
rs2.open"select * from YD_plist where userid="&myid,ydzqconn,1,2
if not rs2.eof then
rs2("votenum")=rs2("votenum")+V_votenum
rs2("jbnum")=rs2("jbnum")+V_jbnum-rs("paycent")
else
rs2.addnew
rs2("userid")=myid
rs2("votenum")=rs2("votenum")+V_votenum
rs2("jbnum")=V_jbnum-rs("paycent")
end if
rs2.update
rs2.close
set rs2=nothing

End function
ydzqconn.Execute("update YD_voteid set ballj=1 Where id=" & id)  


%>
<!--#include file="fanhui.asp"-->
<%call headsay()%>