default.asp

来自「1、全面展示宾馆的自然情况和服务内容; 2、介绍宾馆信息,帮助客人了解宾馆相」· ASP 代码 · 共 210 行

ASP
210
字号
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
if session("admin_name")="" then
    response.redirect "../index.asp"
	response.end
end if
%>
<!--#include file="../inc/adconn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>

<body>
<%
   dim totalPut   
   dim CurrentPage
   dim TotalPages
   dim i,j
   const MaxPerPage=8
   '获取当前页
   if not isempty(request("page")) then
      currentPage=cint(request("page"))
   else
      currentPage=1
   end if
   dim rs
   dim sql
   '获取将要被删除的id,并将其转换成数组
   if not isempty(request("id")) then
     idlist=request("id")
     if instr(idlist,",")>0 then
       dim idarr
       idArr=split(idlist)
       for i = 0 to ubound(idarr)
         id=clng(idarr(i))
         call deleteannounce(id)
       next
     else
       call deleteannounce(clng(idlist))
     end if
   end if
   typeid=request("typeid")
   set rs=server.createobject("adodb.recordset") 
   if typeid="" then
      sql="select * from news where Title like '%"&request("txtitle")&"%' order by NewsID desc"
   elseif request("txtitle")<>"" then
      sql="select * from news where Title like '%"&request("txtitle")&"%'  and typeid="+cstr(typeid)+" order by NewsID desc"
   else 
   sql="select * from news where typeid="+cstr(typeid)+" order by NewsID desc"
   end if
   rs.open sql,conn,1,1  
   if rs.eof and rs.bof then 
        response.write "<p align='center'>暂时没有信息</p>"
%> 
<CENTER> 
<TABLE border="0" cellspacing="0" width="100%" cellpadding="0"> 
  <TR> 
    <TD height=25 align=left bgcolor="#FFCC00"><a href="add.asp?typeid=<%=typeid%>">&nbsp;&nbsp;添加<img border=0  src="../images/add.gif" align="absbottom"></a></TD> 
  </TR> 
</TABLE> 
<%else 
        totalPut=rs.recordcount 
           if currentpage<1 then 
                 currentpage=1 
           end if 
           if (currentpage-1)*MaxPerPage>totalput then 
	 if (totalPut mod MaxPerPage)=0 then 
	      currentpage= totalPut \ MaxPerPage 
	 else 
	      currentpage= totalPut \ MaxPerPage + 1 
	 end if 
           end if 
           if currentPage=1 then 
               showContent  totalput,MaxPerPage
               showpage totalput,MaxPerPage,"default.asp"
           else 
               if (currentPage-1)*MaxPerPage<totalPut then 
                     rs.move  (currentPage-1)*MaxPerPage 
                     dim bookmark 
                     bookmark=rs.bookmark 
                     showContent  totalput,MaxPerPage
                     showpage totalput,MaxPerPage,"default.asp"
                else 
                     currentPage=1 
                     showContent  totalput,MaxPerPage
                     showpage totalput,MaxPerPage,"default.asp"
               end if 
           end if 
           rs.close 
       end if 
       set rs=nothing
       sub showContent (totalput,MaxPerPage)
%> 
<CENTER> 
<TABLE border=0 cellPadding=3 cellSpacing=1 width="100%"> 
  <TBODY> <Form name="search" method="POST" action="default.asp"> 
   <TR> 
    <TD height=30>&nbsp;</td> 
    <TD>  
    <td><IMG border=0 src="../images/search.gif"></td> 
    <TD>搜索关键字:
       <input type="text" name="txtitle" size="25"> 
&nbsp;&nbsp;
       <select name="typeid"> 
        <option value="" selected>--请选择类别--</option> 
        <% 'dim name1
      set rstype=server.createobject("adodb.recordset")
      sqltype="select * from newstype"
      rstype.open sqltype,conn,1,1
      do while not rstype.eof
      if typeid=cstr(rstype("typeid")) then
         sel="selected"
      else
         sel=""
      end if
      response.write "<option " & sel & " value='"+CStr(rstype("typeID"))+"' name=typeid>"+rstype("type")+"</option>"+chr(13)+chr(10)
      rstype.movenext
      loop
      rstype.close
    %> 
      </select> 
       <INPUT align=absMiddle border=0 src="../images/search1.gif" type=image> </TD> 
  </TR> 
  </TBODY> 
