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(); } }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)