<!--#include file="../../conn/conn_other.asp"-->
<!--#include file="../check.asp"-->
<!--#include file="../../film/Incs/syscode.asp"-->
<!--#include file="../../inc/sql.asp"-->
<%
	end if
	useflag=1
%>
<!--#include file="../flag.asp"-->
<link href="css/Admin_Style.Css" rel="stylesheet">
<link href='../Include/Admin_Style.CSS' rel='stylesheet' type='text/css'>
<script language="javascript" src="js/Admin_Js.js"></script>
<%
	Dim Action,LinkID
	Action=CheckStr(Request("Action"))
	LinkID=CheckNum(Request("LinkID"))
	Select Case Action
		Case "LinkEdit"
			Call LinkEdit()
		Case "LinkSave"
			Call LinkSave()
		Case "LinkDel"
			Call LinkDel()
		Case Else
			Call LinkList()
	End Select
	
	Function LinkList()
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="sortbutton">
<tr>    
<td height="23" align="center" valign="middle">友情链接列表</td>
</tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
  <tr>
    <td colspan="4" class="title">友情链接列表</td>
  </tr>
  <tr>
    <td class="tabletd tc" width="16%">站点名称</td>
    <td class="tabletd tc" width="50%">网站地址</td>
    <td class="tabletd tc" width="14%">网站LOGO</td>
    <td class="tabletd tc">管理操作</td>
  </tr>
<%
	Dim Tag,Table,TagStr,Order,PageSize,PageUrl
	Tag="LinkID"										
	Table="[Dm_Link]"								
	TagStr="*"	
	Order="LinkID"									
	PageSize=10									
	PageUrl="Admin_Link.asp"								
	LinkNum=5										
	Dim TotalCount,PageCount,Page
	Dim Rs,Sql,WhereStr
	TotalCount=GetTotalCount(Tag,Table,WhereStr)
	PageCount=GetPageCount(TotalCount,PageSize)
	Page=GetPageNow(PageCount)
	Sql=GetPageSql(Tag,Table,TagStr,Order,PageSize,WhereStr,Page)
	Set Rs=Server.CreateObject("Adodb.RecordSet")
	Rs.Open Sql,Conn,1,1
	If Rs.Bof And Rs.Eof Then
		Rw("<tr>")
    	Rw("<td colspan='4' class=""tabletd tc"">暂无数据！</td>")
  		Rw("</tr>")
	Else
		Do While Not Rs.Eof
%>
  <tr onmouseover="this.className='tabletr';" onmouseout="this.className='tabletr2';">
    <td class="tabletd tc"><%=Rs("LinkName")%></td>
    <td class="tabletd tc"><a href="<%=Rs("LinkUrl")%>" target="_blank"><%=Rs("LinkUrl")%></a></td>
    <td class="tabletd tc"><%If Rs("LinkPic")<>"" And IsNull(Rs("LinkPic"))=False Then%>
      <a href="<%=Rs("LinkUrl")%>" target="_blank"><img src="<%=Rs("LinkPic")%>" width="88" height="31" border="0" align="absmiddle"/></a>
<%
	Else 
		Rw("")
	End If
%>	</td>
    <td class="tabletd tc"><a href="?Action=LinkEdit&LinkID=<%=Rs("LinkID")%>"><img src="Images/edit.gif" align="absmiddle" border="0" /> 修改</a>&nbsp;<a href="?Action=LinkDel&LinkID=<%=Rs("LinkID")%>"><img src="Images/del.gif" align="absmiddle" border="0" /> 删除</a></td>
  </tr>
<%
		Rs.MoveNext
		Loop
%>
  <tr>
    <td colspan="4" class="tabletd"><%Call PageShow(TotalCount,PageSize,Page,PageCount,PageUrl,LinkNum)%></td>
  </tr>
