<% userPageRights="{links}" %>
<!--#include file="check.asp"-->
<%
'Define Variable 
dim i
dim rs,rst
dim mTypeName,mGrade,mSql,mFlag,mBgColor
Set rs=Server.CreateObject("Adodb.RecordSet")

'initialization 
mFlag=true'add


'edit
if request("action")="edit" then 
  mSql="Select * From T_FriendLink Where F_ID="&Request.QueryString("ModifyID")
  Set rs=Conn.Execute(mSql)
  If not rs.Eof then
    mValue=rs("F_Value")
    mValue2=rs("F_Value2")
	mValue3=rs("F_Value3")
	F_Index=rs("F_Index")
	F_Top=rs("F_Top")
	F_Logo=rs("F_Logo")
	F_Num=rs("F_Num")
    rs.Close
  End if
  mFlag=false
end if

'Insert Records
if request("action")="Insert" then
  mSql="Select * From T_FriendLink"
  rs.open mSql,conn,1,3
  rs.AddNew
  rs("F_Value")=Trim(Request.Form("txtValue"))
  rs("F_Value2")=Trim(Request.Form("txtValue2"))
  rs("F_Value3")=Trim(Request.Form("selTarget"))
  rs("F_Index")=Trim(Request.Form("F_Index"))
  rs("F_Top")=Trim(Request.Form("F_Top"))
  rs("F_Logo")=Trim(Request.Form("F_Logo"))
  rs("F_Num")=Trim(Request.Form("F_Num"))
  rs.update
  rs.close
  response.redirect "admin_Link.asp?action=IsInsert&pageno="&Request("pageno")
end if

'Modify Records
if request("action")="editsave" then
  mSql="Select * From T_FriendLink Where F_ID="&Request.QueryString("ModifyID")
  rs.open mSql,conn,1,3
  rs("F_Value")=Trim(Request.Form("txtValue"))
  rs("F_Value2")=Trim(Request.Form("txtValue2"))
  rs("F_Value3")=Trim(Request.Form("selTarget"))
  rs("F_Index")=Trim(Request.Form("F_Index"))
  rs("F_Top")=Trim(Request.Form("F_Top"))
  rs("F_Logo")=Trim(Request.Form("F_Logo"))
  rs("F_Num")=Trim(Request.Form("F_Num"))
  rs.update
  response.redirect "admin_Link.asp?action=IsModify&pageno="&Request.Querystring("pageno")
  flag=false
end if

'Delect Records
if request("action")="delete" then
  mSql = "DELETE FROM T_FriendLink WHERE F_ID=" &Request.QueryString("DeleteID")
  conn.execute mSql
  Response.write "<script>location.replace('admin_Link.asp?action=IsDelete&pageno="&Request.Querystring("pageno")&"')</script>"
end if


%>

<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="Images/Style.css" rel="stylesheet" type="text/css">
<SCRIPT language="JavaScript">
function jDelete(url)
{
  if((confirm(" 警告:请确定是否删除,删除后不能恢复! "))==true) 
	self.location=url+'&action=delete';
}
</SCRIPT>
<script language="javascript">
function CheckData(){
  if (document.form1.txtValue.value=="")
   {
    alert("网站名称不能为空，请输入！");
	document.form1.txtValue.focus();
	return false;
   }
  if (document.form1.txtValue2.value=="")
   {
    alert("网址不能为空，请输入！");
	document.form1.txtValue2.focus();
	return false;
   }

}
</script>
</head>
<body text="#000000" >

<br>
<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
    <tr > 
    <th height="22" colspan="6"> 友情链接列表</span></th>
   </tr>
  <tr > 
    <td width="8%" align="center" class=forumHeaderBackgroundAlternate><b>ID</b></td>
    <td class=forumHeaderBackgroundAlternate width="19%"><b>网站名称</b></td>
    <td class=forumHeaderBackgroundAlternate><b>网址</b></td>
    <td width="11%" align="center" class=forumHeaderBackgroundAlternate><b>_Target</b></td>
    <td width="8%" align="center" class=forumHeaderBackgroundAlternate><b>点击</b></td>
    <td width="21%" align="center" class=forumHeaderBackgroundAlternate><b>管理</b></td>
  </tr>
  <%  
	Set rs=Server.createobject("Adodb.RecordSet")
    pageno=request.querystring("pageno")
    pmcount=16  
    mSql="select * from T_FriendLink order by F_ID"
	rs.open mSql,conn,1,1
	if rs.eof then
	   'response.write "<br><p  align='center'><font color=red><B> 对不起，数据已清空！</B></font></p>"
    else
    rs.pagesize=pmcount
    mpage=rs.pagecount
    if pageno="" then pageno=1
    if  cint(pageno)<1 or cint(pageno)>mpage then  pageno=1
    rs.absolutepage=pageno

 Dim rc,re
 rc=rs.pagesize
 re=1
 do while not rs.eof and rc>0
 mBgColor=Request.Querystring("BgColor")
 if Trim(rs("F_ID"))=Trim(mBgColor) then mColor= "D6DFFF" else mColor= "ffffff"
