<!--#include file="../fy.Function.asp"-->
<!--#include file="../../fy_inc/cls_pageview.asp"-->
<% If Not fycms.ChkAdmin() Then  Call fycms.Alert("对不起，您没有操作权限！","")
 %><!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>content</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="?A=Add" class="btn">添加栏目</a>
     </div>
  	 <% 
  	Dim ClassName,UModeID,ClassOrder,ClassTemp,A,Action,ModeID,rs,RsSql,ID
	Action = Request("A")
	ID=ChkNumeric(Request("ID"))
	If Not fycms.ChkAdmin() Then   Call fycms.Alert("对不起，你没有操作权限！","")
 	Select Case Action
			Case "Edit","Add"
				Call Main()
				Call AddEdit()
			Case "AddSave"
				Call AddSave
			Case "ESave"
				Call ESave
			Case "del"
				Call Del()
 			Case Else
				Call Main()
	End Select
	
	IF Action = "Del" Then
		If ID="1" Then  Call fycms.ActErr("该栏目禁止删除","user/fy.space.asp",""):response.end
		fycms.ACTEXE("Delete From space_fy Where ID=" & ID)		
		Call fycms.ActErr("删除栏目成功","user/fy.space.asp","")
 	End IF
	
	
	sub AddSave()
		 ClassName = fycms.S("ClassName")
		 UModeID = ChkNumeric(Request("UModeID"))
		 ModeID = ChkNumeric(Request("ModeID"))
		 ClassOrder = fycms.S("ClassOrder")
	     ClassTemp = fycms.S("ClassTemp")
 		 IF fycms.S("ClassName") = "" Then
		 	Call fycms.Alert("栏目名称不能为空!",""):Exit Sub
		 End if
 	 	 IF fycms.S("ClassTemp") = "" Then
		 	Call fycms.Alert("模板文件名不能为空!",""):Exit Sub
		 End if
 		 Set Rs = Server.CreateObject("adodb.recordset")
		  RsSql = "select * from space_fy"
		  Rs.Open RsSql, Conn, 1, 3
		  Rs.AddNew
		  Rs("ClassName") = ClassName
		  Rs("UModeID") = UModeID
		  Rs("ModeID") = ModeID
		  Rs("ClassOrder") = ClassOrder
		  Rs("ClassTemp") = ClassTemp
 		  Rs.Update
		 Call fycms.ActErr("操作成功","User/fy.space.asp","")
	end sub 
	sub ESave()
		 ClassName = fycms.S("ClassName")
		 UModeID = ChkNumeric(Request("UModeID"))
		 ModeID = ChkNumeric(Request("ModeID"))
		 ClassOrder = fycms.S("ClassOrder")
	     ClassTemp = fycms.S("ClassTemp")
		 IF fycms.S("ClassName") = "" Then
		 	Call fycms.Alert("栏目名称不能为空!",""):Exit Sub
		 End if
 	 	 IF fycms.S("ClassTemp") = "" Then
		 	Call fycms.Alert("模板文件名不能为空!",""):Exit Sub
		 End if
		 Set Rs = Server.CreateObject("adodb.recordset")
		  RsSql = "select * from space_fy where id="&ID
		  Rs.Open RsSql, Conn, 1, 3
		  if not rs.eof then 
			  Rs("ClassName") = ClassName
			  Rs("UModeID") = UModeID
			  Rs("ModeID") = ModeID
			  Rs("ClassOrder") = ClassOrder
		 	  Rs("ClassTemp") = ClassTemp
			  Rs.Update
		  end if 
		 Call fycms.ActErr("操作成功","User/fy.space.asp","")
	end sub 
	sub main()
	Dim strLocalUrl,pages
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
 	Dim intPageNow
	intPageNow = request.QueryString("page")
 	Dim intPageSize, strPageInfo
	intPageSize = 30
 	Dim arrinfo, i,GroupSettingSet
	Dim sql, sqlCount
	sql = "SELECT [ID], [ClassName],[UModeID],[ClassOrder],[ModeID]" & _
		" FROM [space_fy]" & _
		"ORDER BY [ID] ASC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [space_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 = pages
		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>
	 <%
 		If IsArray(arrinfo) Then
			For i = 0 to UBound(arrinfo, 2)
 	%>
    <tr>
      <td ><%=arrinfo(0,i)%></td>
	  <td ><%=arrinfo(1,i)%></td>
       <td ><%=fycms.ACT_C(arrinfo(4,i),1)%>模型</td>						
       <td ><%=fycms.ACT_U(arrinfo(2,i),1)%>模型</td>						
       <td ><%=arrinfo(3,i)%></td>
       <td  ><a href="?A=Edit&ID=<%=arrinfo(0,i)%>">修改</a>┆
	 <a href="?A=Del&ID=<%=arrinfo(0,i)%>" onClick="return confirm('确认删除此栏目吗?')">删除</a></td>
    </tr>
	
  	<% 
	Next
	End If
	%>
      

	</table>
    <div class="pagelist">
    	 <%= strPageInfo %>
   </div>
	
	<% end sub %>


