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

<!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 showset(thisform)
{
		if(thisform.FilterType.selectedIndex==1)
		{
        	FilterType1.style.display = "none";
			FilterType2.style.display = "";
		}
		else
		{
        	FilterType1.style.display = "";
			FilterType2.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="2" ><a href="admin_FilterAdd.asp">添加过虑规则</a></th>
</tr>
<%

Dim stAction,stFoundErr,stErrMsg
Dim FilterName,ID,FilterObject,FilterType,FilterContent,FisString,FioString,FilterRep,FilterID,sType,Flag
Dim rrs,SqlItemR


Flag=True
sType=Trim(Request("Type"))
FilterID=Trim(Request("FilterID"))
If sType="modify" then
	Set rrs=server.createobject("adodb.recordset")
	SqlItemR="Select * from Filters Where FilterID=" & FilterID
	rrs.open SqlItemR,connc,1,1	
	'ID=rrs("ID")
	FilterName=rrs("FilterName")
	FilterObject=rrs("FilterObject")
	FilterType=rrs("FilterType")
	FilterContent=rrs("FilterContent")
	FisString=rrs("FisString")
	FioString=rrs("FioString")
	FilterRep=rrs("FilterRep")
	Flag=rrs("Flag")
	
	rrs.close
	set rrs=nothing
Else

End if

stAction=Trim(Request("Action"))

If stAction="SaveAdd" Then
   Call Save()
Else
   Call Main()
End If


Call conncclose()
%>
<%Sub Main%>
<form method="post" action="admin_FilterAdd.asp" name="form1"> 
	<tr bgcolor="#FFFFFF">
		<td> 过滤名称：</td>
		<td><input name="FilterName" type="text" id="FilterName" size="25" maxlength="30" value="<%=FilterName%>">&nbsp;</td>
	</tr>                                
	<tr bgcolor="#FFFFFF">                                 
		<td> 过滤对象：</td>                               
		<td><select name="FilterObject" id="FilterObject" size="1"><option value="1"<%if FilterObject=1 or FilterObject="" then Response.write " selected"%>>标题过滤</option>
		<option value="2"<%if FilterObject=2 or FilterObject="" then Response.write " selected"%>>简介过滤</option></select></td>                               
	</tr>                               
	<tr bgcolor="#FFFFFF">                                
		<td> 过滤类型：</td>                               
		<td><select name="FilterType" id="FilterType" onchange=showset(this.form)><option value="1"<%if FilterType=1 or FilterType="" then Response.write " selected"%> >简单替换</option><option value="2"<%if FilterType=2 then Response.write " selected"%>>高级过滤</option></select></td>                                
	</tr>                                
	<tr bgcolor="#FFFFFF" id="FilterType1" style="display:<%if FilterType=2 then Response.write "none"%>">                                 
      <td> 过虑内容：</td>                               
      <td><textarea name="FilterContent" cols="49" rows="5"><%=FilterContent%></textarea><font color="#FF0000">&nbsp;&nbsp;&nbsp; 
		填你要过虑的内容,每条规则只能填一个内容!</font></td>                               
	</tr>                            
	<tr bgcolor="#FFFFFF" id="FilterType2" style="display:<%if FilterType=1 or FilterType="" then Response.write "none"%>">                               
      <td> 开始标记：<br><br><br><br><br> 结束标记：</td>                              
      <td>
      	<textarea name="FisString" cols="49" rows="5"><%=FisString%></textarea><font color="#FF0000">&nbsp;&nbsp;&nbsp; 
		过虑开始标记,包括标记同时过虑掉!</font><br>
      	<textarea name="FioString" cols="49" rows="5"><%=FioString%></textarea><font color="#FF0000">&nbsp;&nbsp;&nbsp; 
		过虑结束标记,包括标记同时过虑掉!</font></td>                                
	</tr>                                
	<tr bgcolor="#FFFFFF" id="FilterRep">                                 
      <td> 过虑替换：</td>                                
      <td><textarea name="FilterRep" cols="49" rows="5"><%=FilterRep%></textarea>&nbsp;<font color="#FF0000">&nbsp;&nbsp; 
		可为空,为空则只过虑掉你要过虑的内容.</font></td>                               
	</tr>   
	<tr bgcolor="#FFFFFF">
		<td><b>是否启用：</b></td><td>&nbsp;&nbsp;<input name='Flag' type='checkbox' id='Flag' value='Yes'<%if Flag<>False then response.write "Checked"%>></td>
	</tr> 
	<tr bgcolor="#FFFFFF">                                
		<td colspan="2"><input name="FilterID" type="hidden" id="FilterID" value="<%=FilterID%>"><input name="Action" type="hidden" id="Action" value="SaveAdd"><input  type="submit" class="btn" name="Submit" value="确&nbsp;&nbsp;定" >&nbsp;&nbsp;&nbsp;&nbsp;<input name="Cancel" class="btn" type="button" id="Cancel" value="取&nbsp;&nbsp;消" onClick="window.location.href='admin_Filters.asp'"></td>                               
	</tr>                               
</form> 
</table>
</tbody>
</div>
</body>                                         
</html>                                
<%End Sub%><%                                
Sub Save()                                
                                
Dim SqlItem,RsItem                                
Dim FilterName,ID,FilterObject,FilterType,FilterContent,FisString,FioString,FilterRep,Flag                           
FilterName=Trim(Request.Form("FilterName"))                                
'ID=Trim(Request.Form("ID"))     
FilterObject=Request.Form("FilterObject")                              
FilterType=Clng(Request.Form("FilterType"))                                
FilterContent=Request.Form("FilterContent")                                
FisString=Request.Form("FisString")                                
FioString=Request.Form("FioString")                                
FilterRep=Request.Form("FilterRep") 
Flag=Request.Form("Flag") 

If FilterName="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<tr bgcolor=""#FFFFFF""><td><li>过滤名称不能为空</li></tr></td>"                                 
End If                                
   
If FilterObject="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<tr bgcolor=""#FFFFFF""><td><li>请选择过滤对象</li></tr></td>"                                 
Else                                
   FilterObject=Clng(FilterObject)   
End If                                
                            
If FilterType="" Then                                
   stFoundErr=True                                
   stErrMsg=stErrMsg & "<tr bgcolor=""#FFFFFF""><td><li>请选择过滤类型</li></tr></td>"                                 
Else                                
   FilterType=Clng(FilterType)                                
   If FilterType=1 Then     
      If FilterContent="" Then                              
         stFoundErr=True                                
         stErrMsg=stErrMsg & "<tr bgcolor=""#FFFFFF""><td><li>过滤的内容不能为空</li></tr></td>"   
      End If   
   ElseIf FilterType=2 Then   
      If FisString="" or FioString="" Then   
         stFoundErr=True                                
         stErrMsg=stErrMsg & "<tr bgcolor=""#FFFFFF""><td><li>开始/结束标记不能为空</li></tr></td>"   
      End If   
   Else   
      stFoundErr=True                                
      stErrMsg=stErrMsg & "<tr bgcolor=""#FFFFFF""><td><li>参数错误，请从有效链接进入</li></tr></td>"   
   End If   
End If                                
                             
If stFoundErr<>True Then                                
   SqlItem ="select top 1 *  from Filters"
   if FilterID<>"" then
   	  SqlItem=SqlItem&" where FilterID="&FilterID&""
   End if    
   Set RsItem=server.CreateObject("adodb.recordset")                                
   RsItem.open SqlItem,connc,1,3
  
   if FilterID="" then
   	  RsItem.AddNew
   End if
   RsItem("FilterName")=FilterName                                
   'RsItem("ID")=ID   
   RsItem("FilterObject")=FilterObject
   RsItem("FilterType")=FilterType                                
   If FilterType=1 Then                                
      RsItem("FilterContent")=FilterContent                                
   ElseIf FilterType=2 Then                                
      RsItem("FisString")=FisString                                
      RsItem("FioString")=FioString                                
   End If                                                
   RsItem("FilterRep")=FilterRep    
   
if Flag="Yes" then  
   RsItem("Flag")=True
Else
   RsItem("Flag")=False
End if
   RsItem.Update                                
   RsItem.Close                                
   Set RsItem=Nothing                                
   Response.Redirect "admin_Filters.asp"                                
Else     
Response.write stErrMsg                           
End If                                
                                
End Sub                                
%>