




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、JAVA課程設(shè)計(jì)報(bào)告(圖書管理系統(tǒng))1. 系統(tǒng)目的與功能(1)本系統(tǒng)通鏈接ACCESS完成對(duì)用戶信息和圖書信息的管理,并制作可視化界面進(jìn)行操作。(2)系統(tǒng)主要實(shí)現(xiàn)的功能有用戶的登陸,圖書的插入、修改、刪除、查看、借閱、歸還。2. 開發(fā)工具開發(fā)工具使用Eclipse作為主用開發(fā)環(huán)境,并使用VE相關(guān)制作系統(tǒng)界面部分。3. 系統(tǒng)說(shuō)明(以下名字都是類名)1. Access類來(lái)進(jìn)行界面切換,數(shù)據(jù)庫(kù)操作等。2. MainMenu、Regsdit類是系統(tǒng)登陸界面和用戶注冊(cè)界面。3. MainCl類是系統(tǒng)的主要界面。4. Insert、Look、Update、Delete、Sendbook、Backbook類
2、分別用來(lái)進(jìn)行圖書插入、圖書信息查看、圖書信息修改、圖書刪除、借閱圖書、歸還圖書。5. 程序代碼Access類package access;import java.sql.*;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JTextField;import view.*;public class Access Connection conn = null;Statement stmt = null;ResultSet rs = null;PreparedStatement ps = null;Stri
3、ng username; String temp;String password;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 C
4、lass.forName("sun.jdbc.odbc.JdbcOdbcDriver");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(String bookname,String bookid,Stri
5、ng author,String publisher,JTextField test) this.bookname=bookname;this.bookid=bookid;this.author=author;this.publisher=publisher;this.test=test;try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");String strurl = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.m
6、db"conn = DriverManager.getConnection(strurl);stmt = conn.createStatement(); catch (Exception e) public Access(String 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
7、 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");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() try Class.forName("sun.jd
8、bc.odbc.JdbcOdbcDriver");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(String temp,JTextField test1) this.temp=temp;this.test1=tes
9、t1;try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");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(String aname,JPanel jpane,
10、JLabel jLabel) name=aname;this.jpane=jpane;this.jLabel=jLabel;try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");String strurl = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb"conn = DriverManager.getConnection(strurl);stmt = conn.createStatement(); c
11、atch (Exception e) public Access(String aname,JLabel jLabel) name=aname;this.jLabel=jLabel;try Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");String strurl = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=D:workspacebookmis.mdb"conn = DriverManager.getConnection(strurl);stm
12、t = conn.createStatement(); catch (Exception e) public void regsdit() try result=stmt.executeUpdate("insert into userinform(username,password) values('"+username+"','"+password+"')"); catch (SQLException e) / TODO 自動(dòng)生成 catch 塊new Fail().getJDialog();if (
13、result = 1) MainMenu mainmenu = new MainMenu();mainmenu.getJFrame(); else public void login() try rs=stmt.executeQuery("select * from userinform where username='"+username+"' and password='"+password+"'");if(rs.next()MainCl maincl =new MainCl();maincl.ge
14、tJFrame();else LoginFail loginfail=new LoginFail();loginfail.getJDialog(); catch (SQLException e) / TODO 自動(dòng)生成 catch 塊e.printStackTrace();public void insert() try result=stmt.executeUpdate("insert into bookmis(bookname,num,auther,publisher) values('"+bookname+"','"+boo
15、kid+"','"+author+"','"+publisher+"')"); catch (SQLException e) / TODO 自動(dòng)生成 catch 塊e.printStackTrace();if(result=1)test.setText("插入成功");else test.setText("插入失敗");public void look() Look alook =new Look();tryrs = stmt.executeQuery(&
16、quot;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 te
17、mp="書名: "+bookname+" 編號(hào): "+bookid+" 作者: "+author+" 出版社: "+publisher+" 數(shù)量:"+acount;alook.getList().add(temp);alook.getJFrame();alook.getList().add("nnnn");catch(Exception e)public void delete() tryresult=0;result=stmt.executeUpdate("del
18、ete from bookmis where bookname='"+temp+"'");catch(Exception e)if(result=1)test1.setText("刪除成功");else test1.setText("刪除失敗,你輸入的書名有誤");public void update() try rs = stmt.executeQuery("select * from bookmis where bookname='"+name+"'"
19、;);if(rs.next()stmt.executeUpdate("delete from bookmis where bookname='"+name+"'");jpane.setVisible(true);elsejLabel.setText("請(qǐng)輸入正確的書名"); catch (SQLException e) public void aupdate() try result=stmt.executeUpdate("insert into bookmis(bookname,num,auther,pub
20、lisher) values('"+bookname+"','"+bookid+"','"+author+"','"+publisher+"')"); catch (SQLException e) / TODO 自動(dòng)生成 catch 塊e.printStackTrace();if(result=1)jLabel.setText("修改成功");else jLabel.setText("修改失敗");pu
21、blic void sendbook() try rs = stmt.executeQuery("select * from bookmis where bookname='"+name+"'");if(rs.next()int bcount=rs.getInt("count");if(bcount<=0)jLabel.setText("書已經(jīng)全部借完");return;stmt.executeUpdate("update bookmis set count=count-1 wher
22、e bookname='"+name+"'");jLabel.setText("借閱成功");elsejLabel.setText("沒(méi)有這本書"); catch (SQLException e) e.printStackTrace();public void backbook() try stmt.executeUpdate("update bookmis set count=count+1 where bookname='"+name+"'");jL
23、abel.setText("還書成功"); catch (SQLException e) MainMenu類package view;import javax.swing.JFrame;import javax.swing.JPanel;import java.awt.Dimension;import javax.swing.JLabel;import java.awt.Rectangle;import javax.swing.JTextField;import javax.swing.JButton;import access.Access;import javax.sw
24、ing.JPasswordField;public class MainMenu private JFrame jFrame = null; / jve: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 JBut
25、ton jButton1 = null;private JPasswordField jPasswordField = null;/* * This method initializes jFrame * * return */public JFrame getJFrame() if (jFrame = null) jFrame = new JFrame();jFrame.setSize(new Dimension(461, 320);jFrame.setTitle("圖書管理系統(tǒng)登陸界面");jFrame.setContentPane(getJContentPane();
26、jFrame.setVisible(true);return jFrame;/* * This method initializes jContentPane * * 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
27、 Rectangle(30, 45, 167, 31);jLabel.setText(" 用戶名");jContentPane = new JPanel();jContentPane.setLayout(null);jContentPane.add(jLabel, null);jContentPane.add(getJTextField(), null);jContentPane.add(jLabel1, null);jContentPane.add(getJButton(), null);jContentPane.add(getJButton1(), null);jCon
28、tentPane.add(getJPasswordField(), null);return jContentPane;/* * This method initializes jTextField * * return */private JTextField getJTextField() if (jTextField = null) jTextField = new JTextField();jTextField.setBounds(new Rectangle(211, 44, 223, 35);return jTextField;/* * This method initializes
29、 jButton * * return */private JButton getJButton() if (jButton = null) jButton = new JButton();jButton.setBounds(new Rectangle(61, 211, 121, 32);jButton.setText("登陸");jButton.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) Str
30、ing username=jTextField.getText();String password=jPasswordField.getText();Access access=new Access(username,password);access.login();jFrame.setVisible(false););return jButton;/* * This method initializes jButton1 * * return */private JButton getJButton1() if (jButton1 = null) jButton1 = new JButton
31、();jButton1.setBounds(new Rectangle(269, 210, 139, 32);jButton1.setText("注冊(cè)");jButton1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) Regsdit regsdit=new Regsdit();regsdit.getJFrame();jFrame.setVisible(false););return jButton
32、1;/* * 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=ne
33、w MainMenu();mainmenu.getJFrame();MainCl類package view;import javax.swing.JFrame;import javax.swing.JPanel;import java.awt.Dimension;import java.awt.Rectangle;import javax.swing.*;import access.Access;public class MainCl private JFrame jFrame = null; / jve:decl-index=0:visual-constraint="203,74&
34、quot;private JPanel jPanel = null;private JPanel jPanel1 = null;private JLabel jLabel6 = null;private JLabel jLabel7 = null;private JButton jButton = null;private JButton jButton1 = null;private JButton jButton2 = null;private JButton jButton3 = null;private JButton jButton4 = null;private JButton j
35、Button5 = null;private JButton jButton6 = null;/* * This method initializes jFrame * * return */public JFrame getJFrame() if (jFrame = null) jFrame = new JFrame();jFrame.setSize(new Dimension(420, 333);jFrame.setTitle("圖書管理系統(tǒng)");jFrame.setContentPane(getJPanel();jFrame.setVisible(true);retu
36、rn jFrame;/* * This method initializes jPanel * * return */private JPanel getJPanel() if (jPanel = null) jPanel = new JPanel();jPanel.setLayout(null);jPanel.add(getJPanel1(), null);jPanel.add(getJButton(), null);jPanel.add(getJButton1(), null);jPanel.add(getJButton2(), null);jPanel.add(getJButton3()
37、, null);jPanel.add(getJButton4(), null);jPanel.add(getJButton5(), null);jPanel.add(getJButton6(), null);return jPanel;/* * This method initializes jPanel1 * * return */private JPanel getJPanel1() if (jPanel1 = null) jLabel7 = new JLabel();jLabel7.setBounds(new Rectangle(6, 21, 376, 18);jLabel7.setTe
38、xt(" 插入,修改,刪除操作僅管理員可以操作。");jLabel6 = new JLabel();jLabel6.setBounds(new Rectangle(6, 1, 382, 22);jLabel6.setText("相關(guān)操作提示;");jPanel1 = new JPanel();jPanel1.setLayout(null);jPanel1.setBounds(new Rectangle(12, 211, 391, 41);jPanel1.add(jLabel6, null);jPanel1.add(jLabel7, null);retur
39、n jPanel1;/* * This method initializes jButton * * return */private JButton getJButton() if (jButton = null) jButton = new JButton();jButton.setBounds(new Rectangle(15, 44, 150, 34);jButton.setText("插入書");jButton.addActionListener(new java.awt.event.ActionListener() public void actionPerfo
40、rmed(java.awt.event.ActionEvent e) Insert insert=new Insert();insert.getJFrame();jFrame.setVisible(false););return jButton;/* * This method initializes jButton1 * * return */private JButton getJButton1() if (jButton1 = null) jButton1 = new JButton();jButton1.setBounds(new Rectangle(15, 105, 151, 31)
41、;jButton1.setText("修改書");jButton1.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) new Update().getJFrame();jFrame.setVisible(false););return jButton1;/* * This method initializes jButton2 * * return */private JButton getJButto
42、n2() if (jButton2 = null) jButton2 = new JButton();jButton2.setBounds(new Rectangle(16, 164, 150, 31);jButton2.setText("刪除書");jButton2.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) new Delete().getJFrame();jFrame.setVisible(
43、false););return jButton2;/* * This method initializes jButton3 * * return */private JButton getJButton3() if (jButton3 = null) jButton3 = new JButton();jButton3.setBounds(new Rectangle(211, 45, 150, 33);jButton3.setText("查看書");jButton3.addActionListener(new java.awt.event.ActionListener()
44、public void actionPerformed(java.awt.event.ActionEvent e) Access access=new Access();access.look(););return jButton3;/* * This method initializes jButton4 * * return */private JButton getJButton4() if (jButton4 = null) jButton4 = new JButton();jButton4.setBounds(new Rectangle(211, 104, 150, 35);jBut
45、ton4.setText("借閱書");jButton4.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) new Sendbook().getJFrame();jFrame.setVisible(false););return jButton4;/* * This method initializes jButton5 * * return */private JButton getJButton5(
46、) if (jButton5 = null) jButton5 = new JButton();jButton5.setBounds(new Rectangle(213, 166, 149, 29);jButton5.setText("歸還書");jButton5.addActionListener(new java.awt.event.ActionListener() public void actionPerformed(java.awt.event.ActionEvent e) new Backbook().getJFrame();jFrame.setVisible(
47、false););return jButton5;/* * This method initializes jButton6 * * return */private JButton getJButton6() if (jButton6 = null) jButton6 = new JButton();jButton6.setBounds(new Rectangle(265, 261, 94, 27);jButton6.setText("退出");jButton6.addActionListener(new java.awt.event.ActionListener() p
48、ublic void actionPerformed(java.awt.event.ActionEvent e) System.exit(0););return jButton6;Insert類package view;import javax.swing.JFrame;import javax.swing.JPanel;import java.awt.Dimension;import javax.swing.JLabel;import java.awt.Rectangle;import javax.swing.JTextField;import javax.swing.JButton;imp
49、ort access.Access;public class Insert private JFrame jFrame = null; / jve:decl-index=0:visual-constraint="203,93"private JPanel jContentPane = null;private JLabel jLabel = null;private JLabel jLabel1 = null;private JLabel jLabel2 = null;private JLabel jLabel3 = null;private JTextField jTex
50、tField = null;private JTextField jTextField1 = null;private JTextField jTextField2 = null;private JTextField jTextField3 = null;private JButton jButton = null;private JButton jButton1 = null;private JTextField jTextField4 = null;private JButton jButton2 = null;/* * This method initializes jFrame * *
51、 return */public JFrame getJFrame() if (jFrame = null) jFrame = new JFrame();jFrame.setSize(new Dimension(418, 303);jFrame.setTitle("插入新書");jFrame.setContentPane(getJContentPane();jFrame.setVisible(true);return jFrame;/* * This method initializes jContentPane * * return */private JPanel getJContentPane() if (jContentPane = null) jLabel3 = new JLabel();jLabel3.setBounds(new Rectangle(16, 164, 181, 31);jLabel3.setText("請(qǐng)輸入要插入書的出版社:");jLabel2 =
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 浙江國(guó)企招聘2025臺(tái)州灣新區(qū)招聘7人筆試參考題庫(kù)附帶答案詳解
- 浙江國(guó)企招聘2024浙江省文化產(chǎn)業(yè)投資集團(tuán)有限公司招聘14人筆試參考題庫(kù)附帶答案詳解
- 二零二五年度企業(yè)入駐高新技術(shù)產(chǎn)業(yè)園區(qū)入駐合同
- 二零二五年度工程款抵扣工程結(jié)算審計(jì)協(xié)議
- 二零二五年度地下停車場(chǎng)車位出售合同協(xié)議
- 二零二五年度事業(yè)單位解聘合同模板(綠化養(yǎng)護(hù)人員崗位)
- 2025年度深圳租房合同租賃期限變更與租賃物維護(hù)服務(wù)協(xié)議
- 二零二五年度電商直播平臺(tái)主播勞動(dòng)合同
- 2025年度新能源儲(chǔ)能技術(shù)股東合作協(xié)議書
- 二零二五年度新能源電池回收利用合作開發(fā)協(xié)議范本
- 《走近世界民間美術(shù)》 課件 2024-2025學(xué)年人美版(2024)初中美術(shù)七年級(jí)下冊(cè)
- (正式版)JBT 14449-2024 起重機(jī)械焊接工藝評(píng)定
- 河北單招考試三類職業(yè)適應(yīng)性測(cè)試考試題與答案
- 中交項(xiàng)目標(biāo)準(zhǔn)化手冊(cè)-第一冊(cè)工地建設(shè)
- 茂名市2008-2016年土地增值稅工程造價(jià)核定扣除標(biāo)準(zhǔn)
- 部編版語(yǔ)文九年級(jí)下冊(cè)《棗兒》公開課一等獎(jiǎng)教案
- L阿拉伯糖與排毒課件
- 《現(xiàn)代交換原理》期末考試試習(xí)題和答案(免費(fèi))
- 手機(jī)開發(fā)流程圖
- 隊(duì)列隊(duì)形比賽評(píng)分標(biāo)準(zhǔn)
- 生產(chǎn)礦井儲(chǔ)量管理規(guī)程
評(píng)論
0/150
提交評(píng)論