Você está na página 1de 71

ONLINE CAR SALES MANAGEMENT SYSTEM

BY

ABDUL-AZEEZ ADAMU BADARA


(2031100001)

B.Sc. PROJECT 2015

ONLINE CAR SALES MANAGEMENT SYSTEM

BY

ABDUL-AZEEZ ADAMU BADARA

(2031100001)

A Project Submitted in Partial Fulfilment of the


Requirements for the Degree of Bachelor of
Science in Department of Computer Science,
Federal University Lafia.

AUGUST, 2015

ii

DECLARATION
This project is my original work and has not been presented for a degree in any other
University. No part of this project may be reproduced without the prior written
permission of the author and/or Federal University Lafia.

Abdul-Azeez Adamu Badara :______________________________( Signature ).

Date:_____________________

iii

APPROVAL
This is to certify that ABDUL-AZEEZ, ADAMU BADARA; MAT NO: 2031100001
undertook this research work ONLINE CAR SALES MANAGEMENT SYSTEM and
meets the requirements for submission to the Department of Computer science, Federal
University Lafia, in partial fulfilment for the award of Bachelor of science (B.Sc.)
Computer Science Degree 2015.

..
Mr Ofem, Paulinus
(Project Supervisor)

.
Date

Prof. N.D Choji


(Head of Department)

.
Professor S. B. Junaidu
(External Examiner)

Date

Date

iv

DEDICATION
This project is dedicated to the memory of my late father, Mal. Abdul-Azeez Rabiu
Badara. Indeed he was a good father and to my humble Uncle Mal. Ishaka Ahmad
Galadima, who is the bone and marrow of my education right from primary level up to
the University level.
And to my lovely sister Amina Abdul-Azeez, my beloved mother and the entire
family for their moral and financial support throughout my stay in the University.

ABSTRACT
With the intention of upgrading the current manual system to a web-based system, the
work reported in this project has been proposed to aid effective and efficient management
of vehicle sales. The proposed system is for Sansani Motors (Our real case study). The
new system manages and keeps track of stock and sales of vehicles for effective customer
service delivery and profit maximization. The current management of vehicle stock and
sales at the company is handled manually. The business process relies heavily on paperwork for manual information processing. There is no well-organized system to manage
stock levels and sales. The current manual system was therefore found not suitable for
continuous usage as it does not meet the current needs of the fast-growing company. The
initiative to create a new system that is web-based will help the company to boost
customer service delivery and profit. Business information can be stored and managed
efficiently and in a more organized manner. The new system was developed following the
Analysis and Design Method (SSADM) which structures a project into small, welldefined activities and specifies the sequence and interaction of these activities. This
method enables the user of the system and the developer to better comprehend the
problem and the proposed solution. This new system, if deployed, will enable Sansani
Motors to better manage its business operations.

vi

Table of Contents
TITLE PAGE.i
DECLARATION .............................................................................................................. ii
APPROVAL .................................................................................................................... iii
DEDICATION ................................................................................................................. iv
ABSTRACT...................................................................................................................... v
ACKNOWLEDGEMENT ............................................................................................... ix
CHAPTER ONE: INTRODUCTION ............................................................................... 1
1.1

Background of the Study.................................................................................... 1

1.2

Problem Statement ............................................................................................. 2

1.3

Justification of the Study.................................................................................... 3

1.4

Scope of the Study ............................................................................................. 3

1.5

Aim and Objective ............................................................................................. 4

1.6

Limitations of the Study ..................................................................................... 4

CHAPTER TWO: LITERATURE REVIEW ................................................................... 6


2.1

Electronic Commerce (e-commerce) ................................................................. 6

2.2

Automated Inventory Control System Software ................................................ 8

2.3

Car Sales Management System .......................................................................... 9

2.4

Types of Inventory Control Systems................................................................ 10

2.4.1

Manual Inventory Management System ................................................... 10

2.4.2

Barcode Technology ................................................................................ 11

2.4.3

Radio Frequency Identification (RFID) .................................................... 11

2.4.4

Warehouse Management System .............................................................. 12

2.5

Definition of Basic Concepts ........................................................................... 14

CHAPTER THREE: RESEARCH METHODOLOGY ................................................. 15


3.1

Introduction ...................................................................................................... 15

3.1.1

Waterfall Model............................................................................................ 15

3.1.2 Prototyping ......................................................................................................... 18


3.1.3

The Spiral Model .......................................................................................... 19

3.2

Analysis of the Existing System ..................................................................... 20

3.3

Limitation of the Existing System.................................................................... 20

3.4

Input, Process and Output Analysis ................................................................ 21

3.4.1

Inputs Analysis ......................................................................................... 21

vii
3.4.2

Process Analysis ....................................................................................... 21

3.4.3

Output Analysis ........................................................................................ 22

3.5

Data Flow Diagrams (DFDs) ........................................................................... 23

3.6

Programming Language Choice ....................................................................... 25

3.7

Use Cases ......................................................................................................... 26

3.8

Entity Relationship Diagram for Car Sales System ......................................... 28

3.9

Requirements Specification ............................................................................. 29

3.9.1

Software Requirements ............................................................................. 29

3.9.2

Hardware Requirements ........................................................................... 29

3.9.3

Database Design ........................................................................................... 29

3.9.4

Normalization of Database ....................................................................... 30

CHAPTER FOUR: RESULTS AND FINDINGS .......................................................... 33


4.1

Implementation ................................................................................................ 33

4.2

Results: ............................................................................................................. 33

4.3

Findings ............................................................................................................ 33

CHAPTER FIVE: SUMMARY, CONCLUSION AND RECOMMENDATIONS ...... 34


5.1

Summary .......................................................................................................... 34

5.2

Conclusion........................................................................................................ 35

5.3

Recommendation.............................................................................................. 35

REFERENCES ............................................................................................................... 36
APPENDIX A: User Interface ........................................................................................ 38
APPENDIX B: Source Code .......................................................................................... 44

viii

List of Figures
Fig 3.0-Program Flowchart for Car Sales Management System.24
Fig 3.1-Usecase diagram for a Car Sales Management System..26
Fig 3.2-Entity Relationship diagram for a Car Sales Management System27

ix

ACKNOWLEDGEMENT
Every project big or small is successful largely due to the effort of a number of
wonderful people who have always given their valuable advice or lent a helping hand. I
sincerely appreciate the inspiration; support and guidance of all those people who have
been instrumental in making this project a success.
I feel deeply honoured to express my sincere thanks to my project supervisor, Mr
Paulinus Ofem for guiding me all through the project and providing valuable insights
leading to the successful completion of my project.
I am extremely grateful to the department of Computer Science for the confidence
bestowed in me and entrusting my project entitled Online Car sales Management
System with special reference to Sansani Motors Enterprise Ltd.
Also, am highly indebted to Sansani Motors Enterprise Ltd for taking their time to
provide me with necessary information regarding the project.
Last but not the least I wish to express my deep sense of gratitude to my family
members; especially my uncle, Mal. Ishaka Ahmad Galadima who has been my
sponsor all through, and my friends who have been constant source of inspiration and
encouragement during this project work.

CHAPTER ONE: INTRODUCTION


1.1

Background of the Study

Todays world is computer age; Stone Age is replaced with fabulous achievements

in

science. We are living in the computer age so humans are trying to become automated in
each and every field of his need. Basically automation is an act of replacing human
labour by machines. Automation is useful because when there are machines in place of
humans then the probability of error is minimized.
E-commerce is fast gaining ground as an accepted and used business paradigm. More
and more business houses are implementing web sites providing functionality for
performing commercial transactions over the web. It is reasonable to say that the process
of shopping on the web is becoming commonplace. The objective of this project is to
develop a general purpose e-commerce store where cars can be bought from the comfort
of home through the Internet (Swapna, 2007). However, for implementation purposes,
this paper will deal with an online book store. An online store is a virtual store on the
Internet where customers can browse the catalogue and select products of interest. The
selected items may be collected in a shopping cart. At checkout time, the items in the
shopping cart will be presented as an order. At that

time, more information will be

needed to complete the transaction. Usually, the customer will be asked to fill or select a
billing address, a shipping address, a shipping option, and payment information such as
credit card number. An e-mail notification will be sent to the customer as soon as the
order is placed.

1.2

Problem Statement

