<%@language=vbscript codepage=936%>
<%
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
dim dns
dns="../"
%>
<!--#Include file="../Common/Inc_DatConn.asp"-->
<!--#Include file="Common/Inc_Config.asp"-->
<!--#Include file="Common/Inc_Function.asp"-->
<!--#Include file="fy_admin_check.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="images/Admin_Style.Css" rel="stylesheet" type="text/css">
<script src="../common/Admin.js" type="text/javascript"></script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<%
if fla22<>1 and Session("intUserLevel")<2 then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>错误：操作权限出错，您没有权限操作些功能！</li>"
Call Admin_ShowErr(ErrMsg)
end if
bbaction=changechr(request("bbaction"))
Select case bbaction
  	Case "addlink"
		call addlink
	Case "saveaddlink"
		call saveaddlink
 	Case "editlink"
		call editlink
 	Case "locklink"
		call locklink
	Case "saveeditlink"
		call saveeditlink
	Case "dellink"
		call dellink
	Case else
%>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>热 门 商 家 管 理</strong></td>
  </tr>
  <tr class="tdbg"> 
    <td width="70" height="30"><strong>管理导航：</strong></td>
    <td height="30">
			<img border="0" src="../images/dot_02.gif" width="14" height="14"><a href="?bbaction=addlink">添加</a>&nbsp;&nbsp;
			<img border="0" src="../images/dot_02.gif" width="14" height="14"><a href="?strstata=0">未审链接</a>&nbsp;&nbsp;
			<img border="0" src="../images/dot_02.gif" width="14" height="14"><a href="?strstata=1">已审链接</a></td>
  </tr>
</table>
<br>
  <table width="100%" border="0" align="center" cellpadding="0" cellspacing="1" Class="border">
    <tr class="title"> 
      <td width="60" align="center">编 号</td>
      <td align="center">标 题</td>
      <td width="40" align="center">状 态</td>
      <td width="120" align="center">添加时间</td>
      <td width="120" align="center">操 作</td>
    </tr>
<%
Dim rdsLink    '/通告的数据库对象及SQL语句/
Dim sqlLink
Dim rdsTotalRec   
Dim strKeyWord    '/关键字/
Dim intPage       '/当前页/
Dim intTotalRec	  '/所有记录/
Dim intLinkCot	  '/通告条数/
Dim intLinkCount
Dim n,p,ii	      '/定义一些临时变量/
Dim strState
Dim strLinkClass

strKeyWord = Request("KeyWord")
strstata= Request("strstata")
strsql=""
if strstata<>"" then
strsql=strsql&" and State="&strstata&" "
end if
if strKeyWord<>"" then
strsql=strsql&"  And Homepage like '%"& strKeyWord &"%' "
end if

intPage = Trim(Request("Page"))
if intPage = "" then
	intPage = 1
else
	intPage = Clng(intPage)
end if

intLinkCot = 20

set rdsLink = Server.CreateObject("ADODB.Recordset")
	set rdsTotalRec = Conn.Execute("Select Count(LinkKey) From Dat_Link Where Homepage<>'' "&strsql&"")
	intTotalRec = rdsTotalRec(0)
	sqlLink = "Select * From Dat_Link Where Homepage<>'' "&strsql&" Order By LinkKey Desc"
rdsLink.Open sqlLink,Conn,1,1
if not rdsLink.EOF then
	if intTotalRec mod intLinkCot = 0 then
		n = intTotalRec \ intLinkCot
	else
		n = intTotalRec \ intLinkCot + 1
	end if
	rdsLink.MoveFirst
	if intPage > n then intPage = n
	if intPage < 1 then intPage = 1
	rdsLink.Move (intPage - 1) * intLinkCot
	do while not rdsLink.EOF and intLinkCount < Clng(intLinkCot)
		intLinkCount = intNewsCount + 1
		linkid=rdsLink("LinkKey")
		if rdsLink("State") = 1 then
			strState = "<font color=""#FF0000"">活动</font>"
			strOperState = "<a href=""?bbaction=locklink&id="&linkid&"&lx=0"">锁定</a>"
		else
			strState = "<font color=""#0000ff"">未审</font>"
			strOperState = "<a href=""?bbaction=locklink&id="&linkid&"&lx=1"">审核</a>"
		end if
		if rdsLink("LinkClass") = 1 then
			strLinkClass = ""
		else
			strLinkClass = ""	
		end if
