图书馆管理系统.doc_第1页
图书馆管理系统.doc_第2页
图书馆管理系统.doc_第3页
图书馆管理系统.doc_第4页
图书馆管理系统.doc_第5页
已阅读5页,还剩21页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

package abc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.SQLException;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import java.sql.*;class BookAddFrame extends JFrame /添加书籍private ConnectionDB myCon=new ConnectionDB();private JButton YesBtn,NoBtn;private static JTextField bookNo,bookName,bookPress,bookPrice,bookWriter,bookPosition,bookRemain;/空白区private JLabel bookNoLabel,bookNameLabel,bookPressLabel,bookPriceLabel,bookWriterLabel,bookPositionLabel,bookRemainLabel;/提示区private static Font font=new Font(楷体,Font.BOLD,14);public BookAddFrame()this.setTitle(添加书籍);this.setSize(400,600);this.setLayout(null);this.setResizable(false);this.setVisible(true);this.addCompnents();this.add(getbookName();this.add(getbookNo();this.add(getbookPress();this.add(getbookPrice();this.add(getbookWriter();this.add(getbookPosition();this.add(getbookRemain();private void addCompnents()bookNameLabel=new JLabel(书 名:);bookNameLabel.setFont(font);bookNameLabel.setBounds(100, 10, 60, 20);this.add(bookNameLabel);bookNoLabel=new JLabel(书 号:);bookNoLabel.setFont(font);bookNoLabel.setBounds(100, 50, 60, 20);this.add(bookNoLabel);bookPressLabel=new JLabel(出版社:);bookPressLabel.setFont(font);bookPressLabel.setBounds(100, 90, 60, 20);this.add(bookPressLabel);bookPriceLabel=new JLabel(价 格:);bookPriceLabel.setFont(font);bookPriceLabel.setBounds(100, 130, 60, 20);this.add(bookPriceLabel);bookWriterLabel=new JLabel(作 者:);bookWriterLabel.setFont(font);bookWriterLabel.setBounds(100, 170, 60, 20);this.add(bookWriterLabel);bookPositionLabel=new JLabel(位 置:);bookPositionLabel.setFont(font);bookPositionLabel.setBounds(100, 210, 60, 20);this.add(bookPositionLabel);bookRemainLabel=new JLabel(进货量:);bookRemainLabel.setFont(font);bookRemainLabel.setBounds(100, 250, 60, 20);this.add(bookRemainLabel);YesBtn = new JButton(确定);YesBtn.setFont(font);YesBtn.setBounds(130,300,80, 30);this.add(YesBtn);NoBtn = new JButton(取消);NoBtn.setFont(font);NoBtn.setBounds(220,300,80, 30);this.add(NoBtn);YesBtn.addActionListener(new ActionListener() /添加确认按钮响应Overridepublic void actionPerformed(ActionEvent e)/ TODO 自动生成的方法存根String sql=insert into Book(bookNo,bookName,bookPress,bookPrice,bookWriter,bookPosition,bookRemain)values(+bookNo.getText()+,+bookName.getText()+,+bookPress.getText()+,+bookPrice.getText()+,+bookWriter.getText()+,+bookPosition.getText()+,+bookRemain.getText()+); try myCon.getStatement().executeUpdate(sql);myCon.breakDB(); catch (SQLException e1) e1.printStackTrace(); MFrame frame=new MFrame(); dispose(); );NoBtn.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) / TODO 自动生成的方法存根 MFrame frame=new MFrame(); dispose(); ); public static JTextField getbookName() if(bookName=null)bookName=new JTextField();bookName.setBounds(155,10,150,20);bookName.setFont(font);bookName.setForeground(Color.blue);return bookName;public static JTextField getbookNo() if(bookNo=null)bookNo=new JTextField();bookNo.setFont(font);bookNo.setBounds(155,50,150,20);bookNo.setForeground(Color.blue);return bookNo; public static JTextField getbookPress() if(bookPress=null)bookPress=new JTextField();bookPress.setFont(font);bookPress.setBounds(155,90,150,20);bookPress.setForeground(Color.blue);return bookPress;public static JTextField getbookPrice() if(bookPrice=null)bookPrice=new JTextField();bookPrice.setFont(font);bookPrice.setBounds(155,130,150,20);bookPrice.setForeground(Color.blue);return bookPrice;public static JTextField getbookWriter() if(bookWriter=null)bookWriter=new JTextField();bookWriter.setFont(font);bookWriter.setBounds(155,170,150,20);bookWriter.setForeground(Color.blue);return bookWriter;public static JTextField getbookPosition() if(bookPosition=null)bookPosition=new JTextField();bookPosition.setFont(font);bookPosition.setBounds(155,210,150,20);bookPosition.setForeground(Color.blue);return bookPosition;public static JTextField getbookRemain() if(bookRemain=null)bookRemain=new JTextField();bookRemain.setFont(font);bookRemain.setBounds(155,250,150,20);bookRemain.setForeground(Color.blue);return bookRemain;/public void setFrame(LoginFrame frame)/this.frame1=frame;/package abc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import java.sql.*;class BookSERFrame extends JFrame /修改书籍private ConnectionDB myCon=new ConnectionDB();private JButton YesBtn,NoBtn;private static JTextField bookName,bookNo,bookPress,bookPrice,bookWriter,bookPosition,bookRemain;/空白区private JLabel bookNameLabel,bookNoLabel,bookPressLabel,bookPriceLabel,bookWriterLabel,bookPositionLabel,bookRemainLabel;/提示区private static Font font=new Font(楷体,Font.BOLD,14);public BookSERFrame()this.setTitle(修改书籍);this.setSize(400,600);this.setLayout(null);this.setResizable(false);this.setVisible(true);this.addCompnents();this.add(getbookName();this.add(getbookNo();this.add(getbookPress();this.add(getbookPrice();this.add(getbookWriter();this.add(getbookPosition();this.add(getbookRemain();private void addCompnents()bookNoLabel=new JLabel(书 号:);bookNoLabel.setFont(font);bookNoLabel.setBounds(100, 10, 60, 20);this.add(bookNoLabel);bookNameLabel=new JLabel(书 名:);bookNameLabel.setFont(font);bookNameLabel.setBounds(100, 120, 60, 20);this.add(bookNameLabel);bookPressLabel=new JLabel(出版社:);bookPressLabel.setFont(font);bookPressLabel.setBounds(95, 160, 60, 20);this.add(bookPressLabel);bookPriceLabel=new JLabel(价 格:);bookPriceLabel.setFont(font);bookPriceLabel.setBounds(100, 200, 60, 20);this.add(bookPriceLabel);bookWriterLabel=new JLabel(作 者:);bookWriterLabel.setFont(font);bookWriterLabel.setBounds(100, 240, 60, 20);this.add(bookWriterLabel);bookPositionLabel=new JLabel(位 置:);bookPositionLabel.setFont(font);bookPositionLabel.setBounds(100, 280, 60, 20);this.add(bookPositionLabel); bookRemainLabel=new JLabel(库 存:);bookRemainLabel.setFont(font);bookRemainLabel.setBounds(100, 320, 60, 20);this.add(bookRemainLabel);YesBtn = new JButton(确定);YesBtn.setFont(font);YesBtn.setBounds(130,50,80, 30);this.add(YesBtn);NoBtn = new JButton(取消);NoBtn.setFont(font);NoBtn.setBounds(220,50,80, 30);this.add(NoBtn);YesBtn.addActionListener(new ActionListener() /添加确认按钮响应Overridepublic void actionPerformed(ActionEvent e)/ TODO 自动生成的方法存根/bookName,bookNo,bookPress,bookPrice,bookWriter,bookPosition,bookRemain String sql=select * from Book where bookNo=+bookNo.getText()+; try myCon.getStatement().executeUpdate(sql); myCon.breakDB(); catch (SQLException e1) e1.printStackTrace(); );NoBtn.addActionListener(new ActionListener() Override public void actionPerformed(ActionEvent e) / TODO 自动生成的方法存根 MFrame frame=new MFrame(); dispose(); ); public static JTextField getbookNo() if(bookNo=null)bookNo=new JTextField();bookNo.setFont(font);bookNo.setBounds(150,10,150,20);bookNo.setForeground(Color.blue);return bookNo; public static JTextField getbookName() if(bookName=null)bookName=new JTextField();bookName.setBounds(150,120,150,20);bookName.setFont(font);bookName.setForeground(Color.blue);return bookName; public static JTextField getbookPress() if(bookPress=null)bookPress=new JTextField();bookPress.setFont(font);bookPress.setBounds(150,160,150,20);bookPress.setForeground(Color.blue);return bookPress;public static JTextField getbookPrice() if(bookPrice=null)bookPrice=new JTextField();bookPrice.setFont(font);bookPrice.setBounds(150,200,150,20);bookPrice.setForeground(Color.blue);return bookPrice;public static JTextField getbookWriter() if(bookWriter=null)bookWriter=new JTextField();bookWriter.setFont(font);bookWriter.setBounds(150,240,150,20);bookWriter.setForeground(Color.blue);return bookWriter;public static JTextField getbookPosition() if(bookPosition=null)bookPosition=new JTextField();bookPosition.setFont(font);bookPosition.setBounds(150,280,150,20);bookPosition.setForeground(Color.blue);return bookPosition;public static JTextField getbookRemain() if(bookRemain=null)bookRemain=new JTextField();bookRemain.setFont(font);bookRemain.setBounds(150,320,150,20);bookRemain.setForeground(Color.blue);return bookRemain;/public void setFrame(LoginFrame frame)/this.frame1=frame;/package abc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.SQLException;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import java.sql.*;class BorrowFrame extends JFrame /借书private ConnectionDB myCon=new ConnectionDB();private JButton YesBtn,NoBtn;private static JTextField readNo,bookNo;/空白区private JLabel readNoLabel,bookNoLabel;/提示区private static Font font=new Font(楷体,Font.BOLD,14);public BorrowFrame()this.setTitle(借阅书籍);this.setSize(400,400);this.setLayout(null);this.setResizable(false);this.setVisible(true);this.addCompnents();this.add(getreadNo();this.add(getbookNo();private void addCompnents()readNoLabel=new JLabel(借阅号:);readNoLabel.setFont(font);readNoLabel.setBounds(95, 10, 60, 20);this.add(readNoLabel);bookNoLabel=new JLabel(书编号:);bookNoLabel.setFont(font);bookNoLabel.setBounds(100, 50, 60, 20);this.add(bookNoLabel);YesBtn = new JButton(确定);YesBtn.setFont(font);YesBtn.setBounds(130,150,80, 30);this.add(YesBtn);NoBtn = new JButton(取消);NoBtn.setFont(font);NoBtn.setBounds(220,150,80, 30);this.add(NoBtn);YesBtn.addActionListener(new ActionListener() /添加确认按钮响应Overridepublic void actionPerformed(ActionEvent e)/ TODO 自动生成的方法存根String sql=insert into Borrow(readNo,bookNo)values(+readNo.getText()+, +bookNo.getText()+); try myCon.getStatement().executeUpdate(sql);myCon.breakDB(); catch (SQLException e1) e1.printStackTrace();); public static JTextField getreadNo() if(readNo=null)readNo=new JTextField();readNo.setBounds(155,10,150,20);readNo.setFont(font);readNo.setForeground(Color.blue);return readNo;public static JTextField getbookNo() if(bookNo=null)bookNo=new JTextField();bookNo.setFont(font);bookNo.setBounds(155,50,150,20);bookNo.setForeground(Color.blue);return bookNo;package abc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;public class ConnectionDB private String JDriver=sun.jdbc.odbc.JdbcOdbcDriver;private String sqlURL=jdbc:odbc:library;/private String JDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver;/private String sqlURL=jdbc:sqlserver:/localhost:1433;DatabaseName=MyTest;integratedSecurity=TRUE;private Connection connection;private Statement statement;private String tableSQL=new String4;public ConnectionDB()try Class.forName(JDriver);connection=DriverManager.getConnection(sqlURL);statement=connection.createStatement(); catch (ClassNotFoundException e) e.printStackTrace();catch (SQLException e) e.printStackTrace();public Connection getConnection()return connection;public Statement getStatement()return statement;public void breakDB()try statement.close();connection.close(); catch (SQLException e) e.printStackTrace();public void createTable()tableSQL0=create table Book(+ bookNo int primary key,+ bookName varchar(20),+ bookPress varchar(20),+ bookPrice int,+ bookWriter varchar(20),+ bookPosition varchar(20),+ bookRemain int);/*tableSQL1=create table pz_info(+ arrive_hour char(2),+ arrive_minute char(2),+ leave_hour char(2),+ leave_minute char(2),+ everyday_time char(2);tableSQL2=create table everymonth_statistics(+ Sno char(9) not null,+ Sname char(10) not null,+ remain_time char(4),+ late_times smallint,+ early_leave smallint,+ work_day smallint,+ primary key(Sno),+ foreign key(Sno)+ references staff_info(Sno) on delete cascade);tableSQL3=create table everyday_statistics(+ Sno char(9) not null,+ Sname char(10) not null,+ hour char(2),+ minute char(2),+ action char(6),+ time char(4),+ primary key(Sno),+ foreign key(Sno)+ references staff_info(Sno) on delete cascade);*/ try for(int i=0;i1;i+)statement.executeUpdate(tableSQLi); catch (SQLException e) e.printStackTrace();package abc;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.SQLException;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.util.*;import java.sql.*;class LendFrame extends JFrame /还书private ConnectionDB myCon=new ConnectionDB();private JButton YesBtn,NoBtn;private static JTextField readNo,bookNo;/空白区private JLabel readNoLabel,bookNoLabel;/提示区private static Font font=new Font(楷体,Font.BOLD,14);public LendFrame()this.setTitle(归还书籍);this.setSize(400,600);this.setLayout(null);this.setResizable(false);this.setVisible(true);this.addCompnents();this.add(getreadNo();this.add(getbookNo();private void addCompnents()readNoLabel=new JLabel(借阅号:);readNoLabel.setFont(font);readNoLabel.setBounds(100, 10, 60, 20);this.add(readNoLabel);bookNoLabel=new JLabel(书编号:);bookNoLabel.setFont(font);bookNoLabel.setBounds(100, 50, 60, 20);this.add(bookNoLabel);YesBtn = new JButton(确定);YesBtn.setFont(font);YesBtn.setBounds(130,180,80, 30);this.add(YesBtn);NoBtn = new JButton(取消);NoBtn.setFont(font);NoBtn.setBounds(220,180,80, 30);this.add(NoBtn);YesBtn.addActionListener(new ActionListener() /添加确认按钮响应Overridepublic void actionPerformed(ActionEvent e)/ TODO 自动生成的方法存根String sql1=insert into Lend(readNo,bookNo)values(+readNo.getText()+, +bookNo.getText()+); try myCon.getStatement().executeUpdate(sql1);myCon.breakDB(); catch (SQLException e1) e1.printStackTrace(); String sql2=delete from Borrow where readNo=+readNo.getText()+; try myCon.getStatement().executeUpdate(sql2);myCon.breakDB(); catch (SQLException e1) e1.printStackTrace(); String sql3=delete from Lend where readNo=+readNo.getText()+; try myCon.getStatement().executeUpdate(sql3);myCon.breakDB(); catch (SQLException e1) e1.printStackTrace(); dispose(););NoBtn.addActionListener(new ActionListener() /添加确认按钮响应Overridepublic void actionPerformed(ActionEvent e)dispose();); public static JTextField getreadNo() if(readNo=null)readNo=new JTextField();readNo.setBounds(155,10,150,20);readNo.setFont(font);readNo.setForeground(Color.blue);return readNo;public stat

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论