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

下載本文檔

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

文檔簡(jiǎn)介

1、圖書管理系統(tǒng)數(shù)據(jù)庫(kù)源代碼/創(chuàng)建工程及設(shè)計(jì)主界面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è)置窗體標(biāo)題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)建一個(gè)標(biāo)簽,用來(lái)顯示圖片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、置標(biāo)簽大小lable.setText(); /設(shè)置標(biāo)簽文本,設(shè)置窗口背景 /將標(biāo)簽添加到桌面窗體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è)置是否可以移動(dòng)工具欄toolBar.setBorder(new Beve

6、lBorder(BevelBorder.RAIZED); /設(shè)置邊框/圖書信息添加按鈕JButton bookAddButton=new JButton(MenuActions.BOOK_ADD);bookAddButton.setIcon(icon); /設(shè)置按鈕圖標(biāo)bookAddButton.setHideActionText(true); /顯示提示文本toolBar.add(bookAddButton); /添加到工具欄中JButton bookModiAndDelButton=new JButton(MenuActions.BOOK_MODIFY); /圖書信息修改按鈕ImageIc

7、on bookmodiicon=Icon.add(bookModiAndDeltb.jpg); /創(chuàng)建圖表方法bookModiAndDelButton.setIcon(bookmodiicon); /設(shè)置按鈕圖標(biāo)bookModiAndDelButton.setHideActionText(true); /顯示提示文本toolBar.add(bookModiAndDelButton); /添加到工具欄JButton bookTypeAddButton=new JButton(MenuActions.BOOKTYPE_ADD); /圖書類別添加按鈕ImageIcon bookTypeAddicon

8、=Icon.add(bookTypeAddtb.jpg); /創(chuàng)建圖標(biāo)方法bookTypeAddButton.setIcon(bookTypeAddicon); /設(shè)置按鈕圖標(biāo)bookTypeAddButton.setHideActionText(true); /顯示提示文本toolBar.add(bookTypeAddButton); /添加到工具欄JButton bookBorrowButton=new JButton(MenuActions.BORROW); /圖書借閱按鈕ImageIcon bookBorrowicon=Icon.add(bookBorrowtb.jpg); /創(chuàng)建圖標(biāo)

9、方法bookBorrowButton.setIcon(bookBorrowicon); /設(shè)置按鈕圖標(biāo)bookBorrowButton.setHideActionText(true); /顯示提示文本toolBar.add(bookBorrowButton); /添加到工具欄JButton bookOrderButton=new JButton(MenuActions.NEWBOOK_ORDER); /新書訂購(gòu)按鈕ImageIcon bookOrdericon=Icon.add(bookOrdertb.jpg); /創(chuàng)建圖標(biāo)方法bookOrderButton.setIcon(bookOrder

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

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

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

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

14、ted static String dbUser=root; /數(shù)據(jù)庫(kù)用戶名protected static String dbpwd=root; /數(shù)據(jù)庫(kù)密碼private static Connection conn=null; /數(shù)據(jù)庫(kù)連接對(duì)象,初值為nullpublic Business()tryif(coon=null) /連接對(duì)象為空Class.forName(dbClassName); /加載驅(qū)動(dòng)類信息conn=DriverManager.getConnection(dbUr1,dbUser,dbPwd); /建立連接對(duì)象catch(Exception ee)ee.printSt

15、ackTrace();public static ResultSet executeQuery(String sql) /執(zhí)行查詢方法try/如果連接對(duì)象為空,則重新調(diào)用構(gòu)造方法if (conn=null)new Business();return conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE).executeQuery(sql); /執(zhí)行查詢catch(SQLException e)e.printStackTrace();return null; /返回null值finallyp

16、ublic static int executeUpdata(String sql) /更新方法tryif(conn=null)new Business(); /如果連接對(duì)象為空,則重新調(diào)用構(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)閉連接對(duì)象catch(SQLException e)e.printStac

17、kTrace();finallyconn=null; /設(shè)置連接對(duì)象為null值/為數(shù)據(jù)庫(kù)添加對(duì)應(yīng)的類public class BookInfoprivate String Book_id; /圖書編號(hào)private String typeid; /類別編號(hào)private String writer; /作者private String translator; /譯者private String publisher; /出版社private Date date; /出版日期private Double price; /圖書單價(jià)private String getBookname; /圖書名稱p

18、ublic String getBookname()return bookname;public void setBookname(String bookname)this.bookname=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 get

19、Price()return price;public void setprice(Double price)this.price=price;public String getPublisher()return Publisher;public void setPublisher(String publisher)this.Publisher=Publisher;public String getTranslator()return translator;public void setTranslator(String translator)this.translator=translator

20、;public String getTypeid()return typeid;public void setTypeid(String typeid)this.typeid=typeid;public String getWriter()return writer;public void setWriter(String writer)this.writer=writer;public class BookType /圖書列表信息類private String id; /圖書類別編號(hào)private String typeName; /圖書類別名稱private String days; /可

21、解天數(shù)private String fk; /每罰款金額public String getFk()return fk;public void setFk(String fk)this.fk=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

22、 void setTypeName(String typeName)this.typeName=typeName;public class Order /圖書訂單信息類private String Book_id; /圖書編號(hào)private Date date; /下單時(shí)間private String number; /圖書數(shù)量private String operator; /操作員private String checkAndAccept; /是否收到貨private String zk; /圖書折扣public String getcheckAndAccept()return check

23、AndAccept;public void setcheckAndAccept(String checkAndAccept)this.checkAndAccept=checkAndAccept;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()

24、return number;public void setNumber(String number)this.number=number;public String getOperator()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; /操作員編號(hào)private

25、String name; /操作員用戶名private String grade; /操作員等級(jí)private String password; /操作員密碼private String type; /出版社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()retur

26、n id;public void setId(String id)this.id=id;public String getName()return name;public void setName(String name)=name;public String getPassword()return password;public void setPassword(String password)this.password=password;public class Borrow /書籍借閱信息類private int id; /借閱編號(hào)private String book

27、_id; /圖書編號(hào)private String reader_id; /讀者編號(hào)private String num; /借書數(shù)量private String borrowDate; /借書日期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 ba

28、ckDate;public void setBackDate(String backDate)this.backDate=backDate;public string getBorrowDate()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 boo

29、k_id;public void setBook_id(String book_id)this.book_id=book_id;public String getReader_id()return 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; /圖書編號(hào)priva

30、te String bookname; /圖書名稱private String operatorId; /操作員編號(hào)private String borrowDate; /圖書借閱時(shí)間private String backDate; /圖書歸還時(shí)間private String readerName; /讀者姓名private String reader_id; /讀者編號(hào)private int typeId;private int id;public int getId()return id;public void setId(int id)this.id=id;public int getT

31、ypeId()return typeid;public void setTypeId(int typeid)this.typeId=typeId;public string getBackDate()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 g

32、etBorrowDate()return borrowDate;public void setBorrowDate(String borrowDate)this.borrowDate=borrowDate;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)