In todays fast paced society, its very hard to be competitive without using cutting-edge
technology available in market. After years of business, the data has grown much for
Sansani Motors. It is becoming a challenge for Sansani Motors to manage that data in an
effective way. To be more productive in order processing, Sansani Motors needs a
solution which can facilitate their current processes with use of technology. With
increased amount of orders, it will be difficult for Sansani Motors to manage orders in an
effective and efficient manner. It will be very hard to go through all paper work and back
tracking orders. If there is any complain or review of any order, it takes large amount of
effort and time to backtrack and fix the problem. This results in loss of resources,
increased time, and low output.
All orders are managed using different papers; all information regarding one order is
stored in one physical file. This file contains all the documents related to that particular
order. Once Sansani Motors receive an order, they assign a unique number to that
order/file. Some of the financial details regarding orders are managed in an Excel sheet.
Currently in Sansani Motors the work flow followed is not very efficient due to lack of
Software and digital media usage. Workflow from order quotes, order to invoice and
payments are today made manually without the help of a computerized management
system. This means a lot of manual work, which leads to the loss of control over
operations. Due to higher workloads and more errors, delay in the whole process is
experienced on daily basis. No database exists and thus poor ability to pick out statistics
on for example the existing order stock.

1.3

Justification of the Study

The car sales System is a java based application that can be accessed easily. It basically
provides a tool so as to simplify all the activities involved in cars details. This project
primarily focuses on the elimination of hassles and paperwork to maintain the cars
records. Generally, the proposed system can help provide users with efficient working
environment and more output can be generated through this .This system provide the
user with friendly interface resulting in knowing each and every usability feature of the
system. The proposed system helps in tracking record so that past record can be verified
and one can make decision based on the past records. The system completes the work in
a very less time consumption and high level efficiency. The system is developed in such
way that even new users can also operate the system easily. The calculations are made
quickly and the records are directly saved into the database and can be maintain for
longer period of time. Each record can be retrieved and can be verified for future
transaction. Also the system provides high level of security of data so as to prevent
unauthorized access to the admin modules.

1.4

Scope of the Study

Scope of this project is to investigate and design a software solution which can facilitate
Sansani Motors in performing their daily tasks, improving efficiency, and

helping

them to be more productive. This project will provide a solution through

which

Sansani Motors can easily manage, handle and generate all required information in their
respective format when needed. It will help them to manage order details, financial data,
and historical data and also in producing documents of different

formats

for

different customers. This solution will help Sansani Motors in reducing effort spent on
managing orders. It will also provide them opportunity to explore

possibility

of

4
generating documents, managing financial details and analysing historical data with use
of digitalized solution.

1.5

Aim and Objective

The aim of this research work is to develop a Car Sales Management System for Sansani
Motors. This will aid the management of Sansani Motors in tracking car sales and
control. The aim of the proposed Car Sales Management System is to help

small scale

dealers manage their business with a generic accounting package and extended
functionality with plug-in or other bolt-on software. The specific objectives of

the

research are as follows. To


i.

Investigate the related works on Car Sales Management System domains.

ii.

Design appropriate representation architecture or the proposed Car Sales

Management System.
iii.

Develop a system that supports the implementation of the proposed systems

functionality.
Test and validate the systems performance.

iv.

1.6

Limitations of the Study

This project was constrained by the following factors:


a)

Financial Constraints Bearing in mind the economic state of the nation, it was

found difficult in making both ends meet, because of the exorbitant nature of things
nowadays in travelling for the collection of data needed for the project.
b)

Time Constraints Looking at the interval between the resumption and

vacation of the final semester for the project to be completed, the time given seemed to
be short for the collection of required information for better work to be done.

5
c)

Non-Availability of Material During this project, it was noticed that the

required materials needed for the project are not documented. Those that were
documented lacked storage facilities where they can be reached.

CHAPTER TWO: LITERATURE REVIEW


2.1

Electronic Commerce (e-commerce)

Electronic Commerce (e-commerce) applications support the interaction between


different parties participating in a commerce transaction via the network, as well as the
management of the data involved in the process (Diwakar, 2000). The increasing
importance of e-commerce is apparent in the study conducted by researchers at the GVU
(Graphics, Visualization, and Usability) Centre at the Georgia Institute of Technology. In
their summary of the findings from the eighth survey, the researchers report that ecommerce is taking off both in terms of the number of users shopping as well as the total
amount people are spending via Internet based transactions (Diwakar, 2000). Over three
quarters of the 10,000 respondents report having purchased items online. The most cited
reason for using the web for personal shopping was convenience (65%), followed by
availability of vendor information (60%), no pressure from sales person (55%) and
saving time (53%). Although the issue of security remains the primary reason why more
people do not purchase items online, the GVA survey also indicates that faith in the
security of ecommerce is increasing. As more people gain confidence in current
encryption technologies, more and more users can be expected to frequently purchase
items online (Wiley et al, 1997). A good e-commerce site should present the following
factors to the customers for better usability (Wiley et al, 1997):

Knowing when an item was saved or not saved in the shopping cart.

Returning to different parts of the site after adding an item to the shopping cart.

Easy scanning and selecting items in a list.

Effective categorical organization of products.

Simple navigation from home page to information and order links for specific

products.

Obvious shopping links or buttons.

Minimal and effective security notifications or messages.

Consistent layout of product information.

Another important factor in the design of an e-commerce site is feedback (Kubilus, 200).
The interactive cycle between a user and a web site is not complete until the web site
responds to a command entered by the user. According to Norman (Norman, 1994),
"feedback sending back to the user information about what action has actually been
done, what result has been accomplished is a well-known concept in the science of
control and information theory. Imagine trying to talk to someone when you cannot even
hear your own voice, or trying to draw a picture with a pencil that leaves no mark: there
would be no feedback". Web site feedback often consists of a change in the visual or
verbal information presented to the user. Simple examples include highlighting a
selection made by the user or filling a field on a form based on a user's selection from a
pull down list. Another example is using the sound of a cash register to confirm that a
product has been added to an electronic shopping cart (Norman, 1994).
Completed orders should be acknowledged quickly. This may be done with an
acknowledgment or fulfilment page. The amount of time it takes to generate and
download this page, however, is a source of irritation for many e-commerce users. Users
are quick to attribute meaning to events. A blank page, or what a user perceives to be "a
long time" to receive an acknowledgment, may be interpreted as "there must be
something wrong with the order." If generating an acknowledgment may take longer than
what may be reasonably expected by the user, then the design should include
intermediate feedback to the user indicating the progress being made toward

8
acknowledgment or fulfilment (Norman, 1994). Finally, feedback should not distract the
user. Actions and reactions made by the web site should be meaningful. Feedback should
not draw the user's attention away from the important tasks of gathering information,
selecting products, and placing orders (Norman, 1994).

2.2

Automated Inventory Control System Software

The automated inventory control system software is a computer based system for
tracking product levels, orders, sales and deliveries. It can also be used in the
manufacturing industry to create a work order, bill of materials and other production
related documents. Companies use inventory management software to avoid product
overstock and outages and also, as a tool for organizing inventory data that was generally
stored in hardcopy form (Bolton, 2001).
According to Bolton (2001), the software is made up of components working together to
create a cohesive inventory control system which include:
i.

Asset tracking: This involves tracking products via its barcodes and other

tracking criteria such as serial number when they are in a warehouse or store.
ii.

Order management: Once products reach a certain low level, a companys

inventory control system can be programmed to tell managers to reorder that product.
This helps companies to avoid running out of products or tying up too much capital in
inventory.
iii.

Service management: Companies that are primarily service oriented rather

than product oriented can use this software to track the cost of the materials they use to
provide services. This way, they can attach prices to their services that reflect the total
cost of performing them.

9
Automated inventory control systems are efficient, effective and have helped to
improve the manufacturing industry thereby providing more security to warehouses
while improving customer service.

2.3

Car Sales Management System

According to Wikipedia, a car sale management or dealership management system


(DMS) or auto dealership management system is a bundled management information
system created specifically for automotive industry car dealerships or large equipment
manufacturers, such as Caterpillar Inc. Dealerships, and also adapted for cars, boats,
bikes, RV, and power sports dealers. These systems often contain software that cater to
the needs of the finance, sales, parts, inventory and administration components of
running the dealership. One of their functions can be automating tax returns. A typical
DMS installation includes a central server which stores all data, allowing multi-user
access for as many as 50 or more client computers. Some installations may include thin
clients. Other DMS providers use a centrally-hosted, or software as a service/application
service provider model. A DMS usually offers interfaces with other systems, especially
manufacturer's systems to enable automatic processing of purchases, warranty claims,
price lists and many other data. In Europe many automotive manufacturers prescribe
specific DMS to their dealers though this is no longer officially allowed under the Block
Exemption Regulation. Dealerships use specific software to meet the complex
requirements of their business. Typically small scale dealers will manage their business
with a generic accounting package and extend functionality with plugin's or other bolt-on
software. The advantage for dealers running a specialized system are numerous, however
the primary outcome is a more efficient dealership. Dealer Management software
typically encompasses all the tools mentioned above however difficulty arises when

