下载

2下载券

加入VIP
  • 专属下载特权
  • 现金文档折扣购买
  • VIP免费专区
  • 千万文档免费下载

上传资料

关闭

关闭

关闭

封号提示

内容

首页 java课程设计小型图书管理系统

java课程设计小型图书管理系统.doc

java课程设计小型图书管理系统

另一种清高
2012-09-23 0人阅读 举报 0 0 暂无简介

简介:本文档为《java课程设计小型图书管理系统doc》,可适用于其他资料领域

Java应用课程设计项目名称:小型图书管理系统课程名称:Java应用项目作者:***完成日期:年月日前言本系统是小型图书管理系统专为个人设计。本系统启动后需要登陆然后进入主界在这个界面我们可以选择所需要的功能模块来完成所要执行的功能。系统共有个功能模块:图书入库、图书查询、图书删除、图书概览、修改密码。支持一系列关于图书管理方面的简单操作,诸如查询、删除、添加、修改密码等。系统流程图说明:首先是输入判断相当于在登陆模块要求用户输入用户名和密码然后判断如果判断失败退出系统否则进入图书管理系统的主界面。进入主界面后用户要选择所需执行的功能即通过鼠标点击相应项来完成所需操作。数据库设计在图书管理系统中共设计张表。本系统使用Access来创建数据表。数据库的名称为Bookmdb。表book字段名称数据类型图书名文本图书号文本(主键)单价文本作者文本出版社文本入库时间文本表user字段名称数据类型用户名文本(主键)密码文本系统源码程序代码登陆界面:程序名Loginjavaimportjavaawtevent*importjavaxswing*importjavaawt*importjavaawtContainerimportjavautil*importjavasql*classLoginextendsJFrameimplementsActionListener{Containercp=JFramef=JButtonj,jJTextFieldtJPasswordFieldtJLabeljlable,jlableColorcJPaneljp,jpLogin(){f=newJFrame("小型图书管理系统")j=newJButton("确定")j=newJButton("取消")cp=fgetContentPane()jlable=newJLabel("输入用户名")jlable=newJLabel("用户密码")jp=newJPanel()jp=newJPanel()t=newJTextField()t=newJPasswordField()jpadd(jlable)jpadd(t)jpadd(jlable)jpadd(t)JLabelJL=newJLabel("<html><fontcolor=#CCFFsize=''><i>欢迎登陆<i><font>",SwingConstantsCENTER)cpadd(JL,"North")jpadd(j)jpadd(j)cpadd(jp,"Center")cpadd("South",jp)jpsetBackground(newColor(,,))Toolkitkit=ToolkitgetDefaultToolkit()Dimensionscreen=kitgetScreenSize()intx=screenwidth*取得显示器窗口的宽度*inty=screenheight*取得显示器窗口的高度*setSize(x,y)*让系统窗口平铺整个显示器窗口*fsetSize(,)intxcenter=(x)intycenter=(y)fsetLocation(xcenter,ycenter)*显示在窗口中央*fsetVisible(true)jaddActionListener(this)注册事件监听器jaddActionListener(this)faddWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){Systemexit()}})}publicvoidconfirm()验证用户和密码是否存在{try{ClassforName("sunjdbcodbcJdbcOdbcDriver")}catch(ClassNotFoundExceptione){Systemoutprintln("加载驱动程序失败!")}try{Stringurl="jdbc:odbc:driver={MicrosoftAccessDriver(*mdb)}DBQ=Bookmdb"直接使用当前类目录下的数据库文件Connectioncon=DriverManagergetConnection(url)Statementsql=concreateStatement()Stringuname=tgetText()trim()StringMima=tgetText()trim()StringqueryMima="select*fromuserwhere用户名='"uname"'and密码='"Mima"'"ResultSetrs=sqlexecuteQuery(queryMima)if(rsnext()){newBook(uname)fhide()conclose()}else{JOptionPaneshowMessageDialog(,"该用户不存在","提示!",JOptionPaneYESNOOPTION)}tsetText("")tsetText("")}catch(SQLExceptiong){Systemoutprintln("ECode"ggetErrorCode())Systemoutprintln("EM"ggetMessage())}}publicvoidactionPerformed(ActionEvente){Stringcmd=egetActionCommand()if(cmdequals("确定")){confirm()}elseif(cmdequals("取消")){fdispose()}}publicstaticvoidmain(Stringarg){Logina=newLogin()}}图书概览:程序名BookBrowerjavaimportjavaawtevent*importjavaxswing*importjavaawt*importjavaawtContainerimportjavautil*importjavasql*classBookBrowerimplementsActionListener{JFramefContainercpJPaneljpS,jpanelWestJButtonjbt,jbt按钮查询、取消、修改JLabellabel,L标签定义文本框JTabletable用来接收数据库中返回的信息ObjectcolumnName={"图书名","图书号","单价","作者","出版社","入库时间"}Objectar=newObjectStringsnoStringcount="xx"BookBrower(){f=newJFrame()cp=fgetContentPane()初始化面板、按钮、标签、文本框jpS=newJPanel()jpanelWest=newJPanel()jbt=newJButton("确定")jbt=newJButton("返回")label=newJLabel("<html><fontcolor=#CCFFsize=''>图书概览<font>",SwingConstantsCENTER)labelsetForeground(Colorblue)L=newJLabel("书库现在共有图书"count"本")table=newJTable(ar,columnName)ar存放表中的数据columnname表示列名JScrollPanescrollpane=newJScrollPane(table)布局,添加控件jpSadd(jbt)jpSadd(jbt)JPaneljpanel=newJPanel()jpaneladd(label)JPanelpp=newJPanel()JPaneljpE=newJPanel()cpadd(jpanel,"North")JPaneljp=newJPanel()jpadd(scrollpane)JPanelp=newJPanel()用来放两个表psetLayout(newBorderLayout())padd(L,"North")padd(scrollpane)cpadd(pp,"West")cpadd(p,"Center")cpadd(jpS,"South")cpadd(jpE,"East")Toolkitkit=ToolkitgetDefaultToolkit()Dimensionscreen=kitgetScreenSize()intx=screenwidth*取得显示器窗口的宽度*inty=screenheight*取得显示器窗口的高度*fsetSize(,)intxcenter=(x)intycenter=(y)fsetLocation(xcenter,ycenter)*显示在窗口中央*fsetVisible(true)jbtaddActionListener(this)注册监听器jbtaddActionListener(this)*faddWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){Systemexit()}})*}inti=publicvoidshowRecord(){while(i>=){ari=""ari=""ari=""ari=""ari=""ari=""i}i=try{ClassforName("sunjdbcodbcJdbcOdbcDriver")}catch(ClassNotFoundExceptione){Systemoutprintln("加载驱动程序失败!")}try{Stringurl="jdbc:odbc:driver={MicrosoftAccessDriver(*mdb)}DBQ=Bookmdb"直接使用当前类目录下的数据库文件Connectioncon=DriverManagergetConnection(url)Strings="select*frombook"Statementsql=concreateStatement()ResultSetrs=sqlexecuteQuery(s)while(rsnext()){Stringbname=rsgetString()Stringbno=rsgetString()Stringprice=rsgetString()Stringwriter=rsgetString()Stringpublish=rsgetString()Stringindate=rsgetString()ari=bnameari=bnoari=priceari=writerari=publishari=indatei}count=""i""LsetText("书库现在共有图书"count"本")frepaint()conclose()}catch(SQLExceptiong){Systemoutprintln("ECode"ggetErrorCode())Systemoutprintln("EM"ggetMessage())}}publicvoidactionPerformed(ActionEvente){Stringcmd=egetActionCommand()if(cmdequals("确定")){fhide()}if(cmdequals("返回"))fhide()}publicstaticvoidmain(Stringarg){BookBrowera=newBookBrower()ashowRecord()}}图书查询:程序名QueryBookjavaimportjavaawtevent*importjavaxswing*importjavaawt*importjavaawtContainerimportjavautil*importjavasql*classQueryBookimplementsActionListener{JFramefContainercpJPaneljp,jp,jp,jp,jp,jpanelWestJButtonjbt,jbt按钮确定、取消JLabellabel标签:请输入图书号JTextFieldtf,tf,tf,tf,tf,tf,tf定义文本框JLabellabel,label,label,labelQueryBook(){f=newJFrame()cp=fgetContentPane()初始化面板、按钮、标签、文本框jp=newJPanel()jp=newJPanel()jp=newJPanel()jp=newJPanel()jpanelWest=newJPanel()jp=newJPanel()jbt=newJButton("确定")jbt=newJButton("取消")label=newJLabel("<html><fontcolor=#CCFFsize=''>请输入图书号:<font>",SwingConstantsCENTER)labelsetForeground(Colorblue)tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()布局,添加控件JPaneljpanel=newJPanel()jpaneladd(label)jpaneladd(tf)JPanelpp=newJPanel()JPaneljpane=newJPanel()cpadd(jpanel,"North")JPanelpp=newJPanel(newGridLayout(,))JPanelpp=newJPanel()ppsetLayout(newGridLayout(,))ppadd(newJLabel("图书名",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("图书号",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("单价",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("作者",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("出版社",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("入库时间",SwingConstantsCENTER))ppadd(tf)ppadd(jbt)ppadd(jbt)cpadd(pp,"West")cpadd(pp,"Center")cpadd(pp,"South")cpadd(jpane,"East")Toolkitkit=ToolkitgetDefaultToolkit()Dimensionscreen=kitgetScreenSize()intx=screenwidth*取得显示器窗口的宽度*inty=screenheight*取得显示器窗口的高度*fsetSize(,)intxcenter=(x)intycenter=(y)fsetLocation(xcenter,ycenter)*显示在窗口中央*fsetVisible(true)jbtaddActionListener(this)注册监听器jbtaddActionListener(this)*faddWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){Systemexit()}})*}publicvoidshowRecord(){try{ClassforName("sunjdbcodbcJdbcOdbcDriver")}catch(ClassNotFoundExceptione){Systemoutprintln("加载驱动程序失败!")}try{Stringurl="jdbc:odbc:driver={MicrosoftAccessDriver(*mdb)}DBQ=Bookmdb"直接使用当前类目录下的数据库文件Connectioncon=DriverManagergetConnection(url)StatementsqlStringql=tfgetText()trim()Strings="select*frombookwhere图书号='"ql"'"sql=concreateStatement()ResultSetrs=sqlexecuteQuery(s)if(rsnext()){Stringbname=rsgetString()Stringbno=rsgetString()Stringprice=rsgetString()Stringwriter=rsgetString()Stringpublish=rsgetString()Stringindate=rsgetString()tfsetText(bname)tfsetText(bno)tfsetText(price)tfsetText(writer)tfsetText(publish)tfsetText(indate)}else{JOptionPaneshowMessageDialog(,"您输入的图书号不存在请重新输入","输入错误",JOptionPaneYESNOOPTION)}conclose()}catch(SQLExceptiong){Systemoutprintln("ECode"ggetErrorCode())Systemoutprintln("EM"ggetMessage())}tfsetEditable(false)tfsetEditable(false)tfsetEditable(false)tfsetEditable(false)tfsetEditable(false)tfsetEditable(false)}publicvoidactionPerformed(ActionEvente){Stringcmd=egetActionCommand()if(cmdequals("确定")){showRecord()tfsetText("")}elseif(cmdequals("取消"))fhide()}publicstaticvoidmain(Stringarg){QueryBooka=newQueryBook()}}图书删除:程序名RemoveBookjavaimportjavaawtevent*importjavaxswing*importjavaawt*importjavaawtContainerimportjavautil*importjavasql*classRemoveBookimplementsActionListener{JFramefContainercpJPaneljpS,jpanelWestJButtonjbt,jbt,jbt按钮查询、取消、修改JLabellabel,L标签:请输入学号JTextFieldtf定义文本框JTabletable用来接收数据库中返回的信息ObjectcolumnName={"图书名","图书号","单价","作者","出版社","入库时间"}Objectar=newObjectStringsnoStringcount="xx"RemoveBook(){f=newJFrame()cp=fgetContentPane()初始化面板、按钮、标签、文本框jpS=newJPanel()jpanelWest=newJPanel()jbt=newJButton("查询")jbt=newJButton("取消")jbt=newJButton("删除")label=newJLabel("<html><fontcolor=#CCFFsize=''>请输入要删除的图书名:<font>",SwingConstantsCENTER)labelsetForeground(Colorblue)L=newJLabel("该种图书共有"count"本")table=newJTable(ar,columnName)ar存放表中的数据columnname表示列名JScrollPanescrollpane=newJScrollPane(table)tf=newJTextField()布局,添加控件jpSadd(jbt)jpSadd(jbt)jpSadd(jbt)JPaneljpanel=newJPanel()jpaneladd(label)jpaneladd(tf)JPanelpp=newJPanel()JPaneljpE=newJPanel()cpadd(jpanel,"North")JPaneljp=newJPanel()jpadd(scrollpane)JPanelp=newJPanel()用来放两个表psetLayout(newBorderLayout())padd(L,"North")padd(scrollpane)cpadd(pp,"West")cpadd(p,"Center")cpadd(jpS,"South")cpadd(jpE,"East")Toolkitkit=ToolkitgetDefaultToolkit()Dimensionscreen=kitgetScreenSize()intx=screenwidth*取得显示器窗口的宽度*inty=screenheight*取得显示器窗口的高度*fsetSize(,)intxcenter=(x)intycenter=(y)fsetLocation(xcenter,ycenter)*显示在窗口中央*fsetVisible(true)jbtaddActionListener(this)注册监听器jbtaddActionListener(this)jbtaddActionListener(this)*faddWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){Systemexit()}})*}inti=publicvoidshowRecord(Stringql){while(i>=){ari=""ari=""ari=""ari=""ari=""ari=""i}i=try{ClassforName("sunjdbcodbcJdbcOdbcDriver")}catch(ClassNotFoundExceptione){Systemoutprintln("加载驱动程序失败!")}try{Stringurl="jdbc:odbc:driver={MicrosoftAccessDriver(*mdb)}DBQ=Bookmdb"直接使用当前类目录下的数据库文件Connectioncon=DriverManagergetConnection(url)StatementsqlStrings="select*frombookwhere图书名='"ql"'"sql=concreateStatement()ResultSetrs=sqlexecuteQuery(s)while(rsnext()){Stringbname=rsgetString()Stringbno=rsgetString()Stringprice=rsgetString()Stringwriter=rsgetString()Stringpublish=rsgetString()Stringindate=rsgetString()ari=bnameari=bnoari=priceari=writerari=publishari=indatei}count=""i""LsetText("该种图书共有"count"本")frepaint()conclose()Systemoutprintln(ar)}catch(SQLExceptiong){Systemoutprintln("ECode"ggetErrorCode())Systemoutprintln("EM"ggetMessage())}}publicvoiddeleteRecord(intindex){try{ClassforName("sunjdbcodbcJdbcOdbcDriver")}catch(ClassNotFoundExceptione){Systemoutprintln("加载驱动程序失败!")}try{Stringurl="jdbc:odbc:driver={MicrosoftAccessDriver(*mdb)}DBQ=Bookmdb"直接使用当前类目录下的数据库文件Connectioncon=DriverManagergetConnection(url)StatementsqlStringql=(String)(arindex)Strings="delete*frombookwhere图书号='"ql"'"sql=concreateStatement()intdel=sqlexecuteUpdate(s)if(del==){JOptionPaneshowMessageDialog(,"删除成功!","信息",JOptionPaneYESNOOPTION)}conclose()frepaint()}catch(SQLExceptiong){Systemoutprintln("ECode"ggetErrorCode())Systemoutprintln("EM"ggetMessage())}}publicvoidactionPerformed(ActionEvente){Stringremember=""Stringql=""Stringcmd=egetActionCommand()if(cmdequals("查询")){ql=tfgetText()trim()remember=qlshowRecord(ql)}if(cmdequals("删除")){intindex=tablegetSelectedRow()if(index==)JOptionPaneshowMessageDialog(,"请选定要删除的表格行","输入错误",JOptionPaneYESNOOPTION)else{deleteRecord(index)showRecord(remember)}}if(cmdequals("取消"))fhide()}publicstaticvoidmain(Stringarg){RemoveBooka=newRemoveBook()}}图书入库:程序名BookInjavaimportjavaawtevent*importjavaxswing*importjavaawt*importjavaawtContainerimportjavautil*importjavasql*importjavaxswingtextJTextComponentextendsJFrameclassBookInimplementsActionListener{JFramefContainercpJPaneljp,jp,jp,jp,jp,jpanelWestJButtonjbt,jbt按钮:确定、取消、JLabellabel标签JTextFieldtf,tf,tf,tf,tf,tf定义文本框JLabellabel,label,label,labelStringsnoBookIn(){f=newJFrame()cp=fgetContentPane()初始化面板、按钮、标签、文本框jp=newJPanel()jp=newJPanel()jp=newJPanel()jp=newJPanel()jpanelWest=newJPanel()jp=newJPanel()jbt=newJButton("确定")jbt=newJButton("取消")label=newJLabel("<html><fontcolor=#CCFFsize=''>图书入库<font>",SwingConstantsCENTER)labelsetForeground(Colorblue)tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()tf=newJTextField()布局,添加控件jpadd(jbt)jpadd(jbt)sno=tfgetText()jpadd(newJLabel("您好"sno"欢迎登陆学生信息系统"))JPaneljpanel=newJPanel()jpaneladd(label)JPanelpp=newJPanel()JPaneljpane=newJPanel()cpadd(jpanel,"North")JPanelpp=newJPanel(newGridLayout(,))JPanelpp=newJPanel()ppsetLayout(newGridLayout(,))ppadd(newJLabel("图书名",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("图书号",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("单价",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("作者",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("出版社",SwingConstantsCENTER))ppadd(tf)ppadd(newJLabel("入库时间",SwingConstantsCENTER))ppadd(tf)ppadd(jbt)ppadd(jbt)cpadd(pp,"West")cpadd(pp,"Center")cpadd(pp,"South")cpadd(jpane,"East")Toolkitkit=ToolkitgetDefaultToolkit()Dimensionscreen=kitgetScreenSize()intx=screenwidth*取得显示器窗口的宽度*inty=screenheight*取得显示器窗口的高度*fsetSize(,)intxcenter=(x)intycenter=(y)fsetLocation(xcenter,ycenter)*显示在窗口中央*fsetVisible(true)jbtaddActionLis

用户评价(0)

关闭

新课改视野下建构高中语文教学实验成果报告(32KB)

抱歉,积分不足下载失败,请稍后再试!

提示

试读已结束,如需要继续阅读或者下载,敬请购买!

文档小程序码

使用微信“扫一扫”扫码寻找文档

1

打开微信

2

扫描小程序码

3

发布寻找信息

4

等待寻找结果

我知道了
评分:

/34

java课程设计小型图书管理系统

VIP

在线
客服

免费
邮箱

爱问共享资料服务号

扫描关注领取更多福利