<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.asp"-->
<!--#include file="../include/fy.F.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>评论管理</title>
<link rel="stylesheet" type="text/css" href="../css/base.css">
<link rel="stylesheet" type="text/css" href="../css/content.css">
</head>
<body>
<%
	Dim sql, sqlCount,Sqls,intPageSize, strPageInfo,arrinfo, i,pages,intPageNow,strLocalUrl,Action,style,Hits
	Dim title
	Action=Request("Action")
		Dim ShowErr,ModeID:ModeID = ChkNumeric(request("ModeID"))
	 if ModeID=0 or ModeID="" Then ModeID=1
%><div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 模型管理</div>
    <div class="opers">
<form name="Article" method="post" action="?Action=">
    <a href="?Action=add&ModeID=<%=ModeID%>" class="btn<%If Request("Action")="add" Then echo " btn_primary" %>">添加tags</a>
	<a href="?" class="btn<%If Request("Action")="" Then echo " btn_primary" %>"><strong>查看</strong></a>
 <select name="ClassID" size="1" onChange="javascript:window.location=this.options[this.selectedIndex].value;">
<option value='?' >全部</option>
      <% 	 
	  
	  	Dim IF_NULL,ij,checked
		IF_NULL=fycms.Act_MXtab_Arr()
 		If IsArray(IF_NULL) Then
			For ij=0 To Ubound(IF_NULL,2)
			If modeid=IF_NULL(0,ij) Then checked="selected" Else checked=""
 			 echo "<option value='?ModeID="&IF_NULL(0,ij)&"' "&checked&">"& IF_NULL(2,ij) & "模型</option>"& vbCrLf
 			Next
		End If
  		%>
    </select>
	</form>
	</div>
   <%  

		IF Request.QueryString("Action") = "del" Then
		Dim ID:ID = Request("ID")
			IF ID = "" Then
				Call fycms.ActErr("请指定要删除的自定义tags","","1")
 				Response.end
			End IF
		If instr(ID,",")>0 then
			ID=replace(ID," ","")
			Sql="delete from Tags_fy where ID in (" & ID & ")"
		Else
			Sql="delete from Tags_fy where ID=" &  ChkNumeric(ID) & ""
		End if
		Conn.Execute sql:Set Conn=nothing
		Call fycms.ActErr("自定义tags删除成功","fy_Mode/fy.Tags.asp","")
 	  End IF
	  
	  Select Case Action
	  		Case "edit","add"
				call edit()
			Case "AddSave","EditSave"
				Call Saves()
			Case Else
				call main()
		end select
		sub main()
	 Dim ACT_TypeDiY,TypeDiY,Manage
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	intPageNow = request.QueryString("page")
	intPageSize =20
	pages = "ModeID="&Request("ModeID")&"&page"
	If ChkNumeric(request("ModeID"))>0 Then 
		Sqls = " where ModeID = "& ModeID
	End If 
	sql = "SELECT [ID], [title], [AddTime], [Hits], [ClicksTime],[Modeid]" & _
		" FROM [Tags_fy]" &Sqls& _
		" ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [Tags_fy]"&Sqls
		Dim clsRecordInfo
		Set clsRecordInfo = New Cls_PageView
			clsRecordInfo.intRecordCount = 2816
			clsRecordInfo.strSqlCount = sqlCount
			clsRecordInfo.strSql = sql
			clsRecordInfo.intPageSize = intPageSize
			clsRecordInfo.intPageNow = intPageNow
			clsRecordInfo.strPageUrl = strLocalUrl
			clsRecordInfo.strPageVar = pages
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>
<form name="Articles" method="post" action="?Action=">
 <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>选中</th><th>ID</th><th>tags名称</th><th>对应模型</th><th>添加时间</th><th>点击数</th><th>管理操作</th>
	  </tr>
    </thead>

  


	 <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
	%>
    <tr>
      <td>
	  <input type="checkbox" name="ID" value="<%= arrinfo(0,i) %>">	  </td>
      <td ><%= arrinfo(0,i) %></td>
      <td ><%= arrinfo(1,i) %></td>
      <td ><%= fycms.act_c(arrinfo(5,i),1) %>模型</td>
      <td ><%= arrinfo(2,i) %></td>
      <td ><%= arrinfo(3,i) %></td>
      <td colspan="2" align="center">
	  <a href="?Action=edit&id=<%= arrinfo(0,i) %>">修改</a>┆
	  <a href="?Action=del&ID=<%= arrinfo(0,i) %>" onClick="return confirm('确认删除此自定义tags吗?')">删除</a>	  </td>
    </tr>
	<% 
	Next
	End If
	%>



	   <tr >
      <td colspan="8" class="tl">
	 <label for=chk>
		<input id="chk" type="checkbox" name="chkall" value="checkbox" onClick="CheckAll(this.form)">选择全部评论</label>
