<!-- #include file="include/admin_onlogin.asp" -->
<!-- #include file="include/common_plugin.asp" -->
<%
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************

index_url="emoney"
data_name="get_emoney"
tit_fir="红包"
tit="红包管理"
call admin_header(0,0)
%>
<tr><td align=center colspan=3 height=30>
  <table border=0>
  <tr>
  <td width=10></td>
  <td><a href='?'><% response.write tit %></a></td>
  <td width=10></td>   
  <td><a href='?action=del_table_emoney' onclick="return click_return('清空<%response.write tit_fir%>数据',0);">清空<%response.write tit_fir%>数据</a></td>
  <td width=10></td>
  <td><a href='?action=creat_table' alt='建立新的<% response.write tit_fir %>数据库'>建立数据库</a></td>
  <td width=10></td>      
  <td><a href='?action=initialize_table' alt='重新删除原来的 <% response.write data_name %> 表'>重新初始化</a></td>
  <td width=10></td>   
  <td><%call admin_read("",tit&"相关说明","使用前请点插件管理，并设置相关参数即可使用<br>前台显示页面文件为get_money.asp (此文件在根目录下)<br>使用时，只需在菜单栏添加，或者直接出地址即可<br>例：http://您的地址/get_money.asp")%></td>
  <td width=10></td>
  </tr>
  </table>
</td></tr> 
<%
call admin_table(1)
select case action
  case "creat_table"
    call create_table_emoney()
  case "initialize_table"
    call initialize_table_emoney()  
  case "del_table_emoney"
    call del_table_emoney()
  case "delete"
    call get_emoney_del()  
  case else
    call get_emoney_main()
end select

sub get_emoney_main()
  if chk_table_emoney=false then 
    call admin_error(tit_fir&"数据库未建立！请点击“建立数据库”执行！")  
  else
%>
<form name=sel_form action='?action=delete' method=post>
<tr align=center>
<td class=td width='6%'>序号</td>
<td class=td width='12%'>用户名</td>
<td class=td width='12%'>领取数量</td>
<td class=td width='12%'>红包类型</td>
<td class=td width='15%'>操作时间</td>
<td class=td width='6%'><input type=checkbox name=sel_all value='yes' onclick="javascript:select_all(this.form);"></td>
</tr>
<%
  dim tim,emoney_num,emoney_type
  pageurl="?action=&"
  sql="select count(id) from "&data_name&sql_add
  set rs=joekoe_cms.exec(sql,1)
  rssum=rs(0)
  rs.close
  call format_pagecute()
  sql="select top "&nummer*viewpage&" * from "&data_name&sql_add&" order by id desc"
  call joekoe_cms.exec(sql,-1)
  rs.open sql,conn,1,1
  if int(viewpage)>1 then rs.move (viewpage-1)*nummer
  if int(viewpage*nummer)>int(rssum) then nums=nummer-(viewpage*nummer-rssum)
  for i=1 to nums    
    tim=rs("tim")
    emoney_num=rs("emoney_num")
    emoney_type=rs("emoney_type")
%>
<tr align=center>
<td><%response.write (viewpage-1)*nummer+i%></td>
<td><%response.write rs("username")%></td>
<td align=center><% response.write emoney_num %></a></td>
<td align=center><% response.write emoney_type %></a></td>
<td><font alt='操作时间：<%response.write joekoe_cms.time_type(tim,2)%>'><%response.write joekoe_cms.time_type(tim,3)%></font></td>
<td><input type=checkbox name=sel_id value='<%response.write rs("id")%>'></td>
</tr>
<%
    rs.movenext
  next
  rs.close
%>
<tr class=tr1>
<td colspan=4>
现有<font class=red><%response.write rssum%></font>条<%response.write tit_fir%>，
每页<font class=red><%response.write nummer%></font>条，
页次：<font class=red><%response.write viewpage%></font>/<font class=red><%response.write thepages%></font>
分页：<%response.write jk_pagecute(nummer,thepages,viewpage,pageurl,5,"#ff0000")%>
</td>
<td colspan=2 align=center>
执行
<select name=sel_type size=1>
<option value='delete'>删除</option>
</select>
<input type=submit value='操作' onclick="return sel_click(this.form);">
</td>
</tr>
</form>
<%  
  end if
end sub

sub create_table_emoney()
  on error resume next
  sql="create table "&data_name
  response.write joekoe_cms.exec(sql,0)
  if err then error.clear:call admin_error("数据库执行失败，请检查您是否有数据库执行权限！或者数据库里已经有该数据表！"):exit sub
  sql="alter table "&data_name&" add column id autoincrement"
  response.write joekoe_cms.exec(sql,0)
  sql="alter table "&data_name&" add column username text(50) null"
  response.write joekoe_cms.exec(sql,0)
  sql="alter table "&data_name&" add column emoney_num integer"
  response.write joekoe_cms.exec(sql,0)  
  sql="alter table "&data_name&" add column emoney_type text(10) null"
  response.write joekoe_cms.exec(sql,0)   
  sql="alter table "&data_name&" add column tim datetime"
  response.write joekoe_cms.exec(sql,0)   
  call admin_msg("成功建立"&tit_fir&"插件的数据库！","?",1)
end sub

sub del_table_emoney()
  on error resume next
  sql="delete from "&data_name
  response.write joekoe_cms.exec(sql,0)
  call admin_msg("成功清除"&tit_fir&"插件数据表","?",1)
end sub

sub initialize_table_emoney()
  on error resume next
  sql="drop table "&data_name 
  response.write joekoe_cms.exec(sql,0)
  call admin_msg("初始化数据库成功！","?",1)
end sub


sub get_emoney_del()
  dim sel_id,ddim,dnum,ni
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  if sel_id="" then
    call joekoe_chk_main()
    exit sub
  end if
  ddim=split(sel_id,",")
  dnum=ubound(ddim)
  ni=0
  for i=0 to dnum
    if isnumeric(ddim(i)) then
      call joekoe_cms.exec("delete from "&data_name&" where id="&ddim(i),0)
      ni=ni+1
    end if
  next
  call admin_msg("已成功删除 "&ni&" 条"&tit_fir&"记录！","?",1)
end sub

function chk_table_emoney()
  chk_table_emoney=true
  on error resume next
  sql="select * from "&data_name
  response.write joekoe_cms.exec(sql,0)
  if err then
    err.clear
    rs.close
    chk_table_emoney=false
  end if  
end function
'****************************************************
' 阳光情缘 2006V3.0      Power by sdsun.com.cn
' Email: 27072320@qq.com  , sdsun163@163.com
' Web: http://www.sdsun.com.cn
' Copyright (C) 2006 sdsun.com.cn All Rights Reserved.
'****************************************************


%>