10
dealership staff are evaluating vendors and deciding what software to implement.
Integration of these tools is the key but dealer principals and other key staff still need to
pay attention to other factors such as cost.

2.4

Types of Inventory Control Systems

Properly managing inventory requires a system of some sort. It does not matter if the
system consists of writing inventory levels on the back of an envelope or using the most
sophisticated radio frequency identification system. As the old saying goes, there are
many ways to skin a cat, the different types of inventory control systems all have pros
and cons. choosing the right one boils down to which system holds the most value for the
company (Rubin, 2007).Basically, there are four types of inventory control systems:

Manual inventory management system

Barcode technology

Radio Frequency Identification (RFID)

Warehouse Management System

2.4.1 Manual Inventory Management System


Many small business owners, especially if the business has very few products, keep track
of inventory manually using a spread sheet. Spread sheets are set up to calculate when
products need to be reordered. At the start of each week, the owner manually counts
products and materials that are on hand and enters the values in the spread sheet and also
enters expected usage based on existing orders. Using the appropriate spread sheet
formulas, the owner can determine if he has enough materials for the week or if
purchases should be made. Manual systems allow the small business owner to manage
inventory with very little investment in systems or training. Maintaining data integrity is

11
a major downside to manual inventory management as a single data entry or formula
error can cause major inaccuracies in the data output. (Lysons, 2001).

2.4.2 Barcode Technology


Barcodes consist of series of parallel vertical lines, or bars, used to assign a unique
identification code to an item. The major use of barcode identification system is to track
inventory automatically. A barcode combines several sequences to create a unique set of
numbers or characters that identifies the item (Encarta, 2009).All major retailers use
barcode technology as part of an overall inventory control system because it increases
the accuracy and efficiency of managing inventory. When a barcode is read at the point
of sale, inventory sales data is immediately read and sent to a broader system that
maintains usage statistics. Barcodes manage inventory at the warehouse level as it
facilitates movement of inventory within the confines of the warehouse. (Kenneth, 2002)

2.4.3 Radio Frequency Identification (RFID)


This technology is relatively new and it works by having a tag that emits information that
can be collected by a reader from a distance. RFID uses two types of technology
manage inventory movement; active and passive technology. Active RFID

to

technology

uses fixed tag readers assigned throughout a warehouse such that anytime an item with
an RFID tag passes the reader, the movement of the item is recorded in the inventory
management software. Active systems work best in environments that require real time
inventory tracking or where inventory security problems exist. Passive RFID technology
requires the use of handheld readers to monitor inventory movement. Because RFID
technology has a reading range of up to 40 feet using passive technology and 300 feet

12
using active technology, it greatly increases the accuracy of moving inventory around a
warehouse (Hamlett, 2006).

2.4.4 Warehouse Management System


According to Wikipedia the free encyclopaedia, a warehouse management system
(WMS) is a key part of the supply chain and primarily aims to control the

movement

and storage of materials within a warehouse and process the associated transactions,
including shipping, receiving, put away and picking. The systems also direct and
optimize stock put away based on real time information about the status of bin
utilization. A WMS monitors the progress of products through the warehouse. It involves
the physical warehouse infrastructure, tracking systems, and communication between
product stations. It is the management of storage of products and services rendered on
the product within the four walls of a warehouse (Sande, 2003). More precisely,
warehouse management involves the receipt, storage and movement of goods, (normally
finished goods), to intermediate storage locations or to a final customer. In the
multiechelon model for distribution, there may be multiple levels of warehouses. This
includes a central warehouse, a regional warehouses (serviced by the central warehouse)
and potentially retail warehouses (serviced by the regional warehouses). According to
Sande (2003), Warehouse management systems help to efficiently monitor the flow of
products. Once data has been collected, there is either batch synchronization with, or a
real time wireless transmission to a central database. The database can then provide
useful reports about the status of goods in the warehouse. Warehouse management
systems often utilize automatic identification and data capture technology, such as
barcode scanners, mobile computers, wireless LANs and potentially radio frequency
identification (RFID) to efficiently monitor the flow of products. According to
Wikipedia, the objective of a warehouse management system is to provide a set of

13
computerized procedures for management of warehouse inventory, space, equipment and
people with the goal of minimizing cost and fulfilment times. This includes:

A standard receiving process to properly handle a shipment when it arrives.

This process can be individualized to each warehouse or product type.

The receipt of stock and returns into a warehouse facility. An efficient

warehouse management system helps companies cut expenses by minimizing the amount
of unnecessary parts and products in storage. It also helps companies keep lost sales to a
minimum by having enough stock on hand to meet demand.

Modelling and managing the logical representation of the physical storage

facilities (e.g. racking, etc.). For example, if certain products are often sold together or
are more popular than others, those products can be grouped together or placed near the
delivery area to speed up the process of picking, packing and shipping to customers.

Enabling a seamless link to order processing and logistics management in order

to pick, pack, and ship product out of the facility.

Tracking where products are stocked, which suppliers they come from, and the

length of time they are stored. By analysing such data, companies can control inventory
levels and maximize the use of warehouse space. Furthermore, firms are more prepared
for the demands and supplies of the market, especially during special circumstances such
as a peak season on a particular month. Through the reports generated by the inventory
management software, firms are also able to gather important data that may be put in a
model for it to be analysed.

14

2.5

Definition of Basic Concepts

Automation: This is the use of technology or computers to control and process data
reducing the need for human intervention.
Software: A computer program or set of instructions that direct a computer to perform
a processing functions.
Information System: A collection of procedures, people, instruction and equipment to
produce information in a useful form.
Processing: This is dealing with something according to an established procedure.
Database: This refers to a large store of related data on a computer that a user can
access and modify.
Password: This is a secret code that must be entered into a computer to enable access
to its applications. It is made up of numbers, letters, special characters or a combination
of any of the above categories.
Inventory Control System: A list of orders to be filled, and prompts workers to pick
the necessary items and provides them with packaging and shipping information.
Computerization: This is the conversion of a manually operated system to a
controlled, organized and automated system.
Research: A careful study of a subject to discover facts, establish a theory or develop a
plan of action based on the facts discovered.
System: A set of computer components functioning together.
Technology: The study of techniques of mobilizing resources such as information for
accomplishing objectives that benefit man and his environment.

15

CHAPTER THREE: RESEARCH METHODOLOGY


3.1

Introduction

The analysis approach adopted in this research work is the Structured Systems Analysis
and Design Method (SSADM). SSADM structures a project into small, well-defined
activities and specify the sequence and interaction of these activities. SSADM also uses
diagrammatic and other modelling techniques to give a more precise (structured)
definition that is understandable by both users and developers. SSADM follows the
waterfall life cycle model starting from the feasibility study to the physical design stage
of development.

3.1.1 Waterfall Model


The Waterfall Model was first Process Model to be introduced. It is also referred to as
a linear-sequential life cycle model. It is very simple to understand and use. In a
waterfall model, each phase must be completed before the next phase can begin and
there is no overlapping in the phases.

Waterfall model is the earliest SDLC approach that was used for software
development.

The waterfall Model illustrates the software development process in a linear sequential
flow; hence it is also referred to as a linear-sequential life cycle model. This means that
any phase in the development process begins only if the previous phase is complete. In
waterfall model phases do not overlap.

16

Waterfall Model design


Waterfall approach was first SDLC Model to be used widely in Software Engineering
to ensure success of the project. In "The Waterfall" approach, the whole process of
software development is divided into separate phases. In Waterfall model, typically,
the outcome of one phase acts as the input for the next phase sequentially.

Following is a diagrammatic representation of different phases of waterfall model.

The sequential phases in Waterfall model are:


Requirement Gathering and analysis: All possible requirements of the system
to be developed are captured in this phase and documented in a requirement
specification doc.
System Design: The requirement specifications from first phase are studied in this
phase and system design is prepared. System Design helps in specifying hardware
and system requirements and also helps in defining overall system architecture.

17
Implementation: With inputs from system design, the system is first developed in
small programs called units, which are integrated in the next phase. Each unit is
developed and tested for its functionality which is referred to as Unit Testing.
Integration and Testing: All the units developed in the implementation phase are
integrated into a system after testing of each unit. Post integration the entire
system is tested for any faults and failures.
Deployment of system: Once the functional and non-functional testing is done,
the product is deployed in the customer environment or released into the market.
Maintenance: There are some issues which come up in the client environment. To
fix those issues patches are released. Also to enhance the product some better
versions are released. Maintenance is done to deliver these changes in the
customer environment.