33、this.book_id=book_id; public String getReader_id()return reader_id;public void setReader_id(String reader_id)this.reader_id=reader_id; public String getReaderName()return readerName;public void setReaderName(String readerName)this.readerName=readerName;/系統(tǒng)登錄模塊設(shè)計(jì)public class BookLogin extends JFramep

34、rivate static final Operater Type=null; /人員類型private static Operater user; /用戶名private JPasswordField password;private JTextField username;private JButton login;private JButton reset;public BookLogin()super();final BorderLayout borderLayout=new BorderLayout(); /創(chuàng)建布局管理器setDefaultCloseOperation(JFrame

35、.EXIT_ON_CLOSE); /設(shè)置“關(guān)閉”按鈕處理事件borderLayout.setVgap(10); /設(shè)置組件間的垂直關(guān)系getContentPane().setLayout(borderLayout); /使用布局管理器setTitle(圖書管理系統(tǒng)登錄) /設(shè)置窗體標(biāo)題Toolkit tool=Toolkit.getDefaultToolkit(); /獲得默認(rèn)的工具箱Dimension screenSize=tool.getScreenSize(); /獲得屏幕的大小setSize(285,194);setLocation(screenSize.width-getWidth(

36、)/2,(screenSize.height-getHeight()/2); /設(shè)置窗體位置final JPanel mainPanel=new JPanel(); /創(chuàng)建主面板mainPanel.setLayout(new BorderLayout(); /設(shè)置邊框布局mainPanel.setBorder(new EmptyBorder(0,0,0,0) /設(shè)置邊框?yàn)?getContentPane().add(mainPanel); /在窗體中加入主面板final JLabel imageLabel=new JLabel; /創(chuàng)建一個(gè)標(biāo)簽,用來(lái)顯示圖片ImageIcon loginIcon

37、=Icon.add(login.jpg); /創(chuàng)建一個(gè)圖像圖標(biāo)imagelabel.setIcon(loginIcon); /設(shè)置圖片imageLabel.setOpaque(true); /設(shè)置繪制其邊界內(nèi)的所有像素imageLabel.setBackground(Color.GREEN); /設(shè)置背景顏色imageLabel.setpreferredSize(new Dimension(260,60); /設(shè)置標(biāo)簽大小mainPanel.add(imageLabel,BorderLayout.NORTH); /添加標(biāo)簽到主面板final JPanel centerPanel=new JPa

38、nel(); /添加一個(gè)中心面板final GridLayout gridLayout=new GridLayout(2,2); /創(chuàng)建網(wǎng)絡(luò)布局管理器gridLayout.setHgap(5); /設(shè)置組件之間平行的距離gridLayout.setVgap(20); /設(shè)置組件之間垂直的距離centerPanel.setLayout(gridLayout); /使用布局管理器mainPanel.add(centerPanel); /添加到主桌面final JLabel userNamelabel=new JLabel(); /創(chuàng)建一個(gè)標(biāo)簽userNameLabel.setHorizontalA

39、lignment(SwingConstants.CENTER); /設(shè)置對(duì)齊方式userNameLabel.setPreferredSize(new Dimension(0,0); /設(shè)置組件大小userNameLabel.setMinimumSize(new Dimension(0,0); /設(shè)置組件最小的大小centerPanel.add(userNameLabel); /添加到中心面板userNameLabel.setText(用 戶 名:); /設(shè)置標(biāo)簽文本username=new JTextField(20); /創(chuàng)建文本框username.setPreferredSize(new

40、Dimension(0,0); /設(shè)置組件大小centerPanel.add(username); /添加到中心面板final JLabel passwordLabel=new JLabel(); /創(chuàng)建一個(gè)標(biāo)簽passwordLabel.setHorizontalAlignment(SwingConstants.CENTER); /設(shè)置對(duì)齊方式centerPanel.add(passwordLabel); /添加到中心面板passwordLabel.setText(密 碼:); /設(shè)置標(biāo)簽文本password=new JPasswordField(20); /創(chuàng)建密碼框password.se

41、tDocument(new Document(6); /設(shè)置密碼長(zhǎng)度為6password.addKeyListener(new KeyAdapter() /監(jiān)聽(tīng)密碼框public void keyPressed(final keyEvent e) /監(jiān)聽(tīng)鍵盤案件事件if(e.getKeyCode()=10) /如果按了回車鍵 login.doClick(); /進(jìn)行登錄)centerPanel.add(password); /添加到中心面板final JPanel southPanel=new JPanel; /新增一個(gè)底部面板mainPanel.add(southPanel,BorderLa

42、yout.SOUTH); /添加到主面板中l(wèi)ogin=new JButton(); /創(chuàng)建按鈕組件login.addActionListener(new BookLoginAtion(); /添加監(jiān)聽(tīng)器login.setText(登錄); /設(shè)置按鈕文本southPanel.add(login); /把按鈕添加到底部面板reset=new JButton(); /創(chuàng)建按鈕組件reset.addActionListener(new BookResetAction(); /添加監(jiān)聽(tīng)器reset.setText(重置); /設(shè)置按鈕文本southPanel.add(reset); /把按鈕添加到底部

43、面板setVisible(true); /設(shè)置創(chuàng)建可見(jiàn)setResizable(false); /設(shè)置窗體不可改變大小public static Operater getUser()return user;public static Operater getType()return Type;publicstatic void setUser(Operater user)BookLogin.user=user;private class BookResetAction implements ActionListenerpublic void actionPerformed(final Acti

44、onEvent e)username.setText(); /設(shè)置用戶名輸入框?yàn)榭誴assword.setText(); /設(shè)置密碼輸入框?yàn)榭誴rivate class BookLoginAction implements ActionListenerpublic void actionPerformed(final ActionEvent e)user=Business.check(username.getText(),new String(password.getPassword(); /調(diào)用business方法if(user.getName()!=null) /判斷用戶名是否為nullt

45、ryMain frame=new Main(); /創(chuàng)建一個(gè)主窗體frame.setVisible(true); /設(shè)置其可見(jiàn)catch(Exception ex)ex.printStackTrace();else JOptionPane.showMessageDialog(null,請(qǐng)輸入正確的用戶名和密碼!); /彈出提示框 username.setText(); /設(shè)置用戶名輸入框?yàn)榭?password.setText(); /設(shè)置密碼輸入框?yàn)榭?基本信息管理模塊public class ReaderAdd extends JInternalFrame /添加讀者信息public Rea

46、derAdd()super();setTitle(讀者相關(guān)信息添加);setIconifiable(true); /設(shè)置窗體可最小化setClosable(true); /設(shè)置窗體可關(guān)閉setBounds(100,100,500,350);final JLabel logoLabel=new JLabel();ImageIcon readerAddIcon=Icon.add(readerAdd.jpg);logoLabel.setIcon(readerAddIcon);logoLabel.setOpaque(true);logoLabel.setBackground(Color.CYAN);logoLabel

溫馨提示

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

最新文檔

評(píng)論

0/150

提交評(píng)論