1、 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 stru
2、rl = 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.bo
3、okid=bookid; this.author=author; this.publisher=publisher; this.test=test; public Access(String bookname,String bookid,String author,String publisher,JLabel jlabel) this.jLabel=jlabel; public Access() public Access(String temp,JTextField test1) this.temp=temp; this.test1=test1; public Access(String
4、aname,JPanel jpane,JLabel jLabel) name=aname; this.jpane=jpane; this.jLabel=jLabel; public Access(String aname,JLabel jLabel) public void regsdit() result=stmt.executeUpdate(insert into userinform(username,password) values(+username+,+password+); catch (SQLException e) / TODO 自动生成 catch 块 new Fail()
5、.getJDialog(); if (result = 1) MainMenu mainmenu = new MainMenu(); mainmenu.getJFrame(); else public void login() rs=stmt.executeQuery(select * from userinform where username= and password= if(rs.next() MainCl maincl =new MainCl(); maincl.getJFrame(); else LoginFail loginfail=new LoginFail(); loginf
6、ail.getJDialog(); e.printStackTrace(); public void insert() insert into bookmis(bookname,num,auther,publisher) values(+bookname+bookid+author+publisher+ if(result=1) test.setText(插入成功 else test.setText(插入失败 public void look() Look alook =new Look(); try rs = stmt.executeQuery(select * from bookmis w
7、hile (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=书名: 编号: 作者: 出版社: 数量:+acount; alook.getList().add(temp); alook.getJFrame(); alook.getList().add(n
8、nnn catch(Exception e) public void delete() tryresult=0;delete from bookmis where bookname=+temp+ catch(Exception e) if(result=1) test1.setText(删除成功 else test1.setText(删除失败,你输入的书名有误 public void update() rs = stmt.executeQuery(select * from bookmis where bookname=+name+ if(rs.next() stmt.executeUpdat
9、e( jpane.setVisible(true); else jLabel.setText(请输入正确的书名 catch (SQLException e) public void aupdate() 修改成功 else jLabel.setText(修改失败 public void sendbook() int bcount=rs.getInt( if(bcount=0) jLabel.setText(书已经全部借完return; stmt.executeUpdate(update bookmis set count=count-1 where bookname=借阅成功没有这本书 publ
10、ic void backbook() update bookmis set count=count+1 where bookname=还书成功MainMenu类package view;import access.Access;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 jText
11、Field = null; private JLabel jLabel1 = null; private JButton jButton = null; private JButton jButton1 = null; private JPasswordField jPasswordField = null; /* * This method initializes jFrame * * return */ public JFrame getJFrame() if (jFrame = null) jFrame = new JFrame(); jFrame.setSize(new Dimensi
12、on(461, 320); jFrame.setTitle(图书管理系统登陆界面 jFrame.setContentPane(getJContentPane(); jFrame.setVisible(true); return jFrame; * This method initializes jContentPane private JPanel getJContentPane() if (jContentPane = null) jLabel1 = new JLabel(); jLabel1.setBounds(new Rectangle(30, 121, 167, 30); jLabel
13、1.setText( 密 码 jLabel = new JLabel(); jLabel.setBounds(new Rectangle(30, 45, 167, 31); 用户名 jContentPane = new JPanel(); jContentPane.setLayout(null); jContentPane.add(jLabel, null); jContentPane.add(getJTextField(), null); jContentPane.add(jLabel1, null); jContentPane.add(getJButton(), null); jConte
14、ntPane.add(getJButton1(), null); jContentPane.add(getJPasswordField(), null); return jContentPane; * This method initializes jTextField private JTextField getJTextField() if (jTextField = null) jTextField = new JTextField(); jTextField.setBounds(new Rectangle(211, 44, 223, 35); return jTextField; *
15、This method initializes jButton private JButton getJButton() if (jButton = null) jButton = new JButton(); jButton.setBounds(new Rectangle(61, 211, 121, 32); jButton.setText(登陆 jButton.addActionListener(newr() public void String username=jTextField.getText(); String password=jPasswordField.getText();
16、 Access access=new Access(username,password); access.login(); jFrame.setVisible(false); ); return jButton; * This method initializes jButton1 private JButton getJButton1() if (jButton1 = null) jButton1 = new JButton(); jButton1.setBounds(new Rectangle(269, 210, 139, 32); jButton1.setText(注册 jButton1
17、.addActionListener(new Regsdit regsdit=new Regsdit(); regsdit.getJFrame(); return jButton1;/* * This method initializes jPasswordField 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类import ja
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1