All these phases are cascaded to each other in which progress is seen as flowing
steadily downwards (like a waterfall) through the phases. The next phase is started only
after the defined set of goals are achieved for previous phase and it is signed off, so the
name "Waterfall Model". In this model phases do not overlap.

Waterfall Model Application


Every software developed is different and requires a suitable SDLC approach to be
followed based on the internal and external factors. Some situations where the use of
Waterfall model is most appropriate are:
Requirements are very well documented, clear and fixed.
Product definition is stable.
Technology is understood and is not dynamic.
There are no ambiguous requirements.

18
Ample resources with required expertise are available to support the
product.
The project is short.

3.1.2 Prototyping
(Chester & Athwall, 2002 ) state that a prototyping methodology produces a
preliminary version of the required system that can be reviewed by end-users. This
means that the system developers would build a prototype of the application based on
the users initial requirements, and then present this to the users for them to test and
review. When the user has reviewed the prototype system, they can suggest
modifications and improvements to the system, which the developers can then go back
and produce a better working system that meets the users requirements identified in
the review. There are two methods of Prototyping, these are identified as:
Throw-away prototypes: a prototype is developed for the users to review to
identify their requirements, this is then discarded and the developers start to
build a new system that incorporates the users requirements, which will then
lead towards the final system.
Evolutionary prototypes: these are based on the idea of developing an initial
implementation, exposing this to user comment and refining it through many
versions until an adequate system has been developed as (Sommerville, 2007)
states. This means that an initial prototype is developed for the users to review,
the user then makes suggestions for modifications or improvements, and these
suggestions are then developed further into the prototype. This process is
carried out until a final system is produced for the user.
The prototyping methodology provides benefits such as better user involvement during
the development of the application, this means that they are also involved in helping to

19
develop the system by suggesting areas of improvement as well as reveal errors and
omissions in the requirements that have been proposed as they review the prototype,
(Sommerville, 2007 ) identified. Another benefit of Prototyping is that it presents the
potential user interface of the application to the user at an early stage of the project.
This allows the developers to modify the interface if it does not satisfy the users needs
before completing the final version of the system.

3.1.3 The Spiral Model


The Spiral model was proposed by Boehm and introduces an evolutionary or iterative
approach to the systems development when compared to the waterfall model as
(Cadle & Yeates, 2008) state. The requirements are gathered and the system is
developed by performing the same activities over a number of cycles, whereas in the
waterfall model the life cycle is all carried out once over a period of time. The process
begins in the center of the spiral and a phase of the development life cycle is
represented within each loop as described by (Sommerville, 2007), therefore the inner
loop may identify system feasibility, the next loop may identify systems analysis, the
next loop systems design, and so on up to the completion of the system. Each of the
four phases in the model are also considered with the completion of each cycle.
The Spiral model introduces the important concepts of objective-setting, risk
management and planning into the development life cycle as (Cadle & Yeates, 2008)
suggest. The factors that affect the outcome of an information system apply to all of
these concepts which the spiral model identifies.
This is therefore an important aspect for the management of the project as it could
determine the success or failure of the development of an information system.
The Waterfall model was chosen in this project work because it is more advantageous
over the other model just as it is highlighted above.

20

3.2

Analysis of the Existing System

The existing system is one that has been manually operated over the years. It is a system
in which all the processes involved are achieved by manual approach. Critical analysis of
this system reveals that it is prone to errors. Careful analysis also shows that due to the
complexities of the manual system, records of inventory kept are inaccurate and
manually operated in such a way that requires the dealer to register sales on a book,
thereby making a staff handle two or three jobs at a time. An example is a staff trying to
register sales and at the same time rushing back to face a queue of impatient retailers
waiting to be attended to. This makes the place so crowded with customers waiting to be
served. Sometimes, due to inadequate staff, customers who have other things to do, end
up missing their various appointments. As a result of this, the attendant finds it very
difficult to have an accurate record as pressure is being mounted on him. The attendant
might end up writing an order meant for another customer and have it delivered to the
wrong person. Sansani Motors operates manually and has not adopted a computerised
mode of operation. This generates inadequate records or exercise improper management
of the company and in extreme cases, the company may lose her customers.

3.3

Limitation of the Existing System

As we know, manual inventory control systems are quite tedious, time consuming and
less efficient and less accurate in comparison to the computerised system. Sansani
Motors has the following problems/weaknesses.
a)

The manual system cannot maintain inventory stocks by its self or without

human help.
b)

Compilation of inventory records consumes a lot of time and manpower.

21
c)

Some records get lost over time while some are not easily found.

d)

It involves lot of paperwork and data processing is very slow.

e)

The environment is not user friendly.

f)

The system does not calculate and give financial reports at a glance and as such,

the degree of decision making in urgent matters is not applicable.


g)

The system is unable to detect faults within the system in case of rectifying

fraud. It takes a long time for mistakes to be rectified and sometimes throws the system
into confusion.

3.4

Input, Process and Output Analysis

3.4.1 Inputs Analysis

The various system inputs include the following input systems.


i.

Customer information

ii.

Card information
This is used to capture customer details and payment information. First a

customer searches for a vehicle, once the search is successful, the customer's basic
details are collected. Lastly, the customer enters his/her credit/debit card information to
pay for the selected vehicle online.

3.4.2 Process Analysis


The customer information collected is stored in a database for future retrieval. Also after
the payment is successful, some processing is carried out to generate the customer's
payment invoice.

22

3.4.3 Output Analysis


Output is the outcome of processing and is generated after the customer's payment is
successful. The output file (invoice) contains the customers basic information like full
names, contact details, shipping details etc. It also contains the total amount paid by the
customer.

3.4.4 FEASIBILITY ANALYSIS


Whatever we think need not be feasible .It is wise to think about the feasibility of any
problem we undertake. Feasibility is the study of impact, which happens in the
organization by the development of a system. The impact can be either positive or
negative. When the positives dominate the negatives, then the system is considered
feasible. Here the feasibility study can be performed in two ways such as technical
feasibility and Economical Feasibility.

Technical Feasibility:
We can strongly say that it is technically feasible, since there will not be much
difficulty in getting required resources for the development and maintaining the system
as well. All the resources needed for the development of the software as well as the
maintenance of the same is available in the organization here we are utilizing the
resources which are available already.

Economic Feasibility
Development of this application is highly economically feasible .The organization
needed not spend much money for the development of the system. The only thing is to
be done is making an environment for the development with an effective supervision.
If we are doing so, we can attain the maximum usability of the corresponding

23
resources. Even after the development, the organization will not be in a condition to
invest more in the organization .Therefore, the system is economically feasible.

3.5

Data Flow Diagrams (DFDs)

System analysis and application developers often make use of data flow diagram also
(called data flow charts or data flow graphs) during problem analysis for software
requirement specifications. DFDs are very important in understanding a system and
effectively used during analysis to show flow of data and or information through a
system. It views a system as a function that transforms inputs to required outputs in a
system. The DFDs aims to capture the transformation that takes place within a system to
the input data so that eventually the output data is produced. Data flow diagrams are
composed of the four basic symbols shown below:

The External Entity symbol represents sources of data to the system or

destinations of data from the system.

The Data Flow symbol represents movement of data

The Data Store symbol represents data that is not moving (delayed data at rest)

The Process symbol represents an activity that transforms or manipulates


Below is the Data Flow Diagram of the proposed Car Sales Management System

24

Start

User Account

Valid User

is
User Valid
?

No

Yes

Is
User
Admin?

No

Is User
Customer?

No

Yes
Yes
Enable all menus

Enable customer menus

Perform operation

Logout/close the software


Stop

Fig 3.0: Program Flowchart for Car Sales Management System

Enable basic menus

25

3.6

Programming Language Choice

Programming languages have strengths in different areas. Some languages are powerful
but can be bug-prone and difficult to work with, while others are simpler but can be
limiting in terms of functionality or performance (Ben et al., 2001). Java can be defined
as a collection of objects that communicate via invoking each other's methods. With the
advancement of Java and its widespread popularity, multiple configurations were built to
suite various types of platforms. Example: J2EE for

Enterprise Applications, J2ME for

Mobile Applications. In this research work, J2EE is used. In this project work, EJB3 is
used because of the following reasons:

Object Oriented: In Java, everything is an Object. Java can be easily extended

since it is based on the Object model.

Platform independent: Unlike many other programming languages including

C and C++, when Java is compiled, it is not compiled into platform specific machine,
rather into platform independent byte code. This byte code is distributed over the web
and interpreted by virtual Machine (JVM) on whichever platform it is being run.

Simple: Java is designed to be easy to learn. If you understand the basic

concept of OOP, Java would be easy to master.

Secure: With Java's secure feature, it enables to develop virus-free, tamper-free

systems. Authentication techniques are based on public-key encryption.

Architectural-neutrality: Java compiler generates an architecture-neutral

object file format, which makes the compiled code to be executable on many processors,
with the presence of Java runtime system.

Robust: Java makes an effort to eliminate error prone situations by

emphasizing mainly on compile time error checking and runtime checking.

26

Multithreaded: With Java's multithreaded feature, it is possible to write

programs that can do many tasks simultaneously. This design feature allows developers
to construct smoothly running interactive applications

Interpreted: Java byte code is translated on the fly to native machine

instructions and is not stored anywhere. The development process is more rapid and
analytical since the linking is an incremental and lightweight process.

High Performance: With the use of Just-In-Time compilers, Java enables high

performance.

Distributed: Java is designed for the distributed environment of the internet.

Dynamic: Java is considered to be more dynamic than C or C++ since it is

designed to adapt to an evolving environment. Java programs can carry extensive amount
of run-time information that can be used to verify and resolve accesses to objects on runtime.

3.7

Use Cases

A use case illustrates a unit of functionality provided by the system. The main purpose of
the use-case diagram is to help development teams visualize the functional requirements
of a system, including the relationship of "actors" (human beings who will interact with
the system) to essential processes, as well as the relationships among different use cases
(Donald, 2003).The use-case diagram of this research work is presented below:

27

System

addCar

deleteCar

updateCarDetails

viewSalesReport
Manager

registerCustomer

viewCar
Customer

orderCar

viewPreviousOrder

Fig 3.1 Use case diagram for a Car Sales Management System

28

3.8

Entity Relationship Diagram for Car Sales System

The Entity relationship is also a part of UML diagrams. The purpose of entity relation
diagram is to depict the classes within a model. In an object oriented programming
classes have attributes or variables, operations or functions and relations with other
classes. A UML diagram can depict all these things very easily. A class icon is simply
a rectangle divided into three parts: the topmost contains class name, the middle
contains list of attributes and the part bottom contains list of functions function.
The following figure shows that the declaration of each parameter of different classes
and it shows the relation among the classes. It also shows that after registering a
customer the information will be saved in the database that will utilized to be logged in
CustomerProfile

CarDatabsae

-String customer Id
-String surname
-String midname
-String fname
-String address
-Int phoneNo
-String email
-String country
-String state

-Int id primary key


-String carMake
-String year
-String EngineNo
-String chasisNo
-Float price
-String image
-Int CarQuantity
-String rview

n
1

Orders
-Int Id primary key
-String customer
-String product
-Int quantity
-Float price
-String

OrderDetails

Fig 3.2 Entity relationship diagram for Car Sales System

-Int order id primary key


-String username
-String fname
-String lname
-String address

29

3.9

Requirements Specification

This proposed software runs effectively on a computer system which has the
minimum requirements. The requirements are split into two categories, namely:

3.9.1 Software Requirements


The minimum software requirements to run the program are listed below

Microsoft Windows XP (Home and Professional Editions), Windows 7

MySQL

JavaScript, NetBeans IDE, CSS, jQuery, JBoss Application Server V6.0.

MySQL-Connector-Java

Browser e.g. Mozilla Firefox, chrome, Flock etc.


Window 7 is used as the operating system in this research work.

3.9.2 Hardware Requirements


The minimum hardware required to run the program are listed below

Hard disk of 20 Giga bytes

System memory (RAM) of 512 Mega bytes

Dot Matrix, Laser jet Printer

Compatible flash drive or external Hard disk

3.9.3 Database Design


In any good database design, effort should be made to remove completely or at worst
reduce redundancy. The database design for the software is achieved using MySQL
database. The database file structure of the proposed system is presented below:

30
Entities/Tables
After the users requirements were defined in the analysis section of the report, the
tables (entities) required in the new database can now be identified. The tables required
in the database were identified as follows for the first iteration of the prototyping
methodology being followed:
Cars: to hold the details of a vehicle.
Pricing: to hold the pricing details of a vehicle.
Customer: to hold details of a buyer of a vehicle.
Payment: to hold the details of payment transaction service.
Sales: to hold the details of Vehicle sales.
Users: to hold the details of the users of the System and their role.
The users table holds only three attributes i.e. username, password and role this is
because the System is designed to accommodate multiple user but each with separate
username and password and their roles are specified.
The decision to have a separate Pricing table to store the pricing details for a vehicle
was simply because there are many pricing attributes required to be stored, and
therefore it would be much more sensible to keep all pricing details in a separate table
for neatness, rather than cluttering the Cars table with too many attributes that could
lead to possible confusion.

3.9.4 Normalization of Database


Database Normalisation is a technique of organizing the data in the database.
Normalization is a systematic approach of decomposing tables to eliminate data
redundancy and undesirable characteristics like Insertion, Update and Deletion

31
Anomalies. It is a multi-step process that puts data into tabular form by removing
duplicated data from the relation tables.
Normalization is used for mainly two purposes,
Eliminating redundant (useless) data.
Ensuring data dependencies make sense i.e. data is logically stored.

Without Normalization, it becomes difficult to handle and update the database, without
facing data loss. Insertion, Update and Deletion Anomalies are very frequent if
Database is not normalized.

An anomaly is an irregularity, or something which deviates from the expected or


normal state.
Update Anomaly: exists when one or more instances of duplicated data are
updated, but not all.
Deletion Anomaly: Exist when certain attributes are lost because of the
deletion of other attributes.
Insertion Anomaly: An insert anomaly occurs when certain attributes cannot
be inserted into the database without the presence of other attributes.
Therefore, normalisation is used to normalize the following database tables to avoid
data redundancy.

32

Table 3.0 Login Table


FIELD DESCRIPTION
USER NAME
PASSWORD
SURNAMES
OTHERNAMES
ROLE

FIELD TYPE
VARCHAR
VARCHAR
VARCHAR
VARCHAR
VARCHAR

FIELD SIZE
15
15
15
30
10

FIELD TYPE
INTEGER
INTEGER
INTEGER
DATETIME
BOOLEAN
DOUBLE

FIELD SIZE

FIELD TYPE
INTEGER
VARCHAR
VARCHAR
VARCHAR
NUMBER
VARCHAR

FIELD SIZE

FIELD TYPE
INTEGER
VARCHAR
VARCHAR
VARCHAR
INTEGER
INTEGER
VARCHAR

FIELD SIZE

Table 3.1 Transaction Table


FIELD DESCRPTION
TRANSACTION ID
CUSTOMER
ID
ITEM
ID
DATE
STATUS
AMOUNT

10;2

Table 3.2 Customer Table


FIELD DESCRIPTION
CUSTOMER ID
SURNAME
OTHERNAMES
ADDRESS
PHONE NUMBER
EMAIL

15
30
250
11
20

Table 3.3 Cars Table


FIELD DESCRIPTION
STOCK
BRAND NAME
MODEL
MAKE
YEAR
BOORS NO
FUEL TYPE

50
50
50
20

33

CHAPTER FOUR: RESULTS AND FINDINGS


4.1

Implementation

In any system analysis and design, implementation is the stage where the designed ideas,
software and hardware components come together or are put in place to have the reality
of full operational functionalities of the designed system. The researcher, at this stage
consistently put to implementation, the design ideas or concepts of the new system to
realize the practical system. The implementation of the system was achieved using EJB3
as the programming language and MySQL as the database. The source code of the
system is presented in Appendix below.

4.2

Results:

This system produces physical results. These results are the outcome or output of the
system which are in accordance with the requirement of the system. The outcome or
outputs of the system can be found in APPENDIX A with each output carrying its title
that explains what it does in the system. The researcher believes that after going through
this work and especially the results of this chapter, readers and users should have a clear
idea and understanding of the system.

4.3

Findings

The result of the work shows that manual information processing can be automated.
The advantage of this automation is evidenced by the fact that, the limitations of the
manual system have been overcome by the web-based System. The efficient and
effective Customer service delivery and profit maximization are better supported by the
new System.

34

CHAPTER FIVE: SUMMARY, CONCLUSION AND


RECOMMENDATIONS
5.1

Summary

The Internet has become a major resource in modern business, thus electronic shopping
has gained significance not only from the entrepreneurs but also from the customers
point of view. For the entrepreneur, electronic shopping generates new business
opportunities and for the customer, it makes comparative shopping possible.
In this project, the user is provided with an e-commerce web site that can be used to
buy cars online. To implement this as a web application EJB3 technology is used.
EJB3 has several advantages such as enhanced performance, scalability, built-in
security and simplicity. Chapter one introduces the subject under discussion, the
statement of the problem, scope and limitations, justification of the study, aims and
objectives of the study and definition of terms.
Chapter two revealed the emergence of Internet Security which helped in encryption
and detection of intrusion. The chapter also covers a review of related literature on
Electronic e-Commerce, Automated Inventory Control Systems, Types of Inventory
Control Systems and Warehouse Management System. Chapter three focuses on the
methodology of information or resources gathering and presentation, analysis of the
system, programming language used and system testing and maintenance. In addition,
program development, database, unified modeling language and requirements for the
new system have been dealt with. Chapter four covers the implementation and results
of the research work.
A good shopping cart design must be accompanied with user-friendly shopping cart
application logic. It should be convenient for the customer to view the contents of their

35
cart and to be able to remove or add items to their cart. The shopping cart application
described in this project provides a number of features that are designed to make the
customer more comfortable.

5.2

Conclusion

While developing the system lots of effort has been made to create this software, making
use of available tools, techniques and resources that would generate a proper System.
While making the system; an eye was kept on making it as user friendly, effective and as
flexible as possible. This software will help to reduce the workload of Sansani Motors in
managing their day to day activities which will result in better sales and inventory
management. EJB3 and MYSQL were two main technologies used. These two
technologies have several benefits and are considered as one of the best combination in
the market. Despite of the technologies several other techniques were implemented to
ensure the reliability of the system. The system is built according to the modern web
standards. The system is built in such a manner that it requires

no

special

skills

to

manage the working of the system and it is very easy to perform all business tasks for
administrators as well as the customers.

5.3

Recommendation

Having carefully examined the usefulness of computer in eliminating most of the errors
and hindrances that ensue from paper work, I recommend this car Sales Management
System for Sansani Motors and other car dealers in the state and Nigeria in general in
order to enable them produce an efficient inventory management and likewise reduce
the complexity of manual work.

36

REFERENCES
Ben Albahari, Peter Drayton, Brad Merrill (2001): "C# Essentials, 2nd Edition", UAS,
O'Reilly Publisher, ISBN: 0-596-00315-3.
Bolton, D.J. (2001). Applying Automated Inventory Control Systems in Manufacturing
Industries. London: D.P Publications Ltd.
Donald B (2003). UML basics: An Introduction to the Unified Modelling Language.
IBM Global Services Retrieved 2015-06-26 from
http://www.therationaledge.com/content/jun_03/f_umlintro_db.jsp
Diwakar, H., Marathe, M. (2000). The Architecture of a One-stop Web-window shop.
December, ACM SIGecom Exchanges, Volume 2 Issue 1.
Hamlet, J. (2006). Cultivating Alliances with Customers. International Journal of
Organizational Management, New York. Vol. 7. Issue 3, pp. 255-287.
Kubilus, N. J. (2000). Designing an e-commerce Site for users. September 2000,
Crossroads, Volume 7 Issue 1.
Kenneth. D.C. (2002). Contemporary Inventory Management Systems. New York:
McGraw Go Spot.
Lysons, M.C. (2001). Systematic Planning for Change. Palo Alto, California: Mayfield
Publishing Company.
Rubin, K. (2007). Computer Applications for Inventory Control Systems. Boston:
McGraw Hill.
Norman, D.A. (1994). The Design of Everyday Things. Doubleday, New York.
Sande, O.F. (2003). Automated Warehouse Management Systems. Journal of
Information Technology, Massachusetts. Vol. 2, pp. 35-43.

37
Swapna K. (2007), The Design And Implementation Of An E-Commerce Site For
Online Book Sales. Master of Science Thesis, Department of Computer and
Information

Sciences

Indiana University South Bend.

Wiley, Y. M. J. & Sons. (1997) Creating the Virtual Store: Taking Your Web Site
from Browsing to Buying

38

APPENDIX A: User Interface

Fig 1.0a-Home page


Here Customers can scroll to view the displayed Vehicles and proceed to create
Customer profile. After the Customer has created his profile he/she can login to
proceed to make Vehicle order.

39

Fig 1.1b-Home page

Fig 2.2-Admin Login interface


The admin can login with his/her username & password to be able to perform other
task as described in the Usecase above.

40

Fig 1.3-Admin control page


This page enables the admin to add new Vehicle and upload vehicle images.
The admin can also view sales report, order report and then logout.

Fig 1.4-View Sales Report


This task is only done by the admin who can checks sales report from a particular date
to another to view sales and total amount of all the transaction that took place within the
selected date.

41

Fig 1.5-View order report


The admin can also view order report to know the status of all the order and
transactions made, whether complete or incomplete.

Fig 1.6-User (customer) Login Interface


The user can login with his/her username and password (which is the email used while
creating customer profile).

42

Fig 1.7-Customer Cart


In this page, Customer can view previous orders and can also make new orders. He can
also delete order (s) from the order cart.
A Customer can proceed to make payment or logout from the page.

Fig 1.8-Quick Teller (Payment gateway)


This page enables the Customer to enter his/her card details in order to proceed on pay.

43

Fig 1.9a-Print Transaction Invoice

Fig 1.9b-Print transaction invoice


This page enables the Customer to print invoice of the transaction made

44

APPENDIX B: Source Code


package org.sansani.session;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

java.util.ArrayList;
java.util.Calendar;
java.util.GregorianCalendar;
java.util.Iterator;
java.util.List;
javax.ejb.Stateless;
javax.persistence.EntityManager;
javax.persistence.PersistenceContext;
org.sansani.lafia.Cars;
org.sansani.lafia.Customers;
org.sansani.lafia.Orders;
org.sansani.lafia.Pictures;
org.sansani.lafia.Sales;
org.sansani.lafia.TblCard;
org.sansani.lafia.Users;

