<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.asp"-->
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>fycms自定义属性</title>
<link rel="stylesheet" type="text/css" href="../../css/base.css">
<link rel="stylesheet" type="text/css" href="../../css/content.css">
</head>
<body>
<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 模型管理</div>
    <div class="opers">
	<a href="fy.DiyArticle.ASP?Action=add" class="btn" >添加自定义属性</a>
	<a href="fy.DiyArticle.ASP" class="btn">查看自定义属性</a>

	<a href="fy.author.ASP?Action=add" class="btn<%If Request("Action")="add" Then echo " btn_primary" %>">添加作者</a>
	<a href="fy.author.ASP" class="btn<%If Request("Action")="" Then echo " btn_primary" %>">查看作者</a>

	<a href="fy.CopyFrom.ASP?Action=add" class="btn">添加来源</a>
	<a href="fy.CopyFrom.ASP" class="btn">查看来源</a>

	<a href="fy.SiteLink.ASP?Action=add" class="btn">添加网站关键字</a>
	<a href="fy.SiteLink.ASP" class="btn">查看网站关键字</a>
    </div><% If Not fycms.ChkAdmin() Then  Call fycms.Alert("对不起，您没有操作权限！","")
	Dim sql, sqlCount,Sqls,intPageSize, strPageInfo,arrinfo, i,pages,intPageNow,strLocalUrl,Action,Field2,Field1
	Action=Request("Action")
	Dim ShowErr
		IF Request.QueryString("Action") = "del" Then
		Dim ID:ID = Request("ID")
			IF ID = "" Then
				Call fycms.ActErr("请指定要删除的id","","1")
 				Response.end
			End IF
		If instr(ID,",")>0 then
			ID=replace(ID," ","")
			Sql="delete from AC_fy where ID in (" & ID & ")"
		Else
			Sql="delete from AC_fy where ID=" &  ChkNumeric(ID) & ""
		End if
		Conn.Execute sql:Set Conn=nothing
		Call fycms.ActErr("删除成功","include/plus/fy.author.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
	sql = "SELECT [ID], [Field1], [Field2]" & _
		" FROM [AC_fy]" & _
		" ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [AC_fy]"
		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 = "page"
		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>


      <form name="Article" method="post" action="?Action=">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>选中</th>
      <th>ID</th>
      <th>作者名称</th>
      <th>联系邮箱</th>
      <th>管理操作</th>
	  </tr>
    </thead>
    	 <%
		Dim bgColor
		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
			bgColor="#FFFFFF"
			if i mod 2=0 then bgColor="#DFEFFF"
	%>
     <tr>
      <td>
	  <input type="checkbox" name="ID" value="<%= arrinfo(0,i) %>">	  </td>
      <td><%= arrinfo(0,i) %></td>
      <td><%= arrinfo(1,i) %></td>
      <td><%= arrinfo(2,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('确认删除此自定义属性吗?')">删除</a>	  </td>
    </tr><% 
	Next
	End If
	%>

    <tr >
      <td height="30" colspan="6" 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></form>
    <div class="pagelist">
    <%= strPageInfo%>
   </div>

  <script language="javascript">
function CheckAll(form)  
  {  
 for (var i=0;i<form.elements.length;i++)  
    {  
    var e = Article.elements[i];  
   if (e.name != 'chkall')  
      e.checked = Article.chkall.checked;  
   }  
  }
 function delpost(){
    document.Article.method="post";
    document.Article.action="?Action=del";
{
	if(confirm('确认要删除选中的id吗?')){
	this.document.Article.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 AC_fy Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			Field2=Rs("Field2")
			Field1=Rs("Field1")
			Id=Rs("Id")
		End If
		A="EditSave"
	Else
		A="AddSave"	
		Field2="mailto:"
	End If 
%>


<form name="form1" method="post" action="?action=<%= A %>&ID=<%= ID %>">
    <div class="divtable"> 
        <dl>
            <dt>作者名称：</dt>
            <dd>
              <input name="Field1" type="text" class="Ainput" value="<%= Field1 %>"> 
            </dd>
         </dl>
        
        <dl>
            <dt>联系邮箱：</dt>
            <dd>
               <input name="Field2" type="text" class="Ainput" value="<%= Field2 %>">
             </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" value="  重置  ">
            </dd>
         </dl>
        
    </div>
    </form>

 
<%end sub 


sub saves()
		dim Rs,RsSql
		 Field1=fycms.S("Field1")
		 Field2=fycms.S("Field2")
		 ID=ChkNumeric(fycms.S("ID"))
		 IF fycms.S("Field1") = "" Then
			Call fycms.Alert("请输入作者名称!",""):Exit Sub
		 End if
		If Action="AddSave" Then 
			 If Not fycms.ACTEXE("SELECT Field2 FROM AC_fy Where Field2='" & Field2 & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该联系邮箱!",""):Exit Sub
			 End if
			 If Not fycms.ACTEXE("SELECT Field1 FROM AC_fy Where Field1='" & Field1 & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该作者名称!",""):Exit Sub
			 End if	
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from AC_fy"
			  Rs.Open RsSql, Conn, 1, 3
			  Rs.AddNew
		 	  Rs("Field2") = Field2
		 	  Rs("Field1") = Field1
			  Rs("Types") = 1

			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
		 	  Call fycms.ActErr("添加成功","include/plus/fy.author.ASP","")
		Else
		 	If Not fycms.ACTEXE("SELECT Field2 FROM AC_fy Where ID <>" & ID & " AND  Field2='" & Field2 & "' order by ID desc").eof Then
				Call fycms.Alert("系统已存在该联系邮箱!",""):Exit Sub
			 End if	
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from AC_fy Where ID="&ID
			  Rs.Open RsSql, Conn, 1, 3
		 	  Rs("Field2") = Field2
		 	  Rs("Field1") = Field1
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
		 	  Call fycms.ActErr("修改成功","include/plus/fy.author.ASP","")
 		End If 
end sub
CloseConn %>
<script language="javascript">
function CheckForm()
{ var form=document.form1;
	
	 if (form.Field1.value=='')
		{ alert("请输入作者名称!");   
		  form.Field1.focus();    
		   return false;
		} 
 	    form.submit();
        return true;
	}
	
	
	</script> 









</div>
</body>
</html>