<% Sub AddEdit() 
	if Action="Add" Then
		A="AddSave"
		ClassOrder=10
	Else
		Set Rs=server.CreateObject("adodb.recordset") 
		Rs.OPen "Select * from space_fy Where ID = "&ID,Conn,1,1
		ClassName = Rs("ClassName")
		UModeID = Rs("UModeID")
	    ModeID = Rs("ModeID")
 		ClassOrder=Rs("ClassOrder")
		ClassTemp=Rs("ClassTemp")
 		A="ESave"
	end if

%>
 
    <form name="form1" method="post"  action="?A=<%= A %>">
    <div class="divtable"> 
        <dl>
            <dt>栏目名称：</dt>
            <dd>
                 <input name="ClassName" type="text" class="Ainput" id="ClassName" value="<%=ClassName  %>" size="50">   
            </dd>
         </dl>
        
        <dl>
            <dt>模板文件名：</dt>
            <dd>
               <input name="ClassTemp" type="text" class="Ainput" id="ClassTemp" value="<%= ClassTemp %>" size="50">
             </dd>
         </dl>
 
        <dl>
            <dt>排序：</dt>
            <dd>
               <input name="ClassOrder" type="text" class="Ainput" id="ClassOrder" value="<%= ClassOrder %>" size="50">
             </dd>
         </dl>
 
        <dl>
            <dt>系统模型：</dt>
            <dd>
               <select name="ModeID" id="ModeID">
          <% 
	  dim rs
	 Set Rs =fycms.ACTEXE("SELECT ModeID, ModeName,ModeTable, ModeNote  FROM Mode_fy order by ModeID asc")
	 If Rs.EOF  Then
	 	echo	"<option>没有记录</option>"
	 Else
		Do While Not Rs.EOF	 %>
          <option value="<%= rs("ModeID") %>" <%if rs("ModeID")=ModeID then echo " Selected" %>><%= rs("ModeName") %>模型</option>
          <% 
 		Rs.movenext
		Loop
	End if	 %>
	    </select>
             </dd>
         </dl>
 
        <dl>
            <dt>用户模型：</dt>
            <dd>
                 <select name="UModeID" id="select">
      <% 
 	 Set Rs =fycms.ACTEXE("SELECT ModeID, ModeName,ModeTable, ModeNote  FROM ModeUser_fy order by ModeID asc")
	 If Rs.EOF  Then
	 	echo	"<option>没有记录</option>"
	 Else
		Do While Not Rs.EOF	 %>
         <option value="<%= rs("ModeID") %>" <%if rs("ModeID")=UModeID then echo " Selected" %>><%= rs("ModeName") %></option>
        <% 
 		Rs.movenext
		Loop
	End if	 %></select>   
             </dd>
         </dl>
 
 


            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
                <a class="btn btn_primary" href="javascript:void(0);" onclick="CheckForm()">提交</a>
                <a class="btn" href="javascript:void(0);" onclick="CheckForm()">重置</a>
            </dd>
         </dl>
        
    </div>
    </form>
<script language="JavaScript" type="text/javascript">
 
function CheckForm()
{ var form=document.form1;
	
	 if (form.ClassName.value=='')
		{ alert("请输入栏目名称!");   
		  form.ClassName.focus();    
		   return false;
		} 
	 if (form.ClassTemp.value=='')
		{ alert("请输入模板文件名!");   
		  form.ClassName.focus();    
		   return false;
		} 
	
	    form.submit();
        return true;
	}
</script>

<% end sub  %>


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