基于Oracle数据库的图书管理系统设计与实现

一、系统功能需求

      基于Oracle数据库,实现一个网上书城系统,在该系统中实现用户登陆、用户注册、图书浏览、图书添加和查找等功能,因时间的关系,本设计要求实现的功能作了简化,要求实现的核收功能包括图书展现、添加、删除等。

1.1 图书展现

      用户打开首页后,从数据库中读取数据,将图书信息展现在首页,如下图:

 1.2 用户登录

      在首页中,用户登录框中输入用户名和口令,从数据库中读取已存在的用户名和口令,比对成功后,进入用户界面。如:管理员登录后,可进入管理员界面,在其中展现数据库中图书信息,进行管理员相关操作,类似于下图:

1.3 用户注册

      在首页中,设计“用户注册”链接,类似于下图:

      打开用户注册界面,在其中接受用户输入,并将用户数据存入数据库中。 

1.4 添加图书

      在打开的添加图书页面中,打开图书添加页面,在其中输入图书信息,并提交写入数据库,类似于下图:

1.5 图书删除

      在管理员界面中,选中指定图书,点击图书删除按钮,实现将指定图书数据删除,类似于下图:

二、系统设计

2.1 系统结构设计

      本设计需实现的是一个简化版网上书城系统,系统总体结构采用B/S结构,如下图:

 2.2 数据库设计

      请根据以上功能描述,抽取出功能相关数据项,设计对应的数据库。

三、系统实现

3.1 图书展现实现

      在首页或管理员首页中展现图书基本信息,当用户打开首页时,可看到图书的基本信息,包括书名、简要介绍和图片等。