%>
  <tr  > 
    <td  class=forumRow width="8%" align="center"><%=rs("F_ID")%></td>
    <td class=forumRow width="19%" ><%=rs("F_Value")%> </td>
    <td class=forumRow > <a target="_blank" href="<%=rs("F_Value2")%>"><%=rs("F_Value2")%></a></td>
    <td class=forumRow width="11%" align="center" ><%=rs("F_Value3")%> </td>
    <td class=forumRow width="8%" align="center" ><%=rs("F_Hits")%></td>
    <td class=forumRow width="21%" align="center" ><a title="添加记录" href='admin_Link.asp?pageno=<%=mPage%>'><font color="#666666">[添加]</font></a><a title="修改记录" href='admin_Link.asp?action=edit&ModifyID=<%=rs("F_ID")%>&BgColor=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>'><font color="#666666">[修改]</font></a><a title="请确定是否删除,删除后不能恢复!" href="javascript:jDelete('admin_Link.asp?DeleteID=<%=rs("F_ID")%>&pageno=<%=cstr(pageno)%>')"><font color="#666666">[删除]</font></a> 
    </td>
  </tr>
   <%
 rs.movenext
 re=re+1
 rc=rc-1
 loop
 end if
%>
  <tr  >
    <td class=forumRow align="center" colspan="8"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="38%" height="22"> &nbsp;共 <font color=red><strong>
            <% = rs.recordcount%>
            </strong></font> 条记录 当前第 <font color=red><strong>
            <% = Trim(pageno)%>
            </strong></font>页/共 <font color=red><strong>
            <% = Trim(mpage)%>
            </strong></font>页 </td>
          <td width="62%" align="right"> 
            <%
if pageno>1 then
   response.write "<a href='admin_Link.asp'> <img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='首页' src='Images/boqb02.gif' border=0 width='15' height='14'>"
end if

if pageno>1 then
   response.write "<a href='admin_Link.asp?pageno="&pageno-1&"'><img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='上一页' src='Images/bob02.gif' border=0 width='15' height='14'>"
end if

add=5'数字分页个数+1
if pageno-int(add/2)<=1 then m=1 else m=pageno-int(add/2)
if m+add>mpage then 
   n=mpage
   if mpage-add<=1 then m=1 else m=mpage-add
else
   n=m+add
end if

for pno=m to n
 if pno=cint(pageno) then
   response.write "&nbsp;<font color=red>"&pno&"</font>"
 else
   response.write "<b>&nbsp;<a href='admin_Link.asp?pageno="&pno&"'>"&pno&"</a></b>"
 end if
next
response.write "&nbsp"

if int(pageno) < int(rs.pagecount) then
  response.write "<a href='admin_Link.asp?pageno="&pageno+1&"'><img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'></a>"
else 
  response.write "<img alt='下一页' src='Images/fbob02.gif' border=0 width='15' height='14'>"
end if

if int(pageno) < int(rs.pagecount) then
   response.write "<a href='admin_Link.asp?pageno="&mpage&"'><img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'></a>"
else
   response.write "<img alt='末页' src='Images/fboqb02.gif' border=0 width='15' height='14'>"
end if
Response.write "&nbsp;&nbsp;"
%>
          </td>
        </tr>
      </table></td>

  </tr>

</table> 
        <%if mFlag=true then'add%>
            <form name="form1" method="post" action="admin_Link.asp?pageno=<%=mpage%>&action=Insert" onSubmit="return CheckData()">
