<%
dim testconn
dim testconnstr
dim tdb
tdb=joekoe_cms.web_path&"other/ontest_data/#ontest.asp"
set testconn=server.createobject("adodb.connection")
testconnstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath(tdb)
testconn.open testconnstr

function closetdb()
testconn.close
set testconn=nothing
end function

sub left_type(spageurl)
  'response.write vbcrlf&"<table border=0 width='85%' align=center><tr><td class=htd>"
  dim rs2,sql2,snid
  sql2="select id,type_name from type order by id"
  set rs2=testconn.execute(sql2)
  do while not rs2.eof
    snid=int(rs2(0))
    if cid=snid then
      response.write vbcrlf&img_admin("s_left_sort","")&"&nbsp;<a href='"&spageurl&"c_id="&snid&"'><b><font class=red2>"&rs2(1)&"</b></font></a><br>"
    else
      response.write vbcrlf&img_admin("s_left_sort","")&"&nbsp;<a href='"&spageurl&"c_id="&snid&"'>"&rs2(1)&"</a><br>"
    end if
    rs2.movenext
  loop
  rs2.close
  set rs2=nothing
  'response.write vbcrlf&"</td></tr></table>"
end sub

sub sql_tid(sqlvar)
  if cid<>0 then
    if sqlvar="" then
      sqlvar=" where c_id="&cid
    else
      sqlvar=sqlvar&" and c_id="&cid
    end if
    pageurl=pageurl&"c_id="&cid&"&"
  end if
end sub

sub test_go_handle()
  dim sel_type,seltype,sel_id,hdim,hnum,hid,hi,htype,hintegral
  htype=1
  sel_type=trim(request.form("sel_type"))
  select case sel_type
  case "推荐","取消推荐"
    seltype=istop_var
    if sel_type="取消推荐" then htype=0
  case "审核","待审核","显示","隐藏"
    seltype="hidden"
    if sel_type="待审核" or sel_type="隐藏" then htype=0
  case "删除"
    seltype="delete"
  case else
    sel_type=""
    seltype=""
  end select
  if joekoe_cms.post_chk()=false or seltype="" then exit sub
  hintegral=mp_integral()
  sel_id=trim(request.form("sel_id"))
  sel_id=replace(sel_id," ","")
  hdim=split(sel_id,",")
  hnum=ubound(hdim)
  select case seltype
  case istop_var,"hidden"
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then
        sql="update "&data_name&" set "&seltype&"="&htype&" where id="&hid
        set rs=testconn.execute(sql)
      end if
    next
  case "delete"
    for hi=0 to hnum
      hid=hdim(hi)
      if isnumeric(hid) then
        testconn.execute"delete from "&data_name&" where id="&hid
        testconn.execute"delete from answer where q_id=(SELECT q_id FROM question where t_id="&hid&")"
        testconn.execute"delete from question where t_id="&hid
        testconn.execute"delete from result where t_id="&hid
      end if
    next
  end select
  erase hdim
  action=""
  call admin_event(sel_type&" "&(hnum+1)&"条（"&tit_fir&"）记录",0,0)
  response.write vbcrlf&"<script language=javascript>alert(""已成功（"&sel_type&"）操作了"&(hnum+1)&"条记录！"");</script>"
end sub

sub test_go_clear()
  sql="select count(id) from "&data_name
  set rs=testconn.execute(sql)
  if rs(0)=0 then
    rs.close
    call admin_msg("暂时没有（"&tit_fir&"）数据！","?",1)
    exit sub
  end if
  rs.close
  sql="select id from "&data_name&" order by id"
  set rs=testconn.execute(sql)
  rs.open sql,conn,1,1
  rs.close
  set rs=testconn.execute("delete from "&data_name)
  call admin_event("清空所有 "&tit_fir&" 数据！",0,0)
  call admin_msg("已成功清空所有 "&tit_fir&" 数据！","?",1)
end sub

sub test_csid(cid)
  dim sql2,rs2,sql3,rs3,csnd,now_id,n_id
  csnd="no"
  response.write "<select name=c_id size=1>"
  sql3="select id,type_name from type order by id"
  set rs3=testconn.execute(sql3)
  do while not rs3.eof
    n_id=int(rs3(0))
    response.write vbcrlf&"<option value='"&n_id&"' class=bg_2"
    if cid=n_id then response.write " selected"
    response.write ">"&rs3(1)&"</option>"
    rs3.movenext
  loop
  rs3.close
  set rs3=nothing
  response.write "</select><input type=hidden name=csnd value='"&csnd&"'>"&redx&"请选择一个分类"
end sub
%>