%>
    <tr class="tdbg" onMouseOut="this.className='tdbg'" onMouseOver="this.className='tdbg2'"> 
      <td width="60" align="center"><% =linkid%></td>
      <td><a href="<% = rdsLink("Url")%>" target=_blank><% = rdsLink("Homepage")%></a></td>
      <td width="40" align="center"><% = strState%></td>
      <td width="120" align="center"><% = FormatTime(rdsLink("CreateTime"),4)%></td>
      <td width="120" align="center"> 
		<%=strOperState%>&nbsp; <a href="?bbaction=editlink&ID=<%=linkid%>">编辑</a>&nbsp; <a href="?bbaction=dellink&ID=<%=linkid%>" onClick="{if(confirm('确定删除吗?')){return true;}return false;}">删除</a></td>
    </tr>
<%
		rdsLink.MoveNext
	loop
else
	Response.Write "<tr><td width=""100%"" height=""25"" colspan=""6"" class=""banma1"">&nbsp;<font color=""#FF0000"">没有链接信息...</font></td></tr>"
end if
rdsLink.Close
set rdsLink = nothing

if intPage - 1 mod 10 = 0 then
	p = (intPage - 1) \ 10
else
	p = (intPage - 1) \ 10
end if	
%>
  </table>
  	  <table border="0" width="96%" cellspacing="0" cellpadding="0" align="center">
	    <form method="post" action="?" name="Form2">
	    <input type="hidden" name="KeyWord" value="<% = strKeyWord%>">
	    <tr>
		  <td width="30%" height="30" valign="middle">页次：<b><%= intPage %></b>/<b><%= n %></b>页 每页<b><%= intLinkCot %></b>条 共<b><%= intTotalRec %></b>条</td>
		  <td width="70%" height="30" valign="middle"><div align="right">分页：
			<%
				if intPage = 1 then
					Response.Write "<font face=webdings>9</font>   "
				else
					Response.Write "<a href='?Page=1&KeyWord="& strKeyWord &"' title=首页><font face=webdings>9</font></a>   "
				end if
				if p * 10 > 0 then Response.Write "<a href='?Page="&Cstr(p*10)&"&KeyWord="& strKeyWord &"' title=上十页><font face=webdings>7</font></a>   "
				Response.Write "<b>"
				for ii = p * 10 + 1 to P * 10 + 10
					   if ii = intPage then
				          Response.Write "<font color=""#FF0000"">"+Cstr(ii)+"</font> "
					   else
					      Response.Write "<a href='?Page="&Cstr(ii)&"&KeyWord="& strKeyWord &"'>"+Cstr(ii)+"</a>   "
					   end if
					if ii = n then exit for
				next
				Response.Write "</b>"
				if ii < n then Response.Write "<a href='?Page="&Cstr(ii)&"&KeyWord="& strKeyWord &"' title=下十页><font face=webdings>8</font></a>   "
				if intPage=n then
					Response.Write "<font face=webdings>:</font>   "
				else
					Response.Write "<a href='?Page="&Cstr(n)&"&KeyWord="& strKeyWord &"' title=尾页><font face=webdings>:</font></a>   "
				end if
			%>
			转到：<input type="text" name="Page" size="2" maxlength="10" value="<%= intPage %>" class="face"> <input type="submit" value="Go" name="submit" class="button">
			</div></td>
		</tr>
		</form>
	  </table>
<%
end Select
sub addlink
%>
<script language="javascript">
//检验表单的合法性
function CheckForm() {
	if (document.AddForm.LinkClass.value == "#") {
		alert("\必须选择链接类型！");
		document.AddForm.LinkClass.focus();
	}
	else if (document.AddForm.Homepage.value == "") {
		alert("\请输入链接方网站名称！");
		document.AddForm.Homepage.focus();
	}
	else {
        return true;
    }
    return false;
}
// End of validation form script -->
</script>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>添加信息</strong></td>
  </tr><form method="post" action="?bbaction=saveaddlink" name="AddForm" OnSubmit="return CheckForm()">
  <tr class="tdbg"><input type="hidden" name="Id" value="<% =intNewsKey%>">
    <td width="12%" height="23" align="right">链接类别：</td>
    <td height="23" width="87%"><select size="1" name="LinkClass" class="face">
				  <option value="#" selected>－选择－</option>
				  <option value="1">工商/财务</option>
				  <option value="2">装修/建材</option>
				  <option value="3">搬迁/拆装</option>
				  <option value="4">家居/日用</option>
				  <option value="5">数码/通讯</option>
				  <option value="6">创业/招商</option>
				  <option value="7">教育/培训</option>
				  <option value="8">电脑/网络</option>
				  <option value="9">旅游/票务</option>
				</select></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">网站名称：</td>
    <td height="23" width="87%"><input type="text" name="Homepage" size="25">&nbsp;<font color="#FF0000">**</font></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">网址：</td>
    <td height="23" width="87%"><input type="text" name="Url" size="25"></td>
  </tr>  
  <tr class="tdbg">
    <td width="12%" height="23" align="right">备注：</td>
    <td height="23" width="87%">
	<textarea rows="3" name="Content" cols="68"></textarea></td>
  </tr>    
        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onClick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end sub
