<!--#include file="../../ACT.Function.asp"-->
<!--#include file="../../../ACT_inc/cls_pageview.asp"-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>友情链接系统管理-By ACTCMS</title>
<link href="../../Images/css1/css.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
  <tr>
    <td colspan="2"  class="bg_tr"><strong>您现在的位置：子系统管理 &gt;&gt; 链接系统管理</strong></td>
  </tr>
  <tr>
    <td width="10%" align="right" class="td_bg"><strong>链接选项：</strong></td>
    <td class="td_bg"><strong><a href="?">管理首页</a> ┆ <a href="?Action=Add">新增友情类别</a>┆ <a href="Linksh_Act.asp">链接审核</a></strong></td>
  </tr>
</table><% 
	Dim ShowErr,Action
	If Not ACTCMS.ACTCMS_QXYZ(0,"xqlj_ACT","") Then   Call Actcms.Alert("对不起，你没有操作权限！","") 
	Action = Request("Action")
	Select Case Action
			Case "Edit","Add"
				Call Edit()
			Case "SaveAdd"
				Call SaveAdd
			Case "SaveEdit"
				Call SaveEdit
			Case "del"
				Call Del()
			Case Else
				Call Main()
	End Select
	
	Sub SaveAdd()
		Dim ClassLinkName,Description,SQL,rs,id
		ClassLinkName = Trim(Request.Form("ClassLinkName"))
		Description = ACTCMS.Rsql(Request.Form("Description"))
		IF 	ClassLinkName = "" Then 
			ShowErr = "<li>类别名称不能为空!</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		SQL = "Select * From ClassLink_Act Where ClassLinkName='"&ClassLinkName&"'"
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		IF Not (Rs.Eof And Rs.Bof) Then
			ShowErr = "<li>数据库中已经存在此类别名称!</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		Rs.addnew
		Rs("ClassLinkName")		= ClassLinkName
		Rs("Description")	    = Description
		Rs.update
		Rs.Close:Set Rs=Nothing
		ShowErr = "<li>添加新类别成功!&nbsp;&nbsp;<a href='Link_Act.asp'><b>返回友情链接管理</b></a></li>"
		Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=")
		Response.End
	End Sub	
		
	Sub SaveEdit()
		Dim ClassLinkName,Description,SQL,rs,id
		ClassLinkName = Trim(Request.Form("ClassLinkName"))
		Description = ACTCMS.Rsql(Request.Form("Description"))
		ID = ACTCMS.ChkNumeric(Request("ID"))
		IF 	ClassLinkName = "" Then 
			ShowErr = "<li>类别名称不能为空!</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		IF 	ClassLinkName = "" Then 
			ShowErr = "<li>类别名称不能为空!</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		SQL = "Select * From ClassLink_Act Where ID="&ID
		Set Rs=Server.CreateObject("Adodb.RecordSet")
		Rs.Open SQL,Conn,1,3
		IF Not (Rs.Eof And Rs.Bof) Then
			Rs("ClassLinkName")		= ClassLinkName
			Rs("Description")	    = Description
			Rs.update
		Else
			ShowErr = "<li>无此类别，参数传递出错</li>"
			Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl="&"&Title=1")
			Response.End
		End IF
		Rs.Close:Set Rs=Nothing
		ShowErr = "<li>类别修改成功!&nbsp;&nbsp;<a href='sys_act/link/Index.asp'><b>返回友情链接管理</b></a></li>"
		Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=")
		Response.End
	End Sub	
	Sub Del()
		Conn.Execute ("Delete from ClassLink_Act Where ID=" & ACTCMS.ChkNumeric(Request.QueryString("ID")))
		Conn.Execute ("Delete from Link_Act Where ClassLinkID=" & ACTCMS.ChkNumeric(Request.QueryString("ID")))		
		Set conn=nothing
		ShowErr = "<li>类别删除成功！</li>"
		Response.Redirect("../../Error.asp?Errs="&Server.URLEncode(ShowErr)&"&ErrorUrl=sys_act/link/Index.asp")
  		Response.End
    End Sub
		
 Sub Main
	Dim strLocalUrl
	strLocalUrl = request.ServerVariables("SCRIPT_NAME")
	Dim intPageNow
	intPageNow = request.QueryString("page")
	Dim intPageSize, strPageInfo
	intPageSize = 30
	Dim arrRecordInfo, i
	Dim sql, sqlCount
	sql = "SELECT [ID], [ClassLinkName], [Description], [AddDate]" & _
		" FROM [ClassLink_Act]" & _
		"ORDER BY [ID] ASC"
	sqlCount = "SELECT Count([ID])" & _
			" FROM [ClassLink_Act]"

		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		
		arrRecordInfo = clsRecordInfo.arrRecordInfo
		strPageInfo = clsRecordInfo.strPageInfo
		Set clsRecordInfo = nothing
 %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
    <tr>
      <td width="50" align="center" class="td_bg"><STRONG>ID</STRONG></td>
      <td width="178" align="center" class="td_bg"><STRONG>链接类别名称</STRONG></td>
      <td align="center" class="td_bg"><STRONG>链接类别简介</STRONG></td>
      <td width="225" colspan="2" align="center" class="td_bg"><strong>管理操作</strong></td>
    </tr>
	 <%
		Dim bgColor
		If IsArray(arrRecordInfo) Then
			For i = 0 to UBound(arrRecordInfo, 2)
	%>
    <tr onMouseOver=overColor(this) onMouseOut=outColor(this)>
      <td align="center" class="td_bg" ><%= arrRecordInfo(0,i) %></td>
      <td align="center" class="td_bg" >
	  <a href="?Action=Edit&ID=<%=arrRecordInfo(0,i)  %>">
	  <%=arrRecordInfo(1,i)%></a></td>
      <td align="center" class="td_bg" ><%= arrRecordInfo(2,i) %></td>
      <td  align="center" class="td_bg"><a href="?Action=Edit&ID=<%=arrRecordInfo(0,i)  %>">修改</a>┆
          <a href="?Action=del&ID=<%= arrRecordInfo(0,i) %>" onClick="return confirm('确认删除此类别吗?同时也删除改类别下的所以链接!')">删除</a>┆
    <A href="Link_Act.asp?action=List&classlinkid=<%= arrRecordInfo(0,i) %>">列出所有链接</A>
	<a href="Link_Act.asp?Action=Add&classlinkid=<%= arrRecordInfo(0,i) %>">添加链接</a></td></tr>
	<% 
	Next
	End If
	%>
    
    <tr >
      <td height="25" colspan="5" align="center" class="td_bg"><%= strPageInfo%></td>
    </tr>
  </table>

