java-Single version of the bookstore Management System (series one)

Source: Internet
Author: User

Bookstore Management System:

Project Practice Objectives:
1. Basic analysis of Java application
2. Cultivating the basic idea of object-oriented programming
3, Java basic design mode comprehensive application
4. Master the basic design of layering and interface
5. Construct a reasonable Java application package structure
6, comprehensive application of JSE learning knowledge
7. Use the set frame rationally in the application
8. Use the general components of swing in the application
9. Realization mechanism of basic presentation layer
10. Basic operation of IO stream and file
11. Develop good Java programming habits
12, training the ability to debug Java programs, training the ability to change the wrong

Project function Requirements:
1, can operate the user's registration, modify the basic information, delete and query.
2, can add to the basic information of books, delete, modify and query operation.
3, can fill in the purchase order, a purchase order with a number of specific incoming information, the purchase of books must be in the book management has already had, and the purchase of inventory corresponding to the stock of books.
4, can fill out a sales order, a sales order with a number of specific sales information, sales of books must be in the book management has already had, and the number of sales can not exceed the current inventory quantity, sales of the same time to modify inventory corresponding books inventory volume.
5, you can view the inventory details, you can follow the conditions to find the specific inventory value of the book.
6, the permission to simplify, do a fixed permission control. The user according to the module into different operating rights of the personnel, a special Admin user, you can operate all the functions.

Project Basic Design:
★ Architecture Design
Overall framework, module division
Module Division: 5 Modules for users, books, purchase, Sales and inventory

★ System Function Structure Design
Specific functional sub-modules for each function module

★ Database Design
Project Framework Implementation: Sub-modules, tiering, subcontracting, building applications

1. User Management (User.txt)

Description: The type of which is of type int and is used to represent the types of the operation user.
As the admin, you can do all the work
2--as a person who can operate a library module
3--represents the person who can operate the incoming module
4--represents the person who can operate the sales module
5--represents the person who can operate the Inventory module

2. Book Management (Book.txt)

3. Stock Management (InMain.txt)

4, Purchase details management (InDetail.txt)

5. Sales Management (OutMain.txt)

6. Sales Detail Management (OutDetail.txt)

7. Inventory Management (Stock.txt)

Subcontracting of Projects

First layer: According to the module sub-
User module (users),
Books (book),
Incoming (in),
Sales (out),
Inventory (store)

Second layer: According to the three-layer mode
Presentation layer (UI), logical layer (business), and Data Layer (DAO)
You typically add a Value object layer (VO)

The third layer: according to the division in the layer to divide
Depending on the circumstances, such as business and DAO also in the form of the Iron Triangle to build the sub-package, and the UI and VO do not need to re-draw the molecular bag.

Project Layering idea:

Not perfect, please continue to follow this series (ii)

