Functional requirements of java bookstore system project:
1. Can operate user registration, modify basic information, delete and query.
2. Can add, delete, modify and query the basic information of the book.
3. You can fill out the purchase form. A purchase form contains multiple specific purchase information. The purchased books must be already available in the book management; while purchasing, modifying the inventory volume of the corresponding books in the inventory.
4. You can fill out the sales form. A sales form contains multiple specific sales information. The books sold must be already in the book management, and the sales quantity cannot exceed the current inventory quantity; while selling, modify the inventory volume of the corresponding books in the inventory.
5. You can view the inventory details and find the inventory value of specific books according to the conditions.
6. Simplify the permissions and implement fixed permission control. The user is divided into personnel with different operating permissions according to the module, and a special admin user can operate all functions.
Basic project design:
★ Architectural design:
Overall framework and module division: 5 modules: user, book, purchase, sales and inventory
★ System functional structure design:
Specific functional submodules of each functional module★ Database design:
Project framework implementation: divided into modules, layering, subcontracting, and building application core framework--Implement the transformation of each interface
package cn.hncu.bookStore;import cn.hncu.bookStore.login.ui.Login;/** * *@author<a href="mailto:[email protected]">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));//Add login interface 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.JMenuItem(); cutMenuItem = new javax.swing.JMenuItem(); copyMenuItem = new javax.swing.JMenuItem(); pasteMenuItem = new javax.swing.JMenuItem(); deleteMenuItem = new javax.swing.JMenuItem(); helpMenu = new javax.swing.JMenuItem(); contentsMenuItem = new javax.swing.JMenuItem(); aboutMenuItem = new javax.swing.JMenuItem(); jMenu1 = new javax.swing.JMenuItem(); 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) { //Switch to the login interface and destroy the function menu that switches to five interfaces 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) { //Switch to the inventory module this.setContentPane(new cn.hncu.bookStore.store.ui.listPanel(this)); this.validate(); } void MenuItemOutMainActionPerformed(java.awt.event.ActionEvent evt) { //Switch to sales module this.setContentPane(new cn.hncu.bookStore.out.ui.listPanel(this)); this.validate(); } void menuItemInMainActionPerformed(java.awt.event.ActionEvent evt) { //Switch to purchase module this.setContentPane(new cn.hncu.bookStore.in.ui.listPanel(this)); this.validate(); } void menuItemBookActionPerformed(java.awt.event.ActionEvent evt) { //Switch to the book module this.setContentPane(new cn.hncu.bookStore.book.ui.listPanel(this)); this.validate(); } private void menuItemUserActionPerformed(java.awt.event.ActionEvent evt) { //Switch to the user module 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 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}
Toolkit:
package cn.hncu.bookStore.utils;import java.text.DateFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;public class DateUtils { /** * Convert long-type time to a string in the date format "yyyyy year MM month dd date HH:mm:ss:"* @param t * (long-type) time to be converted* @return * String in the date format*/ public static String longToString(long t){ Date d=new Date(); DateFormat df=new SimpleDateFormat("yyyyy year MM month dd date HH:mm:ss:"); return df.format(d); } /** * Convert the string in the date format "yyyy-MM-dd-HH:mm:ss:" to a long-type time* @param str * Date string to be converted * @return * long-type time* @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 { /** * Constructor privatization*/ private FileIOUtil(){ } /** * Read out the data in the directory fileName* @param fileName * File address* @return * Return the corresponding set of type*/ public static<E> List<E> readFromFile(String fileName){//Define the generic File file=new File(fileName);//For any reading file, it is best to use File to open the channel if(!file.exists()){//The file does not exist and returns an empty set. 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("Data file closing failed", e); } } } return new ArrayList<E>(); } /** * Storage: Read data into the directory fileName* @param list * Collection of data to be stored* @param fileName * File address* @return * Return true if storage is successful, otherwise, return 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("Data file closing failed", e); } } } return false; }} Public functions:
package cn.hncu.bookStore.common;public enum uuidModelConstance { /** * Enumeration: enumerate the five types of 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{ /** * Automatically generate uuid number with vote-sing model* Encapsulate uuid, automatically generate uuid */ private static final long serialVersionUID = 1L; private String modelName;// Indicate UserModel,BookModel,InMainModel,InDetailModel,OutMainModel,OutDetailModel,StockModel private int currentNum;//modelName's current uuid number 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 { /** * Automatically generate uuid number with vote-sing model* @param umc * Types that need to be automatically generated (UserModel,BookModel,InMainModel,InDetailModel,OutMainModel,OutDetailModel,StockModel) * @return * Generate the number of the corresponding type 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";//Storage the data in the uuid.txt file, or read @Override public String getNextNum(uuidModelConstance umc) { String modelName=umc.getName();//Get the user type List<uuidModel> list=FileIOUtil.readFromFile(FILE_NAME);//Read all data of the generated user type uuid from the file for(uuidModel um:list){ if(um.getModelName().equals(modelName.trim())){//If modelName exists in the file, return the next number of this type uuid int res=um.getCurrentNum(); um.setCurrentNum(res+1); FileIOUtil.writeToFile(list, FILE_NAME);//Save the updated uuid data into the folder return ""+res; } } //If the for loop is not found, it means that modelName is the first, numbered 1 //new an object of this type, save it into the folder 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 { /** * constructor private*/ private uuidDAOFactory(){ } /** * Get interface uuidDAO * @return * uuidDAO */ public static uuidDAO getUuidDAO(){ return new uuidEbo(); }} The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.