JAVA课程设计(基于UI的图书管理系统).pdf

上传人:w*** 文档编号:73493807 上传时间:2023-02-19 格式:PDF 页数:47 大小:1.21MB
返回 下载 相关 举报
JAVA课程设计(基于UI的图书管理系统).pdf_第1页
第1页 / 共47页
JAVA课程设计(基于UI的图书管理系统).pdf_第2页
第2页 / 共47页
点击查看更多>>
资源描述

《JAVA课程设计(基于UI的图书管理系统).pdf》由会员分享,可在线阅读,更多相关《JAVA课程设计(基于UI的图书管理系统).pdf(47页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、JAVA 课程设计报告(图书管理系统)1.系统目的与功能(1)本系统通链接 ACCESS 完成对用户信息和图书信息的管理,并制作可视化界面进行操作。(2)系统主要实现的功能有用户的登陆,图书的插入、修改、删除、查看、借阅、归还.2.开发工具 开发工具使用 Eclipse 作为主用开发环境,并使用VE 相关制作系统界面部分。3.系统说明(以下名字都是类名)1.Access 类来进行界面切换,数据库操作等.2.MainMenu、Regsdit 类是系统登陆界面和用户注册界面。3.MainCl 类是系统的主要界面.4.Insert、Look、Update、Delete、Sendbook、Backbo

2、ok类分别用来进行图书插入、图书信息查看、图书信息修改、图书删除、借阅图书、归还图书。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;String u

3、sername;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 Class。forNam

4、e(”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,String author,String publisher,JTextField tes

5、t)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.mdb;conn=DriverManager。getConnection(strurl);stmt=conn.createSt

6、atement();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 Class.forName(”sun。jdbc.odbc.JdbcOdbcDriver);String strurl=”jdbc:odbc:driv

7、er=Microsoft Access Driver(.mdb);DBQ=D:workspacebookmis。mdb”;conn=DriverManager。getConnection(strurl);stmt=conn.createStatement();catch(Exception e)public Access()try Class。forName(”sun.jdbc.odbc.JdbcOdbcDriver);String strurl=jdbc:odbc:driver=Microsoft Access Driver(*。mdb);DBQ=D:workspacebookmis.mdb

8、;conn=DriverManager.getConnection(strurl);stmt=conn。createStatement();catch(Exception e)public Access(String temp,JTextField test1)this.temp=temp;this.test1=test1;try Class.forName(”sun。jdbc.odbc.JdbcOdbcDriver”);String strurl=”jdbc:odbc:driver=Microsoft Access Driver(.mdb);DBQ=D:workspacebookmis。md

9、b;conn=DriverManager。getConnection(strurl);stmt=conn。createStatement();catch(Exception e)public Access(String aname,JPanel jpane,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);D

10、BQ=D:workspacebookmis.mdb;conn=DriverManager.getConnection(strurl);stmt=conn.createStatement();catch(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

11、:workspacebookmis.mdb;conn=DriverManager.getConnection(strurl);stmt=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

12、(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.getJFrame();else LoginFail loginfail=new LoginFail();loginfail.ge

13、tJDialog();catch(SQLException e)/TODO 自动生成 catch 块 e.printStackTrace();public void 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)tes

14、t。setText(”插入成功”);else test.setText(插入失败);public void look()Look alook=new Look();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 acou

15、nt=Integer.toString(count);String temp=书名:+bookname+”编号:”+bookid+作者:+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+”);catc

16、h(Exception e)if(result=1)test1。setText(删除成功”);else test1.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(”请输入正确的书名)

17、;catch(SQLException e)public void aupdate()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)jLabel。setText(修改成功);else jLabel。setText(修改失败”);