The following is part of the code: (A public class inside Util)
Cn.hncu.bookStore.util
Fileioutil.java:

 PackageCn.hncu.bookStore.util;ImportJava.io.File;ImportJava.io.FileInputStream;ImportJava.io.FileNotFoundException;ImportJava.io.FileOutputStream;ImportJava.io.IOException;ImportJava.io.ObjectInputStream;ImportJava.io.ObjectOutputStream;ImportJava.util.ArrayList;ImportJava.util.List;ImportJavax.swing.JOptionPane;/** * User's public data read Write class * @author Chen Haoxiang * * @version 1.0 */ Public  class fileioutil {     Public Fileioutil() {    }/** * Read all data from the database and return it * * @param filename (the file name corresponding to the data table) * @param ee (the type of generic type passed over !     * @return records for all tables! */    @SuppressWarnings("Unchecked")//Pressure warning     Public Static<E> list<e>Readformfile(String filename,e ee) {List<e> List =NewArraylist<e> ();FinalFile File =NewFile (FileName); ObjectInputStream in =NULL;if(!file.exists ()) {Joptionpane.showmessagedialog (NULL,"Data sheet does not exist!" ");returnList }Try{in =NewObjectInputStream (NewFileInputStream (FileName));Try{list = (list<e>) in.readobject (); }Catch(ClassNotFoundException e)            {E.printstacktrace (); }        }Catch(FileNotFoundException e)        {E.printstacktrace (); }Catch(IOException e)        {E.printstacktrace (); }finally{if(in!=NULL){Try{In.close (); }Catch(IOException e) {Throw NewRuntimeException ("Database shutdown failed"); }            }        }returnList }/** * Writes a list collection into the data file filename * * @param list (data collection needed to be stored) * @param filename (written to which The file name of the file) * /     Public Static void Write2file(list<object> List, String fileName) {ObjectOutputStream out =NULL;Try{out =NewObjectOutputStream (NewFileOutputStream (FileName));        Out.writeobject (list); }Catch(FileNotFoundException e)        {E.printstacktrace (); }Catch(IOException e)        {E.printstacktrace (); }finally{if(out!=NULL){Try{Out.close (); }Catch(IOException e) {Throw NewRuntimeException ("Database shutdown failed!"); }            }        }    }}

Encapsulated User data:

Cn.hncu.bookStore.user.vo;
Usermodel.java

 PackageCn.hncu.bookStore.user.vo;/** * @author Chen Haoxiang * @version 1.0 * * <br/> * Value object for saving user information <br/> * 1, Serializable <br/> * 2, Privatization of all variable members, complement Setter-getters method <br/> * 3, Write Equals and hashcode method----Unique identification code with primary key (UUID) <br/> * 4, tostring Method <br/ > * 5, NULL parameter construction method <br/> * / Public  class usermodel {    PrivateString uuid;//user Unique identification code    PrivateString name;//user name    Private intType//user type    PrivateString pwd;//user password     Public Usermodel() {    }/** * Function: Get uuid-user's unique identification code * * @return return uuid-user's unique identifier */     PublicStringGetuuid() {returnUuid }/** * Function: Set uuid-user's unique identification code * @param uuid-User's unique identification code-string type parameter */     Public void Setuuid(String uuid) { This. uuid = UUID; }/** * Function: Get the user's username * @return---name-username */     PublicStringGetName() {returnName }/** * Function: Set User's username * * @param name--user Set user name, string parameter */     Public void SetName(String name) { This. name = name; }/** * Function: Get the type of the user: * As the admin, you can do all the operation * 2--for the person who can operate the Library module * 3--expressed as the person who can operate the incoming module * 4--expressed as able to operate the sales module The person * 5--represents the type of person who can manipulate the Inventory module * @return user * *     Public int GetType() {returnType }/** * Function: Set the type of the user: * As the admin, you can do all the actions * 2--for the person who can operate the book module * 3--expressed as the person who can operate the incoming module * 4--to be able to operate the sales model The person of the block * 5--is expressed as the person who can manipulate the Inventory module * @param type--user type-int parameter */     Public void SetType(intType) { This. type = type; }/** * Function: Get user's password * @return String type, user's password */     PublicStringgetpwd() {returnPwd }/** * Function: Set user's password * @param pwd--string type parameter */     Public void setpwd(String pwd) { This. pwd = pwd; }@Override     Public int hashcode() {Final intPrime = to;intresult =1; result = Prime * result + (uuid = =NULL) ?0: Uuid.hashcode ());returnResult }@Override     Public Boolean equals(Object obj) {if( This= = obj)return true;if(obj = =NULL)return false;if(GetClass ()! = Obj.getclass ())return false; Usermodel other = (Usermodel) obj;if(UUID = =NULL) {if(Other.uuid! =NULL)return false; }Else if(!uuid.equals (Other.uuid))return false;return true; }@Override     PublicStringtoString() {return "Usermodel [uuid="+ UUID +", name="+ name +", type="+ Type +", pwd="+ pwd +"]"; }}

Encapsulated user query data:
Cn.hncu.bookStore.user.vo;
Userquerymodel.java

package cn.hncu.bookStore.user.vo;publicclass UserQueryModel extends UserModel{  }

Although this class does not have anything, just inherits the Usermodel, but still must write, this is everybody adheres to the Java writing specification!

User DAO (Data Layer): (interface)
Cn.hncu.bookStore.user.dao.dao;
Userdao.java

 PackageCn.hncu.bookStore.user.dao.dao;ImportJava.util.List;ImportCn.hncu.bookStore.user.vo.UserModel;ImportCn.hncu.bookStore.user.vo.UserQueryModel;/** * * @author Chen Haoxiang * * @version 1.0 * Data-tier interface for user modules */ Public  interface Userdao {    /** * Function: Create a user * * @param Usermodel---The user data to be created * @return---True indicates a successful creation, false means creation failed */     Public Boolean Create(Usermodel user);/** * Function: Delete a user * * @param UUID---User unique identification code, each user will not be the same * @return---True indicates that the deletion succeeded, false indicates Delete failed * /     Public Boolean Delete(String uuid);/** * Function: Modify user data information * * @param User---Need to modify the parameter name of the users data * @return return true-indicates that the modification succeeded, return false-table Failed to change the display * /     Public Boolean Update(Usermodel user);/** * Function: Get all user Data * * @return---A Usermodel collection, that is, the user's data */     PublicList<usermodel>GetAll();/** * Function: Search According to certain criteria, * <br/> * return user data that satisfies the search criteria. * * @param UQM---encapsulated search criteria * @return---A collection of user data that satisfies the find criteria */     PublicList<usermodel>getbycondition(Userquerymodel UQM);/** * Function: Get a certain user's data information * * @param UUID---User unique identification code * @return ---Returns the number of users found by this unique identification code According to * /     PublicUsermodelGetsingle(String uuid);}

java-Single version of the bookstore Management System (series one)

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.