<!--#include file="inc/Function.asp"-->
<%

Dim SqlItem,RsItem,SqlF,RsF,ItemName,sType
Dim stAction,stFoundErr,stErrMsg,NeedCheckComeUrl
Dim FilterID,ID,FilterName,FilterObject,FilterType
dim MaxPerPage,currentPage

stAction=Trim(Request("Action"))
sType=Trim(Request("Type"))
MaxPerPage=Trim(Request("MaxPerPage"))

if MaxPerPage="" then
	MaxPerPage=20
End if
Dim AllPage,iItem
if request("page")<>"" then
    currentPage=cint(request("page"))
else
    currentPage=1
end if

If stAction="Del" Then
	Call Del()
Elseif sType="Setflag" then
	Call SetFlag(Trim(Request("FilterID")))
End If
If stFoundErr=True Then
   Call WriteErrMsg()
Else
   Call Main()
End If
iItem=0

Call conncclose()
%>

<%Sub Main%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>电影采集系统</title>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<LINK href="../images/css_body.css" type=text/css rel=stylesheet>
<script language="javascript" src="../images/admin.js"></script>

<SCRIPT language=javascript>
function unselectall(thisform)
{
    if(thisform.chkAll.checked)
	{
		thisform.chkAll.checked = thisform.chkAll.checked&0;
    } 	
}

function CheckAll(thisform)
{
	for (var i=0;i<thisform.elements.length;i++)
    {
	var e = thisform.elements[i];
	if (e.Name != "chkAll"&&e.disabled!=true)
		e.checked = thisform.chkAll.checked;
    }
}
function ConfirmDel(thisform)
{
	if(thisform.Action.value=="Del")
	{
		if(confirm("确定要删除选中的记录吗？"))
		    return true;
		else
			return false;
	}
}
function showsetting(thisform)
{
	for (var j=0;j<6;j++)
	{
		var tab = eval("document.all.settable"+j);
		if(thisform.ADType.selectedIndex==j)
			tab.style.display = "";
		else
			tab.style.display = "none";
	}
	if(thisform.ADType.selectedIndex==6)
	{
		nocodead.style.display = "none";
		iscodead.style.display = "";
	}
	else
	{
		nocodead.style.display = "";
		iscodead.style.display = "none";
	}
}
</script>

</head>

<tbody>
<div class="container" id="cpcontainer">
<TABLE width="96%" border=0 align=center cellpadding="5" cellSpacing=1 class=tbtitle style="BACKGROUND: #cad9ea;">
  <tr bgColor="#f5fafe"> 
    <th colspan="6"> 管理导航：<a href="admin_Filters.asp">管理首页</a> | <a href="admin_FilterAdd.asp">添加新项目</a></th>
  </tr>
<br>        
<%                             
Set RsItem=server.createobject("adodb.recordset")         
SqlItem="select * from Filters order by FilterID desc"         
RsItem.open SqlItem,connc,1,1       
if Not(RsItem.Eof) and Not(RsItem.Bof) then 

%>
           
   <form name="form1" method="POST" ACTION="admin_Filters.asp?action=Del" onSubmit="return confirm('确定要删除选定的项目吗？');">         
   <tr bgColor="#f5fafe" style="padding: 0px 2px;">
     <td width="30" height="22" ><strong>选择</strong></td>
     <td width="120" ><strong>过滤名称</strong></td>
     <td width="80" ><strong>过滤类型</strong></td>
     <td width="80" height="22" ><strong>过滤属性</strong></td>
     <td width="40" ><strong>状态</strong></td>
     <td width="90" height="22" ><strong>操作</strong></td>
   </tr>        
<%
   RsItem.pagesize=MaxPerPage
   allpage=RsItem.pagecount
   RsItem.movefirst
   RsItem.absolutepage=currentPage            
   Do While Not RsItem.Eof
           