18、public 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(”书已经全部借完);return;stmt.executeUpdate(update bookmis set count=count-1 where bookname=+name+”);jLabel。setText(”借阅成功”);else jLabel。setText(没有这本

19、书);catch(SQLException e)e。printStackTrace();public void backbook()try stmt。executeUpdate(”update bookmis set count=count+1 where bookname=+name+);jLabel.setText(”还书成功”);catch(SQLException e)MainMenu类 package view;import javax。swing。JFrame;import javax。swing.JPanel;import java.awt。Dimension;import ja

20、vax.swing。JLabel;import java。awt。Rectangle;import javax.swing。JTextField;import javax.swing。JButton;import access.Access;import javax。swing。JPasswordField;public class MainMenu private JFrame jFrame=null;/jve:decl-index=0:visualconstraint=”159,78”private JPanel jContentPane=null;private JLabel jLabe

21、l=null;private JTextField jTextField=null;private JLabel jLabel1=null;private JButton jButton=null;private JButton jButton1=null;private JPasswordField jPasswordField=null;/*This method initializes jFrame return javax。swing.JFrame */public JFrame getJFrame()if(jFrame=null)jFrame=new JFrame();jFrame.

22、setSize(new Dimension(461,320);jFrame.setTitle(”图书管理系统登陆界面);jFrame.setContentPane(getJContentPane();jFrame.setVisible(true);return jFrame;/*This method initializes jContentPane return javax.swing。JPanel /private JPanel getJContentPane()if(jContentPane=null)jLabel1=new JLabel();jLabel1.setBounds(new

23、Rectangle(30,121,167,30);jLabel1.setText(密 码);jLabel=new JLabel();jLabel。setBounds(new 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。

24、add(getJButton(),null);jContentPane。add(getJButton1(),null);jContentPane。add(getJPasswordField(),null);return jContentPane;/*This method initializes jTextField *return javax。swing.JTextField /private JTextField getJTextField()if(jTextField=null)jTextField=new JTextField();jTextField。setBounds(new Re

25、ctangle(211,44,223,35));return jTextField;/*This method initializes jButton return javax.swing.JButton */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()

26、public void actionPerformed(java。awt.event.ActionEvent e)String 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 javax.swing。JButton /

27、private JButton getJButton1()if(jButton1=null)jButton1=new JButton();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。getJ

28、Frame();jFrame.setVisible(false););return jButton1;/*This method initializes jPasswordField *return javax.swing.JPasswordField */private JPasswordField getJPasswordField()if(jPasswordField=null)jPasswordField=new JPasswordField();jPasswordField。setBounds(new Rectangle(211,121,225,29);return jPasswor

29、dField;public static void main(String a)MainMenu mainmenu=new 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 jFram

30、e=null;/jve:decl-index=0:visualconstraint=”203,74”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 jBut

31、ton4=null;private JButton jButton5=null;private JButton jButton6=null;/*This method initializes jFrame *return javax。swing。JFrame /public JFrame getJFrame()if(jFrame=null)jFrame=new JFrame();jFrame.setSize(new Dimension(420,333));jFrame.setTitle(图书管理系统);jFrame.setContentPane(getJPanel());jFrame.setV

32、isible(true);return jFrame;/*This method initializes jPanel *return javax.swing.JPanel /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

33、。add(getJButton3(),null);jPanel.add(getJButton4(),null);jPanel.add(getJButton5(),null);jPanel.add(getJButton6(),null);return jPanel;/*This method initializes jPanel1 *return javax。swing。JPanel */private JPanel getJPanel1()if(jPanel1=null)jLabel7=new JLabel();jLabel7.setBounds(new Rectangle(6,21,376,

34、18);jLabel7。setText(插入,修改,删除操作仅管理员可以操作。);jLabel6=new JLabel();jLabel6.setBounds(new Rectangle(6,1,382,22);jLabel6。setText(相关操作提示;”);jPanel1=new JPanel();jPanel1。setLayout(null);jPanel1.setBounds(new Rectangle(12,211,391,41));jPanel1。add(jLabel6,null);jPanel1。add(jLabel7,null);return jPanel1;/*This m

35、ethod initializes jButton *return javax.swing.JButton /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 actionPerformed(java.awt.event.ActionE

36、vent e)Insert insert=new Insert();insert。getJFrame();jFrame.setVisible(false););return jButton;/*This method initializes jButton1 *return javax.swing.JButton /private JButton getJButton1()if(jButton1=null)jButton1=new JButton();jButton1。setBounds(new Rectangle(15,105,151,31));jButton1。setText(修改书);j

37、Button1。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 javax。swing.JButton */private JButton getJButton2()if(jButton2=null)jBu

38、tton2=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(false););return jButton2;/*This method initializ

39、es jButton3 *return javax.swing。JButton /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()public void actionPerformed(java。awt.event。ActionEvent e)

40、Access access=new Access();access。look(););return jButton3;/This method initializes jButton4 *return javax。swing。JButton /private JButton getJButton4()if(jButton4=null)jButton4=new JButton();jButton4.setBounds(new Rectangle(211,104,150,35));jButton4.setText(”借阅书);jButton4。addActionListener(new java。

41、awt.event.ActionListener()public void actionPerformed(java.awt。event。ActionEvent e)new Sendbook().getJFrame();jFrame.setVisible(false););return jButton4;/*This method initializes jButton5 *return javax.swing。JButton /private JButton getJButton5()if(jButton5=null)jButton5=new JButton();jButton5.setBo

42、unds(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(false););return jButton5;/*This method initializes jButton6 return javax。swin

43、g。JButton */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()public void actionPerformed(java。awt.event。ActionEvent e)System。exit(0););return jBut

44、ton6;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;import access。Access;public class Insert private JFrame jFrame=null;/jve:declindex=0:vi

45、sualconstraint=203,93”private JPanel jContentPane=null;private JLabel jLabel=null;private JLabel jLabel1=null;private JLabel jLabel2=null;private JLabel jLabel3=null;private JTextField jTextField=null;private JTextField jTextField1=null;private JTextField jTextField2=null;private JTextField jTextFie

46、ld3=null;private JButton jButton=null;private JButton jButton1=null;private JTextField jTextField4=null;private JButton jButton2=null;/*This method initializes jFrame *return javax。swing。JFrame */public JFrame getJFrame()if(jFrame=null)jFrame=new JFrame();jFrame。setSize(new Dimension(418,303);jFrame

47、.setTitle(插入新书);jFrame.setContentPane(getJContentPane();jFrame.setVisible(true);return jFrame;/*This method initializes jContentPane return javax.swing.JPanel /private JPanel getJContentPane()if(jContentPane=null)jLabel3=new JLabel();jLabel3。setBounds(new Rectangle(16,164,181,31);jLabel3.setText(”请输

48、入要插入书的出版社:”);jLabel2=new JLabel();jLabel2.setBounds(new Rectangle(15,120,182,31));jLabel2。setText(”请输入要插入书的作者:);jLabel1=new JLabel();jLabel1。setBounds(new Rectangle(16,77,182,29));jLabel1.setText(请输入要插入书的编号:”);jLabel=new JLabel();jLabel.setBounds(new Rectangle(17,32,181,29));jLabel。setText(请输入要插入书的书

49、名:”);jContentPane=new JPanel();jContentPane.setLayout(null);jContentPane。add(jLabel,null);jContentPane。add(jLabel1,null);jContentPane。add(jLabel2,null);jContentPane。add(jLabel3,null);jContentPane。add(getJTextField(),null);jContentPane.add(getJTextField1(),null);jContentPane.add(getJTextField2(),null

50、);jContentPane。add(getJTextField3(),null);jContentPane。add(getJButton(),null);jContentPane。add(getJButton1(),null);jContentPane。add(getJTextField4(),null);jContentPane.add(getJButton2(),null);return jContentPane;/*This method initializes jTextField return javax。swing。JTextField /private JTextField g

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 应用文书 > 工作报告

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