<style type="text/css">
<!--
.STYLE13 {
	font-size: 36px;
	font-weight: bold;
	font-family: "宋体";
	color: #0033CC;
}
.STYLE15 {color: #660000}
-->
</style>
<table width="795" height="62" border="1" bgcolor="#FFFFFF">
  <tr>
    <th colspan="4" align="center" valign="middle" bgcolor="#FFFFFF" scope="col"><h1 align="center" class="STYLE13">智慧书店</h1></th>
  </tr>
  <tr bordercolor="#000000" bgcolor="#FFFFFF">
    <td width="84" bordercolor="#000000"><div align="center">科技</div></td>
    <td width="93" bordercolor="#000000"><div align="center" class="STYLE15">名著</div></td>
    <td width="96" bordercolor="#000000"><div align="center">艺术</div></td>
    <td width="494" align="center" valign="middle">  <div align="center"> 
      <form name="form1" method="post" action="">
          <label>站内搜索:
            <input type="text" name="textfield">
          </label>
          <label>
          <input type="submit" name="Submit" value="提交">
          </label>
      </form>
    </div></td>
  </tr>
</table>
<table width="794" height="253" border="1" bordercolor="#000000" bgcolor="#FFFFFF">
  <tr bgcolor="#FFFFFF">
    <th height="23" colspan="5" scope="col"><div align="right">欢迎光临!</div></th>
  </tr>
  <tr>
    <td width="185" rowspan="3"><div align="center"><img src="300.jpg" width="73" height="95"></div></td>
    <td width="188" height="36">书名:水浒传</td>
    <td width="4" rowspan="6" bgcolor="#FFFFFF">&nbsp;</td>
    <td width="194" rowspan="3"><div align="center"><img src="b24cc8c00097c3d479c85fe12d1ba3da_0_1_300_300.jpg" width="73" height="95"></div></td>
    <td width="189">书名:三国演义</td>
  </tr>
  <tr>
    <td height="34">作者:施耐庵</td>
    <td>作者:罗贯中</td>
  </tr>
  <tr>
    <td>价格:54元</td>
    <td>价格:58元</td>
  </tr>
  <tr>
    <td rowspan="3"><div align="center"><img src="t01548b8f3eb70e1447.jpg" width="114" height="95"></div></td>
    <td height="35">书名:西游记</td>
    <td rowspan="3"><div align="center"><img src="3561effa27b04ddfbfab9769cb27594b.jpeg" width="119" height="95"></div></td>
    <td>书名:红楼梦</td>
  </tr>
  <tr>
    <td height="39">作者:吴承恩</td>
    <td>作者:曹雪芹</td>
  </tr>
  <tr>
    <td height="33">价格:49元</td>
    <td>价格:55元</td>
  </tr>
</table>
<p>&nbsp;</p>

结果展示:

3.2 用户登录实现

      在首页中,设置登录窗口,在其中输入用户名和口令后,可以完成用户登录操作。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {
	font-family: "宋体";
	font-size: xx-large;
}
.STYLE3 {font-size: 36px}
.STYLE7 {font-size: medium}
-->
</style>
</head>

<body>
<div align="center">
  <p class="STYLE1"><span class="STYLE3">欢迎来到智慧书店</span></p>
  <p class="STYLE1"><img src="file:///C|/Users/26480/Desktop/图书馆/23222016_d270a37d4e_small.jpg" width="177" height="143" /></p>
  <p align="center" class="STYLE1"><span class="STYLE7">输入账号: 
		        <input type="text" >
	            <BR>
		        输入密码:  
		         <input type="password" >
               </span><BR>
	            <span class="STYLE8">
	             <input name="submit" type="submit" value="登录" />
	            </span>
	             <input type="submit" value="注册">
  </p>
</div>
</body>
</html>

结果展示:

3.3 用户注册实现

      在首页中,设置注册按钮或界面,用户可以在注册界面输入用户名、口令等基础用户信息,实现用户注册。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body {
	margin-right: 600px;
}
.STYLE1 {
	font-size: xx-large;
	font-family: "新宋体";
}
-->
</style></head>

<body>
<div align="center" class="STYLE1">
  <div align="center"> 用户注册  </div>
</div>
<p>账号信息:</p>
<p>账号:  
  <input type="text" name="textfield" /> 
  (不含空格,长度为4-10位)
</p>
<p>密码:
  <input type="text" name="textfield2" />
(不含空格,长度为4-10位)</p>
<p>确认:
  <input type="text" name="textfield3" /> 
  (再次输入密码)
</p>
<p>姓名:
  <input type="text" name="textfield4" />
</p>
<p>性别:
  <input type="radio" name="radiobutton" value="radiobutton" />
  男
  <input type="radio" name="radiobutton" value="radiobutton" />
  女</p>
<p>电话:
  <input type="text" name="textfield6" /> 
  (正确填写9位数字)
</p>
<p>地址:
  <input type="text" name="textfield7" /> 
  (请输入详细地址)
</p>
<form id="form1" name="form1" method="post" action="">
  <div align="center">
    <input type="submit" name="Submit" value="提交" />
     <input type="submit" name="Submit2" value="重置" />
  </div>
</form>
<p align="center">&nbsp;</p>
</body>
</html>

结果展示:

完成后,到后台数据库,查询对应表中数据。

台数据

3.4 添加图书实现

      设置图书添加按钮或界面,用户可以在此界面中录入图书相关信息,包括书名、作者、价格、简要介绍和图片等,完成图书信息的添加。

<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%>
<html>
	<body>
		<%
    		Class.forName("oracle.jdbc.driver.OracleDriver");
	    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:lib","scott","testdb");
			Statement stat = conn.createStatement();
			String sql = "INSERT INTO libb(BNO,BNAME,AUTHOR,PRICE) VALUES((1,'水浒传','施耐庵',54),(2,'三国演义','罗贯中',58),(3,'西游记','吴承恩',49),(4,'红楼梦','曹雪芹',55))";
			int i = stat.executeUpdate(sql);
			out.println("成功添加" + i + "行");
			stat.close();
			conn.close();
    %>
	</body>
</html>

结果展示:

完成后,到后台数据库,查询对应表中数据。

台数据

3.5 图书删除实现

      在图书展示页面,设置单选或多选功能,用户可以选中指定的图书,点击删除功能按钮后,完成指定图书数据的删除。

<%@ page language="java" import="java.sql.*" pageEncoding="gb2312"%>
<html>
	<body>
		<%
    		Class.forName("oracle.jdbc.driver.OracleDriver");
			Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:lib","scott","testdb");
			Statement stat = conn.createStatement();
			String sql = "DELETE FROM T_STUDENT WHERE BNAME='水浒传'";
			int i = stat.executeUpdate(sql);
			out.println("成功删除" + i + "行");
			stat.close();
			conn.close();
    %>
	</body>
</html>

结果展示:

完成后测试,到后台数据库,查询对应表中数据。

台数据

四、总结

      基于Oracle数据库,我设计并实现了一个简化的网上书城系统。该系统专注于满足用户的核心需求,包括用户登陆、注册,以及图书的浏览、添加和删除等功能。虽然时间有限导致系统功能有所简化,但已涵盖了书城运营的基本要素。用户可以通过该系统方便地浏览图书信息,进行图书的添加和删除操作,提升购物体验。

图书馆图书管理系统 主窗口: import java.awt.*; import java.awt.event.*; import javax.swing.*; import myClass.swing.*; public class MainWindow extends JFrame implements ActionListener { JPanel panel1;//panel2; Container c; JMenuBar MenuB; JMenu SystemMenu,BookMGRMenu,BorrowBookMenu,ReturnBookMenu, InfoBrowseMenu,UserMGRMenu; JMenuItem UserLoginMenuItem,UserAddMenuItem,UserModifyMenuItem, UserDeleteMenuItem,ExitMenuItem,BookAddMenuItem,BookModifyMenuItem,BookDeleteMenuItem, BorrowBookMenuItem,BorrowInfoMenuItem,ReturnBookMenuItem,ReturnInfoMenuItem, BookListMenuItem,BorrowBookListMenuItem,UserListMenuItem; JLabel titleLabel,AuthorLabel,DateLabel; public MainWindow() { super("图书馆管理系统"); //--系统管理菜单-- MenuB=new JMenuBar(); SystemMenu=new JMenu("系统管理"); UserMGRMenu=new JMenu("用户管理"); UserLoginMenuItem=new JMenuItem("用户登录"); UserAddMenuItem=new JMenuItem("添加用户"); UserModifyMenuItem=new JMenuItem("修改用户"); UserDeleteMenuItem=new JMenuItem("删除用户"); ExitMenuItem=new JMenuItem("退出"); SystemMenu.add(UserLoginMenuItem); UserMGRMenu.add(UserAddMenuItem); UserMGRMenu.add(UserModifyMenuItem); UserMGRMenu.add(UserDeleteMenuItem); SystemMenu.add(UserMGRMenu); SystemMenu.add(ExitMenuItem); UserLoginMenuItem.addActionListener(this); UserAddMenuItem.addActionListener(this); UserModifyMenuItem.addActionListener(this); UserDeleteMenuItem.addActionListener(this); ExitMenuItem.addActionListener(this); MenuB.add(SystemMenu); //---书籍管理菜单-- BookMGRMenu=new JMenu("书籍管理"); BookAddMenuItem=new JMenuItem("添加书籍"); BookModifyMenuItem=new JMenuItem("修改书籍"); BookDeleteMenuItem=new JMenuItem("删除书籍"); BookMGRMenu.add(BookAddMenuItem); BookMGRMenu.add(BookModifyMenuItem); BookMGRMenu.add(BookDeleteMenuItem); BookAddMenuItem.addActionListener(this); BookModifyMenuItem.addActionListener(this); BookDeleteMenuItem.addActionListener(this); MenuB.add(BookMGRMenu); //--借书管理菜单-- BorrowBookMenu=new JMenu("借书管理"); BorrowBookMenuItem=new JMenuItem("书籍出借"); BorrowInfoMenuItem=new JMenuItem("出借信息修改"); BorrowBookMenu.add(BorrowBookMenuItem); BorrowBookMenu.add(BorrowInfoMenuItem); BorrowBookMenuItem.addActionListener(this); BorrowInfoMenuItem.addActionListener(this); MenuB.add(BorrowBookMenu); //--还书管理菜单-- ReturnBookMenu=new JMenu("还书管理"); ReturnBookMenuItem=new JMenuItem("书籍还入"); ReturnInfoMenuItem=new JMenuItem("书籍还入信息修改"); ReturnBookMenu.add(ReturnBookMenuItem); ReturnBookMenu.add(ReturnInfoMenuItem); ReturnBookMenuItem.addActionListener(this); ReturnInfoMenuItem.addActionListener(this); MenuB.add(ReturnBookMenu); //--信息一览菜单-- InfoBrowseMenu=new JMenu("信息一览"); BookListMenuItem=new JMenuItem("书籍列表"); BorrowBookListMenuItem=new JMenuItem("借阅情况表"); UserListMenuItem=new JMenuItem("用户列表"); InfoBrowseMenu.add(BookListMenuItem); InfoBrowseMenu.add(BorrowBookListMenuItem); InfoBrowseMenu.add(UserListMenuItem); BookListMenuItem.addActionListener(this); BorrowBookListMenuItem.addActionListener(this); UserListMenuItem.addActionListener(this); MenuB.add(InfoBrowseMenu); //---------------------------------- setJMenuBar(MenuB); //titleLabel=new JLabel("欢迎使用图书管理系统",JLabel.CENTER); //titleLabel.setFont(new Font("TimesRoman",Font.BOLD,24)); //AuthorLabel=new JLabel("作者:麦密辉",JLabel.RIGHT); //DateLabel=new JLabel("完成时间:04-11-04",JLabel.RIGHT); titleLabel=new JLabel(new ImageIcon(".\\pic.jpg")); c=getContentPane(); c.setLayout(new BorderLayout()); panel1=new JPanel(); panel1.setLayout(new BorderLayout()); //panel2=new JPanel(); //panel2.setLayout(new BorderLayout()); panel1.add(titleLabel,BorderLayout.CENTER); //panel2.add(AuthorLabel,BorderLayout.NORTH); //panel2.add(DateLabel,BorderLayout.SOUTH); c.add(panel1,BorderLayout.CENTER); //c.add(panel2,BorderLayout.SOUTH); setBounds(100,50,400,300); show(); //--设置初始功能:-- UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(false); BorrowBookMenu.setEnabled(false); ReturnBookMenu.setEnabled(false); InfoBrowseMenu.setEnabled(false); } //--设置每个菜单点击后出现的窗口和窗口显示的位置-- public void actionPerformed(ActionEvent e) { if(e.getActionCommand()=="用户登录") { UserLogin UserLoginFrame=new UserLogin(this); Dimension FrameSize=UserLoginFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserLoginFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserLoginFrame.pack(); UserLoginFrame.show(); } else if(e.getActionCommand()=="添加用户") { UserAdd UserAddFrame=new UserAdd(); Dimension FrameSize=UserAddFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserAddFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserAddFrame.pack(); UserAddFrame.show(); } else if(e.getActionCommand()=="修改用户") { UserModify UserModifyFrame=new UserModify(); Dimension FrameSize=UserModifyFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserModifyFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserModifyFrame.pack(); UserModifyFrame.show(); } else if(e.getActionCommand()=="删除用户") { UserDelete UserDeleteFrame=new UserDelete(); Dimension FrameSize=UserDeleteFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserDeleteFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserDeleteFrame.pack(); UserDeleteFrame.show(); } else if(e.getActionCommand()=="添加书籍") { BookAdd BookAddFrame=new BookAdd(); Dimension FrameSize=BookAddFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookAddFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookAddFrame.pack(); BookAddFrame.show(); } else if(e.getActionCommand()=="修改书籍") { BookModify BookModifyFrame=new BookModify(); Dimension FrameSize=BookModifyFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookModifyFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookModifyFrame.pack(); BookModifyFrame.show(); } else if(e.getActionCommand()=="删除书籍") { BookDelete BookDeleteFrame=new BookDelete(); Dimension FrameSize=BookDeleteFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookDeleteFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookDeleteFrame.pack(); BookDeleteFrame.show(); } else if(e.getActionCommand()=="书籍出借") { BorrowBook BorrowBookFrame=new BorrowBook(); Dimension FrameSize=BorrowBookFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BorrowBookFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BorrowBookFrame.pack(); BorrowBookFrame.show(); } else if(e.getActionCommand()=="出借信息修改") { BorrowInfo BorrowInfoFrame=new BorrowInfo(); Dimension FrameSize=BorrowInfoFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BorrowInfoFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BorrowInfoFrame.pack(); BorrowInfoFrame.show(); } else if(e.getActionCommand()=="书籍还入") { ReturnBook ReturnBookFrame=new ReturnBook(); Dimension FrameSize=ReturnBookFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); ReturnBookFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); ReturnBookFrame.pack(); ReturnBookFrame.show(); } else if(e.getActionCommand()=="书籍还入信息修改") { ReturnInfo ReturnInfoFrame=new ReturnInfo(); Dimension FrameSize=ReturnInfoFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); ReturnInfoFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); ReturnInfoFrame.pack(); ReturnInfoFrame.show(); } else if(e.getActionCommand()=="书籍列表") { BookList BookListFrame=new BookList(); Dimension FrameSize=BookListFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BookListFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BookListFrame.pack(); BookListFrame.show(); } else if(e.getActionCommand()=="借阅情况表") { BorrowBookList BorrowBookListFrame=new BorrowBookList(); Dimension FrameSize=BorrowBookListFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); BorrowBookListFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); BorrowBookListFrame.pack(); BorrowBookListFrame.show(); } else if(e.getActionCommand()=="用户列表") { UserList UserListFrame=new UserList(); Dimension FrameSize=UserListFrame.getPreferredSize(); Dimension MainFrameSize=getSize(); Point loc=getLocation(); UserListFrame.setLocation((MainFrameSize.width-FrameSize.width)/2+loc.x, (MainFrameSize.height-FrameSize.height)/2+loc.y); UserListFrame.pack(); UserListFrame.show(); } else if(e.getActionCommand()=="退出") { this.dispose(); System.exit(0); } } //--设置登录用户的权限-- public void setEnable(String powerType) { if(powerType.trim().equals("系统管理员")) { UserMGRMenu.setEnabled(true); BookMGRMenu.setEnabled(true); BorrowBookMenu.setEnabled(true); ReturnBookMenu.setEnabled(true); InfoBrowseMenu.setEnabled(true); UserListMenuItem.setEnabled(true); } else if(powerType.trim().equals("书籍管理员")) { UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(true); BorrowBookMenu.setEnabled(false); ReturnBookMenu.setEnabled(false); InfoBrowseMenu.setEnabled(true); UserListMenuItem.setEnabled(false); } else if(powerType.trim().equals("借阅管理员")) { UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(false); BorrowBookMenu.setEnabled(true); ReturnBookMenu.setEnabled(true); InfoBrowseMenu.setEnabled(true); UserListMenuItem.setEnabled(false); } else if(powerType.trim().equals("else")) { UserMGRMenu.setEnabled(false); BookMGRMenu.setEnabled(false); BorrowBookMenu.setEnabled(false); ReturnBookMenu.setEnabled(false); InfoBrowseMenu.setEnabled(false); } } public static void main(String args[]) { MainWindow mainFrame=new MainWindow(); mainFrame.addWindowListener(new MyWindowListener()); } }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值