Java Bookstore System Graduate design overall design (1) _java

Source: Internet
Author: User
Tags dateformat uuid

Java Bookstore System Project functional Requirements:

1, can carry out the operation of the user registration, modify basic information, delete and query.
2. The basic information of the book can be added, deleted, modified and query operation.
3, can fill in the purchase list, a purchase order with a number of specific purchase information, purchase books must be books management inside already have;
4, can fill out a sales list, a sales list with a number of specific sales information, the sale of books must be in the book management has been, and the number of sales can not exceed the current number of inventory, sales and modify the inventory corresponding to the inventory of books.
5, you can view the inventory of the details, you can follow the conditions to find the specific book inventory value.
6, the permissions of the simplification, do a fixed authority control. To the user according to the module into different operating rights of personnel, ad hoc a user admin, you can operate all the functions.

Basic project design:

★ Architecture Design:
Overall framework, module division
Module Division: User, book, purchase, sales and inventory of 5 modules

★ System Functional Structure Design:
Specific function modules for each function module
★ Database Design:
Project Framework Implementation: Sub-module, tiering, subcontracting, building applications
Core framework--implementation of each interface transformation

Package Cn.hncu.bookStore;
Import Cn.hncu.bookStore.login.ui.Login; /** * * * @author <a href= "mailto:2402201666@qq.com" >xzm</a> * * public class Bookstoreapp extends.
 JFrame {private static final long serialversionuid = 1L;
  /** creates new form Bookstoreapp * * Public Bookstoreapp () {initcomponents ();
  This.setcontentpane (this) (new login);//Add Login interface This.validate ();
 Getcontentpane (). setlocation (150, 50); }//gen-begin:initcomponents//<editor-fold defaultstate= "collapsed" desc= "generated Code" > private void InitCom
  Ponents () {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) {//Switch to login interface, eliminate the switch to five interface function menu menuitembook.setenabled (FALSE);
  Menuiteminmain.setenabled (FALSE);
  Menuitemoutmain.setenabled (FALSE);
  Menuitemstock.setenabled (FALSE);
  Menuitemuser.setenabled (FALSE);
  This.setcontentpane (The new Login (this));
 This.validate (); } void Menuitemstockactionperformed (Java.awt.event.ActionEvent evt) {//Switch to Inventory module This.setcontentpane (new Cn.hncu.book
  Store.store.ui.listPanel (this));
 This.validate (); }

 void Menuitemoutmainactionperformed (Java.awt.event.ActionEvent evt) {//Switch to Sales module This.setcontentpane (New Cn.hncu.boo
  KStore.out.ui.listPanel (this));
 This.validate (); } void Menuiteminmainactionperformed (Java.awt.event.ActionEvent evt) {//Switch to inbound module This.setcontentpane (new Cn.hncu.boo
  KStore.in.ui.listPanel (this));
 This.validate (); } void Menuitembookactionperformed (Java.awt.event.ActionEvent evt) {//Switch to Library module This.setcontentpane (new Cn.hncu.bookS
  Tore.book.ui.listPanel (this));
 This.validate (); } private void Menuitemuseractionperformed (Java.awt.event.ActionEvent evt) {//Switch to User module This.setcontentpane (new Cn.hn
  Cu.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 Ma In (String args[]) {java.awt.EventQueue.invokeLater (new Runnable () {public void run () {new Bookstoreapp (). Setvi
   Sible (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}

Tool Kits:

Package cn.hncu.bookStore.utils;

Import Java.text.DateFormat;
Import java.text.ParseException;
Import Java.text.SimpleDateFormat;
Import java.util.Date;

The public class Dateutils {

 /**
  * Converts a long time to the date format "yyyy mm month DD Day HH:MM:SS:" String
  * @param t
  * pending conversion (long) time
  * @return
  * Date format string */public
 static string longtostring (Long T) {
  date d=new date ();
  DateFormat df=new SimpleDateFormat ("YYYY year mm month DD Day HH:MM:SS:");
  Return Df.format (d);
 }

 /**
  * Converts the string of the date format "YYYY-MM-DD-HH:MM:SS:" to a long time
  * @param str
  * Date string to be converted
  * @return
  * Long type Time
  * @throws parseexception
 /public static long Stringtolong (String str) throws parseexception{< C27/>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 set of corresponding type/public static<e> list<e> readfromfile (String fileName) {//define generics on static method
  File File=new file (fileName),//usually read files, preferably with the "clear" (!file.exists ()) {//files do not exist return empty set returns to 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 shutdown failed", e);

 }} return new arraylist<e> (); /** * Storage: Read data to directory FileName * @param list * Collection of data to be deposited * @param filename * address * @return * Store succeeds returns true, otherwise, return 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 shutdown failed", e);
 }} return false;

 }
}

Public functions:

Package Cn.hncu.bookStore.common;

public enum Uuidmodelconstance {
 /**
  * Enum: Put the five types of user Usermodel,bookmodel,inmainmodel,indetailmodel, Outmainmodel,outdetailmodel,stockmodel enumerated
  */
 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 * Package UUID with recount model, automatically generate UUID/private static final L
 Ong serialversionuid = 1L; Private String modelname;//represents Usermodel,bookmodel,inmainmodel,indetailmodel,outmainmodel,outdetailmodel, Stockmodel private int Currentnum;//modelname 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;
 The 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 {
 /**
  * Recount model automatically generates UUID number
  * @param UMC
  * The type of UUID needs to be generated automatically (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; The public class Uuidebo implements Uuiddao {private final static String file_name= "Uuid.txt";//stores the data in a Uuid.txt file, or reads the @Ov Erride public String Getnextnum (Uuidmodelconstance UMC) {string modelname=umc.getname ();//Get the user type to generate the UUID number list&lt ;uuidmodel> List=fileioutil.readfromfile (file_name);//Read all data for the generated user type UUID from the file for (Uuidmodel um:list) {if (
    Um.getmodelname (). Equals (Modelname.trim ())) {//if modelname exists in the file, returns this type UUID next numbered int res=um.getcurrentnum ();
    Um.setcurrentnum (res+1);
   Fileioutil.writetofile (list, file_name);//Send the updated UUID data to the folder return "" +res;
  }//If the For loop is not found, the description modelname is the first, numbered 1//new An object of this type, stored in a 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 Privatization *
  *
 private uuiddaofactory () {

 }
 /**
  * Get interface Uuiddao
  * @return
  * Uuiddao/public
 static Uuiddao Getuuiddao () {return
  new Uuidebo ();
 }

}

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.