圖書管理系統(tǒng)數(shù)據(jù)庫源代碼_第1頁
圖書管理系統(tǒng)數(shù)據(jù)庫源代碼_第2頁
圖書管理系統(tǒng)數(shù)據(jù)庫源代碼_第3頁
圖書管理系統(tǒng)數(shù)據(jù)庫源代碼_第4頁
圖書管理系統(tǒng)數(shù)據(jù)庫源代碼_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、圖書管理系統(tǒng)數(shù)據(jù)庫源代碼/創(chuàng)建工程及設(shè)計主界面public class Main extends JFrameprivate static final JDesktopPaneDESKTOP_PANE=new JDesktopPane(); /桌面窗體public static void main(String args) /入口方法tryUIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName(); /設(shè)置系統(tǒng)界面外觀new BookLogin(); /登錄窗口catch(Exception ex)ex.printSta

2、ckTrace();public static void addIFame(JInternalFrame iframe) /添加子窗體的方法DESKTOP_PANE.add(iframe); /新增子窗體public Main()super(); /設(shè)置“關(guān)閉”按鈕處理事件setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); /創(chuàng)建工具欄Toolkit tool=Toolkit,getDefaultToolkit(); /獲得屏幕大小Dimension screenSize=tool.getScreenSize();setSize(8

3、00,600); /設(shè)置窗體大小setLocation(screenSize.width-getWidth()/2,(screenSize.height-getHeight()/2; /設(shè)置窗體位置setTitle(圖書管理系統(tǒng)); /設(shè)置窗體標題JMenuBar menuBar=createMenu(); /創(chuàng)建菜單欄setJMenuBar(menuBar); /設(shè)置菜單欄JToolBar toolBar=createToolBar(); /創(chuàng)建工具欄的方法getContentPane(),add(toolBar,BorderLayout.NORTH); /設(shè)置工具欄final JLable

4、 lable=new JLable(); /創(chuàng)建一個標簽,用來顯示圖片lable.setBounds(0,0,0,0); /設(shè)置窗體的大小和位置lable.setIcon(null); /窗體背景DESKTOP_PANE.addComponentListener(new ComponentAdapter()public void componentResized(final ComponentEvent e)Dimension size=e.getComponent().getSize(); /獲得組建大小lable.setSize(e.getComponent().getSize(); /設(shè)

5、置標簽大小lable.setText(); /設(shè)置標簽文本,設(shè)置窗口背景 /將標簽添加到桌面窗體DESKTOP_PANE.add(lable,new Integer(Integer.MIN_VALUE);getContentPane().add(DESKTOP_PANE); /將桌面窗體添加到主窗體中private JToolBar createToolBar() /創(chuàng)建工具欄的方法JToolBar toolBar=new JToolBar(); /初始化工具欄toolBar.setFloatable(false); /設(shè)置是否可以移動工具欄toolBar.setBorder(new Beve

6、lBorder(BevelBorder.RAIZED); /設(shè)置邊框/圖書信息添加按鈕JButton bookAddButton=new JButton(MenuActions.BOOK_ADD);ImageIcon icon=new ImageIcon(Main.class.getResource(/bookAddtb.jpg); /添加菜單欄圖標bookAddButton.setIcon(icon); /設(shè)置按鈕圖標bookAddButton.setHideActionText(true); /顯示提示文本toolBar.add(bookAddButton); /添加到工具欄中JButto

7、n bookModiAndDelButton=new JButton(MenuActions.BOOK_MODIFY); /圖書信息修改按鈕ImageIcon bookmodiicon=Icon.add(bookModiAndDeltb.jpg); /創(chuàng)建圖表方法bookModiAndDelButton.setIcon(bookmodiicon); /設(shè)置按鈕圖標bookModiAndDelButton.setHideActionText(true); /顯示提示文本toolBar.add(bookModiAndDelButton); /添加到工具欄JButton bookTypeAddBut

8、ton=new JButton(MenuActions.BOOKTYPE_ADD); /圖書類別添加按鈕ImageIcon bookTypeAddicon=Icon.add(bookTypeAddtb.jpg); /創(chuàng)建圖標方法bookTypeAddButton.setIcon(bookTypeAddicon); /設(shè)置按鈕圖標bookTypeAddButton.setHideActionText(true); /顯示提示文本toolBar.add(bookTypeAddButton); /添加到工具欄JButton bookBorrowButton=new JButton(MenuActio

9、ns.BORROW); /圖書借閱按鈕ImageIcon bookBorrowicon=Icon.add(bookBorrowtb.jpg); /創(chuàng)建圖標方法bookBorrowButton.setIcon(bookBorrowicon); /設(shè)置按鈕圖標bookBorrowButton.setHideActionText(true); /顯示提示文本toolBar.add(bookBorrowButton); /添加到工具欄JButton bookOrderButton=new JButton(MenuActions.NEWBOOK_ORDER); /新書訂購按鈕ImageIcon book

10、Ordericon=Icon.add(bookOrdertb.jpg); /創(chuàng)建圖標方法bookOrderButton.setIcon(bookOrdericon); /設(shè)置按鈕圖標bookOrderButton.setHideActionText(true); /顯示提示文本toolBar.add(bookOrderButton); /添加到工具欄JButton bookCheckButton=new JButton(MenuActions.NEWBOOK_CHECK); /驗收新書按鈕ImageIcon bookCheckicon=Icon.add(newbookChecktb.jpg);

11、 /創(chuàng)建圖標方法bookCheckButton.setIcon(bookCheckicon); /設(shè)置按鈕圖標bookCheckButton.setHideActionText(true); /顯示提示文本toolBar.add(bookCheckButton); /添加到工具欄 JButton readerAddButton=new JButton(MenuActions.READER_ADD); /讀者信息添加按鈕ImageIcon readerAddicon=Icon.add(readerAddtb.jpg); /創(chuàng)建圖標方法readerAddButton.setIcon(readerA

12、ddicon); /設(shè)置按鈕圖標readerAddButton.setHideActionText(true); /顯示提示文本toolBar.add(readerAddButton); /添加到工具欄 JButton readerModiAndDelButton=new JButton(MenuActions.READER_MODIFY); /讀者信息修改按鈕ImageIcon readerModiAndDelicon=Icon.add(readerModiAndDeltb.jpg); /創(chuàng)建圖標方法 readerModiAndDelButton.setIcon(readerModiAndD

13、elicon); /設(shè)置按鈕圖標readerModiAndDelButton.setHideActionText(true); /顯示提示文本toolBar.add(readerModiAndDelButton); /添加到工具欄 JButton ExitButton=new JButton(MenuActions.EXIT); /退出系統(tǒng)按鈕ImageIcon Exiticon=Icon.add(exittb.jpg); /創(chuàng)建圖標方法 ExitButton.setIcon(Exiticon); /設(shè)置按鈕圖標ExitButton.setHideActionText(true); /顯示提示

14、文本toolBar.add(ExitButton); /添加到工具欄 return toolBar;public class Businessprotected static String dbClassName=com.mysql.jdbc.Driver; /數(shù)據(jù)庫驅(qū)動類protected static String dbUr1=jdbc:mysql:/localhost/ts; /連接URLprotected static String dbUser=root; /數(shù)據(jù)庫用戶名protected static String dbpwd=root; /數(shù)據(jù)庫密碼private static

15、Connection conn=null; /數(shù)據(jù)庫連接對象,初值為nullpublic Business()tryif(coon=null) /連接對象為空Class.forName(dbClassName); /加載驅(qū)動類信息conn=DriverManager.getConnection(dbUr1,dbUser,dbPwd); /建立連接對象catch(Exception ee)ee.printStackTrace();public static ResultSet executeQuery(String sql) /執(zhí)行查詢方法try/如果連接對象為空,則重新調(diào)用構(gòu)造方法if (co

16、nn=null)new Business();return conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE).executeQuery(sql); /執(zhí)行查詢catch(SQLException e)e.printStackTrace();return null; /返回null值finallypublic static int executeUpdata(String sql) /更新方法tryif(conn=null)new Business(); /如果連接對象為空,則重新調(diào)用

17、構(gòu)造方法return conn.createStatement().executeUpdate(sql); /執(zhí)行更新catch(SQLException e)e.printStackTrace();return -1;finallypublic static void close() /關(guān)閉方法tryconn.close(); /關(guān)閉連接對象catch(SQLException e)e.printStackTrace();finallyconn=null; /設(shè)置連接對象為null值/為數(shù)據(jù)庫添加對應(yīng)的類public class BookInfoprivate String Book_id;

18、 /圖書編號private String typeid; /類別編號private String writer; /作者private String translator; /譯者private String publisher; /出版社private Date date; /出版日期private Double price; /圖書單價private String getBookname; /圖書名稱public String getBookname()return bookname;public void setBookname(String bookname)this.bookname

19、=bookname;public Date getDate()return date;public void setDate(Date date)this.date=date;public string getBook_id()return Book_id;public void setBook_id(String Book_id)this.Book_id=Book_id;public Double getPrice()return price;public void setprice(Double price)this.price=price;public String getPublish

20、er()return Publisher;public void setPublisher(String publisher)this.Publisher=Publisher;public String getTranslator()return translator;public void setTranslator(String translator)this.translator=translator;public String getTypeid()return typeid;public void setTypeid(String typeid)this.typeid=typeid;

21、public String getWriter()return writer;public void setWriter(String writer)this.writer=writer;public class BookType /圖書列表信息類private String id; /圖書類別編號private String typeName; /圖書類別名稱private String days; /可解天數(shù)private String fk; /每罰款金額public String getFk()return fk;public void setFk(String fk)this.fk=

22、fk;public String getDays()return days;public void setDays(String days)this.days=days;public string getId()return id;public void setId(String id)this.Bid=id;public String getTypeName()return typeName;public void setTypeName(String typeName)this.typeName=typeName;public class Order /圖書訂單信息類private Str

23、ing Book_id; /圖書編號private Date date; /下單時間private String number; /圖書數(shù)量private String operator; /操作員private String checkAndAccept; /是否收到貨private String zk; /圖書折扣public String getcheckAndAccept()return checkAndAccept;public void setcheckAndAccept(String checkAndAccept)this.checkAndAccept=checkAndAccep

24、t;public Date getDate()return date;public void setDate(Date date)this.date=date;public string getBook_id()return book_id;public void setBook_id(String book_id)this.book_id=book_id;public String getNumber()return number;public void setNumber(String number)this.number=number;public String getOperator(

25、)return operator;public void setOperator(String operator)this.operatorr=operator;public String getZk()return zk;public void setZk(String Zk)this.zk=zk;public class Operaterprivate String id; /操作員編號private String name; /操作員用戶名private String grade; /操作員等級private String password; /操作員密碼private String t

26、ype; /出版社public String getType()return type;public void setType(String type)this.type=type;public string getGrade()return grade;public void setGrade(String grade)this.grade=grade;public String getId()return id;public void setId(String id)this.id=id;public String getName()return name;public void setN

27、ame(String name)=name;public String getPassword()return password;public void setPassword(String password)this.password=password;public class Borrow /書籍借閱信息類private int id; /借閱編號private String book_id; /圖書編號private String reader_id; /讀者編號private String num; /借書數(shù)量private String borrowDate; /借

28、書日期private String backDate; /應(yīng)還日期private String Bookname; /圖書名稱public String getBookname()return bookname;public void setBookname(String bookname)this.bookname=bookname;public string getBackDate()return backDate;public void setBackDate(String backDate)this.backDate=backDate;public string getBorrowDa

29、te()return borrowDate;public void setBorrowDate(String borrowDate)this.borrowDate=borrowDate;public String getNum()return num;public void setNum(String num)this.num=num;public String getBook_id()return book_id;public void setBook_id(String book_id)this.book_id=book_id;public String getReader_id()ret

30、urn reader_id;public void setReader_id(String reader_id)this.reader_id=reader_id;public int getId()return id;public void setId(Int id)this.id=id;public class Back /圖書歸還信息類private String book_id; /圖書編號private String bookname; /圖書名稱private String operatorId; /操作員編號private String borrowDate; /圖書借閱時間pri

31、vate String backDate; /圖書歸還時間private String readerName; /讀者姓名private String reader_id; /讀者編號private int typeId;private int id;public int getId()return id;public void setId(int id)this.id=id;public int getTypeId()return typeid;public void setTypeId(int typeid)this.typeId=typeId;public string getBackD

32、ate()return backDate;public void setBackDate(String backDate)this.backDate=backDate;public String getBookname()return bookname;public void setBookname(String bookname)this.bookname=bookname;public string getBorrowDate()return borrowDate;public void setBorrowDate(String borrowDate)this.borrowDate=bor

33、rowDate;public String getOperatorId()return operatorId;public void setOperatorId(String operatorId)this.operatorId=operatorId;public String getBook_id()return book_id;public void setBook_id(String book_id)this.book_id=book_id; public String getReader_id()return reader_id;public void setReader_id(Str

34、ing reader_id)this.reader_id=reader_id; public String getReaderName()return readerName;public void setReaderName(String readerName)this.readerName=readerName;/系統(tǒng)登錄模塊設(shè)計public class BookLogin extends JFrameprivate static final Operater Type=null; /人員類型private static Operater user; /用戶名private JPasswor

35、dField password;private JTextField username;private JButton login;private JButton reset;public BookLogin()super();final BorderLayout borderLayout=new BorderLayout(); /創(chuàng)建布局管理器setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); /設(shè)置“關(guān)閉”按鈕處理事件borderLayout.setVgap(10); /設(shè)置組件間的垂直關(guān)系getContentPane().setLayout(b

36、orderLayout); /使用布局管理器setTitle(圖書管理系統(tǒng)登錄) /設(shè)置窗體標題Toolkit tool=Toolkit.getDefaultToolkit(); /獲得默認的工具箱Dimension screenSize=tool.getScreenSize(); /獲得屏幕的大小setSize(285,194);setLocation(screenSize.width-getWidth()/2,(screenSize.height-getHeight()/2); /設(shè)置窗體位置final JPanel mainPanel=new JPanel(); /創(chuàng)建主面板mainPa

37、nel.setLayout(new BorderLayout(); /設(shè)置邊框布局mainPanel.setBorder(new EmptyBorder(0,0,0,0) /設(shè)置邊框為0getContentPane().add(mainPanel); /在窗體中加入主面板final JLabel imageLabel=new JLabel; /創(chuàng)建一個標簽,用來顯示圖片ImageIcon loginIcon=Icon.add(login.jpg); /創(chuàng)建一個圖像圖標imagelabel.setIcon(loginIcon); /設(shè)置圖片imageLabel.setOpaque(true);

38、/設(shè)置繪制其邊界內(nèi)的所有像素imageLabel.setBackground(Color.GREEN); /設(shè)置背景顏色imageLabel.setpreferredSize(new Dimension(260,60); /設(shè)置標簽大小mainPanel.add(imageLabel,BorderLayout.NORTH); /添加標簽到主面板final JPanel centerPanel=new JPanel(); /添加一個中心面板final GridLayout gridLayout=new GridLayout(2,2); /創(chuàng)建網(wǎng)絡(luò)布局管理器gridLayout.setHgap(5

39、); /設(shè)置組件之間平行的距離gridLayout.setVgap(20); /設(shè)置組件之間垂直的距離centerPanel.setLayout(gridLayout); /使用布局管理器mainPanel.add(centerPanel); /添加到主桌面final JLabel userNamelabel=new JLabel(); /創(chuàng)建一個標簽userNameLabel.setHorizontalAlignment(SwingConstants.CENTER); /設(shè)置對齊方式userNameLabel.setPreferredSize(new Dimension(0,0); /設(shè)置組

40、件大小userNameLabel.setMinimumSize(new Dimension(0,0); /設(shè)置組件最小的大小centerPanel.add(userNameLabel); /添加到中心面板userNameLabel.setText(用 戶 名:); /設(shè)置標簽文本username=new JTextField(20); /創(chuàng)建文本框username.setPreferredSize(new Dimension(0,0); /設(shè)置組件大小centerPanel.add(username); /添加到中心面板final JLabel passwordLabel=new JLabel

41、(); /創(chuàng)建一個標簽passwordLabel.setHorizontalAlignment(SwingConstants.CENTER); /設(shè)置對齊方式centerPanel.add(passwordLabel); /添加到中心面板passwordLabel.setText(密 碼:); /設(shè)置標簽文本password=new JPasswordField(20); /創(chuàng)建密碼框password.setDocument(new Document(6); /設(shè)置密碼長度為6password.addKeyListener(new KeyAdapter() /監(jiān)聽密碼框public void

42、keyPressed(final keyEvent e) /監(jiān)聽鍵盤案件事件if(e.getKeyCode()=10) /如果按了回車鍵 login.doClick(); /進行登錄)centerPanel.add(password); /添加到中心面板final JPanel southPanel=new JPanel; /新增一個底部面板mainPanel.add(southPanel,BorderLayout.SOUTH); /添加到主面板中l(wèi)ogin=new JButton(); /創(chuàng)建按鈕組件login.addActionListener(new BookLoginAtion();

43、/添加監(jiān)聽器login.setText(登錄); /設(shè)置按鈕文本southPanel.add(login); /把按鈕添加到底部面板reset=new JButton(); /創(chuàng)建按鈕組件reset.addActionListener(new BookResetAction(); /添加監(jiān)聽器reset.setText(重置); /設(shè)置按鈕文本southPanel.add(reset); /把按鈕添加到底部面板setVisible(true); /設(shè)置創(chuàng)建可見setResizable(false); /設(shè)置窗體不可改變大小public static Operater getUser()retu

44、rn user;public static Operater getType()return Type;publicstatic void setUser(Operater user)BookLogin.user=user;private class BookResetAction implements ActionListenerpublic void actionPerformed(final ActionEvent e)username.setText(); /設(shè)置用戶名輸入框為空password.setText(); /設(shè)置密碼輸入框為空private class BookLoginA

45、ction implements ActionListenerpublic void actionPerformed(final ActionEvent e)user=Business.check(username.getText(),new String(password.getPassword(); /調(diào)用business方法if(user.getName()!=null) /判斷用戶名是否為nulltryMain frame=new Main(); /創(chuàng)建一個主窗體frame.setVisible(true); /設(shè)置其可見BookLogin.this.setVisible(false)

46、; /設(shè)置登錄窗體為不顯示catch(Exception ex)ex.printStackTrace();else JOptionPane.showMessageDialog(null,請輸入正確的用戶名和密碼!); /彈出提示框 username.setText(); /設(shè)置用戶名輸入框為空 password.setText(); /設(shè)置密碼輸入框為空/基本信息管理模塊public class ReaderAdd extends JInternalFrame /添加讀者信息public ReaderAdd()super();setTitle(讀者相關(guān)信息添加);setIconifiable(true); /設(shè)置窗體可最小化setClosable(t

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論