</TABLE> 
<BR> 
<TABLE border="0" cellspacing="0" width="100%" cellpadding="0"> 
  <TR> 
    <TD height=25 align=left bgcolor="#FFCC00"><a href="add.asp?typeid=<%=request("typeid")%>">&nbsp;&nbsp;&nbsp;添加<%=name1%><img src="../images/add.gif"  border=0 align="absbottom"></a></TD> 
  </TR> 
</TABLE> 
<br> 
<CENTER> 
  <TABLE width="98%" border="0" cellpadding="4" cellspacing="1" bgcolor="#336699"> 
    <tr height=25 > 
      <TD width="106" align="center" background="../images/pics/tile_sub.gif"><font color="#FFFFFF"><b>ID号</b></font></TD> 
      <TD width="712" align="center" background="../images/pics/tile_sub.gif"><font color="#FFFFFF"><b>信息标题</b></font></TD> 
      <TD width="127" align="center" background="../images/pics/tile_sub.gif"><font color="#FFFFFF"> 
        <input type='submit' value='删除'> 
        </font></TD> 
    </TR> 
    <%do while not rs.eof%> 
    <tr height="20"> 
      <td width="106" height="28" align="center" bgcolor="#ffffff"><font face="Arial"><b><%=rs("newsid")%></b></font></td> 
      <td width="712" bgcolor="#ffffff"><a href=edit.asp?Newsid=<%=rs("Newsid")%>><%=rs("title")%></a></td> 
      <td width="127" align="center" bgcolor="#ffffff"> <input name='id' type='checkbox' id="id" value='<%=cstr(rs("newsid"))%>' <%if rs("Newsid")=67 then response.write "disabled" end if%>></td> 
    </tr> 
    <% i=i+1
   if i>=MaxPerPage then exit do
   rs.movenext
   loop
%> 
  </table> 
</center> 
<%
end sub
function showpage(totalnumber,maxperpage,filename) 
    dim n 
    if totalnumber mod maxperpage=0 then 
       n= totalnumber \ maxperpage 
    else 
       n= totalnumber \ maxperpage+1 
    end if     
   if CurrentPage<2 then 
       response.write "<table border=0 width=100%  cellspacing=0 cellpadding=0 bgcolor=#e8f4ff>" 
       response.write "<tr height=30>"
       response.write "<td align=left>"
       response.write "共<font color=#ff6600><b>"&n&"</b></font>页&nbsp;第<font color=#ff6600><b>"&CurrentPage&"</b></font>页&nbsp;共检索到<font color=#ff6600><b>"&totalnumber&"</b></font>条相关信息</td>" 
       response.write "<td align=right>"
       response.write "【最前页】【上一页】" 
  else 
       response.write "<table border=0 width=600 cellspacing=0 cellpadding=0 bgcolor=#e8f4ff>"
       response.write "<tr height=30>"
       response.write "<td align=left>"
       response.write "共<font color=#ff6600><b>"&n&"</b></font>页&nbsp;第<font color=#ff6600><b>"&CurrentPage&"</b></font>页共检索到<font color=#ff6600><b>"&totalnumber&"</b></font>条相关信息</td>" 
       response.write "<td align=right>"
       response.write "【<a href="&filename&"?page=1&typeid="&typeid&"&txtitle="&request("txtitle")&">最前页</a>】" 
       response.write "【<a href="&filename&"?page="&CurrentPage-1&"&typeid="&typeid&"&txtitle="&request("txtitle")&">上一页</a>】&nbsp;" 
 end if 
  if n-currentpage<1 then 
       response.write "【下一页】【最后一页】" 
  else 
      response.write "【<a href="&filename&"?page="&(CurrentPage+1)&"&typeid="&typeid&"&txtitle="&request("txtitle")&">" 
      response.write "下一页</a>】【<a href="&filename&"?page="&n&"&typeid="&typeid&"&txtitle="&request("txtitle")&">最后一页</a>】" 
  end if 
  response.write "</td>"
  response.write "</tr>"
  response.write "</table>"
  response.write "</form>"
end function
sub deleteannounce(id)
  dim rs,sql
  set rs=server.createobject("adodb.recordset")
  sql="SELECT * from [news] where newsid="&cstr(id)
  rs.open sql,conn,1,3
  do while not rs.eof
  	rs.delete
	rs.update
  rs.movenext
  loop
  	response.Write("<script>alert('你确定删除?');this.location.href='default.asp';</script>")
End sub
%> 
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?