<!--#include file="../../fy.Function.asp"-->
<!--#include file="../../../fy_inc/cls_pageview.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 cid,title,cidtitle
cid= ChkNumeric(Request.QueryString("cid")) 
if cid<>0 then cidtitle=Conn.Execute("Select title from diyplus_fy Where ID=" & cid)(0)


%><div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 自定义插件系统</div>
    <div class="opers">
    	<span class="btn btn_success">插件选项：</span>	 
<a href="?Action=add&cid=<%= cid %>" class="btn ">新建[<%=cidtitle%>]参数</a>

<a href="list.asp?cid=<%= cid %>" class="btn">查看参数</a>
    </div>
  <% 
	If Not fycms.fycms_QXYZ(0,"plus","") Then   Call fycms.Alert("对不起，你没有操作权限！","") 
 dim Action,ID,ShowErr,istype,keywords,Clascid,DiyContent,ModeID,TitleLen,DateForm,ContentLen,ListNumber,str
	Action = Request("Action")
	ID = Request("ID")
	cid = Request("cid")
	Select Case Action
			Case "add","edit" 
				Call edit()
			Case "saveadd"
				Call saveadd()
			Case "saveedit"
				Call saveedit()
			Case "del"
				Call del()
			Case Else
				Call Main()
	End Select
	
	Sub Del()
		Conn.Execute ("Delete from plusget_fy Where ID=" & ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
		Call fycms.ActErr("删除成功","sys_fy/plus/list.asp?cid="&cid&"","")
 		Response.End
    End Sub
	Sub saveadd()
	    Dim Rs,content 
		 If Not fycms.ACTEXE("SELECT title FROM plusget_fy Where title='" & RSQL(Request.Form("title")) & "' order by ID desc").eof Then
			Call fycms.Alert("系统已存在该参数名称!",""):Exit Sub
		 End if	
 		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open "Select * from plusget_fy",Conn,1,3
		Rs.addnew
 		
		Rs("title")= Request.Form("title")
 		Rs("istype")= ChkNumeric(Request.Form("istype"))
 		Rs("cid")= ChkNumeric(Request("cid"))
		Rs("entitle")= Request.Form("entitle")
 		Rs("isLock")= ChkNumeric(Request.Form("isLock"))
		Rs("isdefault")= Request.Form("isdefault")
		Rs.update
		Rs.Close:Set Rs=Nothing
 		Call fycms.ActErr("添加成功","sys_fy/plus/list.asp?cid="&cid&"","")
 		Response.End
	End Sub	


	Sub saveedit()
 	Dim DiyPath,Rs,content,sql
		 
		 If Not fycms.ACTEXE("SELECT title FROM plusget_fy Where id<>"&id&" and title='" & RSQL(Request.Form("title")) & "' order by ID desc").eof Then
			Call fycms.Alert("系统已存在该参数名称!",""):Exit Sub
		 End if	
		SQL = "Select * From plusget_fy Where ID="&ID
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		Rs("title")= Request.Form("title")
 		Rs("istype")= ChkNumeric(Request.Form("istype"))
 		Rs("cid")= ChkNumeric(Request("cid"))
		Rs("entitle")= Request.Form("entitle")
		Rs("isdefault")= Request.Form("isdefault")
 		Rs("isLock")= ChkNumeric(Request.Form("isLock"))
  		Rs.update
		Rs.Close:Set Rs=Nothing
 		Call fycms.ActErr("修改成功","sys_fy/plus/list.asp?cid="&cid&"","")
 		Response.End
	End Sub	

	sub Main()
	Dim ShowErr
	ConnectionDatabase
	Dim strLocalUrl,rs
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	Dim intPageNow
	intPageNow = request.QueryString("page")
	Dim intPageSize, strPageInfo
	intPageSize = 20
 	Dim arrinfo, i
	Dim sql, sqlCount,Sqls
	if cid<>0 then Sqls="where cid="&cid
	sql = "SELECT [ID],[title],[cid],[istype]" & _
		" FROM [plusget_fy] "&Sqls&"" & _
		" ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [plusget_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 = "page"

		clsRecordInfo.objConn = Conn		
		arrinfo = clsRecordInfo.arrinfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
	 %>  <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <thead>
      <tr>
      <th>ID</th>
	  <th>名称</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><%= arrinfo(0,i) %></td>
      <td><%= arrinfo(1,i) %> </td>
      <td><%
	   set rs=Conn.Execute("Select title from diyplus_fy Where ID=" & ChkNumeric(arrinfo(2,i))) 
	   if not rs.eof then 
 	   	echo rs("title")
	    
	   end if
	   
	   %></td>
      <td><%
	 Select Case arrinfo(3,i)
		Case "1"
			echo "文本"
		Case "2"
			echo "数字"
 		Case "3"
			echo "时间"
		Case Else 
			echo "文本"
	 End Select 
	  
	  
	  %>	
	  
	  </td>
      <td>
	   <%
	  if arrinfo(2,i)="0" then 
	  	echo "<font color=green>关闭</font>"
	  else 
	  	echo "<font color=red>开启</font>"
	  end if
	  
	  
	  %>	  </td>
      <td   >
	 
<a href="?Action=edit&ID=<%= arrinfo(0,i) %>&cid=<%=cid%>">编辑&nbsp;</a>┆
	 <a href="?Action=del&ID=<%= arrinfo(0,i) %>&cid=<%=cid%> " onClick="return confirm('确认删除此吗?此操作不可恢复!')">删除</a></td>
    </tr>
	<% 
	Next
	End If
	%>
      </table>
    <div class="pagelist">
    	<%= strPageInfo%>
   </div>

  <% end sub
	sub edit()
	Dim DiyPath,Rs,content,isdefault,frmAction,isLock,entitle
	IF Action = "edit" Then
		Set Rs=Conn.Execute("Select * from plusget_fy Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 echo "不存在！"
				Exit Sub
			End IF	
	 
		title=rs("title")
		istype=rs("istype")
		cid=rs("cid")
		isLock=rs("isLock")
		entitle=rs("entitle")
		isdefault=rs("isdefault")
		
   		frmAction = "edit"
	Else
 		frmAction="add"
		istype=1
		isLock=0

	End IF
    %>
	
  <form name="form1" method="post" action="list.asp?cid=<%= cid %>">
    <div class="divtable"> 
        <dl>
            <dt>名称：</dt>
            <dd>
                 <input name="title" type="text"  class="Ainput" id="title" value="<%= title %>" size="30">     
            </dd>
         </dl>
        
        <dl>
            <dt>参数名称：</dt>
            <dd>
               <input name="entitle" type="text"  class="Ainput" id="entitle" value="<%= entitle %>" size="30"> 最好是英文名称
             </dd>
         </dl>
        
        <dl>
            <dt>是否锁定：</dt>
            <dd>
               <label for="isLock1"><input type="radio" name="isLock"  id="isLock1" value="0"   <% if isLock="0" then echo "Checked" %>>否</label>
    <label for="isLock2"><input type="radio" name="isLock"  id="isLock2"  value="1"   <% if isLock="1" then echo "Checked" %>>是</label>
             </dd>
         </dl>
        
        <dl>
            <dt>类型：</dt>
            <dd>
               <label for="istype1"><input type="radio" name="istype"  id="istype1" value="1"   <% if istype="1" then echo "Checked" %>>文本</label>
    <label for="istype2"><input type="radio" name="istype"  id="istype2"  value="2"   <% if istype="2" then echo "Checked" %>>数字</label>
    <label for="istype3"><input type="radio" name="istype"  id="istype3"  value="3"   <% if istype="3" then echo "Checked" %>>日期</label>
             </dd>
         </dl>
        
        <dl>
            <dt>默认值：</dt>
            <dd>
                <input name="isdefault" type="text"  class="Ainput" id="isdefault" value="<%= isdefault %>" size="30"> 如果条件为空的默认值
             </dd>
         </dl>
        
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd><input name="Action" type="hidden" id="Action" value="save<%=frmAction%>">
		
		 <input name="ID" type="hidden" id="ID" value="<%=id%>">
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
 				<input class="btn" type="reset" name="Submit2" value="重置">
            </dd>
         </dl>
        
    </div>
    </form>
 

<script language="javascript">
 
function CheckForm()
{ var form=document.form1;
	 if (form.title.value=='')
		{ alert("请输入插件名称!");   
		 form.title.focus();    
		   return false;
		} 
	 
	
	    form.submit();
        return true;
	}</script>  
	<%end sub
CloseConn %>
</div>
</body>
</html>
