




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、JAVA課程設(shè)計報告(圖書管理系統(tǒng))1. 系統(tǒng)目的與功能(1)本系統(tǒng)通鏈接ACCESS完成對用戶信息和圖書信息的管理,并制作可視化界面進(jìn)行操作。(2)系統(tǒng)主要實現(xiàn)的功能有用戶的登陸,圖書的插入、修改、刪除、查看、借閱、歸還。2. 開發(fā)工具開發(fā)工具使用Eclipse作為主用開發(fā)環(huán)境,并使用VE相關(guān)制作系統(tǒng)界面部分。3. 系統(tǒng)說明(以下名字都是類名)1. Access類來進(jìn)行界面切換,數(shù)據(jù)庫操作等。2. MainMenu、Regsdit類是系統(tǒng)登陸界面和用戶注冊界面。3. MainCl類是系統(tǒng)的主要界面。4. Insert、Look、Update、Delete、Sendbook、Backbook類
2、分別用來進(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 自動生成 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 自動生成 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 自動生成 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+" 編號: "+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("請輸入正確的書名"); 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 自動生成 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("沒有這本書"); 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("注冊");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("請輸入要插入書的出版社:");jLabel2 =
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 項目合作收尾協(xié)議書
- DB36-T1630-2022-修水寧紅茶種植技術(shù)規(guī)程-江西省
- 艾灸治療腰部疼痛
- 2025年北京市大興區(qū)九年級初三二模物理試卷(含答案)
- 高中化學(xué)平衡常數(shù)與轉(zhuǎn)化率專題訓(xùn)練:2025年高考模擬題庫
- 2025年高考化學(xué)沖刺:化學(xué)反應(yīng)速率與平衡圖像專項突破卷
- 2025年資產(chǎn)評估實務(wù)模擬試卷:不動產(chǎn)評估與機器設(shè)備評估技巧詳解與策略應(yīng)用
- 廣東省汕尾市2025學(xué)年八年級上學(xué)期有機化學(xué)命名與結(jié)構(gòu)能力測試題
- 2025年英國大學(xué)入學(xué)考試(UCAT)醫(yī)德與決策模擬試題庫(醫(yī)學(xué)倫理與臨床決策)
- 2025年教學(xué)進(jìn)度調(diào)整審批的科研支持政策
- GB/T 3299-2011日用陶瓷器吸水率測定方法
- GB/T 18867-2014電子工業(yè)用氣體六氟化硫
- GB/T 17793-1999一般用途的加工銅及銅合金板帶材外形尺寸及允許偏差
- FZ/T 51011-2014纖維級聚己二酰己二胺切片
- ICU常見檢查項目及課件
- 《月光下的中國》朗誦稿
- 土地荒漠化的防治(公開課)課件
- 中考備考應(yīng)對中考?xì)v史學(xué)科的復(fù)習(xí)策略和解題技巧課件
- 第15課《驛路梨花》教學(xué)實錄
- 思想道德修養(yǎng)與法律基礎(chǔ)(完整版PPT)
- 全文解讀中國式現(xiàn)代化解讀學(xué)習(xí)PPT
評論
0/150
提交評論