<table class=tableBorder width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
    <tr > 
    <th height="22" colspan="2">功能：新增记录</th>
   </tr>
                        
						<tr> 
                          <td class=forumRowHighlight width="12%" height="19">网站名称：</td>
                          <td class=forumRow width="88%"><input name="txtValue" type="text"  class='text' value="" size="22" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td class=forumRowHighlight>网　　址： </td>
                          <td class=forumRow><input name="txtValue2" type="text"  class='text' value="http://" size="22" maxlength="80"></td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>类　　型：</td>
                          <td class=forumRow><input type="radio" name="F_Top" value="1">
                            图片
                              <input name="F_Top" type="radio" value="0" checked>
                          文字</td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>图　　标：</td>
                          <td class=forumRow><input name="F_Logo" type="text" id="F_Logo"></td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>推　　荐：</td>
                          <td class=forumRow><input type="radio" name="F_Index" value="1">
                          <input name="F_Index" type="radio" value="0" checked></td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>排　　序：</td>
                          <td class=forumRow><input name="F_Num" type="text" id="F_Num"></td>
                        </tr>
                        <tr> 
                          <td class=forumRowHighlight>_Target：</td>
                          <td class=forumRow><select name="selTarget" >
                              <option value="_blank">_blank</option>
							  <option value="_parent">_parent</option>
							  <option value="_self">_self</option>
							  <option value="_top">_top</option>
                            </select></td>
                        </tr>
                        <tr> 
                          <td class=forumRowHighlight height="40" colspan="2"><input type="submit" name="Submit3" value="提交" class="button"> 
        <input type="reSet" name="Submit22" value="重置" class="button"></td>
                        </tr>
                      </table>
            </form>
        <%else%>
            <form name="form1" method="post" action="admin_Link.asp?pageno=<%=request("pageno")%>&action=editsave&ModifyID=<%=request("ModifyID")%>" onSubmit="return CheckData()">
<table class=tableBorder  width="95%" border="0" align="center" cellpadding="2" cellspacing="1">
     <tr > 
      <th height="22" colspan="2">功能：修改记录</th>
   </tr>
                        <tr> 
                          <td class=forumRowHighlight width="12%">网站名称：</td>
                          <td class=forumRow width="88%"><input name="txtValue" type="text"  class='text' value="<%=mValue%>" size="22" maxlength="80"></td>
                        </tr>
                        <tr> 
                          <td class=forumRowHighlight>网　　址：</td>
                          <td class=forumRow><input name="txtValue2" type="text"  class='text' value="<%=mValue2%>" size="22" maxlength="80"></td>
                        </tr>
						<tr>
                          <td class=forumRowHighlight>类　　型：</td>
                          <td class=forumRow><input name="F_Top" type="radio" value="1" <%if F_Top=1 then Response.write "checked"%>>
                            图片
                              <input type="radio" name="F_Top" value="0" <%if F_Top=0 then Response.write "checked"%>>
                              文字</td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>图　　标：</td>
                          <td class=forumRow><input name="F_Logo" type="text" id="F_Logo" value="<%=F_Logo%>"></td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>推　　荐：</td>
                          <td class=forumRow><input type="radio" name="F_Index" value="1" <%if F_Index=1 then Response.write "checked"%>>
                          推荐
                            <input type="radio" name="F_Index" value="0" <%if F_Index=0 then Response.write "checked"%>>
                            不推荐</td>
                        </tr>
                        <tr>
                          <td class=forumRowHighlight>排　　序：</td>
                          <td class=forumRow><input name="F_Num" type="text" id="F_Num" value="<%=F_Num%>"></td>
                        </tr>
                        <tr> 
                          <td class=forumRowHighlight>_Target ：</td>
                          <td class=forumRow><select name="selTarget" >
                              <option value="<%=mValue3%>"><%=mValue3%></option>
							  <option value="_blank">_blank</option>
							  <option value="_parent">_parent</option>
							  <option value="_self">_self</option>
							  <option value="_top">_top</option>
                            </select></td>
                        </tr>
                        <tr> 
                          <td class=forumRowHighlight height="40" colspan="2"><input type="submit" name="Submit32" value="提交" class="button"> 
                    <input type="reSet" name="Submit222" value="重置" class="button"></td>
                        </tr>
                      </table>
            </form>
        <%end if%>

</body>
</html>
<%
 rs.close
 set rs=nothing
 conn.close
 set conn=nothing
%>