<input type="button" Class="btn btn_primary" name="yd" value="批量删除" onClick="delpost()"></td>
    </tr>



	</table>
    <div class="pagelist">
<%= strPageInfo%>
   </div>
   </form>
</div>

<script type="text/javascript">
	function CheckAll(form)  
  {  
 for (var i=0;i<form.elements.length;i++)  
    {  
    var e = Articles.elements[i];  
   if (e.name != 'chkall')  
      e.checked = Articles.chkall.checked;  
   }  
  }

function delpost(){
    document.Articles.method="post";
    document.Articles.action="?Action=del";
{
	if(confirm('确认要删除选中的Tags吗?')){
	this.document.Articles.submit();
	return true;}return false;
}
	}

</script>



  <% end sub
Sub edit() 
	If Action ="edit" Then 
		Dim Rs,ID,A
		id = ChkNumeric(Request.QueryString("id"))
		Set Rs=fycms.actexe("select * from Tags_fy Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			title=Rs("title")
			If Trim(Rs("style"))<>"" Then style=Server.HTMLEncode(Rs("style"))
			Hits=Rs("Hits")
			Id=Rs("Id")
		End If
		A="EditSave"
	Else
		A="AddSave"	
	End If 
%>
<form name="form1" method="post" action="?action=<%= A %>&ID=<%= ID %>&ModeID=<%= ModeID %>">
    <div class="divtable"> 
        <dl>
            <dt>tags名称：</dt>
            <dd>
               <input name="title" type="text"  class="Ainput"   value="<%= title %>" size="30" /> 
            </dd>
         </dl>
        
        <dl>
            <dt>点击数：</dt>
            <dd>
               <input name="Hits" type="text"  class="Ainput"   value="<%= Hits %>" size="30" /> 
            </dd>
         </dl>
        <dl>
            <dt>css样式：</dt>
            <dd>
               <input name="style" type="text"  class="Ainput"   value="<%= style %>" size="30" /> 
            </dd>
         </dl>
       
       
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
                <input name="Submit2" type="reset" class="btn btn_primary" value="  重置  ">
            </dd>
         </dl>
        
    </div>


</form>
 
<%end sub 


sub saves()
		dim Rs,RsSql
		 Hits=fycms.S("Hits")
		 title=fycms.S("title")
		 style=fycms.S("style")
		 
		 ID=ChkNumeric(fycms.S("ID"))
		 IF fycms.S("Hits") = "" Then
			Call fycms.Alert("请输入tagsID!",""):Exit Sub
		 End if
		 IF fycms.S("title") = "" Then
			Call fycms.Alert("请输入tags名称!",""):Exit Sub
		 End if
		If Action="AddSave" Then 
			 If Not fycms.ACTEXE("SELECT title FROM Tags_fy Where title='" & title & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该tags名称!",""):Exit Sub
			 End if
			 
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from Tags_fy"
			  Rs.Open RsSql, Conn, 1, 3
			  Rs.AddNew
		 	  Rs("title") = title
		 	  Rs("Hits") = Hits
		 	  Rs("style") = style
		 	  Rs("modeid") = modeid
		 	  Rs("AddTime") = now
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.ActErr("添加成功","fy_Mode/fy.Tags.asp","")
 		Else
		 	If Not fycms.ACTEXE("SELECT title FROM Tags_fy Where ID <>" & ID & " AND  title='" & title & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该tags名称!",""):Exit Sub
			 End if	
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from Tags_fy Where ID="&ID
			  Rs.Open RsSql, Conn, 1, 3
		 	  Rs("title") = title
		 	  Rs("Hits") = Hits
		 	  Rs("style") = style
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.ActErr("操作成功","fy_Mode/fy.Tags.asp","")
 		End If 
end sub
CloseConn %>
<script language="javascript">
function CheckForm()
{ var form=document.form1;
	
 
	if (isNaN(form.Hits.value))
		{ alert("点击率只能为数字!");   
		  form.Hits.focus();    
		   return false;
		} 
	if (form.title.value=='')
		{ alert("请输入tags名称!");   
		  form.title.focus();    
		   return false;
		} 
		
	    form.submit();
        return true;
	}
	

	</script> 
 </body>
</html>