%>         
    <tr onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#BFDFFF'" style="padding: 0px 2px;" bgcolor="#FFFFFF">          
      <td>          
        <input type="checkbox" value=<%=RsItem("FilterID")%> name="FilterID" onClick="unselectall(this.form)">         
      </td>         
      <td>
      <%=RsItem("FilterName")%>
      </td>
      <td >          
      <%
      If RsItem("FilterObject")=1 Then
         Response.Write "标题过滤" 
      ElseIf RsItem("FilterObject")=2 Then 
         Response.Write "简介过滤" 
      Else
         Response.Write "请选择！" 
      End If
      %>              
      </td>  
            <td >          
      <%
      If RsItem("FilterType")=1 Then
         Response.Write "简单替换" 
      ElseIf RsItem("FilterType")=2 Then 
         Response.Write "高级过滤" 
      Else
         Response.Write "请选择！" 
      End If
      %>              
      </td>        
      <td >      <%
      If RsItem("Flag")=True Then
         Response.Write "<b>√</b>" 
      Else 
         Response.Write "<font color='red'><b>×</b></font>" 
      End If
      %></td>       
      <td ><a href="admin_Filters.asp?Type=Setflag&FilterID=<%=RsItem("FilterID")%>"><%
      If RsItem("Flag")=True Then
         Response.Write "禁用" 
      Else 
         Response.Write "启用" 
      End If
      %></a>&nbsp;<a href="admin_FilterAdd.asp?Type=modify&FilterID=<%=RsItem("FilterID")%>">修改</a>&nbsp;<a href="admin_Filters.asp?Action=Del&FilterID=<%=RsItem("FilterID")%>" onclick='return confirm("确定要删除此项目吗？");'>删除</a></td>         
    </tr>         
<%         
iItem=iItem+1
If iItem >= MaxPerPage Then Exit Do
   RsItem.Movenext         
   Loop         
%>         

    <tr bgcolor="#FFFFFF">          
      <td colspan=6 height="30"><input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">选中所有项目           　　  
将选定的项目：          
        <input type="submit" class="btn" value=" 删&nbsp;&nbsp;除 " name="submit" onClick='return ConfirmDel(this.form);'>&nbsp;&nbsp;  
      </td>         
    </tr>  
</form>         <tr bgcolor="#FFFFFF">          
      <td colspan=6 height="30" >          
               
        &nbsp;&nbsp;&nbsp;&nbsp;共
       

 <b><%=RsItem.recordcount%></b> 个过滤记录&nbsp;&nbsp;<a href="admin_Filters.asp">首页</a>&nbsp;<%if currentPage>1 then %><a href="admin_Filters.asp?MaxPerPage=<%=MaxPerPage%>&page=<%=currentPage-1%>">上一页</a><%else%>上一页<%end if%>&nbsp;<%if currentPage<allpage then%><a href="admin_Filters.asp?MaxPerPage=<%=MaxPerPage%>&page=<%=currentPage+1%>">下一页</a><%else%>下一页<%end if%> <a href="admin_Filters.asp?MaxPerPage=<%=MaxPerPage%>&page=<%=allPage%>">尾页</a>&nbsp;&nbsp;页次：<b><font color=red><%=currentPage%></font>/<%=allpage%></b> &nbsp;&nbsp;<input type='text' name='MaxPerPage' size='3' maxlength='4' value='<%=MaxPerPage%>' onKeyPress="if (event.keyCode==13) window.location='admin_Filters.asp?admin_Filters.asp?page=<%=currentPage%>&MaxPerPage='+this.value;"> 个过滤项目记录/页                                                 
转到第 <select onChange="window.location='admin_Filters.asp?MaxPerPage=<%=MaxPerPage%>&page='+this.value" name="gopage">                                                        
<%
For iItem=1 to allpage%>
<option <%if iItem=currentPage then%>selected<%end if%> value="<%=iItem%>"><%=iItem%></option>
<%next%> </select>      
      </td>         
    </tr>                
        

<%else%>
  
          <tr bgcolor="#FFFFFF"> 
            <td >无任何记录!</td>
          </tr>
  
<%end if%>         
<%         
RsItem.Close         
Set RsItem=nothing           
%>  
</table>
</tbody>
</div>
</body>         
</html>
<%End Sub%><%Sub Del
FilterID=Trim(Request("FilterID"))
If FilterID="" Then
   stFoundErr=True
   stErrMsg=stErrMsg & "<br><li>请选择要删除的项目！</li>"
Else
      If Instr(FilterID,",")>0 Then
         FilterID=Replace(FilterID," ","")   
         connc.Execute("Delete From [Filters] Where FilterID In(" & FilterID & ")")
      Else
         connc.Execute("Delete From [Filters] Where FilterID=" & FilterID)
      End If
End If
End Sub

Sub SetFlag(FilterID)
Dim SqlItem,RsItem
If FilterID="" Then
   stFoundErr=True
   stErrMsg=stErrMsg & "<br><li>请选择要禁止/启用的项目！</li>"
Else
	SqlItem="Select * from Filters Where FilterID=" & FilterID
	Set RsItem=server.CreateObject("adodb.recordset")
	RsItem.Open SqlItem,connc,2,3
	if RsItem("Flag")=True Then
		RsItem("Flag")=False
	Else
		RsItem("Flag")=True
	End if
	RsItem.UpDate
	RsItem.Close
	Set RsItem=Nothing
End If
End Sub
%>