java课程设计----图书馆管理系统.doc_第1页
java课程设计----图书馆管理系统.doc_第2页
java课程设计----图书馆管理系统.doc_第3页
java课程设计----图书馆管理系统.doc_第4页
java课程设计----图书馆管理系统.doc_第5页
已阅读5页,还剩15页未读 继续免费阅读

下载本文档

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

文档简介

图书馆管理系统课程设计报告1目录引言-2正文-3结论和建议-4致谢-5参考文献-5附录-5202 引 言当今时代是飞速发展的信息时代。在各行各业中离不开信息处理,这正是计算机被广泛应用于信息管理系统的环境。计算机的最大好处在于利用它能够进行信息管理。使用计算机进行信息控制,不仅提高了工作效率,而且大大的提高了其安全性。尤其对于复杂的信息管理,计算机能够充分发挥它的优越性。计算机进行信息管理与信息管理系统的开发密切相关,系统的开发是系统管理的前提。图书管理系统就是为了管理好图书馆信息而设计的。图书馆作为一种信息资源的集散地,图书和用户借阅资料繁多,包含很多的信息数据的管理,现今,有很多的图书馆都是初步开始使用,甚至尚未使用计算机进行信息管理。根据调查得知,他们以前对信息管理的主要方式是基于文本、表格等纸介质的手工处理,对于图书借阅情况(如借书天数、超过限定借书时间的天数)的统计和核实等往往采用对借书卡的人工检查进行,对借阅者的借阅权限、以及借阅天数等用人工计算、手抄进行。数据信息处理工作量大,容易出错;由于数据繁多,容易丢失,且不易查找。总的来说,缺乏系统,规范的信息管理手段。尽管有的图书馆有计算机,但是尚未用于信息管理,没有发挥它的效力,资源闲置比较突出,这就是管理信息系统的开发的基本环境。数据处理手工操作,工作量大,出错率高,出错后不易更改。图书馆采取手工方式对图书借阅情况进行人工管理,由于信息比较多,图书借阅信息的管理工作混乱而又复杂;一般借阅情况是记录在借书证上,图书的数目和内容记录在文件中,图书馆的工作人员和管理员也只是当时对它比较清楚,时间一长,如再要进行查询,就得在众多的资料中翻阅、查找了,造成查询费时、费力。如要对很长时间以前的图书进行更改就更加困难了。基于这些问题,有必要建立一个图书管理系统,使图书管理工作规范化,系统化,程序化,避免图书管理的随意性,提高信息处理的速度和准确性,能够及时、准确、有效的查询和修改图书情况。3正 文3.1功能需求分析(1)作为学生对图书管理系统的要求有:1. 能按各种方式(比如书名、编号、作者)查询图书馆的藏书情况。2. 能够方便地借阅图书、续借图书、归还图书。3. 能够查询自己的基本资料、借阅图书情况。4. 能够熟悉图书管理系统的使用。(2)作为图书管理员,他们对图书管理系统的要求有:1. 能方便的对图书进行录入登记,注销陈旧的书籍。2. 能够方便地对新生进行登记,或注销已经毕业的学生信息(基本信息,借阅信息)。3. 能够随时发布一些诸如各学院学生借阅图书超期情况、馆内藏书情况、借情况息,以便各学院能够随时获知本院学生的一些借书信息。3.2系统用例分析图书管理系统中包含书籍的采购、入库、编目、出借、归还、淘汰等功能,以及读者信息的管理。本系统对前期的工作进行了简化,删掉了书籍的采购、入库、编目等繁琐的工作,仅对系统主要部分进行分析。为了提高服务效果,图书馆系统实行开架阅览,并为读者提供客户端,读者可以查询到馆藏书目和个人在借图书的信息。这项功能也可以通过互联网实现。图书管理员通过系统记录图书的出借和归还,以及书目的维护和读者信息的维护。3.3系统模块分析3.3.1新书入库模块: (1)新书入库界面包括图书相关的属性:编号、书名、作者、类别、出版日期、出版社、定价、数量、备注等。 3.3.2图书整理模块: (1)图书整理界面包括:图书修改删除、图书类别编辑 图书修改删除界面除了包括图书的相关属性还包括图书修改功能。 图书类别编辑界面包括对类别编号、类别名称进行添加、删除、修改的功模块。3.3.3办借书卡模块:办借书卡界面包括借书卡编号、持借书卡人的姓名、性别、组名、证件号。3.3.4查询模块: (1)借阅信息查询: 根据查询方式如 按借书证号、按姓名等在文本框中输入相关内容即可查询还可查询到期图书 (2)图书信息查询: 查询方式有:按书号、按书名、按作者、按类别、按出版社。在关键字中输入相关内容,点击“开始查询”按钮,在datalist中列出查询结果。如果选中“模糊查询”可查询更多的相关信息。 (3)用户信息查询: 查询方式有:按借书证号、按姓名。在关键字框中输入借书证号或者读者姓名。 组用户管理模块:(4)组用户管理界面: 操作方式包括:修改、删除、添加。 组用户信息包括:组编号、组名称、最长天数、最多本数。3.3.5图书借还模块:图书借阅界面包括图书编号、书名、类别、出版社、出版日期、借书证号等归还图书界面包括图书的属性、归还者的信息。4 总结通过完成本次图书管理系统实践,使我系统的经历了一次java软件开发的整个设计开发过程,把所学的知识综合的运用到这次实践中,重新复习了课本上讲到的知识,觉得有一种温故而知新的感觉,通过实践同时也收获了许多课本上没有的东西。尤其是在开发图书管理系统的过程当中,也遇到了许多技术上或者其他方面的困难,但是也算经过自己的努力,基本上克服了这些困难。由于我的水平确实有限,加之也没有实际的项目经验,设计时间短,所以该系统还有许多不尽如人意的地方,比如功能较少,出错处理不够等多方面问题 ,距离真正实用的图书管理系统还有许多差距,但我相信,软件开发是一个不断完善的过程,我会在以后得学习当中继续完善的 。在这次设计过程中,培养了我的自学能力,在遇到困难的时候,能够认真的对待,不放弃,无论是查看各种书籍还是到图书馆中查找各种资料,想尽一切办法将这个问题解决。我总结了许多编程经验,这将在以后的学习生活中有很大的帮助。5、致谢感谢那些给我带来帮助的书籍和internet,还有周边的同学们。还要感谢我们的指导老师给我们这么多学生的文档认真批改,让我们知道在课程设计与实现的过程中存在的问题。6、参考文献1 王克宏、郝建文. java技术教程 m. 北京:清华大学出版社,2002年2 基于java的学生信息管理系统 李伟 电子科技大学 【硕士】电子科技大学 2009-04-01 0 578 3 j2ee框架及全文检索技术在信息管理系统中的应用 徐立峰 电子科技大学 【硕士】电子科技大学 2009-10-01 7、附录附部分主要源代码:import javax.swing.*; import java.awt.*;import java.awt.event.*; import javax.swing.table.*;import java.sql.*;import edu.njust.cs.*;public class simplebookmanagerpublic static void main(string args)setfont.setfont(new font(楷体, 0, 12);connection con=null;trycon=sqlutil.acquireconnection(,1433,booktest,admin,xyz);catch(exception e)system.out.println(e);system.exit(-1);if(con!=null)jframe f=new jframe();f.addwindowlistener(new windowadapter()public void windowclosing(windowevent e)system.exit(0););f.getcontentpane().add(new bookmanager(f,con);f.setsize(600,400);f.show();class bookmanager extends jpanel implements actionlistenerprivate string columnnames=图书编号,书名,定价,出版社;private class datatype=string.class,string.class,double.class,string.class;private customtablemodel model=null;private jtable table=null;private connection con=null;private jbutton btnadd=new textandpicbutton(image/addrow20.gif, 增 加 );private jbutton btnsearch=new textandpicbutton(image/search20.gif, 查 询 );private jbutton btndelete=new textandpicbutton(image/deleterow20.gif, 删 除 );private jbutton btnexit=new textandpicbutton(image/exit20.gif, 退 出 );private jframe f=null;public bookmanager(jframe f,connection con)this.f=f;this.con=con;/构建工具条jtoolbar toolbar=new jtoolbar();toolbar.add(btnadd);toolbar.add(btnsearch);toolbar.add(btndelete);toolbar.add(btnexit);/注册事件侦听器btnadd.addactionlistener(this);btnsearch.addactionlistener(this);btndelete.addactionlistener(this);btnexit.addactionlistener(this);/构建表格model=new customtablemodel(0,columnnames.length,columnnames,datatype); table = new jtable(model); table.setautoresizemode(jtable.auto_resize_off);table.setselectionmode(listselectionmodel.single_selection );/设定表格每列的宽度settablecolumnwidth(0,100);settablecolumnwidth(1,200);settablecolumnwidth(2,100);settablecolumnwidth(3,250);/布局工具条及表格this.setlayout(new borderlayout();this.add(toolbar,borderlayout.north);this.add(new jscrollpane(table),borderlayout.center);/设置表格指定列的宽度public void settablecolumnwidth(int column,int width)if(column=0)tablecolumn col=table.getcolumn(columnnamescolumn);col.setpreferredwidth(width);public void actionperformed(actionevent e)object s=e.getsource();if(s=this.btnadd) add();else if(s=this.btnsearch)search();else if(s=this.btndelete) delete();else if(s=this.btnexit) system.exit(0);/增加一条记录到数据库public void add()bookeditor be=new bookeditor(f,增加,true);be.show(); /只有点击了信息对话框中的确定按钮,才增加记录if(be.getactioncode()=be.ok)string insertsql=insert into bookinfo values (?,?,?,?);object linefordbadd=be.getid(),be.getbookname(), be.getbookprice(),be.getbookpress();if(sqlutil.addrowtodb(con,insertsql,linefordbadd) /成功写入数据库的记录,追加到表格的末行显示object linefortable= sqlutil.getlinefortablefromlinefordb(linefordbadd,datatype);model.insertrow(model.getrowcount(),linefortable);/将表格的最后一行选中table.changeselection(model.getrowcount()-1,0,false,false);elsejoptionpane.showmessagedialog(this,新增时出错!,提示,joptionpane.information_message);/查询数据库public void search()searchdialog sd=new searchdialog(f,查询,true);sd.show();if(sd.getactioncode()=sd.ok)string readsql=sd.getsql();sqlutil.readdbtotable(con,readsql,model,datatype);/删除选定的记录public void delete()int selected=table.getselectedrow();if(selected=0&selectedmodel.getrowcount()int result=joptionpane.showconfirmdialog (f,您确定要删除该条图书信息吗? ,确认,joptionpane.yes_no_option,joptionpane.question_message);if (result!=joptionpane.yes_option)return ;string deletesql=delete from bookinfo where bookid=?;object keys=model.getvalueat(selected,0).tostring();if(sqlutil.deletefromdb(con,deletesql,keys)model.removerow(selected);elsejoptionpane.showmessagedialog(f,请选定要删除的一行!,提示,joptionpane.information_message);/内部类,用于显示/编辑图书信息的一个模式对话框class bookeditor extends jdialog implements actionlistenerfinal int ok=1; final int cancel=-1; final int close=0;private int actioncode=cancel;private jlabel labid=new jlabel( 图书编号 );private jtextfield txtid=new jtextfield();private jlabel labbookname=new jlabel( 图书名称 );private jtextfield txtbookname=new jtextfield();private jlabel labbookprice=new jlabel( 单 价 );private jtextfield txtbookprice=new jtextfield();private jlabel labbookpress=new jlabel( 出 版 社 );private jtextfield txtbookpress=new jtextfield();private jbutton btnpre=new jbutton(上一个);private jbutton btnnext=new jbutton(下一个); private jbutton btnok=new jbutton(确定);private jbutton btncancel=new jbutton(取消);private jframe f=null;public bookeditor(jframe f,string s,boolean b)super(f,s,b);this.f=f;/面板p中显示图书信息jpanel p=new jpanel();p.setlayout(new gridbaglayout();layoututil.add(p,gridbagconstraints.none, gridbagconstraints.center,0,0,0,0,1,1,labid);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,1,0,1,1,txtid);layoututil.add(p,gridbagconstraints.none, gridbagconstraints.center,0,0,2,0,1,1,labbookname);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,3,0,1,1,txtbookname);layoututil.add(p,gridbagconstraints.none, gridbagconstraints.center,0,0,0,1,1,1,labbookprice);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,1,1,1,1,txtbookprice);layoututil.add(p,gridbagconstraints.none, gridbagconstraints.center,0,0,2,1,1,1,labbookpress);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,3,1,1,1,txtbookpress);/注册事件侦听器btnok.addactionlistener(this);btncancel.addactionlistener(this);btnpre.addactionlistener(this);btnnext.addactionlistener(this);btnok.seticon(new imageicon(image/ok20.gif);btncancel.seticon(new imageicon(image/cancel20.gif);btnpre.seticon(new imageicon(image/pre20.gif);btnnext.seticon(new imageicon(image/next20.gif);btnnext.sethorizontaltextposition(swingconstants.left);/在增加模式下前后移动按钮置为不可用/读者扩展该程序具有编辑功能时,可以将前后移动按钮置为可用if(s.equals(增加)btnpre.setenabled(false);btnnext.setenabled(false);/面板ap中显示4个按钮jpanel ap=new jpanel();ap.setlayout(new gridbaglayout();layoututil.add(ap,gridbagconstraints.none, gridbagconstraints.center,0,0,0,0,1,1,this.btnpre);layoututil.add(ap,gridbagconstraints.none, gridbagconstraints.center,0,0,1,0,1,1,this.btnnext);layoututil.add(ap,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,2,0,1,1,new jlabel();layoututil.add(ap,gridbagconstraints.none, gridbagconstraints.center,0,0,3,0,1,1,this.btnok);layoututil.add(ap,gridbagconstraints.none, gridbagconstraints.center,0,0,4,0,1,1,this.btncancel); getcontentpane().add(p,borderlayout.center);getcontentpane().add(ap,borderlayout.south);/将对话框窗口定位在父窗口的居中位置setsizeandposition(550,120);this.addwindowlistener(new windowadapter()public void windowclosing(windowevent e)actioncode=close;);/将对话框窗口定位在父窗口的居中位置public void setsizeandposition(int w,int h)this.setsize(w,h);dimension d=f.getsize();point pp=f.getlocation();this.setlocation(pp.x+(d.width-w)/2,pp.y+(d.height-h)/2);public void actionperformed(actionevent e)object s=e.getsource();if(s=this.btncancel)this.actioncode=this.cancel;this.setvisible(false);else if(s=this.btnok) okclicked();public string getid()return txtid.gettext().trim();public string getbookname()return txtbookname.gettext().trim();/将图书单价由字符串类型转化为double类型/如果不是合法的数值字符串,取值double.negative_infinitypublic double getbookprice()double result=double.negative_infinity;tryresult=double.parsedouble(this.txtbookprice.gettext().trim();catch(exception e)result=double.negative_infinity;return new double(result);public string getbookpress()return txtbookpress.gettext().trim();public int getactioncode()return this.actioncode;public void okclicked()/图书编号不为空,且价格为数值类型时 隐藏对话框if(!this.txtid.gettext().trim().equals()try double.parsedouble(this.txtbookprice.gettext().trim();catch(exception e)joptionpane.showmessagedialog(f,价格非法!,提示,joptionpane.information_message); return ;this.actioncode=this.ok;this.setvisible(false);elsejoptionpane.showmessagedialog(f,请设定图书编号!,提示, joptionpane.information_message); class searchdialog extends jdialog implements actionlistenerfinal int ok=1; final int cancel=-1; final int close=0;private int actioncode=cancel;private jradiobutton radid=new jradiobutton( 图书编号 );private jtextfield txtid=new jtextfield();private jradiobutton radbookname=new jradiobutton( 图书名称 );private jtextfield txtbookname=new jtextfield();private jradiobutton radbookpress=new jradiobutton( 出 版 社 );private jtextfield txtbookpress=new jtextfield();private jbutton btnok=new jbutton(确定(yes);private jbutton btncancel=new jbutton(取消(esc); private jframe f=null;public searchdialog(jframe f,string s,boolean b)super(f,s,b);this.f=f;buttongroup group=new buttongroup();group.add(radid);group.add(radbookname);group.add(radbookpress);txtid.seteditable(false);radbookname.setselected(true);txtbookpress.seteditable(false);radid.addactionlistener(this);radbookname.addactionlistener(this);radbookpress.addactionlistener(this);/面板p中显示查询条件jpanel p=new jpanel();p.setlayout(new gridbaglayout();layoututil.add(p,gridbagconstraints.none, gridbagconstraints.center,0,0,0,0,1,1,radid);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,1,0,1,1,txtid);layoututil.add(p,gridbagconstraints.none, gridbagconstraints.west,0,0,0,1,1,1,radbookname);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,1,1,1,1,txtbookname);layoututil.add(p,gridbagconstraints.none, gridbagconstraints.center,0,0,0,2,1,1,radbookpress);layoututil.add(p,gridbagconstraints.horizontal, gridbagconstraints.center,100,0,1,2,1,1,txtbookpress);btnok.seticon(new imageicon(image/ok20.gif);btncancel.seticon(new imageicon(image/cancel20.gif);btnok.addactionlistener(this);btncancel.addactionlistener(this);/面板ap中显示确定 取消按钮jpanel ap=new jpanel();ap.add(btnok);ap.add(btncancel);getcontentpane().add(p,borderlayout.center);getcontentpane().add(ap,borderlayout.south);setsizeandposition(300,200);this.addwindowlistener(new windowadapter()public void windowclosing(windowevent e)actioncode=close;);/将对话框窗口定位在父窗口的居中位置public void setsizeandposition(int w,int h)this.setsize(w,h);dimension d=f.getsize();point pp=f.getlocation();this.setlocation(pp.x+(d.width-w)/2,pp.y+(d.height-h)/2);public void settxteditable(boolean b1,boolean b2,boolean b3)txtid.seteditable(b1);txtbookname.seteditable(b2);txtbookpress.seteditable(b3);public void actionperformed(actionevent e)object s=e.getsource();if(s=this.radid)settxteditable(true,false,false);else if(s=this.radbookname)settxteditable(false,true,false);else if(s=this.radbookpress)settxteditable(false,false,true);else if(s=this.btnok)this.actioncode=this.ok;this.setvisible(false);else if(s=this.btncancel)this.actioncode=this.cancel;this.setvisible(false);public int getactioncode()return actioncode;public string getsql()string sql=select * from bookinfo where ;if(radid.isselected()sql=sql+ bookid like %+txtid.gettext().trim()+%;else if(radbookname.isselected()sql=sql+ bookname like %+txtbookname.gettext().trim()+%;else if(radbookpress.isselected()sql=sql+ bookpress like %+txtbookpress.gettext().trim()+%;return sql;package edu.njust.cs;import java.sql.*;import javax.swing.*;import java.util.*;import java.io.*;public class sqlutil/读入配置文件public static properties loadproperty(string filename)properties prop=new properties();tryfileinputstream in=new fileinputstream( system.getproperties().get(user.dir)+/+filename);prop.load(in);in.close();catch(ioexception e)e.printstacktrace();joptionpane.showmessagedialog(null, 配置文件丢失!n建议重新安装程序, 信息, joptionpane.error_message);prop=null;return prop;/建立和ms sql server的连接public static connection acquireconnection(string host,string port,string dbname,string user,string pwd) throws classnotfoundexception,sqlexceptionconnection connection=null;tryclass.forname(com.microsoft.jdbc.sqlserver.sqlserverdriver);string url =jdbc:microsoft:sqlserver:/+host+:+port+;user=+user+;password=+pwd; co

温馨提示

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

评论

0/150

提交评论