java书店系统毕业设计 总体设计(1)
程序员文章站
2024-03-13 08:51:57
java书店系统项目功能需求:
1、能进行操作用户的注册,修改基本信息,删除和查询。
2、能对图书的基本信息进行增加、删除、修改和查询操作。
3、能填写进货...
java书店系统项目功能需求:
1、能进行操作用户的注册,修改基本信息,删除和查询。
2、能对图书的基本信息进行增加、删除、修改和查询操作。
3、能填写进货单,一张进货单带有多条具体的进货信息,进货的书籍必须是图书管理里面已经有的;进货的同时修改库存对应书籍的存货量。
4、能填写销售单,一张销售单带有多条具体的销售信息,销售的书籍必须是图书管理里面已经有的,而且销售的数量不能超过当前库存的数量;销售的同时修改库存对应书籍的存货量。
5、可以查看库存的明细,可以按照条件进行查找具体的图书的库存值。
6、权限方面进行简化,做固定的权限控制。把用户按照模块分成不同操作权限的人员,特设一个admin的用户,可以操作全部的功能。
项目基本设计:
★ 架构设计:
整体框架、模块划分
模块划分:用户、图书、进货、销售和库存5个模块
★ 系统功能结构设计:
每个功能模块的具体功能子模块
★ 数据库设计:
项目框架实现:分模块、分层、分包、构建应用程序
核心框架—-实现每个界面的转换
package cn.hncu.bookstore; import cn.hncu.bookstore.login.ui.login; /** * *@author<a href="mailto:2402201666@qq.com">xzm</a> */ public class bookstoreapp extends javax.swing.jframe { private static final long serialversionuid = 1l; /** creates new form bookstoreapp */ public bookstoreapp() { initcomponents(); this.setcontentpane(new login(this));//添加登录界面 this.validate(); getcontentpane().setlocation(150, 50); } //gen-begin:initcomponents // <editor-fold defaultstate="collapsed" desc="generated code"> private void initcomponents() { menubar = new javax.swing.jmenubar(); filemenu = new javax.swing.jmenu(); openmenuitem = new javax.swing.jmenuitem(); savemenuitem = new javax.swing.jmenuitem(); saveasmenuitem = new javax.swing.jmenuitem(); exitmenuitem = new javax.swing.jmenuitem(); editmenu = new javax.swing.jmenu(); cutmenuitem = new javax.swing.jmenuitem(); copymenuitem = new javax.swing.jmenuitem(); pastemenuitem = new javax.swing.jmenuitem(); deletemenuitem = new javax.swing.jmenuitem(); helpmenu = new javax.swing.jmenu(); contentsmenuitem = new javax.swing.jmenuitem(); aboutmenuitem = new javax.swing.jmenuitem(); jmenu1 = new javax.swing.jmenu(); menuitemuser = new javax.swing.jmenuitem(); menuitembook = new javax.swing.jmenuitem(); menuiteminmain = new javax.swing.jmenuitem(); menuitemoutmain = new javax.swing.jmenuitem(); menuitemstock = new javax.swing.jmenuitem(); menuitemlogin = new javax.swing.jmenuitem(); setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); setminimumsize(new java.awt.dimension(800, 600)); getcontentpane().setlayout(null); filemenu.settext("file"); openmenuitem.settext("open"); filemenu.add(openmenuitem); savemenuitem.settext("save"); filemenu.add(savemenuitem); saveasmenuitem.settext("save as ..."); filemenu.add(saveasmenuitem); exitmenuitem.settext("exit"); exitmenuitem.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { exitmenuitemactionperformed(evt); } }); filemenu.add(exitmenuitem); menubar.add(filemenu); editmenu.settext("edit"); cutmenuitem.settext("cut"); editmenu.add(cutmenuitem); copymenuitem.settext("copy"); editmenu.add(copymenuitem); pastemenuitem.settext("paste"); editmenu.add(pastemenuitem); deletemenuitem.settext("delete"); editmenu.add(deletemenuitem); menubar.add(editmenu); helpmenu.settext("help"); contentsmenuitem.settext("contents"); helpmenu.add(contentsmenuitem); aboutmenuitem.settext("about"); helpmenu.add(aboutmenuitem); menubar.add(helpmenu); jmenu1.settext("menu"); menuitemuser.setaccelerator(javax.swing.keystroke.getkeystroke( java.awt.event.keyevent.vk_u, java.awt.event.inputevent.ctrl_mask)); menuitemuser.settext("\u7528\u6237\u6a21\u5757"); menuitemuser.setenabled(false); menuitemuser.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { menuitemuseractionperformed(evt); } }); jmenu1.add(menuitemuser); menuitembook.setaccelerator(javax.swing.keystroke.getkeystroke( java.awt.event.keyevent.vk_b, java.awt.event.inputevent.ctrl_mask)); menuitembook.settext("\u56fe\u4e66\u6a21\u5757"); menuitembook.setenabled(false); menuitembook.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { menuitembookactionperformed(evt); } }); jmenu1.add(menuitembook); menuiteminmain.setaccelerator(javax.swing.keystroke.getkeystroke( java.awt.event.keyevent.vk_i, java.awt.event.inputevent.ctrl_mask)); menuiteminmain.settext("\u8fdb\u8d27\u6a21\u5757"); menuiteminmain.setenabled(false); menuiteminmain.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { menuiteminmainactionperformed(evt); } }); jmenu1.add(menuiteminmain); menuitemoutmain.setaccelerator(javax.swing.keystroke.getkeystroke( java.awt.event.keyevent.vk_o, java.awt.event.inputevent.ctrl_mask)); menuitemoutmain.settext("\u9500\u552e\u6a21\u5757"); menuitemoutmain.setenabled(false); menuitemoutmain.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { menuitemoutmainactionperformed(evt); } }); jmenu1.add(menuitemoutmain); menuitemstock.setaccelerator(javax.swing.keystroke.getkeystroke( java.awt.event.keyevent.vk_s, java.awt.event.inputevent.ctrl_mask)); menuitemstock.settext("\u5e93\u5b58\u6a21\u5757"); menuitemstock.setenabled(false); menuitemstock.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { menuitemstockactionperformed(evt); } }); jmenu1.add(menuitemstock); menuitemlogin.setaccelerator(javax.swing.keystroke.getkeystroke( java.awt.event.keyevent.vk_l, java.awt.event.inputevent.ctrl_mask)); menuitemlogin.settext("\u6ce8\u9500"); menuitemlogin.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { menuitemloginactionperformed(evt); } }); jmenu1.add(menuitemlogin); menubar.add(jmenu1); setjmenubar(menubar); pack(); }// </editor-fold> //gen-end:initcomponents private void menuitemloginactionperformed(java.awt.event.actionevent evt) { //切换到登录界面,灭掉切换到五个界面的功能菜单 menuitembook.setenabled(false); menuiteminmain.setenabled(false); menuitemoutmain.setenabled(false); menuitemstock.setenabled(false); menuitemuser.setenabled(false); this.setcontentpane(new login(this)); this.validate(); } void menuitemstockactionperformed(java.awt.event.actionevent evt) { //切换到库存模块 this.setcontentpane(new cn.hncu.bookstore.store.ui.listpanel(this)); this.validate(); } void menuitemoutmainactionperformed(java.awt.event.actionevent evt) { //切换到销售模块 this.setcontentpane(new cn.hncu.bookstore.out.ui.listpanel(this)); this.validate(); } void menuiteminmainactionperformed(java.awt.event.actionevent evt) { //切换到进货模块 this.setcontentpane(new cn.hncu.bookstore.in.ui.listpanel(this)); this.validate(); } void menuitembookactionperformed(java.awt.event.actionevent evt) { //切换到图书模块 this.setcontentpane(new cn.hncu.bookstore.book.ui.listpanel(this)); this.validate(); } private void menuitemuseractionperformed(java.awt.event.actionevent evt) { //切换到用户模块 this.setcontentpane(new cn.hncu.bookstore.user.ui.listpanel(this)); this.validate(); } public javax.swing.jmenuitem getmenuitemoutmain() { return menuitemoutmain; } public javax.swing.jmenuitem getmenuitembook() { return menuitembook; } public javax.swing.jmenuitem getmenuiteminmain() { return menuiteminmain; } public javax.swing.jmenuitem getmenuitemstock() { return menuitemstock; } public javax.swing.jmenuitem getmenuitemuser() { return menuitemuser; } private void exitmenuitemactionperformed(java.awt.event.actionevent evt) {//gen-first:event_exitmenuitemactionperformed system.exit(0); }//gen-last:event_exitmenuitemactionperformed /** * @param args the command line arguments */ public static void main(string args[]) { java.awt.eventqueue.invokelater(new runnable() { public void run() { new bookstoreapp().setvisible(true); } }); } //gen-begin:variables // variables declaration - do not modify private javax.swing.jmenuitem menuitemoutmain; private javax.swing.jmenuitem aboutmenuitem; private javax.swing.jmenuitem contentsmenuitem; private javax.swing.jmenuitem copymenuitem; private javax.swing.jmenuitem cutmenuitem; private javax.swing.jmenuitem deletemenuitem; private javax.swing.jmenu editmenu; private javax.swing.jmenuitem exitmenuitem; private javax.swing.jmenu filemenu; private javax.swing.jmenu helpmenu; private javax.swing.jmenu jmenu1; private javax.swing.jmenubar menubar; private javax.swing.jmenuitem menuitembook; private javax.swing.jmenuitem menuiteminmain; private javax.swing.jmenuitem menuitemlogin; private javax.swing.jmenuitem menuitemstock; private javax.swing.jmenuitem menuitemuser; private javax.swing.jmenuitem openmenuitem; private javax.swing.jmenuitem pastemenuitem; private javax.swing.jmenuitem saveasmenuitem; private javax.swing.jmenuitem savemenuitem; // end of variables declaration//gen-end:variables }
工具包:
package cn.hncu.bookstore.utils; import java.text.dateformat; import java.text.parseexception; import java.text.simpledateformat; import java.util.date; public class dateutils { /** * 把long型时间转换成日期格式"yyyy年mm月dd日hh:mm:ss:"的字符串 * @param t * 待转换的(long型)时间 * @return * 日期格式的字符串 */ public static string longtostring(long t){ date d=new date(); dateformat df=new simpledateformat("yyyy年mm月dd日hh:mm:ss:"); return df.format(d); } /** * 把日期格式"yyyy-mm-dd-hh:mm:ss:"的字符串转换成long型时间 * @param str * 待转换的日期字符串 * @return * long型时间 * @throws parseexception */ public static long stringtolong(string str) throws parseexception{ dateformat df=new simpledateformat("yyyy-mm-dd-hh:mm:ss:"); date d=df.parse(str); return d.gettime(); } }
package cn.hncu.bookstore.utils; import java.io.file; import java.io.fileinputstream; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.io.objectinputstream; import java.io.objectoutputstream; import java.util.arraylist; import java.util.list; public class fileioutil { /** * 构造函数私有化 */ private fileioutil(){ } /** * 把目录filename里的数据读出 * @param filename * 文件地址 * @return * 返回对应类型的集合 */ public static<e> list<e> readfromfile(string filename){//定义在静态方法上的泛型 file file=new file(filename);//凡是读文件,最好用file开道 if(!file.exists()){//文件不存在返回空集合 return new arraylist<e>(); } objectinputstream in=null; try { in=new objectinputstream(new fileinputstream(file)); @suppresswarnings("unchecked") list<e> list=(list<e>)in.readobject(); return list; } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } catch (classnotfoundexception e) { e.printstacktrace(); }finally{ if(in!=null){ try { in.close(); } catch (ioexception e) { throw new runtimeexception("数据文件关闭失败", e); } } } return new arraylist<e>(); } /** * 存储:向目录filename里读入数据 * @param list * 待存入数据的集合 * @param filename * 文件地址 * @return * 存储成功就返回true,否则,返回false */ public static<e> boolean writetofile(list<e> list,string filename){ objectoutputstream out=null; try { out=new objectoutputstream(new fileoutputstream(filename)); out.writeobject(list); return true; } catch (filenotfoundexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); }finally{ if(out!=null){ try { out.close(); } catch (ioexception e) { throw new runtimeexception("数据文件关闭失败", e); } } } return false; } }
公共功能:
package cn.hncu.bookstore.common; public enum uuidmodelconstance { /** * 枚举:把user的五种类型usermodel,bookmodel,inmainmodel,indetailmodel,outmainmodel,outdetailmodel,stockmodel枚举出来 */ user("usermodel"),book("bookmodel"),in_main("inmainmodel"),in_detail("indetailmodel"), out_main("outmainmodel"),out_detail("outdetailmodel"),stock("stockmodel"); private final string name; private uuidmodelconstance(string name){ this.name=name; } public string getname() { return name; } }
package cn.hncu.bookstore.common.uuid.vo; import java.io.serializable; public class uuidmodel implements serializable{ /** * 用唱票模型自动生成uuid编号 * 封装uuid,自动生成uuid */ private static final long serialversionuid = 1l; private string modelname;//表示usermodel,bookmodel,inmainmodel,indetailmodel,outmainmodel,outdetailmodel,stockmodel private int currentnum;//modelname当前的uuid编号 public uuidmodel(){ } //set,get public string getmodelname() { return modelname; } public void setmodelname(string modelname) { this.modelname = modelname; } public int getcurrentnum() { return currentnum; } public void setcurrentnum(int currentnum) { this.currentnum = currentnum; } @override public int hashcode() { final int prime = 31; int result = 1; result = prime * result + ((modelname == null) ? 0 : modelname.hashcode()); return result; } @override public boolean equals(object obj) { if (this == obj) return true; if (obj == null) return false; if (getclass() != obj.getclass()) return false; uuidmodel other = (uuidmodel) obj; if (modelname == null) { if (other.modelname != null) return false; } else if (!modelname.equals(other.modelname)) return false; return true; } }
package cn.hncu.bookstore.common.uuid.dao.ebi; import cn.hncu.bookstore.common.uuidmodelconstance; public interface uuiddao { /** * 用唱票模型自动生成uuid编号 * @param umc * 需要自动生成uuid的类型(usermodel,bookmodel,inmainmodel,indetailmodel,outmainmodel,outdetailmodel,stockmodel) * @return * 生成对应类型uuid的编号 */ public string getnextnum(uuidmodelconstance umc); }
package cn.hncu.bookstore.common.uuid.dao.ebo; import java.util.list; import cn.hncu.bookstore.common.uuidmodelconstance; import cn.hncu.bookstore.common.uuid.dao.ebi.uuiddao; import cn.hncu.bookstore.common.uuid.vo.uuidmodel; import cn.hncu.bookstore.utils.fileioutil; public class uuidebo implements uuiddao { private final static string file_name="uuid.txt";//把数据存储到uuid.txt文件中,或读取 @override public string getnextnum(uuidmodelconstance umc) { string modelname=umc.getname();//获得待生成uuid编号的user类型 list<uuidmodel> list=fileioutil.readfromfile(file_name);//从文件中读取所有已生成user类型uuid的数据 for(uuidmodel um:list){ if(um.getmodelname().equals(modelname.trim())){//如果modelname在文件中存在,则返回此类型uuid下一个编号 int res=um.getcurrentnum(); um.setcurrentnum(res+1); fileioutil.writetofile(list, file_name);//把经过更新的uuid数据存入文件夹 return ""+res; } } //如果for循环没有找到,说明modelname是第一个,编号为1 //new一个此类型的对象,存入文件夹 uuidmodel um=new uuidmodel(); um.setmodelname(modelname); um.setcurrentnum(2); list.add(um); fileioutil.writetofile(list, file_name); return ""+1; } }
package cn.hncu.bookstore.common.uuid.dao.factory; import cn.hncu.bookstore.common.uuid.dao.ebi.uuiddao; import cn.hncu.bookstore.common.uuid.dao.ebo.uuidebo; public class uuiddaofactory { /** * 构造函数私有化 */ private uuiddaofactory(){ } /** * 获得接口uuiddao * @return * uuiddao */ public static uuiddao getuuiddao(){ return new uuidebo(); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。