?? book.asp
字號:
<link href="style.css" type="text/css" rel="stylesheet">
<!--#include file="conn.asp"-->
<%
if request("query")="" then
response.write "<script>alert('全部圖書查看!');window.location.href='book.asp?query=all_book'</script>"
end if
%><br><br>
<%'單本圖書信息查看
if request("bookname")<>"" then
sql="select * from book where bookname like '"&trim(request("bookname"))&"'"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,db,1,3
if rs.eof or rs.bof then
response.write "<script>alert('SORRY!數(shù)據(jù)庫出錯!');HISTORY.GO(-1)</script>"
END IF
%><div>
<table width="593">
<tr>
<td>id</td>
<td>書名</td>
<td>價格</td>
<td>出版社</td>
<td>出版日期</td>
<td>數(shù)量</td>
<td>所屬類型</td>
<td>操作</td>
</tr>
<tr>
<td><%=rs("id")%></td>
<td><a href="book.asp?query=one_book&bookname=<%=rs("bookname")%>"><%=rs("bookname")%></a></td>
<td><%=rs("bookmoney")%></td>
<td><%=rs("publishing")%></td>
<td><%=rs("pdate")%></td>
<td><%=rs("num")%></td>
<td><%=rs("booktype")%></td>
<td height="26">
<%if session("usertype")<>"" then '首先判斷是否正常登陸,有權(quán)限
if session("usertype")="yk" then
response.Write"<a href='login.asp'>登陸</a> <a href='reg.asp'>注冊</a>"
end if
if session("usertype")="admin" then
if rs("num") <="0" then
response.Write("該書沒有庫存咯 ")
end if
%>
<a href="book.asp?query=mod&id=<%=rs("id")%>">修改</a> <a href="book.asp?query=del&id=<%=rs("id")%>">刪除</a>
<%
end if
if session("usertype")="user" then
if rs("num") >"0" then
%>
<a href="borrow.asp?id=<%=rs("id")%>&userid=<%=session("userid")%>" target="right">借閱</a>
<%
else
response.Write("該書沒有庫存咯 ")
end if
end if
%>
<%
end if
%></td>
</tr>
</table></div>
<%end if'單本圖書信息查看結(jié)束%>
<%'功能目標(biāo):實現(xiàn)所有圖書查看,某分類下圖書查看,分類查看,圖書查詢,增加,刪除,修改。。。分類的增加,刪除,修改
'所有圖書查看
if request("query")="all_book" then
set rs=server.createobject("adodb.recordset")
sql="select * from book order by id desc"
rs.open sql,db,1,1
if rs.eof or rs.bof then
response.write "<script>alert('沒有庫存!');history.go(-1)</script>"
else
dim pagenum,i
i=1
rs.pagesize=10
pagecount1=rs.pagecount
if request.querystring("pagenum")=0 or request.querystring("pagenum")="" then
pagenum=1
else
pagenum=trim(request("pagenum"))
rs.absolutepage=trim(request("pagenum"))
end if
%>
<table width="88%" border="0" align="center" cellspacing="0">
<tr align="center" valign="middle" >
<td height="25">ID</td>
<td height="25">書名</td>
<td align="center" class="2">分類</td>
<td align="center" class="2">出版社</td>
<td align="center" class="2">價格</td>
<td align="center" class="2">數(shù)量</td>
<td align="center" class="2">出版日期</td>
<td align="center" class="2">操作</td>
</tr>
<%
do while not rs.eof and i<=rs.pagesize
%>
<tr align="center">
<td height="26"><%=rs("id")%></td>
<td height="26"><a href="book.asp?query=one_book&bookname=<%=rs("bookname")%>"><%=rs("bookname")%></a></td>
<td height="26"><a href="book.asp?query=books_of_type&booktype=<%=rs("booktype")%>" target="right"><%=rs("booktype")%></a></td>
<td height="26"><a href="publishing.asp?p=<%=rs("publishing")%>" target="right"><%=rs("publishing")%></a></td>
<td height="26"><%=rs("bookmoney")%>元</td>
<td height="26"><%=rs("num")%></td>
<td height="26"><%=rs("pdate")%></td>
<td height="26">
<%if session("usertype")<>"" then '首先判斷是否正常登陸,有權(quán)限
if session("usertype")="yk" then
response.Write"<a href='login.asp'>登陸</a> <a href='reg.asp'>注冊</a>"
end if
if session("usertype")="admin" then
if rs("num") <="0" then
response.Write("該書沒有庫存咯 ")
end if
%>
<a href="book.asp?query=mod&id=<%=rs("id")%>">修改</a> <a href="book.asp?query=del&id=<%=rs("id")%>">刪除</a>
<%
end if
if session("usertype")="user" then
if rs("num") >"0" then
%>
<a href="borrow.asp?id=<%=rs("id")%>&userid=<%=session("userid")%>" target="right">借閱</a>
<%
else
response.Write("該書沒有庫存咯 ")
end if
end if
%>
<%
end if
%></td>
</tr><%
i=i+1
rs.movenext
loop
%>
</table>
<p align="center">共<%=rs.pagecount%>頁,當(dāng)前<%=pagenum%>/<%=rs.pagecount%> <a href=book.asp?query=all_book&pagenum=1>首頁</a>
<%if pagenum>1 then%>
<a href=book.asp?query=all_book&pagenum=<%=(pagenum-1)%>>上一頁</a>
<%else%>
上一頁
<%end if%>
<%if pagenum < trim(pagecount1) then%>
<a href=book.asp?query=all_book&pagenum=<%=(pagenum+1)%>>下一頁</a>
<%else%>
下一頁
<%end if%> <a href=book.asp?query=all_book&pagenum=<%=pagecount1%>>尾頁</a>
</p>
<%end if %><%end if %>
<%
'某分類下圖書查看
if request("query")="books_of_type" then
booktype=request("booktype")
if booktype<>"" then
set rs=server.CreateObject("adodb.recordset")
sql="select * from book where booktype='"&booktype&"' order by id desc"
rs.open sql,db,1,3
if rs.eof or rs.bof then
response.write "<script>alert('該分類沒有圖書!');history.go(-1)</script>"
else
%>
<div align="center">[<%=rs("booktype")%>]分類下的書</div>
<table width="88%" border="0" align="center" cellspacing="0">
<tr align="center" valign="middle" >
<td align="center" class="2">圖書名稱</td>
<td align="center" class="2">分類</td>
<td align="center" class="2">出版社</td>
<td align="center" class="2">價格</td>
<td align="center" class="2">數(shù)量</td>
<td align="center" class="2">出版日期</td>
<td align="center" class="2">操作</td>
</tr>
<%do while not rs.eof%>
<tr align="center">
<td height="26"><a href="book.asp?query=one_book&bookname=<%=rs("bookname")%>"><%=rs("bookname")%></a></td>
<td height="26"><a href="book.asp?query=books_of_type&booktype=<%=rs("booktype")%>" target="right"><%=rs("booktype")%></a></td>
<td height="26"><a href="publishing.asp?p=<%=rs("publishing")%>" target="right"><%=rs("publishing")%></a></td>
<td height="26"><%=rs("bookmoney")%>元</td>
<td height="26"><%=rs("num")%></td>
<td height="26"><%=rs("pdate")%></td>
<td height="26">
<% if session("usertype")="yk" then
response.Write"<a href='login.asp'>登陸</a> <a href='reg.asp'>注冊</a>"
end if
if session("usertype")="admin" then %>
<a href="book.asp?query=mod&id=<%=rs("id")%>">修改</a> <a href="book.asp?query=del&id=<%=rs("id")%>">刪除</a>
<%else if session("usertype")="user" then%>
<%if rs("num") >0 then %>
<a href="borrow.asp?id=<%=rs("id")%>&userid=<%=session("userid")%>" target="right">借閱</a>
<%
else
response.Write("沒書咯")%>
<%end if
end if%>
<%end if%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%end if
else
response.write "<script>alert('未選定類型咯!');window.location.href='book.asp?query=all_type'</script>"
end if
%>
<%end if%>
<%'所有分類查看
if request("query")="all_type" then
sql="select * from booktype order by id desc"
set rs=db.execute(sql)
if request("action")="modify" then
%>
<%
dim tp,id
id=request("id")
if request("type")<>"" then
tp=request("type")
sql="update booktype set booktype='"&tp&"' where id="&Id
db.execute(sql)
response.write "<script>alert('未選定類型咯!');window.location.href='book.asp?query=all_type'</script>"
end if
%>
<%
dim tpname,tpid
tpid=request("id")
sql="select * from booktype where id="&tpid
set rs=db.execute(sql)
tpname=rs("booktype")
%>
<form action="" method="post">
<input name="type" type="text" id="bookno" value="<%=rs("booktype")%>"><br>
<input type="submit" value="修改">
<a href="typeview.asp" target="right">返回</a>
</form>
<%end if%>
<table class=1 width="533" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td align="center" class="2">id</td>
<td align="center" class="2">分類名</td>
<td align="center" class="2">操作</td>
</tr>
<%do while not rs.eof%>
<tr>
<td align="center" class="2"><%=rs("id")%></td>
<td align="center" class="2"><a href="book.asp?query=books_of_type&booktype=<%=rs("booktype")%>" target="right">
<%=rs("booktype")%> </a></td>
<td align="center" class="2"><% if session("usertype")="admin" then %>
<a href="book.asp?query=type_mod&id=<%=rs("id")%>" target="right">修改</a>
<a href="book.asp?query=type_del&id=<%=rs("id")%>" target="right">刪除</a>
<%else %>
<a href="book.asp?query=books_of_type&booktype=<%=rs("booktype")%>" target="right">
查看<%=rs("booktype")%>分類下的圖書 </a>
<%end if%></td>
</tr>
<%
rs.movenext
loop
%>
</table>
<%end if
'所有分類查看%>
<%'分類修改以及刪除
'分類修改過程:如果請求修改,判斷是否有類型id.如果有就導(dǎo)出該分類的信息,此時如果請求的確認(rèn)更改是真,更改數(shù)據(jù);沒有類型id.跳轉(zhuǎn)所有分類查看。
if request("query")="type_mod" then
if request("id")<>"" then
if request("mod")="mod" then'修改分類名同時修改原來分類下的圖書所屬分類名,檢查輸入名在數(shù)據(jù)庫中是否已經(jīng)存在咯
set chk=db.execute("select * from booktype where booktype='"&trim(request("booktype"))&"'")
if chk.eof or chk.bof then
set tp=db.execute("select * from booktype where id="&request("id"))
sql2="update book set booktype='"&request("booktype")&"' where booktype ='"&tp("booktype")&"'"
sql1="update booktype set booktype='"&request("booktype")&"' where id="&request("id")
db.execute(sql1)
db.execute(sql2)
response.write "<script>alert('分類更改成功!');window.location.href='book.asp?query=all_type'</script>"
else
response.write "<script>alert('分類名已經(jīng)有了咯!');history.go(-1)</script>"
end if
end if
sql="select * from booktype where id="&request("id")
set rs=db.execute(sql)
%>
<form action="" method="post">
<input name="booktype" type="text" value="<%=rs("booktype")%>"><br>
<input type="submit" value="修改"><input type="hidden" name="mod" value="mod">
<a href="typeview.asp" target="right">返回</a>
</form>
<%
else
response.Write"<script>alert('沒有指定分類id!');window.location.href='book.asp?query=all_type'</script>"
%>
<%end if%>
<%end if
'分類更改結(jié)束%>
<%'圖書查詢
if request("query")="search" then
sql="select * from booktype order by id desc"
set rs=db.execute(sql)
%>
<form name="form1" method="post" action="search.asp">
<table width="333" border="0" align="center" cellpadding="5" cellspacing="0">
<tr align="center" >
<td colspan="2">圖書查詢 </td>
</tr>
<tr align="center">
<td align="center" class="2">書名:</td>
<td align="center" class="2">
<input name="bookname" type="text" id="bookname" ></td>
</tr>
<tr align="center">
<td align="center" class="2">分類:</td>
<td align="center" class="2"><select name="booktype" id="booktype">
<option value="">--我不知道咯--</option>
<%
do while not rs.eof
%>
<option value="<%=rs("booktype")%>"><%=rs("booktype")%></option>
<%
rs.movenext
loop
%>
</select></td>
</tr>
<tr align="center">
<td align="center" class="2">出版社:</td>
<td align="center" class="2">
<input name="publishing" type="text" id="publishing" size="15"></td>
</tr>
<tr align="center">
<td align="center" class="2">價格范圍:</td>
<td align="center" class="2"><input name="money1" type="text" id="money1" value="1" size="8">
到
<input name="money2" type="text" id="money2" value="999" size="8">
元 </td>
</tr>
<tr align="center">
<td align="center" class="2">出版日期:</td>
<td align="center" class="2"> <select name="date1" id="date1">
<option value="01" selected="selected">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
</select>
年
<select name="date2" id="date2">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
月
<select name="date3" id="date3">
<option value="1" selected>1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -