📄 dictionarylist.asp
字号:
<% if Session("dictionery_status") <> "login" then response.redirect "login.asp"
%>
<%
Response.expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
%>
<!--#include file="db.asp"-->
<%
displayRecs = 20
recRange = 10
%>
<%
' Get table name
tablename = "[dictionary]"
dbwhere = ""
a_search = ""
b_search = ""
%>
<%
' Get search criteria for basic search
pSearch = Request.QueryString("psearch")
If pSearch <> "" Then
pSearch = replace(pSearch,"'","''")
pSearch = replace(pSearch,"[","[[]")
b_search = b_search & "[EnglishWord] LIKE '%" & pSearch & "%' OR "
b_search = b_search & "[Chinese] LIKE '%" & pSearch & "%' OR "
End If
If len(b_search) > 4 Then
b_search = mid(b_search,1,len(b_search)-4)
b_search = "(" & b_search & ")"
End If
%>
<%
'Build search criteria
If a_search <> "" Then
dbwhere = dbwhere & a_search 'advance search
ElseIf b_search <> "" Then
dbwhere = dbwhere & b_search 'basic search
End If
'Save search criteria
If dbwhere <> "" Then
Session("tablename") = tablename
Session("dbwhere") = dbwhere
'reset start record counter
startRec = 1
Session("dictionary_REC") = startRec
Else
If tablename = Session("tablename") Then
dbwhere = Session("dbwhere")
Else
'reset search criteria
dbwhere = ""
Session("dbwhere") = dbwhere
End If
End If
'Get clear search cmd
If Request.QueryString("cmd").Count > 0 then
cmd=Request.QueryString("cmd")
If ucase(cmd) = "RESET" Then
'reset search criteria
dbwhere = ""
Session("dbwhere") = dbwhere
End If
End If
%>
<%
' Load Default Order
DefaultOrder = "EnglishWord"
DefaultOrderType = "ASC"
' Check for an Order parameter
OrderBy = ""
If Request.QueryString("order").Count > 0 Then
OrderBy = Request.QueryString("order")
' Check if an ASC/DESC toggle is required
If Session("dictionary_OB") = OrderBy Then
If Session("dictionary_OT") = "ASC" Then
Session("dictionary_OT") = "DESC"
Else
Session("dictionary_OT") = "ASC"
End if
Else
Session("dictionary_OT") = "ASC"
End If
Session("dictionary_OB") = OrderBy
Session("dictionary_REC") = 1
Else
OrderBy = Session("dictionary_OB")
if OrderBy = "" then
OrderBy = DefaultOrder
Session("dictionary_OB") = OrderBy
Session("dictionary_OT") = DefaultOrderType
End If
End If
' Check for a START parameter
If Request.QueryString("start").Count > 0 Then
startRec = Request.QueryString("start")
Session("dictionary_REC") = startRec
Else
startRec = Session("dictionary_REC")
if not isnumeric(startRec) or startRec = "" then
'reset start record counter
startRec = 1
Session("dictionary_REC") = startRec
End If
End If
' Open Connection to the database
set conn = Server.CreateObject("ADODB.Connection")
conn.Open xDb_Conn_Str
' Build Query
strsql = "select * from [dictionary]"
If dbwhere <> "" Then
strsql = strsql & " WHERE " & dbwhere
End If
if OrderBy <> "" then
strsql = strsql & " ORDER BY [" & OrderBy & "] " & Session("dictionary_OT")
end if
'response.write strsql
set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strsql, conn, 1, 2
totalRecs = rs.RecordCount
%>
<!--#include file="header.asp"-->
<form action="dictionarylist.asp">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><font size="-1">快速搜索</font></td>
<td>
<input type="Text" name="psearch" size=10>
<input type="Submit" name="Submit" value="开始搜索!">
</td>
<td><a href="dictionarylist.asp?cmd=reset"><font size="-1">S显示全部</font></a></td>
</tr>
</table>
</form>
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><a href="dictionaryadd.asp"><font size="-1">添加新单词</font></a></td>
</tr>
</table>
<p>
<form>
<table border="0" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC">
<tr bgcolor="#0099CC">
<td>
<a href="dictionarylist.asp?order=<%= Server.URLEncode("EnglishWord") %>"><font color="#FFFFFF"><font size="-1">英语单词</font></font></a></td>
<td>
<a href="dictionarylist.asp?order=<%= Server.URLEncode("Chinese") %>"><font color="#FFFFFF"><font size="-1">中文意思</font></font></a></td>
<td>
<a href="dictionarylist.asp?order=<%= Server.URLEncode("Yin") %>"><font color="#FFFFFF"><font size="-1">音标</font></font></a></td>
<td> </td>
<td> </td>
</tr>
<%
'Avoid starting record > total records
if clng(startRec) > clng(totalRecs) then
startRec = totalRecs
end if
'Set the last record to display
stopRec = startRec + displayRecs - 1
'Move to first record directly for performance reason
recCount = startRec - 1
if not rs.eof then
rs.movefirst
rs.move startRec - 1
end if
recActual = 0
Do While (NOT rs.EOF) AND (recCount < stopRec)
recCount = recCount + 1
If Clng(recCount) >= Clng(startRec) Then
recActual = recActual + 1 %>
<%
'set row color
bgcolor="#FFFFFF"
%>
<%
' Display alternate color for rows
If recCount mod 2 <> 0 Then
bgcolor="#F5F5F5"
End If
%>
<%
x_ID = rs("ID")
x_EnglishWord = rs("EnglishWord")
x_Chinese = rs("Chinese")
x_Yin = rs("Yin")
%>
<tr bgcolor="<%= bgcolor %>">
<td><font size="-1">
<% response.write x_EnglishWord %>
</font></td>
<td><font size="-1">
<% response.write x_Chinese %>
</font></td>
<td><font size="-1">
<% response.write x_Yin %>
</font></td>
<td><a href="<% If not isnull(rs("ID")) Then response.write "dictionaryedit.asp?key=" & Server.URLEncode(rs("ID")) Else response.write "javascript:alert('错误记录,ID无效.');" %>"><font size="-1">编辑</font></a></td>
<td><a href="<% If not isnull(rs("ID")) Then response.write "dictionarydelete.asp?key=" & Server.URLEncode(rs("ID")) Else response.write "javascript:alert('错误记录,ID无效.');" %>"><font size="-1">删除</font></a></td>
</tr>
<%
end if
rs.MoveNext
Loop
%>
</table>
</form>
<%
if totalRecs > 0 then
' Find out if there should be Backward or Forward Buttons on the table.
If startRec = 1 Then
isPrev = False
Else
isPrev = True
PrevStart = startRec - displayRecs
If PrevStart < 1 Then PrevStart = 1 %>
<hr size="1">
<strong><a href="dictionarylist.asp?start=<%=PrevStart%>"><font size="-1">[<< Prev]</font></a></strong>
<%
End If
' Display Page numbers
If (isPrev OR (NOT rs.EOF)) Then
If (NOT isPrev) Then Response.Write "<HR SIZE=1>"
x = 1
y = 1
dx1 = ((startRec-1)\(displayRecs*recRange))*displayRecs*recRange+1
dy1 = ((startRec-1)\(displayRecs*recRange))*recRange+1
If (dx1+displayRecs*recRange-1) > totalRecs then
dx2 = (totalRecs\displayRecs)*displayRecs+1
dy2 = (totalRecs\displayRecs)+1
Else
dx2 = dx1+displayRecs*recRange-1
dy2 = dy1+recRange-1
End If
While x <= totalrecs
If x >= dx1 and x <= dx2 Then
If Clng(startRec) = Clng(x) Then %>
<strong><font size="-1"><%=y%></font></strong>
<% Else %>
<strong><a href="dictionarylist.asp?start=<%=x%>"><font size="-1"><%=y%></font></A></strong>
<% End If
x = x + displayRecs
y = y + 1
elseif x >= (dx1-displayRecs*recRange) and x <= (dx2+displayRecs*recRange) then
if x+recRange*displayRecs < totalRecs then %>
<strong><a href="dictionarylist.asp?start=<%=x%>"><font size="-1"><%=y%>-<%=y+recRange-1%></font></a></strong>
<% else
ny=(totalRecs-1)\displayRecs+1
if ny = y then %>
<strong><a href="dictionarylist.asp?start=<%=x%>"><font size="-1"><%=y%></font></a></strong>
<% else %>
<strong><a href="dictionarylist.asp?start=<%=x%>"><font size="-1"><%=y%>-<%=ny%></font></a></strong>
<% end if
end if
x=x+recRange*displayRecs
y=y+recRange
else
x=x+recRange*displayRecs
y=y+recRange
End If
Wend
End If
' Next link
If NOT rs.EOF Then
NextStart = startRec + displayRecs
isMore = True %>
<strong><a href="dictionarylist.asp?start=<%=NextStart%>"><font size="-1">[Next >>]</font></a></strong>
<% Else
isMore = False
End If %>
<hr size="1">
<% If stopRec > recCount Then stopRec = recCount %>
<font size="-1">Words <%= startRec %> to <%= stopRec %> of <%= totalRecs %></font>
<% Else %>
<br><br>
<font size="-1">没发现任何单词!</font>
<br><br>
<% End If %><%
' Close recordset and connection
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing %><!--#include file="footer.asp"-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -