CPSC 4392 Capstone Project Spring 2011 Software Design Description EZ Inventory Management System (EZIMS) Sean Cox 501-249-1250 srcox@ualr.edu Advisor: Dr. Chia-Chu Chiang Department of Computer Science University of Arkansas at Little Rock Little Rock, Arkansas 72204-1099, USA 501-569-8142 cxchiang@ualr.edu EZ Inventory Management System 1. Introduction 1.1 Purpose 1.2 Scope 1.3 Definitions, acronyms, and abbreviations 1.4 References 1.5 Overview 2. High-Level Design 2.1 Class Descriptions 2.2 Method Descriptions 2.3 Function Call Diagram 3. Detailed Design 3.1 Detailed Method/Variable Descriptions 3.2 Database Entity-Relationship Diagram 3.3 Database Schema 3.4 Database Creation Script 3.5 Database Population Script 3.6 User Interface 4. Appendices 4.1 Screenshots 4.2 Tools Used 1. Introduction 1.1 Purpose The purpose of this software design document is to provide a written description of the software to be produced. The document describes how the various aspects of the software will be implemented. This document will provide enough details and guidance to further develop and implement the EZ Inventory Management System. 1.2 Scope The software to be produced is an inventory management system. The application will reside on the client-side of the client-server configuration and will communicate with the database server to provide information to the user and perform database modification as necessary. This software is designed with simplicity in mind. The average user should be able to use the software in order to add, search, and remove items from inventory as required. The application must be able to provide information accurately and in a timely manner. The application must be able to modify the database as required by the user (adding/removing inventory). 1.3 Definitions, Acronyms and Abbreiviations DBMS – Database Management System EZIMS – EZ Inventory Management System GUI – Graphical User Interface IEEE – Institute of Electrical and Electronics Engineers OS – Operating System SDD – Software Design Document SQL – Server Query Language 1.4 References IEEE Recommended Practice for SRS, IEEE Std 1016-1998, IEEE Computer Society, 1998. Database Systems: Models, Languages, Design and Application Programming, Elmasri R., 2011. 1.5 Overview Section 2 of this document will address the aspects of high-level design. It will provide a list of the methods to be developed and their functionality. It will also describe how the various methods will call each other. Section 3 of this document will address the aspects of detailed design. It will provide a detailed list of the methods to be developed and the pseudo-code for their functionality. It will also describe the design and implementation of the database used with the software. The last section will be an appendix containing any other relevant information to the development of the software. 2. High-Level Design 2.1 Class Descriptions 2.1.1 Server Class – Will provide methods to connect to, disconnect to, initialize, and send commands to the database server. 2.1.2 Database Class – Will provide methods to insert/remove items from the database, search through the database, and modify items in the database. 2.1.3 Item Class – Will provide methods related to individual item objects. Item objects will be able to store information about individual items. A method will be provided to validate objects to ensure that they meet specific format requirements before adding items to the database. 2.2 Method Descriptions 2.2.1 Connect The connect method is used to open a connection to the database server. The user will specify the server which needs to be connected to through the user interface and this method will create the connection. The user must also specify the username and password to login to the server. This method must be able to determine whether the connection was successful and generate appropriate errors on failure. 2.2.2 Disconnect The disconnect method is used to close the connection to the database server. The user will be able to click on a disconnect button which will disconnect them from the server. If the user does not click the button then the connection will be terminated upon exiting the application. 2.2.3 Send The send method will be used to send a command to the server. This will be important because the application must be able to produce the correct SQL queries based on user input. The SQL queries then need to be sent to and executed on the database server. 2.2.4 AddItem The AddItem method will be used to add new items to the database. The user will enter required information into the user interface (from the add item screen) and then submit the information in order to create a new item. The item must be checked to ensure that it meets certain criteria before it can be added to the database. If the new item meets the criteria then the AddItem will invoke the Send method which will be used to create the new item on the database server. 2.2.5 SearchItem The SearchItem method will be used to search for a specified item in the database. The user will be able to enter a set of criteria and values to search for. This method will then retrieve the criteria from the user interface (from the search item screen) and search throughout the database to check for matches. 2.2.6 DeleteItem The DeleteItem method will be used to delete a specified item from the database. The user will be able to select items through the user interface (from the delete item screen) and request to delete them. An important part of this method is to verify that the user wants to delete the specified item. This will help to prevent the accidental deletion of data. 2.2.7 ValidateItem The ValidateItem method will be used to determine whether an item meets specified requirements. This method will be invoked by the AddItem method prior to adding a new item to the database to ensure that the format of each field is correct. If certain fields are not in the correct format then the user will be informed and be requested to correct the required information. 2.2.8 SellItem The SellItem method will be used to indicate that an item is sold. The user will be able to mark an item as sold from the SellItem screen. The user will enter information about the sale such as inventory id, employee id, sale date, and sale amount. The sale will be reflected in the database. 2.3 Function Call Diagram Figure 2.3 shows the various functions used by the application and how they call on each other. The diagram shows the flow of data between different forms and functions of the application. The results of the AddItem, SearchItem, and DeleteItem methods are displayed in the AddItemForm, SearchItemForm, and DelItemForm. The application starts by displaying the Main form. The user then uses the menuinterface to maneuver around the program. Figure 2.3: Function call diagram. 3. Detailed Design 3.1 Detailed Method/Variables Descriptions 3.1 Server Class 3.1.1.1 Server(string server_address) Function: Default constructor for the server class. Requires: Address of the server to connect to. Returns: Nothing. 3.1.1.2 bool Connect(string username, string password) Function: This method connects to the database server. This action must happen prior to any other function because the program requires information from the database to operate. Requires: username - the username to login to the database server. password - the password to login to the database server. Returns: Boolean value dependent on success of connection. true for successful, false for unsuccessful. 3.1.1.3 bool Disconnect() Function: This method disconnects from the database server. This should be the last method executed by the program. If the user does not invoke this method by pressing the disconnect button then it should be automatically performed prior to exiting the program. Requires: Nothing Returns: True if the disconnect operation was successful. False if the operation was unsuccessful. 3.1.1.4 void Send(string Command) Function: This method sends a command to the SQL server. It will be used to provide an interface between the Items class and the database server. Requires: The command to be sent to the server. Returns: Nothing. 3.1.1.5 string username Description: Used to store the username for the database server. Once the Connect method is called with an initial username/password it is stored so that future connections do not require the user to enter login information. 3.1.1.6 string password Description: Used to store the password for the database server. 3.1.1.7 string hostname Description: Stores the hostname to be connected to. The hostname is specified upon the creation of the Server object. The hostname will be stored in the format “tcp://servername:3306”. 3.1.2 Data class 3.1.2.1 bool AddItem(Item myItem) Function: This method adds a new item to the database. It will take all of the information from the application which the user has filled out and store it in the database. Requires: The item object to be added. Returns: A boolean-value based on operation success. If item is successfully added then the method will return true. If the item could not be added then it will return false. 3.1.2.2 bool DeleteItem(int item_id) Function: This method deletes an item from the database. It will allow the user to specify an item by its unique item id and remove it from the database. Requires: The item id to be deleted. Returns: A boolean-value based on the success of the operation. 3.1.2.3 myItem SearchItem(string CriteriaList[], string ValueList[]) Function: This method searches the database for items matching a specified criteria. The method will get search criteria from the user and return the results. Requires: An array of criteria. An array of values for the specified criteria. Returns: An item object. 3.1.2.4 void SellItem(int item_id, int emp_id, int date, int amount) Function: This method is used when an item is sold. It creates a new item in the sales table of the database to indicate that the item has been sold. Requires: The unique item id, the id of the employee who sold the item, the sale date, and the amount the item was sold for. Returns: Nothing. 3.1.3 Item class 3.1.3.1 bool ValidateItem(Item myItem) Function: This method validates the item passed to it. It ensures that all values belonging to the item meet the required format. Requires: The item to be validated. Returns: A Boolean-value based on whether the validation was a successful or not. If the item meets required format then a value of true is returned. 3.1.3.2 int item_id Description: Stores the unique item identifier for the item object. 3.1.3.3 string make Description: Stores the manufacturer of the item. 3.1.3.4 string model Description: Stores the model of the item. 3.1.3.5 string description Description: Stores a description of the item. 3.1.3.6 int cost Description: Stores the amount spent on the item. 3.1.3.7 int price Description: Stores the price of the item. 3.2 Entity-Relationship Diagram Figure 3-2 shows the entity-relationship diagram for the database. Figure 3-2: E-R Diagram for the inventory database. 3.3 Database Schema As displayed by the database schema below, the database will consist of four tables. The items table will contain information about each individual item in the inventory. Each item will be referenced by a unique identifier, known as inv_num. The items table will have a foreign key attribute, category, from the category table. This will be used so that a user must select an item’s category from a list of predefined categories. This reduces the complexity of the program because a user will not have to think of and create a category for each item. They will be able to select one from the drop-down list. The employee table will contain information about employees of the company. Each employee will be referenced by a unique eid. Other information which will be available will be their name and the commission which they receive from each item sold. The category table will consist of a category name and then a description for the category. The name will be the unique identifier for each category as two categories should never have the same name. The category description will be able to assist users in making decisions on which category to place an item. The sales table will consist of the inventory number of the item sold, the id of the employee that sold it, the date it was sold, and the price it was sold for. Although the price for an item is listed under the items table, the employee may reduce the price prior to selling the item. This reduction in price will be reflected in the sales table. Figure 3-3: Database schema for the inventory database. 3.4 Database Creation Script CREATE TABLE ITEM ( inv_num INT NOT NULL, category VARCHAR(30), make VARCHAR(30), model VARCHAR(30), description VARCHAR(200), cost INT, price INT, PRIMARY KEY (inv_num) ); CREATE TABLE CATEGORY ( cat_name VARCHAR(30) NOT NULL, cat_desc VARCHAR(200), PRIMARY KEY(cat_name) ); CREATE TABLE EMPLOYEE ( eid VARCHAR(5) NOT NULL, name VARCHAR(30), commission INT, PRIMARY KEY(eid) ); CREATE TABLE SALES ( sold_by VARCHAR(5) NOT NULL, item_num INT NOT NULL, sale_date DATE, sale_price INT, PRIMARY KEY (item_num, sold_by), FOREIGN KEY (item_num) REFERENCES ITEM(inv_num), FOREIGN KEY (sold_by) REFERENCES EMPLOYEE(eid) ); 3.5 Database Population Script LOAD DATA LOCAL INFILE 'categories.csv' INTO TABLE category FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; LOAD DATA LOCAL INFILE 'employees.csv' INTO TABLE employee FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; LOAD DATA LOCAL INFILE 'items.csv' INTO TABLE item FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; LOAD DATA LOCAL INFILE 'sales.csv' INTO TABLE sales FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n'; 3.6 User Interface This section will describe the user interface which will be used for the program. The user interface will be developed using the Windows Forms applications in Visual Studio. The user interface will use a variety of input devices such as text boxes, buttons, and menus to retrieve input from the user. 3.6.1 Main Form The main form will be the initial screen of the program. All other screens will be generated from this form. The screen will display the options of Connect/Disconnect, Add Item, Search Item, Sell Item, and Delete Item. The user will be able to exit the program by clicking the close button. 3.6.2 AddItem Form The AddItem form will be used to add new items to the database. The form will display fields based on the item attributes from the database. There will be a cancel button so that the user can go back to the main menu if it is decided that an item is not to be added. Each item must have an inventory id, category, make, model, cost, and price, but other fields are not required. The category field will be a drop-down text box which will be generated by obtaining categories from the database. Once the user has entered the required information they will be able to click the add button. Once the add button is clicked a new item object is created from the information retrieved from the form. The information is validated by the ValidateItem method and then added to the database by the AddItem method. 3.6.3 SearchItem Form The SearchItem form will be used to search for items in the database. The form will display a list of fields which can be used as search criteria and then text-boxes which can be used to specify values of the criteria. Once the search criteria are entered the user can click the Search button which calls the SearchItem method. Items which match the criteria are displayed on screen via a text box. 3.6.4 DeleteItem Form The DeleteItem form will be used to delete items from the database. The user will be able to enter an inventory number and then delete the item from the inventory. If the item cannot be found then an error message is displayed. A pop-up box will verify that the user is sure they want to delete the item before deletion takes place. 4. Appendix 4.1 Screenshots The below screen shots give an idea of the look of the user interface. The interface is a form-based environment in which users fill in textboxes and click buttons to perform their actions. Screenshot 1 – Adding new merchandize Screenshot 2 – Logging on to database server. Screenshot 3 – Searching for an item. 4.2 Tools Used Microsoft Office was used to produce this document. The database creation/load script was extracted from a SQL script produced in Notepad. All graphics in this document were produced by OpenOffice Draw, with an exception of screenshots which were produced by Microsoft Paint.