1、JAVA课程设计基于UI的图书管理系统JAVA课程设计报告(图书管理系统)1. 系统目的与功能(1)本系统通链接ACCESS完成对用户信息和图书信息的管理,并制作可视化界面进行操作。(2)系统主要实现的功能有用户的登陆,图书的插入、修改、删除、查看、借阅、归还。2. 开发工具开发工具使用Eclipse作为主用开发环境,并使用VE相关制作系统界面部分。3. 系统说明(以下名字都是类名)1. Access类来进行界面切换,数据库操作等。2. MainMenu、Regsdit类是系统登陆界面和用户注册界面。3. MainCl类是系统的主要界面。4. Insert、Look、Update、Delete
2、、Sendbook、Backbook类分别用来进行图书插入、图书信息查看、图书信息修改、图书删除、借阅图书、归还图书。5. 程序代码Access类package access;import java.sql.*;importimportimportimport view.*;public class Access Connection conn = null; Statement stmt = null; ResultSet rs = null; PreparedStatement ps = null; String username; String temp; String password
3、; String bookname; String bookid; String author; String publisher; String name; int count; JTextField test; JTextField test1; JLabel jLabel; JPanel jpane; int result=0; public Access(String username, String password) this.username = username; this.password = password; try Class.forName(); String str
4、url = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; conn = DriverManager.getConnection(strurl); stmt = conn.createStatement(); catch (Exception e) public Access(String bookname,String bookid,String author,String publisher,JTextField test) this.bookname=bookname; this.b
5、ookid=bookid; this.author=author; this.publisher=publisher; this.test=test; try Class.forName(); String strurl = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; conn = DriverManager.getConnection(strurl); stmt = conn.createStatement(); catch (Exception e) public Access(S
6、tring bookname,String bookid,String author,String publisher,JLabel jlabel) this.bookname=bookname; this.bookid=bookid; this.author=author; this.publisher=publisher; this.jLabel=jlabel; try Class.forName(); String strurl = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; c
7、onn = DriverManager.getConnection(strurl); stmt = conn.createStatement(); catch (Exception e) public Access() try Class.forName(); String strurl = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; conn = DriverManager.getConnection(strurl); stmt = conn.createStatement(); c
8、atch (Exception e) public Access(String temp,JTextField test1) this.temp=temp; this.test1=test1; try Class.forName(); String strurl = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; conn = DriverManager.getConnection(strurl); stmt = conn.createStatement(); catch (Excepti
9、on e) public Access(String aname,JPanel jpane,JLabel jLabel) name=aname; this.jpane=jpane; this.jLabel=jLabel; try Class.forName(); String strurl = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; conn = DriverManager.getConnection(strurl); stmt = conn.createStatement();
10、catch (Exception e) public Access(String aname,JLabel jLabel) name=aname; this.jLabel=jLabel; try Class.forName(); String strurl = jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb; conn = DriverManager.getConnection(strurl); stmt = conn.createStatement(); catch (Exception
11、e) public void regsdit() try result=stmt.executeUpdate(insert into userinform(username,password) values(+username+,+password+); catch (SQLException e) / TODO 自动生成 catch 块 new Fail().getJDialog(); if (result = 1) MainMenu mainmenu = new MainMenu(); mainmenu.getJFrame(); else public void login() try r
12、s=stmt.executeQuery(select * from userinform where username=+username+ and password=+password+); if(rs.next() MainCl maincl =new MainCl(); maincl.getJFrame(); else LoginFail loginfail=new LoginFail(); loginfail.getJDialog(); catch (SQLException e) / TODO 自动生成 catch 块 e.printStackTrace(); public void
13、 insert() try result=stmt.executeUpdate(insert into bookmis(bookname,num,auther,publisher) values(+bookname+,+bookid+,+author+,+publisher+); catch (SQLException e) / TODO 自动生成 catch 块 e.printStackTrace(); if(result=1) test.setText(插入成功); else test.setText(插入失败); public void look() Look alook =new Lo
14、ok(); try rs = stmt.executeQuery(select * from bookmis); while (rs.next() bookname=rs.getString(bookname); bookid=rs.getString(num); author=rs.getString(auther); publisher=rs.getString(publisher); count=rs.getInt(count); String acount=Integer.toString(count); String temp=书名: +bookname+ 编号: +bookid+
15、作者: +author+ 出版社: +publisher+ 数量:+acount; alook.getList().add(temp); alook.getJFrame(); alook.getList().add(nnnn); catch(Exception e) public void delete() tryresult=0; result=stmt.executeUpdate(delete from bookmis where bookname=+temp+); catch(Exception e) if(result=1) test1.setText(删除成功); else test
16、1.setText(删除失败,你输入的书名有误); public void update() try rs = stmt.executeQuery(select * from bookmis where bookname=+name+); if(rs.next() stmt.executeUpdate(delete from bookmis where bookname=+name+); jpane.setVisible(true); else jLabel.setText(请输入正确的书名); catch (SQLException e) public void aupdate() try
17、result=stmt.executeUpdate(insert into bookmis(bookname,num,auther,publisher) values(+bookname+,+bookid+,+author+,+publisher+); catch (SQLException e) / TODO 自动生成 catch 块 e.printStackTrace(); if(result=1) jLabel.setText(修改成功); else jLabel.setText(修改失败); public void sendbook() try rs = stmt.executeQue
18、ry(select * from bookmis where bookname=+name+); if(rs.next() int bcount=rs.getInt(count); if(bcount=0) jLabel.setText(书已经全部借完);return; stmt.executeUpdate(update bookmis set count=count-1 where bookname=+name+); jLabel.setText(借阅成功); else jLabel.setText(没有这本书); catch (SQLException e) e.printStackTra
19、ce(); public void backbook() try stmt.executeUpdate(update bookmis set count=count+1 where bookname=+name+); jLabel.setText(还书成功); catch (SQLException e) MainMenu类package view;importimportimportimportimportimportimportimport access.Access;importpublic class MainMenu private JFrame jFrame = null; / j
20、ve:decl-index=0:visual-constraint=159,78 private JPanel jContentPane = null; private JLabel jLabel = null; private JTextField jTextField = null; private JLabel jLabel1 = null; private JButton jButton = null; private JButton jButton1 = null; private JPasswordField jPasswordField = null; /* * This met
21、hod initializes jFrame * * return */ public JFrame getJFrame() if (jFrame = null) jFrame = new JFrame(); jFrame.setSize(new Dimension(461, 320); jFrame.setTitle(图书管理系统登陆界面); jFrame.setContentPane(getJContentPane(); jFrame.setVisible(true); return jFrame; /* * This method initializes jContentPane * *
22、 return */ private JPanel getJContentPane() if (jContentPane = null) jLabel1 = new JLabel(); jLabel1.setBounds(new Rectangle(30, 121, 167, 30); jLabel1.setText( 密 码); jLabel = new JLabel(); jLabel.setBounds(new Rectangle(30, 45, 167, 31); jLabel.setText( 用户名); jContentPane = new JPanel(); jContentPa
23、ne.setLayout(null); jContentPane.add(jLabel, null); jContentPane.add(getJTextField(), null); jContentPane.add(jLabel1, null); jContentPane.add(getJButton(), null); jContentPane.add(getJButton1(), null); jContentPane.add(getJPasswordField(), null); return jContentPane; /* * This method initializes jT
24、extField * * return */ private JTextField getJTextField() if (jTextField = null) jTextField = new JTextField(); jTextField.setBounds(new Rectangle(211, 44, 223, 35); return jTextField; /* * This method initializes jButton * * return */ private JButton getJButton() if (jButton = null) jButton = new J
25、Button(); jButton.setBounds(new Rectangle(61, 211, 121, 32); jButton.setText(登陆); jButton.addActionListener(newr() public void String username=jTextField.getText(); String password=jPasswordField.getText(); Access access=new Access(username,password); access.login(); jFrame.setVisible(false); ); ret
26、urn jButton; /* * This method initializes jButton1 * * return */ private JButton getJButton1() if (jButton1 = null) jButton1 = new JButton(); jButton1.setBounds(new Rectangle(269, 210, 139, 32); jButton1.setText(注册); jButton1.addActionListener(new public void Regsdit regsdit=new Regsdit(); regsdit.g
27、etJFrame(); jFrame.setVisible(false); ); return jButton1; /* * This method initializes jPasswordField * * return */ private JPasswordField getJPasswordField() if (jPasswordField = null) jPasswordField = new JPasswordField(); jPasswordField.setBounds(new Rectangle(211, 121, 225, 29); return jPasswordField; public static void main(String a) MainMenu mainmenu=new MainMenu(); mainmenu.getJFrame(); MainCl类package view;importimportimportimportimport ja
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1