/**
*
* @author mrbadara
*/
@Stateless
public class MainSession implements MainSessionLocal {
@PersistenceContext(unitName = "SansaniMotors-ejbPU")
private EntityManager em;
public void persist(Object object) {
em.persist(object);
}
// Add business logic below. (Right-click in editor and
choose
// "Insert Code > Add Business Method")
@Override
public boolean loginUser(String username, String password)
{
boolean isLogin = false;
Users us = (Users)em.find(Users.class, username);
if(us.getPassword().equals(password))
{
isLogin = true;
}
return isLogin;
}
@Override
public String returnRole(String username) {
Users us = (Users)em.find(Users.class, username);
return us.getRole();
}

45

@Override
public String addNewCar(Cars car) {
int id =0;
try
{
Cars c = new Cars(null, car.getMake(), car.getModel(),
car.getYear(),
car.getCondition(),
car.getColour(),
car.getEngineno(),
car.getChasisno(),
car.getPrice(),
car.getQuantity(),car.getDetails());
em.persist(c);
id = c.getId();
}
catch(Exception ec)
{
System.out.println("Error
in
Session::::;
"+ec.getMessage());
ec.printStackTrace();
}
return new Integer(id).toString();
}
@Override
public int getApplicatPassport(String carid) {
int id = 0;
int newid =0;
try
{
Pictures
p
=
new
Pictures(null,new
Integer(carid).intValue());
em.persist(p);
id = p.getId();
}
catch(Exception ex)
{
System.out.println("Error
in
Picture
Upload
"+ex.getMessage());
}
return id;
}
@Override
public byte[] viewPassport(String id) {
try
{
Pictures p1 = (Pictures) em.find(Pictures.class,
new Integer(id).intValue());
return p1.getPicture();
}
catch(Exception ex){}
return null;
}
@Override
public int uploadPassport(int parameter, byte[] passport) {

46
Pictures
p1
=
(Pictures)
parameter);
p1.setPicture(passport);
em.merge(p1);
return p1.getId();
}

em.find(Pictures.class,

@Override
public List viewCars() {
List<Cars> list = null;
try
{
list
=(List<Cars>)em.createNamedQuery("Cars.findAll").getResultList();
}
catch(Exception ex)
{
System.out.println("Error
while
viewing
cars
"+ex.getMessage());
}
return list;
}
@Override
public byte[] viewPassport1(String id) {
byte[] pic = null;
try
{
List<Pictures>
p1
=
(List<Pictures>)
em.createNamedQuery("Pictures.findByCarid").setParameter("carid",
Integer.parseInt(id)).getResultList();
Iterator it = p1.iterator();
while(it.hasNext())
{
Pictures p = (Pictures)it.next();
pic = p.getPicture();
break;
}
}
catch(Exception ex){}
return pic;
}
@Override
public void deleteCar(int id) {
try
{
Cars c = (Cars)em.find(Cars.class, id);
em.remove(c);
}
catch(Exception ex){}
}
@Override
public List listSingleCar(int id) {
List<Cars> list = null;

47
try
{
list
=(List<Cars>)em.createNamedQuery("Cars.findById").setParameter("i
d", id).getResultList();
}
catch(Exception ex)
{}
return list;
}
@Override
public List listCarPictures(int id) {
List<Pictures> pic = null;
try
{
pic
=
(List<Pictures>)
em.createNamedQuery("Pictures.findByCarid").setParameter("carid",
id).getResultList();
}
catch(Exception ex){}
return pic;
}
@Override
public byte[] viewPassport2(String id) {
byte[] pic = null;
try
{
Pictures p1 = (Pictures)em.find(Pictures.class,
Integer.parseInt(id));
pic = p1.getPicture();
}
catch(Exception ex){}
return pic;
}
@Override
public int getCarIdFromPictures(int id) {
int pic = 0;
try
{
List<Pictures>
p1
=
(List<Pictures>)
em.createNamedQuery("Pictures.findByCarid").setParameter("carid",
id).getResultList();
Iterator it = p1.iterator();
while(it.hasNext())
{
Pictures p = (Pictures)it.next();
pic = p.getId();
break;
}
}
catch(Exception ex){}

48
return pic;
}
private String getCurrentDate() {
GregorianCalendar cal = new GregorianCalendar();
String mon = "";
String da = "";
String year = (cal.get(Calendar.YEAR))+"";
String month = (cal.get(Calendar.MONTH) + 1)+"";
String day = (cal.get(Calendar.DAY_OF_MONTH))+"";
try {
if (month.length() < 2) {
mon = "0" + month;
} else {
mon = month;
}
if (day.length() < 2) {
da = "0" + day;
} else {
da = day;
}
} catch (Exception ex) {
}
return year + "-" + mon + "-" + da;
}
@Override
public String addOrders(Orders od) {
try
{
Orders
orr
=
new
Orders(null,
od.getCarid(),
this.getCurrentDate(),
od.getAmount(),
od.getHaspaid(),
od.getCustomerid());
em.persist(orr);
return "DONE";
}
catch(Exception ex){}
return null;
}
@Override
public String addCustomer(Customers cst) {
try
{
Customers
cs
=
new
Customers(cst.getEmail(),
cst.getSurname(),
cst.getMidname(),
cst.getFirstname(),
cst.getAddress(),
cst.getPhone(),
cst.getEmail(),
cst.getCountry(), cst.getState());
em.persist(cs);
}
catch(Exception ex){}
try
{
Users
us
=
Users(cst.getEmail(),cst.getEmail(),"Customer");

new

49
em.persist(us);

//This code is the mainSession.java


//It contains all the method involved in the program
package org.sansani.session;
import
import
import
import
import
import
import
import
import
import
import
import
import
import
import

java.util.ArrayList;
java.util.Calendar;
java.util.GregorianCalendar;
java.util.Iterator;
java.util.List;
javax.ejb.Stateless;
javax.persistence.EntityManager;
javax.persistence.PersistenceContext;
org.sansani.lafia.Cars;
org.sansani.lafia.Customers;
org.sansani.lafia.Orders;
org.sansani.lafia.Pictures;
org.sansani.lafia.Sales;
org.sansani.lafia.TblCard;
org.sansani.lafia.Users;

/*
*/
@Stateless
public class MainSession implements MainSessionLocal {
@PersistenceContext(unitName = "SansaniMotors-ejbPU")
private EntityManager em;
public void persist(Object object) {
em.persist(object);
}
// Add business logic below. (Right-click in editor and
choose
// "Insert Code > Add Business Method")
@Override
public boolean loginUser(String username, String password)
{
boolean isLogin = false;
Users us = (Users)em.find(Users.class, username);
if(us.getPassword().equals(password))
{
isLogin = true;
}
return isLogin;
}
@Override
public String returnRole(String username) {
Users us = (Users)em.find(Users.class, username);
return us.getRole();
}

50

@Override
public String addNewCar(Cars car) {
int id =0;
try
{
Cars c = new Cars(null, car.getMake(), car.getModel(),
car.getYear(), car.getCondition(), car.getColour(),
car.getEngineno(), car.getChasisno(), car.getPrice(),
car.getQuantity(),car.getDetails());
em.persist(c);
id = c.getId();
}
catch(Exception ec)
{
System.out.println("Error in Session::::;
"+ec.getMessage());
ec.printStackTrace();
}
return new Integer(id).toString();
}
@Override
public int getApplicatPassport(String carid) {
int id = 0;
int newid =0;
try
{
Pictures p = new Pictures(null,new
Integer(carid).intValue());
em.persist(p);
id = p.getId();
}
catch(Exception ex)
{
System.out.println("Error in Picture Upload
"+ex.getMessage());
}
return id;
}
@Override
public byte[] viewPassport(String id) {
try
{
Pictures p1 = (Pictures) em.find(Pictures.class,
new Integer(id).intValue());
return p1.getPicture();
}
catch(Exception ex){}
return null;
}
@Override
public int uploadPassport(int parameter, byte[] passport) {

51
Pictures p1 = (Pictures) em.find(Pictures.class,
parameter);
p1.setPicture(passport);
em.merge(p1);
return p1.getId();
}
@Override
public List viewCars() {
List<Cars> list = null;
try
{
list
=(List<Cars>)em.createNamedQuery("Cars.findAll").getResultList();
}
catch(Exception ex)
{
System.out.println("Error while viewing cars
"+ex.getMessage());
}
return list;
}
@Override
public byte[] viewPassport1(String id) {
byte[] pic = null;
try
{
List<Pictures> p1 = (List<Pictures>)
em.createNamedQuery("Pictures.findByCarid").setParameter("carid",
Integer.parseInt(id)).getResultList();
Iterator it = p1.iterator();
while(it.hasNext())
{
Pictures p = (Pictures)it.next();
pic = p.getPicture();
break;
}
}
catch(Exception ex){}
return pic;
}
@Override
public void deleteCar(int id) {
try
{
Cars c = (Cars)em.find(Cars.class, id);
em.remove(c);
}
catch(Exception ex){}
}
@Override
public List listSingleCar(int id) {
List<Cars> list = null;

52
try
{
list
=(List<Cars>)em.createNamedQuery("Cars.findById").setParameter("i
d", id).getResultList();
}
catch(Exception ex)
{}
return list;
}
@Override
public List listCarPictures(int id) {
List<Pictures> pic = null;
try
{
pic = (List<Pictures>)
em.createNamedQuery("Pictures.findByCarid").setParameter("carid",
id).getResultList();
}
catch(Exception ex){}
return pic;
}
@Override
public byte[] viewPassport2(String id) {
byte[] pic = null;
try
{
Pictures p1 = (Pictures)em.find(Pictures.class,
Integer.parseInt(id));
pic = p1.getPicture();
}
catch(Exception ex){}
return pic;
}
@Override
public int getCarIdFromPictures(int id) {
int pic = 0;
try
{
List<Pictures> p1 = (List<Pictures>)
em.createNamedQuery("Pictures.findByCarid").setParameter("carid",
id).getResultList();
Iterator it = p1.iterator();
while(it.hasNext())
{
Pictures p = (Pictures)it.next();
pic = p.getId();
break;
}
}
catch(Exception ex){}

53
return pic;
}
private String getCurrentDate() {
GregorianCalendar cal = new GregorianCalendar();
String mon = "";
String da = "";
String year = (cal.get(Calendar.YEAR))+"";
String month = (cal.get(Calendar.MONTH) + 1)+"";
String day = (cal.get(Calendar.DAY_OF_MONTH))+"";
try {
if (month.length() < 2) {
mon = "0" + month;
} else {
mon = month;
}
if (day.length() < 2) {
da = "0" + day;
} else {
da = day;
}
} catch (Exception ex) {
}
return year + "-" + mon + "-" + da;
}
@Override
public String addOrders(Orders od) {
try
{
Orders orr = new Orders(null, od.getCarid(),
this.getCurrentDate(), od.getAmount(), od.getHaspaid(),
od.getCustomerid());
em.persist(orr);
return "DONE";
}
catch(Exception ex){}
return null;
}
@Override
public String addCustomer(Customers cst) {
try
{
Customers cs = new Customers(cst.getEmail(),
cst.getSurname(), cst.getMidname(), cst.getFirstname(),
cst.getAddress(), cst.getPhone(), cst.getEmail(),
cst.getCountry(), cst.getState());
em.persist(cs);
}
catch(Exception ex){}
try
{
Users us = new
Users(cst.getEmail(),cst.getEmail(),"Customer");

54
em.persist(us);
return "<p class=success>Account created
successfully... click <a href=login.jsp>here</a> and login with
your email as username/password to continue</p>";
}
catch(Exception ex1){}
return null;
}
@Override
public List getCustomerByUsername(String username) {
List<Customers> cus = null;
try
{
cus =
(List<Customers>)em.createNamedQuery("Customers.findByCode").setP
arameter("code", username).getResultList();
}
catch(Exception wx){}
return cus;
}

@Override
public String checkMyCard(String cardno, String pin, String
cvv2, String amount, String dateExp) {
String msg = "Waiting...";
TblCard cardLocal = null;
try {
cardLocal =
(TblCard)em.createNamedQuery("TblCard.findByCardnoAndPinAndCvv2")
.setParameter("cardno", cardno)
.setParameter("pin", pin)
.setParameter("cvv2", cvv2)
.getSingleResult();
} catch (Exception ex) {
System.out.println("Error in getting card
details;;;;;" + ex.getMessage());
}
if (cardLocal != null) {
//String[] expDate =
cardLocal.getExpirydate().split("/");
int expMonth =
Integer.parseInt(cardLocal.getMonth());
int expYear =
Integer.parseInt(cardLocal.getYear());
String[] currentDate = dateExp.split("-");
int currentYear = Integer.parseInt(currentDate[0]);
int currentMonth =
Integer.parseInt(currentDate[1]);

55
if (currentYear > expYear && currentMonth >
expMonth) {
msg = "Card is Expired!!!";
} else if (expYear > currentYear && expMonth >
currentMonth) {
msg = "Card is Expired!!!";
} else {
if (cardLocal.getAmount() <
Double.parseDouble(amount)) {
msg = "Insufficient Amount";
} else {
msg = cardLocal.getAmount()+"";
}
}
} else {
msg = "Invalid Card";
}
return msg;
}
@Override
public String makePayment(Sales parameter) {
try
{
Sales s = new Sales(null, parameter.getOrderid(),
parameter.getCarid(), this.getCurrentDate(),
parameter.getAmount(),parameter.getCustomerid());
em.persist(s);
return "DONE";
}
catch(Exception ex){}
return null;
}
@Override
public List getCarsByMake(String make) {
List<Cars> list = null;
try
{
list
=(List<Cars>)em.createNamedQuery("Cars.findByMake").setParameter(
"make", make).getResultList();
}
catch(Exception ex)
{}
return list;
}
@Override
public List searchCarsByMakeModel(String make, String
model) {
List<Cars> car = null;
try
{
if(!model.equals("00") && make != "")

56
{
car =
(List<Cars>)em.createNamedQuery("Cars.findByModel")
.setParameter("model", model)
.getResultList();
}
else
{
car =
(List<Cars>)em.createNamedQuery("Cars.findByMake")
.setParameter("make", make)
.getResultList();
}
}
catch(Exception ex){}
return car;
}
@Override
public void deleteOrder(String id) {
int nid = Integer.parseInt(id);
try
{
Orders c = (Orders)em.find(Orders.class, nid);
em.remove(c);
}
catch(Exception ex){}
}
@Override
public void updateOrders(String username) {
List<Orders> ord = null;
try
{
ord =
(List<Orders>)em.createNamedQuery("Orders.findByCustomerid")
.setParameter("customerid",
username).getResultList();
Iterator it = ord.iterator();
while(it.hasNext())
{
Orders od = (Orders)it.next();
od.setHaspaid("YES");
}
em.merge(ord);
}
catch(Exception ex){}
}
@Override
public void newSales(Sales cs) {
//Sales(Integer id, int orderid, int carid, String
date, String amount, String customerid)
try

57
{
List det =
this.getOrderByUsernameHaspaid(cs.getCustomerid(), "NO");
Iterator it = det.iterator();
while(it.hasNext())
{
Orders o=(Orders)it.next();
Sales sale = new
Sales(null,o.getId(),0,this.getCurrentDate(),o.getAmount(),cs.get
Customerid());
em.persist(sale);
}
}
catch(Exception ex){}
}
@Override
public List salesReport(String date1, String date2) {
List<Sales> list = null;
try
{
list
=(List<Sales>)em.createNamedQuery("Sales.findByDate1AndDate2").se
tParameter("date", date1).setParameter("date",
date2).getResultList();
}
catch(Exception ex)
{}
return list;
}
@Override
public Cars viewSingleCar(int id) {
Cars car = null;
try
{
Cars c =(Cars)em.find(Cars.class, id);
car = new
Cars(c.getId(),c.getMake(),c.getModel(),c.getYear(),c.getConditio
n(),c.getColour(),c.getEngineno(),c.getChasisno(),c.getPrice(),c.
getQuantity(),c.getDetails());
}
catch(Exception ex)
{
System.out.println("Error while viewing cars
"+ex.getMessage());
}
return car;
}
@Override
public String modifyCar(Integer id, String make, String
model, String year, String condition, String colour, String
engineno, String chasisno, String price, String quantity,String
details) {

58
String ok="NOT";
try
{
Cars c =(Cars)em.find(Cars.class, id);
c.setChasisno(chasisno);
c.setColour(colour);
c.setCondition(condition);
c.setDetails(details);
c.setEngineno(engineno);
c.setMake(make);
c.setModel(model);
c.setPrice(price);
c.setQuantity(quantity);
c.setYear(year);
em.merge(c);
ok="DONE";
}
catch(Exception ex){}
return ok;
}
@Override
public List viewPicturesByCardId(int carid) {
List<Pictures> pic = null;
try
{
pic =
(List<Pictures>)em.createNamedQuery("Pictures.findByCarid").setPa
rameter("carid", carid).getResultList();
}
catch(Exception ex){}
return pic;
}
@Override
public void deletePic(int id) {
try
{
Pictures pic = (Pictures)em.find(Pictures.class,
id);
em.remove(pic);
}
catch(Exception ex){}
}
@Override
public List viewDistinctCar() {
List<Cars> list = new ArrayList();
try
{
list
=(List<Cars>)em.createNamedQuery("Cars.findAll").getResultList();
}
catch(Exception ex)
{

59
System.out.println("Error while viewing cars
"+ex.getMessage());
}
return list;
}
@Override
public List getOrderByUsernameHaspaid(String username,
String haspaid) {
List<Orders> ord = null;
try
{
ord =
(List<Orders>)em.createNamedQuery("Orders.findByCustomeridAndHasp
aid")
.setParameter("customerid", username)
.setParameter("haspaid", haspaid)
.getResultList();
}
catch(Exception ex){}
return ord;
}
@Override
public List getOrderByUsernameHaspaidAndId(String username,
String haspaid, int id) {
List<Orders> ord = null;
try
{
ord =
(List<Orders>)em.createNamedQuery("Orders.findByCustomeridAndHasp
aidAndId")
.setParameter("customerid", username)
.setParameter("haspaid", haspaid)
.setParameter("id", id)
.getResultList();
}
catch(Exception ex){}
return ord;
}
@Override
public List allOrders(String date) {
List<Orders> ord = null;
try
{
ord =
(List<Orders>)em.createNamedQuery("Orders.findByDate")
.setParameter("date", date)
.getResultList();
}
catch(Exception ex){}
return ord;
}
}

60
//**

*//

package org.sansani.session;
import
import
import
import
import
import

java.util.List;
javax.ejb.Local;
org.sansani.lafia.Cars;
org.sansani.lafia.Customers;
org.sansani.lafia.Orders;
org.sansani.lafia.Sales;

/**
*
* @author mradamu
*/
@Local
public interface MainSessionLocal {
boolean loginUser(String username, String password);
String returnRole(String username);
String addNewCar(Cars car);
int getApplicatPassport(String carid);
byte[] viewPassport(String id);
int uploadPassport(int parameter, byte[] passport);
List viewCars();
byte[] viewPassport1(String id);
void deleteCar(int id);
List listSingleCar(int id);
List listCarPictures(int id);
byte[] viewPassport2(String id);
int getCarIdFromPictures(int id);
String addOrders(Orders od);
String addCustomer(Customers cst);
List
haspaid);

getOrderByUsernameHaspaid(String

username,

String

List getCustomerByUsername(String username);


String checkMyCard(String cardno, String pin, String cvv2,
String amount, String dateExp);

61
String makePayment(Sales parameter);
List getCarsByMake(String make);
List searchCarsByMakeModel(String make, String model);
void deleteOrder(String id);
void updateOrders(String username);
void newSales(Sales cs);
List salesReport(String date1, String date2);
Cars viewSingleCar(int id);
String modifyCar(Integer id, String make, String model,
String year, String condition, String colour, String engineno,
String chasisno, String price, String quantity,String details);
List viewPicturesByCardId(int carid);
void deletePic(int id);
List viewDistinctCar();
List getOrderByUsernameHaspaidAndId(String username, String
haspaid, int id);
List allOrders(String date);
}

Você também pode gostar