</table>
<%
	End If
	Rs.Close
	Set Rs=Nothing
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
<form id="form1" name="form1" method="post" action="?Action=LinkSave">
  <tr>
    <td colspan="7" class="title">添加友情链接</td>
  </tr>
  <tr>
    <td class="tbove">网站名称：</td>
    <td class="tbove"><input name="LinkName" type="text" class="text" id="LinkName" size="20" />
      <input name="LinkID" type="hidden" id="LinkID" value="0" /></td>
    <td class="tbove">网站地址：</td>
    <td class="tbove"><input name="LinkUrl" type="text" class="text" id="LinkUrl" size="20" /></td>
    <td class="tbove">Logo地址：</td>
    <td class="tbove"><input name="LinkPic" type="text" class="text" id="LinkPic" size="20" /></td>
    <td class="tbove"><input name="button" type="submit" class="button" id="button" value="添加" /></td>
  </tr>
</form>
</table>
<%
End Function

Function LinkEdit()
	If Action="LinkEdit" And LinkID<>0 Then
		Dim Rs,Sql
		Set Rs=Server.Createobject("Adodb.Recordset")
		Sql="Select * From Dm_Link Where LinkID="&LinkID&""
		Rs.Open Sql,Conn,1,3
		If Rs.Bof And Rs.Eof Then
			Call ShowErr ("该数据不存在！")
		Else
			LinkName=Rs("LinkName")
			LinkUrl=Rs("LinkUrl")
			LinkPic=Rs("LinkPic")
		End If
		Rs.Close
		Set Rs=Nothing
	End If
%>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="table">
  <form id="form2" name="form1" method="post" action="?Action=LinkSave">
    <tr>
      <td colspan="7" class="title">修改友情链接</td>
    </tr>
    <tr>
      <td class="tbove">网站名称：</td>
      <td class="tbove"><input name="LinkName" type="text" class="text" id="LinkName" value="<%=LinkName%>" size="20" />
       <input name="LinkID" type="hidden" id="LinkID" value="<%=LinkID%>" /></td>
      <td class="tbove">网站地址：</td>
      <td class="tbove"><input name="LinkUrl" type="text" class="text" id="LinkUrl" value="<%=LinkUrl%>" size="20" /></td>
      <td class="tbove">Logo地址：</td>
      <td class="tbove"><input name="LinkPic" type="text" class="text" id="LinkPic" value="<%=LinkPic%>" size="20" /></td>
      <td class="tbove"><input name="button2" type="submit" class="button" id="button2" value="保存" /></td>
    </tr>
  </form>
</table>
<%
	End Function
	
	Function LinkSave()
		LinkName=CheckStr(Request("LinkName"))
		LinkUrl=CheckStr(Request("LinkUrl"))
		LinkPic=CheckStr(Request("LinkPic"))
		If LinkName ="" Then Call ShowErr("请输入网站名称!")
		If LinkUrl ="" Then Call ShowErr("请输入网站地址!")
		Dim Rs,Sql
		If CheckNum(Request.Form("LinkID"))=0 Then
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Link"
			Rs.Open Sql,Conn,1,3
			Rs.AddNew
			Rs("LinkName")=LinkName
			Rs("LinkUrl")=LinkUrl
			Rs("LinkPic")=LinkPic
			Rs.Update
			Rs.Close
			Set Rs=Nothing
		Else
			Set Rs=Server.Createobject("Adodb.Recordset")
			Sql="Select * From Dm_Link Where LinkID="&LinkID&""
			Rs.Open Sql,Conn,1,3
			Rs("LinkName")=LinkName
			Rs("LinkUrl")=LinkUrl
			Rs("LinkPic")=LinkPic
			Rs.Update
			Rs.Close
			Set Rs=Nothing
		End If
		Call ShowSuccMsg("<li>友情链接保存成功！</li>","Admin_Link.asp")
	End Function
	
	Function LinkDel()
		Call DBDel("Dm_Link","LinkID="&LinkID&"")
		Call ShowSuccMsg("<li>友情链接删除成功！</li>","")
	End Function
	
	Call CloseDB()
%>