sub editlink
intLinkKey = Request("Id")
	set rdsLink = Server.CreateObject("ADODB.Recordset")
	sqlLink = "Select * From Dat_Link Where LinkKey = "& intLinkKey
	rdsLink.Open sqlLink,Conn,1,1
	if not rdsLink.EOF then
%>
<script language="javascript">
//检验表单的合法性
function CheckForm1() {
	if (document.AddForm1.LinkClass.value == "#") {
		alert("\必须选择链接类型！");
		document.AddForm1.LinkClass.focus();
	}
	else if (document.AddForm1.Homepage.value == "") {
		alert("\请输入链接方网站名称！");
		document.AddForm1.Homepage.focus();
	}
	else {
        return true;
    }
    return false;
}
// End of validation form script -->
</script>
<br>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="border" height="73">
  <tr class="title"> 
    <td height="22" colspan="2" align="center"><strong>修改信息</strong></td>
  </tr><form method="post" action="?bbaction=saveeditlink" name="AddForm1" OnSubmit="return CheckForm1()">
  <tr class="tdbg">
    <td width="12%" height="23" align="right">链接类别：</td>
    <td height="23" width="87%"><select size="1" name="LinkClass" class="face">
				  <option value="1" <%if rdsLink("LinkClass") = "1" then Response.Write "selected"%>>工商/财务</option>
				  <option value="2" <%if rdsLink("LinkClass") = "2" then Response.Write "selected"%>>装修/建材</option>
				  <option value="3" <%if rdsLink("LinkClass") = "3" then Response.Write "selected"%>>搬迁/拆装</option>
				  <option value="4" <%if rdsLink("LinkClass") = "4" then Response.Write "selected"%>>家居/日用</option>
				  <option value="5" <%if rdsLink("LinkClass") = "5" then Response.Write "selected"%>>数码/通讯</option>
				  <option value="6" <%if rdsLink("LinkClass") = "6" then Response.Write "selected"%>>创业/招商</option>
				  <option value="7" <%if rdsLink("LinkClass") = "7" then Response.Write "selected"%>>教育/培训</option>
				  <option value="8" <%if rdsLink("LinkClass") = "8" then Response.Write "selected"%>>电脑/网络</option>
				  <option value="9" <%if rdsLink("LinkClass") = "9" then Response.Write "selected"%>>旅游/票务</option>
				</select></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">网站名称：</td>
    <td height="23" width="87%">
	<input type="hidden" name="Id" value="<% =intLinkKey%>"><input type="text" name="Homepage" size="25" class="face" value="<% = rdsLink("Homepage")%>">&nbsp;<font color="#FF0000">**</font></td>
  </tr>
  <tr class="tdbg">
    <td width="12%" height="23" align="right">网址：</td>
    <td height="23" width="87%">
	<input type="text" name="Url" size="25" class="face" value="<% = rdsLink("Url")%>"></td>
  </tr>  
  <tr class="tdbg">
    <td width="12%" height="23" align="right">备注：</td>
    <td height="23" width="87%">
	<textarea rows="3" name="Content" cols="68" class="face"><% = rdsLink("Content")%></textarea></td>
  </tr>    
        <tr class="tdbg">
          <td height="12" align="right" colspan="2">
			<p align="center"><input type="submit" value="提 交" name="Submit"> <input onClick="parent.location.href='Javascript:history.back()'" type="button" value="返 回" name=button1></td>
        </tr></form>
</table>
<%
end if
end sub
%>