<!--#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>


<div class="content"> 
	<div class="breadnav">当前位置：<a href="#">后台首页</a> >> 自定义菜单管理</div>
    <div class="opers">
	<a href="?Action=add" class="btn <%If Request("Action")="add"  Then echo " btn_primary" %>">添加菜单</a>
	<a href="?" class="btn <%If Request("Action")=""  Then echo " btn_primary" %>">查看菜单</a>
    </div>




<% 
	Dim sql,OpenWay,sqlCount,Sqls,intPageSize, strPageInfo,arrinfo, i,pages,intPageNow,strLocalUrl,Action,MenuUrl,MenuName
	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 DiyMenu_fy where ID in (" & ID & ")"
		Else
			Sql="delete from DiyMenu_fy where ID=" &  ChkNumeric(ID) & ""
		End if
		Conn.Execute sql:Set Conn=nothing
		 Call fycms.ActErr("删除成功","include/plus/fy.DiyMenu.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], [MenuName], [MenuUrl]" & _
		" FROM [DiyMenu_fy] where AdminID="&Cint(Request.Cookies(fycmsN)("AdminID"))&"" & _
		" ORDER BY [ID] DESC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [DiyMenu_fy] where AdminID="&Cint(Request.Cookies(fycmsN)("AdminID"))&""
		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"  cellpadding="1" cellspacing="1" class="table">
    <thead>
      <tr>
      <th>选中</th>
	  <th>ID</th>
	  <th>菜单名称</th>
	  <th>打开链接</th>
	  <th>管理操作</th>
	  </tr>
    </thead>
	 
	 <%
		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  ><%= arrinfo(2,i) %></td>
      <td colspan="2" >
	  <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>
    <tr >
      <td height="25" colspan="6" ><%= strPageInfo%></td>
    </tr>
</table></form>

<p>
  <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('确认要删除选中的Tags吗?')){
	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 DiyMenu_fy Where id="&id&"")
		If rs.eof Then
			Call fycms.alert("未知错误","")
		Else
			MenuUrl=Rs("MenuUrl")
			MenuName=Rs("MenuName")
			Id=Rs("Id")
			OpenWay=Rs("OpenWay")
		End If
		A="EditSave"
	Else
		A="AddSave"	
		OpenWay="ifrcontent"
	End If 
%>
<form name="form1" method="post" action="?action=<%= A %>&ID=<%= ID %>">
    <div class="divtable"> 
        <dl>
            <dt>菜单名称：</dt>
            <dd>
             <input name="MenuName" type="text" class="Ainput" value="<%= MenuName %>" size=50>
            </dd>
         </dl>
        <dl>
            <dt>菜单链接：</dt>
            <dd>
             <input name="MenuUrl" type="text" class="Ainput" value="<%= MenuUrl %>" size=50>
    支持HTML

            </dd>
         </dl>
        <dl>
            <dt>打开方式：</dt>
            <dd>
             <input name="OpenWay" type="text" class="Ainput" value="<%= OpenWay %>">

            </dd>
         </dl>
      
 
            <dl>
            <dt class="vhid">提交：</dt>
            <dd>
				<input type=button onclick=CheckForm() class="btn btn_primary"  name=Submit1 value="  保存  " />
				<input name="Submit2" type="reset" class="btn btn_primary" value="  重置  ">
            </dd>
         </dl>
        
    </div>
    </form>
 
<%end sub 


sub saves()
		dim Rs,RsSql
		 MenuName=fycms.S("MenuName")
		 MenuUrl=fycms.S("MenuUrl")
		 OpenWay=fycms.S("OpenWay")
		 ID=ChkNumeric(fycms.S("ID"))
		 IF fycms.S("MenuName") = "" Then
			Call fycms.Alert("请输入属性ID!",""):Exit Sub
		 End if
		 IF fycms.S("MenuUrl") = "" Then
			Call fycms.Alert("请输入属性名称!",""):Exit Sub
		 End if
		If Action="AddSave" Then 
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from DiyMenu_fy"
			  Rs.Open RsSql, Conn, 1, 3
			  Rs.AddNew
		 	  Rs("MenuUrl") = MenuUrl
		 	  Rs("MenuName") = MenuName
		 	  Rs("OpenWay") = OpenWay
			  Rs("AdminID") =Cint(Request.Cookies(fycmsN)("AdminID"))
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.ActErr("添加成功","include/plus/fy.DiyMenu.ASP","")
 		Else
			 Set Rs = Server.CreateObject("adodb.recordset")
			  RsSql = "select * from DiyMenu_fy Where ID="&ID
			  Rs.Open RsSql, Conn, 1, 3
		 	  Rs("MenuUrl") = MenuUrl
		 	  Rs("MenuName") = MenuName
		 	  Rs("OpenWay") = OpenWay
			  Rs("AdminID") =Cint(Request.Cookies(fycmsN)("AdminID"))
			  Rs.Update
			  Rs.Close:Set Rs = Nothing			
			  Call fycms.ActErr("修改成功","include/plus/fy.DiyMenu.ASP","")
 		End If 
end sub
CloseConn %>
<script language="javascript">
function CheckForm()
{ var form=document.form1;
	
	 if (form.MenuName.value=='')
		{ alert("请输入菜单名称!");   
		  form.MenuName.focus();    
		   return false;
		} 
	if (form.MenuUrl.value=='')
		{ alert("请输入菜单链接!");   
		  form.MenuUrl.focus();    
		   return false;
		} 
 	    form.submit();
        return true;
	}</script> 
</div>
</body>
</html>