<script language="javascript">
function SelectIterm(form,sign){
	for (var i=0; i<form.elements.length;i++ ){
		if (form.elements[i].type == "checkbox"){
				var e=form.elements[i];
					if (sign==0) e.checked= true;
					if (sign==1) e.checked= !e.checked;
					if (sign==2) e.checked= false;
		}
	} 
}
function overColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg1"
		Obj.bgColor="";
	}
	
}
function outColor(Obj)
{
	var elements=Obj.childNodes;
	for(var i=0;i<elements.length;i++)
	{
		elements[i].className="tdbg";
		Obj.bgColor="";
	}
}
</script>
<% 
 End Sub
sub edit()
	Dim ID,Rs,ClassLinkName,Description,frmAction
	IF Action = "Edit" Then
		ID = ACTCMS.ChkNumeric(Request("ID"))
		IF ID = 0 Then Response.Write "请指定要修改的类别":Response.End
		Set Rs=Conn.Execute("Select * from ClassLink_Act Where ID=" & ID)
			if Rs.Bof And Rs.EOF then
				 Response.Write "不存在此类别！"
				Exit Sub
			End IF	
		ClassLinkName = Rs("ClassLinkName")	
		Description = Rs("Description")
		frmAction		= "Edit"
	Else
		ClassLinkName = ""	
		Description = ""
		frmAction		= "Add"
	End IF
  %>
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" class="table">
 <form name="form1" method="post" action="?">  <tr>
      <td width="13%" align="right"  class="td_bg"><strong>类别名称：</strong></td>
      <td width="80%"  class="td_bg"><input name="ClassLinkName" type="text" id="ClassLinkName" value="<%= ClassLinkName %>"></td>
    </tr>
    <tr>
      <td align="right"  class="td_bg"><strong>简要说明：</strong></td>
      <td  class="td_bg"><textarea name="Description" cols="50" rows="8" id="Description"><%= Description %></textarea></td>
    </tr>
    <tr>
      <td align="right"  class="td_bg">&nbsp;</td>
      <td  class="td_bg">
	  	  <input name="ID" type="hidden" value="<%=ID%>">
	  <input name="Action" type="hidden" id="Action" value="Save<%=frmAction%>">
	<input type="submit"  onclick=CheckInfo()  class="act_btn" name="Submit" value=" 保 存 "> 
	  <input type="reset" class="act_btn"  name="Submit2" value=" 取 消 " /></td>
    </tr>
  </table>
</form>
<SCRIPT language=javascript>
		function CheckInfo()
		{
		  if(document.form1.ClassLinkName.value=="")
			{
			  form1.Submit.disabled=true;	
			  form1.Submit2.disabled=true;	
			  alert("类别不能为空！");
			  document.form1.ClassLinkName.focus();
			  form1.Submit.disabled=false;	
			  form1.Submit2.disabled=false;	
			  return false;
			}
		form1.Submit.value="正在提交数据,请稍等...";
		form1.Submit.disabled=true;	
		form1.Submit2.disabled=true;	
	    form1.submit();
        return true;
		}
		</script>
<%
 
 end sub
 CloseConn %>
<br>
<br> </body>
</html>
