<!--#include file="conn.asp"-->
<!--#include file="inc/const.asp"-->
<!-- #include file="tc_dv.asp" -->
<!-- #include file="tc_conn.asp" -->
<%
  
Response.Buffer=True 
Dvbbs.stats="<a href=plus_tc.asp>社区体彩</a>"
Dvbbs.Nav()
Dvbbs.Head_var 2,0,"",""
if dvbbs.Membername="" or dvbbs.usergroupid<>1 then
  Dvbbs.AddErrCode(6)
  Dvbbs.Showerr()
else
	
response.write "<table cellpadding=3 cellspacing=1 align=center class=tableborder1><tr><th valign=middle colspan=2 align=center height=25><b>社区体彩</b></td></tr><tr><td valign=middle class=tablebody1 height=100><CENTER>"

%>
<table width="100%" border="0" align="center">
  <tr>
    <td>
	 <%
	   dim rs0,intqs,intdzje,strtime,strkjhm,zjyf,zjyf1,zjyf2,zjyf3
	   Set rs0=Server.CreateObject("ADODB.RecordSet")'当前期数的设置
	   rs0.Open "select * from cp_sz order by qs desc",tc_conn,3,1
	   intqs=rs0("qs")'期数
	   intdzje=rs0("dzje")'单注金额
	   strtime=rs0("kjsj")'开奖时间
	   strkjhm=rs0("kjhm")'开奖号码
	   rs0.close
	   set rs0=nothing
	   zjyf=tc_conn.execute("select count(id) from cp_gmxx where qs="&intqs&" and zj=5")(0)'特等奖。
	   zjyf1=tc_conn.execute("select count(id) from cp_gmxx where qs="&intqs&" and zj=4")(0)'一等奖。
	   zjyf2=tc_conn.execute("select count(id) from cp_gmxx where qs="&intqs&" and zj=3")(0)'二等奖。
       zjyf3=tc_conn.execute("select count(id) from cp_gmxx where qs="&intqs&" and zj=2")(0)
	 %>
      <form name="form1" method="post" action="plus_tc_admin.asp?do=edit">
        <table width="90%" border="0" align="center">
          <tr> 
            <td> <div align="center">本期彩票为：总第<%=intqs%>期</div></td>
          </tr>
          <tr> 
            <td> 
              <div align="center"><span class="a3">修改请严格按<font color="#FF0000">原来的形式</font>。</span> 
              </div>
            </td>
          </tr>
          <tr> 
            <td>开奖时间为： <%=strtime%>请输入新的时间（请严格按原来的<font color="#FF0000">格式</font>） 
              <textarea name="ttime" cols="30" rows="1" wrap="VIRTUAL"><%=strtime%></textarea>
            </td>
          </tr>
          <tr> 
            <td>开奖号号码为： 
              <input type="text" name="tkjhm" maxlength="20" value=<%=strkjhm%>>
              （请严格按原来的<font color="#FF0000">格式：开奖号码为：01-22</font>） 单注金额为： 
              <input type="text" name="tdzje" maxlength="2" size="3" value=<%=intdzje%>>
            单注金额修改中能影响此后时间购买的用户。</td>
          </tr>
          <tr> 
            <td>购买者<font color="#FF0000">准中奖</font>情况为：<font color="#FF0000">此为系统随机情况下设置的中奖号后的中奖情况，您更改后中奖情况将重新更新。(为中奖人数)</font></td>
          </tr>
          <tr>
            <td> <%
			response.write("特等奖："&zjyf&" 一等奖："&zjyf1&" 二等奖："&zjyf2&" 三等奖："&zjyf3)
			%></td>
          </tr>
          <tr>
            <td>
              <input type="submit" name="Submit" value="修改">
            </td>
          </tr>
        </table>
      </form>
    </td>
  </tr>
</table>
<table width="90%" border="0" cellspacing="0" cellpadding="0" align="center">
          <tr>
            
          <td> 
            <form name="form1" method="post" action="plus_tc_admin.asp?do=del">
              删除 
              <input type="text" name="tshu" maxlength="3" size="3" value="20">
              期前的记录（为了数据库的查询速度，建议定期操作） 
              <input type="submit" name="Submit2" value="删除">
            </form>
          </td>
          </tr>
        </table>
<%
'修改信息
dim strnewtime,strnewkjhm,intnewdzje,strkj,rs1,kk,intzj
if request("do")="edit" then
strnewtime=request.form("ttime")
strnewkjhm=request.form("tkjhm")
intnewdzje=request.form("tdzje")
tc_conn.execute("update cp_sz set kjsj='"&strnewtime&"',kjhm='"&strnewkjhm&"',dzje="&intnewdzje&" where qs="&intqs&"")
'更新有效，更改中奖情况！
strkj=strnewkjhm'开奖的号码

set rs1=tc_conn.execute("select id,gmhm from cp_gmxx where qs="&intqs&" ")
do while not rs1.eof
   kk=split(rs1("gmhm"),",")'用户购买的号码
   intzj=0
' response.write(kk)
   for i=LBound(kk) To UBound(kk)
   if instr(strkj,trim(kk(i))) then
   intzj=cint(intzj)+1
   'response.write(strkj&"<br>"&kk(i)&"<br>")
   end if
   next
   '判断是几等奖。并更新
   tc_conn.execute("update cp_gmxx set zj="&intzj&" where id="&rs1("id")&"")
   

rs1.movenext
loop
rs1.close
set rs1=nothing
response.redirect("plus_tc_admin.asp")
end if
'删除操作
dim intshu
if request("do")="del" then '删除购买记录，开奖记录等
intshu=request.form("tshu")
intqs=intqs-intshu
tc_conn.execute("delete from cp_kjxx where qs<"&intqs&"")
tc_conn.execute("delete from cp_gmxx where qs<"&intqs&"")
tc_conn.execute("delete from cp_sz where qs<"&intqs&"")
response.redirect("plus_tc_admin.asp")
end if

response.write "</CENTER></td></tr></table>"
 end if
 call Dvbbs.footer() 
%>
