⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.asp

📁 一个简单的图书管理系统!毕业论文
💻 ASP
📖 第 1 页 / 共 2 页
字号:
<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!数据库出错!');HISTORY.GO(-1)</script>"
END IF
%><div>
<table width="593">
<tr>
    <td>id</td>
    <td>书名</td>
    <td>价格</td>
    <td>出版社</td>
    <td>出版日期</td>
    <td>数量</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 '首先判断是否正常登陆,有权限
	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("该书没有库存啦!&nbsp;")
	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("该书没有库存啦!&nbsp;")
	end if
	end if 
	%>
    <%
	end if
	%></td>
  </tr>
</table></div>
<%end if'单本图书信息查看结束%>
<%
'所有图书查看
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">数量</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 '首先判断是否正常登陆,有权限
	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("该书没有库存咯&nbsp;")
	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("该书没有库存啦!&nbsp;")
	end if
	end if 
	%>
    <%
	end if
	%></td>
	</tr><%
        i=i+1
        rs.movenext
        loop
    %>
</table>
<p align="center">共<%=rs.pagecount%>页,当前<%=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">数量</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="修改">
              &nbsp; <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.如果有就导出该分类的信息,此时如果请求的确认更改是真,更改数据;没有类型id.跳转所有分类查看。
if request("query")="type_mod" then
if request("id")<>"" then
if request("mod")="mod" then'修改分类名同时修改原来分类下的图书所属分类名,检查输入名在数据库中是否已经存在咯
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('分类名已经有了!');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">
              &nbsp; <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
'分类更改结束%>
<%'图书查询
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="" selected="selected">--请选择--</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>
          <option value="28">28</option>
          <option value="29">29</option>

⌨️ 快捷键说明

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