Sie sind auf Seite 1von 78

1

Chapter ONE

1. Introduction

1.1 Background

The hotel industry is Zimbabwe has grown to the level at which they are now
using computers for their operations. Computers have been introduced to
automate functions like reservations, accounting, human resources management
and inventory control. Several hotels now use such systems, for example Cresta
and Monomutapa hotel use computer systems for their operations.

1.2 Problem Statement

The hotels use different computer packages for their operations. They have
separate packages for human resource management, inventory control,
accounting and hotel reservation.

Weaknesses of the current system

• Inefficiency in transferring data between different module for example


transferring payment details from reservations to accounting

• It take more time to reconcile documents and data if an error occurs as


there are several independent modules with related information that has to
be looked for manually

• The manual transfer on data is prone to human errors that may lead to
2

inconsistency in the system

• Product details in the inventory are duplicated and data duplication is


wasteful and costs time and money

• Data backup has to be performed separately for the different systems that
are being used in the hotel

1.3 Previous and Current Work, Methods and


Procedures

Recent work has been done in this field but has been mainly concerned
with the design for individual packages that can be used for the different
modules that are used in the system. Some of the software that is
currently in use in hotel are Medallion, which caters for reservations,
AccPack which monitors the accounting and other software that exist in
the industry.

1.4 Project Description

The new system that is to be developed is an integrated computer package that


can be used on run the accounting module, human resources management
module, the reservations module and the inventory control module on one
system that shares the same database.

1.5 Research Purpose

Objectives
3

• To reduce errors that occur when moving data from different modules to
other modules manually
• To allow for a secure system for the whole hotel management
• To reduce time taken when getting information about customers,
reservations made, accounting information, workers information etc.
• To reduce time taken when trying to acquire details about a product or
suppliers of products.
• To keep track of orders that will have been made
• To reduce time taken when placing an order to a supplier
• To be able to manipulate details of products in the inventory or of
suppliers that supply the product.
• To reduce the use of manual things like paper.

1.6 Justification of Project

The hotel industry has been forced to pay multiple licenses for the different
systems that they use in their operations which is very expensive when
compared to paying for a single license for a single system that performs all the
operations that are being done by the different packages that are being used.

1.7 Scope of the Study


After taking a close study of the hotel management systems we decided to
design an integrated system that will cater for the reservations, inventory
control, human resources management, and accounting. This will help us
in developing a system that can reduce any errors involved during the
4

transfer of information between this departments and will cut off any
manual work that was being done in re-entering data into different
systems as this will be done once at any point that needs data entry in the
system.

1.8 Organisation of the project

The project is to have the following stages:


System specifications which is concerned with the functional and non functional
requirements of the new system that is to be developed. This is followed by the
project planning and literature review which is mainly about the actual plan as to
how the project is to be done and a historical or conceptual survey of relevant
work done in the area by previous system developers. After this stage the project
then goes into the System Analysis and Design stage which is mainly concerned
with the design of the new system that is to be used. . After design
Implementation and testing is done. This involves putting into use the new
system and making sure that errors in the designed system are corrected
5

Chapter TWO

2. System specification

2.1 Introduction

At this stage we will be looking at the general requirements of the proposed


system and identifying whether the system is feasible enough for the project to
continue The purpose of this stage is to help the organization identify the
important risks associated with the project that must be addressed and help to
decide whether to abort the issue of computerization at an early stage if it is not
worthwhile to implement. The chosen feasibility is analyzed based on economic,
technical, and social feasibility.

2.2 System Functional Specification


2.2.1 Functional requirements
These requirements specify what the system is supposed to do:

2.2.1.1 General objectives


• The new computerized system can manipulate data more accurately
without consuming much time and also saving much ground space
• Cost is reduced when using the computerized system since there will a cut
off of paper work bought.
• Effective security is obtained on the system; hence no fear of
unauthorized user is feared.
• Use of technology such as those computers put an institution at a
competitive advantage in the economy.
6

2.2.1.2 Specific requirements


• Capturing and storing of inventory product details such as name,
description, suppliers name,
• Capturing and storing of the suppliers details such as name, address,
products they sell,
• Data should be validated to check for general errors such as entering
characters on a section that requires numbers.
• The system should add, delete, search and modify product, inventory list
and suppliers data without any problems.
• Produce requested reports such as orders made, cancelled orders,
product details, suppliers details, products to be reordered, products taken
from inventory,
• The new system will provide very complex security that if no one leaks the
password for the system no one will be able to access any information
stored in the system.
• The proposed system will have a strong backup system since the data
stored on the database can be saved on diskettes and kept somewhere
safe away from the premises, so if information is corrupted, there will be
backup to reload the wanted information.
• The system stores names of employees , employee numbers
,addresses ,phone numbers ,account details of employees.
• It also store the day of commencement (date of employment of workers)
• Calculation of leave days
i)detection of leave days – the system will detect if some employee’s
leave days are due
ii)detection of leave due –the system will detect the end of leave
• Calculation of medical aid expenses
i) Executive contribution
ii) Management contribution
iii) General employees
• Calculation of salary
i) Pay in advance
i) Priority ( selection depending on who you are )
ii) Contract workers and permanent workers
ii) Grading system
iii) Rate per hour
7

i) grading
iv) Overtime
i) grading
ii) overtime calculations
• Selection of received benefits
i) company cars
ii) transport
iii) fuel
iv) accommodation
v) school fees
vi) rates eg water , electricity , phone
vii) lunch
viii) breakfast
ix) bonus
x) loans
• Daily registration
i)mark your name for daily registration
• Grouping of employees
i) permanent employees
ii) contract employees
• Pension management
i) NSSA deduction
ii) note working years
• Retirement package
i) grading
ii)detection of employees ready for retirement
• Condolences funds
i)company contribution
• Vashandi funeral contribution
• Confirmation of incoming and outgoing employees
i) avoid ghost workers
ii) confirmation of workers to be approved by many people
• Archives
i)fired empl0oyees
ii)hearing
iii)history of workers
• Generate ledger accounts
• Collection of day to day transactions
• Generating customer receipts
• Sending purchases orders
• Sending sales orders
• Generating the trial balance
• Generating income statement
• Generating the balance sheet
• Keeping supplier details
8

• Monitoring accounts users

2.2.2 Non functional requirements


These are mainly concerned with the constraints under which the proposed system is
supposed to operate and can be further classified into
• Hardware
• Software
• Manpower

2.2.2.1 Hardware requirements


• At least a 10Gigabit hard drive.
• Pentium 4 computer.
• 256MB system memory (Random Access Memory-RAM).
• Ink cartridge
• Printer
• Modem for internet connection
• Fax machine

2.2.2.2 Software requirements


• An Operating System (Windows XP SP2)
• JAVA JDK1.6 OR upper versions
• MYSQL Server version5
• Printer software
2.2.3. System scope
Constraints associated with the development of the system include:
9

• The system should respond to queries presented to it by end users.

• The database should not be vulnerable to the end users.

• Each individual should have a unique log-in, which should designate the
level of access required

• The system should be consistent in its operation.

• The interface should provide appropriate interaction facilities for different


types of system users.

• The system should be portable, i.e. be able to provide the same


functionality under a different set of the organization’s hardware or
operating system.

2.3 Feasibility Study


A feasibility study is an assessment of an information system to determine
whether the system can meet the specified business requirements of the
organization and whether a business case exists for developing such a system.

2.3.1. Economic Feasibility


This attempts to find out whether the benefits of the new system justify the costs
(in terms of time or money spent) of developing the project. This project was
found to have the benefits of the new system outweighing the costs of developing
and implementing the system as we are going to see from the costs breakdown
and thus economically feasible. The costs were classified into tangible and
intangible costs.

2.3.1.1 Tangible cost benefits


Benefits quantified in dollar terms and also can be classified as operational and
development cost benefits.
10

1 Operational cost benefits


Under this we outlined the costs relating to the operations that are carried out in
the day to day running of the system and these include:

• Reduction in costs by reducing theft and hence the amount of products


used by the school since a computerized system can strictly monitor the
flow of products in the inventory
• Security of records is maintained since access will be through the use of
passwords. If information is available to everyone then it means any
unauthorized person can gain access to the records and alter or delete the
information, which may result in the company losing billions of dollars.
• Very little training will be required to equip the users about how the system
works.
11 Development costs
Under development costs we looked at costs pertaining to the development of
the proposed system. We included the costs of purchasing hardware and
software that will be used in the building of the system, salaries of the developing
team as well as stationery costs. The software that will be used in developing the
system Java Eclipse IDE and MYSQL database are all open source software and
are hence free on the software market and can be downloaded over the internet
which is available at the University Of Zimbabwe. As for Hardware, the University
Of Zimbabwe honors lab will be used

2.3.1.2 Intangible benefits


Benefits found to be difficult to quantify in dollars terms but are enjoyed by
the organization as it uses the system and the following were included:

• Worker moral is boosted as a result of the computerized system since


there will be no duplication of data
• Low errors through use of database that observes validation rules and
stores data of the same type.
11

• Reduction in time taken to access files since records are kept on a


database and is uniquely identifiable by a primary key
• Improved efficiency. High productivity, that is increased output as
compared to the old system

2.3.2. Technical Feasibility


I have looked at the extent, to which the system can successfully be designed,
Developed and installed by the developer.

2.3.2.1. Technical Expertise


The developer has studied the concepts of database design and is currently
studying the programming language that will be used in developing the system.
The users of the system will need to have basic knowledge of how to use a
computer using Windows operating system as the system being developed used
on the computer already at the school which uses Windows XP operating
system. The user manual will provide enough information on how to operate the
system.
2.3.2.2 Availability of necessary equipment
The hardware for using the system will not be an issue as the school has already
bought a Pentium IV computer. The school also has a printer that will be used to
print out reports and is connected to the internet so as to can communicate to
suppliers via email.

2.3.3 Operational Feasibility


This questions whether the implication so using the technology is justified on
people such as employees. The developer analyzed how the users and
management will accept the new system. The urgency of the problem and
acceptability of the solution to management was studied. Emphasis was placed
on the throughput and response time of the system to address user’s queries,
12

and security of information. The proposed system will definitely cater for all these
making the project feasible operationally.

2.4 System Performance Requirements


2.4.1 Efficiency
The system should be able to work an high speed. Data should be easy to
retrieve and it should not make use of a lot of hard drive space.

2.4.2 Reliability
The system should be reliable in that it should make sure that there are no errors
made in calculations or during its operation. It should validate input and give an
error message if wrong input is entered.

2.4.3 Security
The system should prompt the user for a password before giving the user access
to the system. t should validate input to ensure security of execution so that there
are no conflicts between what will have been entered and the database.

2.4.3 Maintainability
The system should allow for modifications to be made to it for purposes of
maintaining the system. This therefore means the system should make use of
object oriented principles which make programs maintainable.

2.4.4 Portability
The system should be able to run on multiple operating environments and should
be able allow for the system to be moved from one place/machine to another
13

Chapter THREE

3. Project planning and Literature Review


14

3.1 Introduction
3.2 Project planning and scheduling
At this stage we are going to show all the phases that the project will go
through. The work plan was developed using the system development cycle
and was developed in such a way that it allows adequate participation from all
relevant stakeholders. Each stage is allocated a time span in which it has to be
carried out. The table below shows the project work plan:

gantt chart

WEEK/STAGE 1 2 3 4 5 6 7 8 9 10
Documentation
project proposal
planning phase
Analysis
Design
Implementation
Maintenance

POSSIBLE PROBLEMS

• Limited resources:
There are a limited number of computers to use at the computer lab at the
university. As a developer this will affect me as I do not possess a personal
computer.
• Delays due to:
1. Power cuts
2. The programming language that I am going to implement i.e. Java is new
to hence the need to study them first. As a result there will be a delay in
this process.
3. There is also the issue of time constrains due to lack of having a vacation

3.3 Literature Review


15

Technology advancements have been made in the hotel industry with various
softwares being developed fore the different areas involved in the hotel industry.
We have software like Medallion , Pastel, AccPack and many others that are
being used for operating hotels but none of this has an intergrated package for
the operations of the hotel as each department has to use its own software for
the operations that it does.

CHAPTER FOUR
4. System Analysis and Design

4.1 Introduction

In this phase the researcher was putting much concentration on the design of the
proposed system making sure that all the objectives stated in the project
proposal are fulfilled. The database design and entity relationships table,
architecture design and the database queries. The data flow diagram of the
proposed system is going to be shown with all the data flows and data stress for
easy understanding of the system

4.2 System Architecture


• See insert on database design

4.2.3 SYSTEM DATA DICTIONARY


HUMAN RESOURCES MANAGEMENT
COMPANY DETAILS
Field name Field type
Company Id Long integer
Company name String
Company legal name String
Address String
City String
Country String
16

Phone number Long integer


Fax Long integer
Email-address String
Website string

Leave details
Field name Field type
Leave id Long integer
Leave name String
Length Integer
Number Of hours worked before allocation Integer

OVERTIME DETAILS
Field name Field type
Id Long integer
Rate (number of hours) Integer
Rate Percent decimal

Deductions
Field name Field type
Deduction id Long id
Deduction Name String
Rate Decimal
Amount double

Payroll frequencies
Field name Field type
frequency id Long integer
frequency name String
Pay-period integer

Employee Details
Field name Field type
Employee id String
First name String
Initials String
Surname String
Date of birth Date
Gender String
National id number String
Address String
City String
Country String
Landline phone number Long integer
17

Mobile phone number Long integer


Email address String
Nationality String
Passport number String
Passport valid up to Date
Marital status String
Grade id Long integer
Frequency id Long integer

Grading
Field name field type
Grade id Long integer
Grade name String
Description Text
Salary Double(2)

Tax
Field name field type
Tax id Long integer
Grade id Long integer
Tax name String
Rate Decimal

Allowances
Field name field type
Allowance id Long integer
Allowance name String
Rate Decimal
Amount double

Employee-deductions
Field name field type
Employee id String
Deduction id Long integer

Employee-tax
Field name field type
Employee id String
Tax id Long integer

Employee-allowance
18

Field name field type


Employee id String
Allowance id Long integer

Time sheet
Field name field type
Time id Long integer
Employee id String
Check in Date time
Check out Date time

Employee-number of hours worked from last pay period


Field name field type
Employee id String
Number of hours worked integer

Payroll
Field name field type
Payroll id Long integer
Employee id String
Start day Date
End date Date
Hours worked Integer
Gross pay Double
Deductions Double
Net pay double

Employee-leave
Field name field type
Employee Id String
Leave id Long integer
Hours gained Long integer

Database design for Hotel Reservation module

hCUSTOMERS

FIELD NAME TYPE


customer id Long integer
Customerfirst name String
customerSurname String
Customer date of birth Date-time
Gender Char
Nationality String
19

Address String
City String
Country String
National id number String
Passport number String
dateOfIssueOfpassport Date-time
DateOfexpiryOfpassport Date-time
phonenumber Long integer
e-mailAddress String
carRegistrationNumber String
organizationId Long integer
faxNumber Long integer

organisation
Field name Field type
organisationId Long integer
Name String
Address Text
PhoneNumber Long integer
Country String
Email-address String
faxNumber Long integer

ROOMS
FIELD NAME TYPE
Room number Long integer
room type id Long integer
Locationid Long integer

ROOM TYPE
FIELD NAME TYPE
Room type id Long integer
Room type name String
Service id Long integer

BOOKING
FIELD NAME TYPE
Booking id Long integer
Customer id Long integer
Booking date Date-time
Number of staying days Long integer
Preferred Check in date Date-time
Preferred cjeck out date Date-time
Room number Long integer
Number of adults Long integer
20

Number of children Long integer


Travel agent id Longid
Event String
Table arrangement String
Equipment text
location
Field name Field type
Location id Long integer
Location name String

Services
Field name Field type
ServiceId Long integer
Service name String
Description Text
pricePerUnit decimal

Services offered
Field name Field type
ServiceOfferedid Long integer
BookingId Long integer
Service id Long integer
Units offered Units offered

PAYMENTS
FIELD NAME TYPE
Paymentid Long integer
Booking id Long integer
Amount decimal Decimal
Date Date-time

Costs Encured By Customer


Field name Field type
costecuredId Long integer
Booking id Long integer
External charges Decimal
Services charged decimal
Total cost Decimal
Outstanding balance Decimal

intrest
Field name Field type
Intrestid Long id
Name String
21

Rate decimal

Travel agents
Field name Field type
travelAgentId Long integer
Name String
Address String
Phone number Long integer
e-mail address String
Country string

House keeping
Field name Field type
Room number Long id
Status string

We have the following tables for the inventory module


• ProductsDetails
• SuppliersDetails
• SupplierProducts
• InventoryList
• InventoryReceiving
• InventoryHistory
• Orders
• Category
• PriceList

Product details
Field name Type
ProductId Long integer
ProductName String
CategoryId Long integer
ReorderLevel Long interger
DefaultReorderQuantity Long integer
DefaultSupplierId Long integer
Status Boolean(1/0)

SuppliersDetails
Field name Type
SupplierId Long integer
SupplierName String
PhysicalAddress String
Street String
22

City String
Country String
BusinessPhone Number
MobilePhone Number
FaxNumber Number
EmailAddress String
Status Boolean(1/0)

SupplierProducts
Field name Type
SupplierId Long integer
ProductId Long integer

InventoryList
Field name Type
InventoryId Long integer
ProductId Long integer
QuantityAvailable Long integer
Target level Long integer
InventoryDue Long integer

InventoryReceiving
Field name Type
ReceivingId Long integer
ProductId Long integer
Quantity Long integer
Date Date-time
ReceivedBy Long integer

InventoryHistory
Field name Type
ActivityNumber Long integer
ProductId Long integer
Quantity Long integer
Date Date-time
GivenTo Long integer
GivenBy Long integer

Orders
Field name Type
OrderNumber Long integer
ProductId Long integer
SupplierId Long integer
Quantity Long integer
Submittedby Long integer
23

Date Date-time
status Done/notdone
sentStatus Sent/notsent
Cancelled Yes/no

Category
Field name Type
CategoryId Long integer
CategoryName String

Price list
Field name Type
productId Long integer
Price Decimal

4.2.4 EQUIPMENT CONFIGURATION

The following equipment will be used for the operation and support of the System
to be designed..
• Telephone System – to help with the internet connection
• Paper for printing out any reports that can be produced by the System

• Printer for printing the reports

4.3 SYSTEM DATA STRUCTURE SPECIFICATIONS


4.3.1 OTHER USER INPUT SPECIFICATION

IDENTIFICATION SOURCE INPUT DATA Legal value


DEVICE FORMAT specification
User details input
Username System user Keyboard Any All values
characters
Password System user Keyboard Any All values
characters
Product and Inventory details
24

Product name System user Keyboard Any All values


characters
Reorder level System user Keyboard Number Integers
Default reorder System user Keyboard Number Integers
quantity
Target level System user Keyboard Number Integer
Quantity available System user Keyboard Number Integer
Supplier details
Supplier name System user Keyboard Any All values
characters
Physical address System user Keyboard Any All values
characters
City System user Keyboard Any All values
characters
Country System user Keyboard Any All values
characters
Business phone System user Keyboard Number Integer
Mobile phone System user Keyboard Number Integer
Fax number System user Keyboard Number Integer
e-mail address System user Keyboard Any e-mail address
characters
Orders ,inventory activity history
Quantity System user Keyboard Number Integer

4.3.2 OTHER USER OUTPUT SPECIFICATIONS


IDENTIFICATION DESTINATION MEDIUM FORMAT INTERPRETATION
OF OUTPUT OF OUTPUT
Product details System user Monitor/printer Table List of product
details of the
products that are
in the system
Inventory list System user Monitor/printer Table List of inventory
list details
Inventory System user Monitor/printer Table List of details of
activity products taken
from the inventory
Order Supplier printer Text/report Letter to place an
order for products
from a supplier
Supplier details System user Monitor/printer Table List of all
suppliers in the
system
Suppliers System user Monitor/printer Table List of products
products supplied by a
25

specific supplier
Product suppliers System user Monitor/printer Table List of suppliers of
a certain product
Users System user Monitor/printer Table List of all users of
the system

4.3.3 SYSTEM DATABASE SPECIFICATIONS

FIELD NAME TYPE DESCRIPTION


USERS
Userid Integer the key for the users table, unique for all users
Username Text name to be used by the use to login to the system
Roleid Integer Foreign key to connect to the users table to roles table

Password Text Password to be used by the user to login to the system

Roles
Role_id Integer Key for roles table
Role Text The role of the user in the system i.e. Administrator, super or
ordinary user

Product details
Product_id Integer Key for product details table
Product name Text Name of product that is being stored in the inventory
Reorder_level Integer Level of stock for which the system is to identify whether a
product needs to be reordered
Default reorder Integer Default amount to be reordered for a certain product when making
quantity an order
Default supplier id Integer The default supplier from which a product will be reordered

Inventory list
Inventory_list id Integer key for the inventory list table
productid Integer Id of the product in the inventory
Quantity available Integer Amount of product that is available at that specific time
Target level Integer The expected level of the inventory for a product
Inventory due Integer Amount of product that is due to be received from the supplier
26

Supplier details
Supplier id Integer key to identify a supplier in the supplier details table
Supplier name Text name of supplier whose details are in the system
Physical address Text The address of the supplier whose details are in the system
City Text
Country Text
Business phone Integer Phone number for the supplier preferable landline
Mobile phone Integer Mobile phone number for the supplier
Fax number Integer Suppliers fax number
e-mail address Text Suppliers e-mail address

Inventory activity history


Activity number Integer Key for the inventory activity history table which is used to record
all products taken from the inventory and those who took them
Product id Integer id of the product taken from the inventory
Staff given Text Staff that took the product from the inventory
given by Text User who gave the staff the product
date Text Date on which the product was taken from the inventory
Quantity Integer Amount taken from the inventory
Inventory receiving
Receiving id Integer id for the inventory receiving table, which keeps details of
products received Integer the inventory
Product id Integer id for the product that will have been received to the inventory
quantity Integer Amount of the product that will have been received Integer the
inventory
date Date Date on which the product will have been added to the inventory

Supplier products
Supplier id Integer Id to identify the supplier
Product id Integer Id to identify the product supplied by the identified supplier

Orders
Order number Integer Key for the orders table to identify each order made for every
product
Product id Integer id for the product that will have been ordered
Supplier id Integer Id for supplier to which the order is to be sent
Quantity Integer Amount of the product ordered
Submitted by Text Person who made the order
Date Date Date on which order was made
Status Text Whether the order has been approved or not i.e. by the
administrator
Acceptance status Text If the order has been accepted by the supplier
Sent status Text If the order has been sent

Purchases
27

Purchase id Integer Id to identify purchases made


Product id Integer id of product that will have been purchased
Order number Integer id of order that will have been made for the purchased product
Quantity Integer Amount of product that will have been purchased
Date date Date on which the purchase was made
Status Text If the purchase has been delivered or not
Supplier id Integer Id of supplier from which the product was purchased

4.4 MODULE DESIGN SPECIFICATION

4.4.1 MODULE FUNCTIONAL SPECIFICATIONS

The researcher divided the System into the following module


• Login
• Products and Inventory
• Orders
• Suppliers
• Users

Login
This module is responsible for entering the System by use of a username and password.
The algorithm for this is shown below

Product details and Inventory


This module is responsible for manipulating details of products that are kept in the
inventory, that is, product details, amounts in inventory, reorder levels and quantities.

Orders
This module is responsible for checking which products need to be reordered, placing the
orders and sending the orders to the suppliers.

Suppliers
This module is responsible for the manipulation of supplier’s details, that is, entering or
updating the details.

Users
This module is responsible for the manipulation of details of the users in the System. This
includes creation of a user, deletion of a user, changing of password and changing of user
roles

4.4.2 MODULE OPERATIONAL SPECIFICATIONS

FLOW CHARTS
28

Login
The system user enters the username and password and the input is compared to that
stored in the system database. If they are correct the user is allowed access to the system.
START

enter username
and password

are user details correct

go to main
system

END

Products and inventory


This module provides the way for adding, deleting, updating product and inventory
details. The module facilitates the taking of products from the inventory and the addition
of products to the System. It allowing for making of different queries from the database
like displaying product details, inventory list details and products that need to be
reordered.
29

START

LOGIN

ENTER
PRODU CT
DETAILS

ADDPR ODUCT
DETAILSTO
DATABASE

END

Orders
This module allows the user of the system to be able to place orders to the supplier and
identify in the system the orders that will have been made. The user should be allows to
see the orders that will have been made.
START

LOGIN

ENTER
O RDER
DETAILS

ADDO RDER
DETAILSTO
DATABASE

END
30

Suppliers
The suppliers details are entered into the system and depending on the choice made by
the user the details are updated in the database.
START

LOGIN

ENTER
SUPPLIER
DETAILS

ADDPU RCHASE
DETAILSTO
DATABASE

END

Users
In the Users modules basic system setup and configuration takes place. This includes
creation, updating, deleting of new users with different access levels, changing passwords
and roles
31
START

LOGIN

ENTERUSER
DETAILS

ADDUSERDETAILS
TODATABASE

END

.
CHAPTER FIVE

5. Implementation and Testing

5.1 Introduction

 The main objective of implementation is to transform the requirements


specification and design into an executable system that users interact
with.
 JAVA and MYSQL Server 5 would be utilized for the interface and
database implementation respectively.

5.1.1 Choosing the language


32

The implementation language of choice was Java in conjunction with MYSQL


Server 5 Database.
There were several reasons owing to the decision of the above 2 choices of
implementation. Mainly the selection of JAVA as the language to use was
because the researcher was at the time learning the language and so would not
have to learn two languages at the same time.
Apart from the reason stated above, JAVA was also chosen as the
implementation language mainly because of the following reasons:

 It has a great deal of facilities that allow easy and direct access to many
database engines, and this increased our choice on database selection.
 It is a high level language which is closely related to the human language-
English, and this consequently made the translation from the system’s
algorithm design to the system’s implementation a relatively simpler task,
than a language like C/C++ which is close to machine language.
 Eclipse compiles every line of code as it is written; therefore errors are
identified before runtime making the time spend in debugging the program
shorter.
 In the current world where open source operating systems are slowly
becoming popular the researcher saw it fit to use JAVA as it is a portable
programming language that can be run on any operating system.
Therefore the system can be run on multiple operating systems and still
perform the same function.

5.2 Choice of environment

On the database selection, the choice was more or less a choosy one, because
Oracle and MS SQL Server 2005 and MYSQL Sever 5 were potential candidates
for selection as the database engine.
MS Access was out of the menu of Database choices simply because of its
miniature storage capacity and its lack of a professional appearance.
33

MS SQL Server though it’s a good database engine with a large storage
capacity, it was not used simply because of its lack of a user-friendly user
interface. It lacks graphical user interface working environment. i.e. It‘s not the
most preferred choice of database in JAVA. SQL Server provided just enough for
the system’s database storage requirements but because it can only be used on
Windows Operating Systems it did not provide the portability to match that of
JAVA.MYSQL Sever became the appropriate choice because it provided enough
storage capacity, is an open source database therefore very portable and can be
setup on many operating systems and Since the school is still developing it
would be expensive to use other database systems like oracle and SQL Sever as
the license requirements would be expensive for the school therefore it was a
better choice to use the free database system MYSQL.

5.3 Efficiency

Java is a portable programming language that can be used for creating desktop
applications using the java swing class. It can also create a good graphic user
interface that can then make it easier for the users of the system when they are
using it. MYSQL Sever is a fast and robust database that has a very high storage
capacity. This enables it to store a lot of information. JAVA and MYSQL are both
open source and because of this both are designed in a way that makes it easier
to use the two together.

5.4 Correctness

The system that was designed by Java and has managed to correctly implement
the requirements. This therefore means that the System is correct

5.5. Documentation of code


package hms;
34

import javax.swing.*;
import javax.swing.table.DefaultTableModel;

import java.sql.*;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Vector;

public class hrActions extends properties {


Statement stmt = null;
static DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd
HH:mm:ss");
static Date date = new Date();
static String todaysdate= dateFormat.format(date);
private static JPanel Jpaneltable;

//adding a new employee to the employeedetails


public static void addEmployee(Object employeeid,String
firstname,String initials,String surname,String dateofbirth,String
nationalId,Object gender,String address,String city,Object
countryId,String landlinephone,String mobilephone,String
emailadress,Object nationality,String passportNumber,Object
passportvalid,Object maritalStatus,Object gradeId,Object
frequecyId,Object educationQualification,String description){
System.out.println("exe");
String addemployeedetailstable =("INSERT INTO hrempoyeedetails
VALUES('"+employeeid+"','"+firstname+"','"+initials+"','"+surname+"','"
+dateofbirth+"','"+nationalId+"','"+gender+"','"+address+"','"+city+"',
'"+countryId+"','"+landlinephone+"','"+mobilephone+"','"+emailadress+"'
,'"+nationality+"','"+passportNumber+"','"+
passportvalid+"','"+maritalStatus+"','"+gradeId+"','"+frequecyId+"','"+
educationQualification+"','"+description+"')");

String checkemployee ="SELECT employeeid FROM hrempoyeedetails


WHERE employeeid='"+employeeid+"' ";
try{
long count=0;
ResultSet rs = DBconnect.stmt.executeQuery( checkemployee);
while(rs.next()){
count++;
}
if(count==0){
DBconnect.stmt.execute(addemployeedetailstable);

JOptionPane.showMessageDialog(null,employeeid+" has been


added the system");

}
else{
//indatabase(""+firstname);
JOptionPane.showMessageDialog(null,""+employeeid+"
already exists");
35

}
System.out.println("jihgdhjgddihv");
}
catch(SQLException e){
System.err.println(e.getMessage());
}

}
//end adding employee
// searching for an employee

public static void searchemployee(String empid){

String searchstatement = "SELECT * FROM hrempoyeedetails


WHERE employeeid='"+empid+"'";
String takename = "SELECT firstname,surname FROM
hrempoyeedetails WHERE employeeid='"+empid+"'";

try{
long count=0;
ResultSet rs =
DBconnect.stmt.executeQuery(searchstatement);
//DBconnect.stmt.execute(searchstatement);
while(rs.next()){
count++;}
//DBconnect.stmt.execute(takename);
if (count==0){

JOptionPane.showMessageDialog(null, empid+"
DOES NOT EXIST.");
}
else{
ResultSet rs2 =
DBconnect.stmt.executeQuery(takename);
while(rs2.next()){
String name=rs2.getString("firstname");
String surname=rs2.getString("surname");
JOptionPane.showMessageDialog(null, name+" "+surname+
" FOUND.");

}
}

catch(SQLException e){
//System.out.print(e.getMessage());
JOptionPane.showMessageDialog(null, "
"+e.getMessage());
//JOptionPane.showMessageDialog(null, empid+" DOES
NOT EXIST");

}
36

//end employee search

//updating employee details


public static void updateEmployee(Object employeeid,String
firstname,String initials,String surname,String dateofbirth,String
nationalId,Object gender,String address,String city,Object countryId
,String landlinephone,String mobilephone,String emailadress,Object
nationality,String passportNumber,String passportvalid,Object
maritalStatus,Object gradeId,Object frequecyId,Object
educationQualification,String description){
String updatestatement=("UPDATE hrempoyeedetails SET
firstname='"+firstname+"',initials='"+initials+"',surname='"+surname+"'
,dateOfBirth='"+dateofbirth+"',nationalIdnumber='"+nationalId+"',gender
='"+gender+"',address='"+address+"',city='"+city+"',countryid='"+countr
yId+"',landlinePhonenumber='"+landlinephone+"',mobilePhoneNumber='"+mob
ilephone+"',emailAddress='"+emailadress+"',nationality='"+nationality+"
',passportNumber='"+passportNumber+"',passportValidUpTO='"+passportvali
d+"',maritalStatus='"+maritalStatus+"',gradeId='"+gradeId+"',frequencyI
d='"+frequecyId+"',educationalQualification='"+educationQualification+"
',description='"+description+"' WHERE employeeid='"+employeeid+"'");

try{
DBconnect.stmt.execute(updatestatement);
JOptionPane.showMessageDialog(null, employeeid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
//end updating product details

//receive product to the inventory

//delete employee from hrempoyedetails


public static void deleteemployee(Object empid){

String deletestatement = "DELETE FROM hrempoyeedetails


WHERE employeeid='"+empid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+empid+"?");
if(opt==JOptionPane.YES_OPTION){
//DBconnect.stmt.executeUpdate(deletestatement);
//JOptionPane.showMessageDialog(null,empid+"
has been removed");
DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, empid+" HAS BEEN
DELETED FROM THE SYSTEM");
37

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void addallowances(Object allowanceid,String


allowancename,String rate,String amount){
String addallowance="INSERT INTO hrallowances VALUES('"+
allowanceid+"','"+allowancename+"','"+rate+"','"+amount+"' )";
String takename = "SELECT allowanceid,allowanceName FROM
hrallowances WHERE allowanceid='"+allowanceid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addallowance);
//while(rs2.next())
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deleteallowance(Object allwid){

String deletestatement = "DELETE FROM hrallowances WHERE


allowanceid='"+allwid+"'";
String deletestatement2 = "DELETE FROM hremployeeallowance
WHERE allowanceId='"+allwid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+allwid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, allwid+" HAS BEEN
DELETED FROM THE SYSTEM");
DBconnect.stmt.execute(deletestatement2);
JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");
38

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void updateallowance(Object allowanceid,String


allowancename,String rate,String amount){
String updatestatement=("UPDATE hrallowances SET
allowanceName='"+allowancename+"',rate='"+rate+"',amount='"+amount+"'
WHERE allowanceid='"+allowanceid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, allowanceid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void addallowancestoemployee(Object


employeeid,Object allowanceid){
String addallowance="INSERT INTO hremployeeallowance
VALUES('"+ employeeid+"','"+allowanceid+"' )";
String takename = "SELECT employeeid,allowanceid FROM
hremployeeallowance WHERE employeeid='"+employeeid+"'AND
allowanceid='"+allowanceid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addallowance);
//while(rs2.next())
JOptionPane.showMessageDialog(null,
allowanceid+" DETAILS SAVED TO"+ employeeid);
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
39

public static void adddeductions(Object deductionid,String


deductionname,String rate,String amount){
String adddeduction="INSERT INTO hrdeductions VALUES('"+
deductionid+"','"+deductionname+"','"+rate+"','"+amount+"' )";
String takename = "SELECT deductionId,deductionName FROM
hrdeductions WHERE deductionId='"+ deductionid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( adddeduction);
//while(rs2.next())
JOptionPane.showMessageDialog(null,
deductionname+" DETAILS SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deletedeductions(Object dedid){

String deletestatement = "DELETE FROM hrdeductions WHERE


deductionId='"+dedid+"'";
String deletestatement2 = "DELETE FROM hremployeedeductions
WHERE deductionId='"+dedid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+dedid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, dedid+" HAS BEEN
DELETED FROM THE SYSTEM");
DBconnect.stmt.execute(deletestatement2);
JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
40

public static void updatedeductions(Object deductionid,String


deductionname,String dedrate,String dedamount){
String updatestatement=("UPDATE hrdeductions SET
deductionName='"+deductionname+"',rate='"+dedrate+"',amount='"+dedamoun
t+"' WHERE deductionId='"+deductionid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, deductionid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void adddeductionstoemployee(Object


employeeid,Object dedid){
String adddeductions="INSERT INTO hremployeedeductions
VALUES('"+ employeeid+"','"+dedid+"' )";
String takename = "SELECT employeeid,deductionId FROM
hremployeedeductions WHERE employeeid='"+employeeid+"'AND
deductionId='"+dedid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( adddeductions);
//while(rs2.next())
JOptionPane.showMessageDialog(null, dedid+"
DETAILS SAVED TO"+ employeeid);
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void addleave(Object leaveid,String


leavename,String length,String hoursforallocation){
String addleave="INSERT INTO hrleavedetails VALUES('"+
leaveid+"','"+leavename+"','"+length+"','"+hoursforallocation+"' )";
41

String takename = "SELECT leaveId,leaveName FROM


hrleavedetails WHERE leaveId='"+ leaveid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addleave);
//while(rs2.next())
JOptionPane.showMessageDialog(null, leavename+"
DETAILS SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deleteleave(Object leaveid){

String deletestatement = "DELETE FROM hrleavedetails WHERE


leaveId='"+leaveid+"'";
String deletestatement2 = "DELETE FROM hremployeeleave
WHERE leaveId='"+leaveid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+leaveid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, leaveid+" HAS
BEEN DELETED FROM THE SYSTEM");
DBconnect.stmt.execute(deletestatement2);
JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void updateleaves(Object leaveid,String


leavename,String length,String hoursforallocation){
42

String updatestatement=("UPDATE hrleavedetails SET


leaveName='"+leavename+"',length='"+length+"',hoursWorkedforAllocation=
'"+hoursforallocation+"' WHERE leaveId='"+leaveid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, leaveid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void addleavetoemployee(Object employeeid,Object
leaveid,String hoursgained){
String addleave="INSERT INTO hremployeeleave VALUES('"+
employeeid+"','"+leaveid+"','"+hoursgained+"' )";
String takename = "SELECT employeeid,leaveId,hoursGained
FROM hremployeeleave WHERE employeeid='"+employeeid+"'AND
leaveId='"+leaveid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addleave);
//while(rs2.next())
JOptionPane.showMessageDialog(null, leaveid+"
DETAILS SAVED TO"+ employeeid);
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void addtax(Object taxid,Object gradeid,String


taxName,String rate,String amount){
String addleave="INSERT INTO hrtax VALUES('"+ taxid+"','"+
gradeid+"','"+taxName+"','"+rate+"','"+amount+"' )";
String takename = "SELECT taxid,taxName FROM hrtax WHERE
taxid='"+ taxid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
43

//if (count==0){
DBconnect.stmt.execute( addleave);
//while(rs2.next())
JOptionPane.showMessageDialog(null, taxName+"
DETAILS SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deletetax(Object taxid){

String deletestatement = "DELETE FROM hrtax WHERE


taxid='"+taxid+"'";
String deletestatement2 = "DELETE FROM hremployeetax WHERE
taxid='"+taxid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+taxid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, taxid+" HAS BEEN
DELETED FROM THE SYSTEM");
DBconnect.stmt.execute(deletestatement2);
JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void updatetax(Object taxid,Object gradeid,String
taxName,String rate,String amount){
String updatestatement=("UPDATE hrtax SET
gradeid='"+gradeid+"',taxName='"+taxName+"',rate='"+rate+"',amount='"+a
mount+"' WHERE taxid='"+taxid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, taxid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}
44

}
public static void addtaxtoemployee(Object employeeid,Object
taxid){
String addtax="INSERT INTO hremployeetax VALUES('"+
employeeid+"','"+taxid+"' )";
String takename = "SELECT employeeid,taxid FROM
hremployeetax WHERE employeeid='"+employeeid+"'AND taxid='"+taxid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addtax);
//while(rs2.next())
JOptionPane.showMessageDialog(null, taxid+"
DETAILS SAVED TO"+ employeeid);
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void addgrades(Object gradeid,String


gradeName,String description,String salary){
String addleave="INSERT INTO hrgrading VALUES('"+
gradeid+"','"+gradeName+"','"+description+"','"+salary+"' )";
String takename = "SELECT gradeId,gradeName FROM hrgrading
WHERE gradeId='"+ gradeid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addleave);
//while(rs2.next())
JOptionPane.showMessageDialog(null,gradeName+"
DETAILS SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
45

}
public static void deletegrade(Object grdid){

String deletestatement = "DELETE FROM hrgrading WHERE


gradeId='"+grdid+"'";
//String deletestatement2 = "DELETE FROM hremployeetax
WHERE gradeId='"+grdid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+grdid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, grdid+" HAS BEEN
DELETED FROM THE SYSTEM");
//DBconnect.stmt.execute(deletestatement2);
//JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void updategrades(Object gradeid,String
gradeName,String description,String salary){
String updatestatement=("UPDATE hrgrading SET
gradeName='"+gradeName+"',gradeDescription='"+description+"',salary='"+
salary+"' WHERE gradeId='"+gradeid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, gradeid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void addfrequency(Object frequencyid,String
frequencyName,String payperiod){
String addfrequency="INSERT INTO hrpayrollfrequencies
VALUES('"+ frequencyid+"','"+frequencyName+"','"+payperiod+"' )";
String takename = "SELECT frequencyId,frequencyName FROM
hrpayrollfrequencies WHERE frequencyId='"+ frequencyid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
46

//}
//if (count==0){
DBconnect.stmt.execute( addfrequency);
//while(rs2.next())

JOptionPane.showMessageDialog(null,frequencyName+" DETAILS
SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deletefrequency(Object frqid){

String deletestatement = "DELETE FROM hrpayrollfrequencies


WHERE frequencyId='"+frqid+"'";
//String deletestatement2 = "DELETE FROM hremployeeleave
WHERE leaveId='"+frqid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+frqid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, frqid+" HAS BEEN
DELETED FROM THE SYSTEM");
//DBconnect.stmt.execute(deletestatement2);
//JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void updatefrequency(Object frequencyid,String
frequencyName,String payperiod){
String updatestatement=("UPDATE hrpayrollfrequencies SET
frequencyName='"+frequencyName+"',payPeriod='"+payperiod+"' WHERE
frequencyId='"+frequencyid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, frequencyid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
47

System.out.print(e.getMessage());
}

}
public static void addovertime(Object overtimeid,String
maxovertimehrs,String rateperhr,String amount){
String addleave="INSERT INTO hrovertimedetails VALUES('"+
overtimeid+"','"+maxovertimehrs+"','"+rateperhr+"','"+amount+"' )";
String takename = "SELECT overtimeId FROM hrovertimedetails
WHERE overtimeId='"+ overtimeid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addleave);
//while(rs2.next())
JOptionPane.showMessageDialog(null,overtimeid+"
DETAILS SAVED");
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deleteovertime(Object ovrid){

String deletestatement = "DELETE FROM hrovertimedetails


WHERE overtimeId='"+ovrid+"'";
//String deletestatement2 = "DELETE FROM hremployeeleave
WHERE leaveId='"+ovrid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+ovrid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, ovrid+" HAS BEEN
DELETED FROM THE SYSTEM");
//DBconnect.stmt.execute(deletestatement2);
//JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}
48

}
public static void updateovertime(Object overtimeid,String
maxovertimehrs,String rateperhr,String amount){
String updatestatement=("UPDATE hrovertimedetails SET
maximumOvertimeHours='"+maxovertimehrs+"',ratePerHour='"+rateperhr+"',a
mountPerHour='"+amount+"' WHERE overtimeId='"+overtimeid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, overtimeid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}
}

public static void addpayroll(Object payrollid,Object


employeeid,String startday,String endday,String hrsworked,String
grosspay,String deductions,String netpay){
String addpayroll="INSERT INTO hrpayroll VALUES('"+
payrollid+"','"+employeeid+"','"+startday+"','"+endday+"','"+
hrsworked+"','"+grosspay+"','"+deductions+"','"+ netpay+"' )";
String takename = "SELECT payrollid FROM hrpayroll WHERE
payrollid='"+payrollid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addpayroll);
//while(rs2.next())
JOptionPane.showMessageDialog(null,payrollid+"
DETAILS SAVED FOR: "+ employeeid);
//}
/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void updatepayroll(Object payrollid,Object
employeeid,String startday,String endday,String hrsworked,String
grosspay,String deductions,String netpay){
String updatestatement=("UPDATE hrpayroll SET
startdate='"+startday+"',enddate='"+endday+"',hoursWorked='"+hrsworked+
"',grossPay='"+grosspay+"',deductions='"+deductions+"',netPaye='"+netpa
y+"' WHERE payrollid='"+payrollid+"'AND employeeid='"+employeeid+"'");

try{
49

DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, payrollid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}
}
public static void deletepayroll(Object payrolid ,Object empid){

String deletestatement = "DELETE FROM hrpayroll WHERE


payrollid='"+payrolid+"'AND employeeid'"+empid+"'";
//String deletestatement2 = "DELETE FROM hremployeeleave
WHERE leaveId='"+payrolid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+payrolid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, payrolid+" HAS
BEEN DELETED FROM THE SYSTEM");
//DBconnect.stmt.execute(deletestatement2);
//JOptionPane.showMessageDialog(null,empid+"'s
payroll details has been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

public static void addcompanydetails(Object companyid,String


companyname,String legalname,String address,String city,Object
countryid,String phone ,String fax,String email,String website){
String addcompany="INSERT INTO hrcompanydetails VALUES('"+
companyid+"','"+companyname+"','"+legalname+"','"+address+"','"+
city+"','"+countryid+"','"+ phone+"','"+ fax+"','"+
email+"','"+website+"' )";
String takename = "SELECT companyId,companyName FROM
hrcompanydetails WHERE companyId='"+companyid+"'";

try{//long count=0;
DBconnect.stmt.execute( takename);
//while(rs.next()){
//count ++;
//}
//if (count==0){
DBconnect.stmt.execute( addcompany);
//while(rs2.next())
JOptionPane.showMessageDialog(null," COMPANY
DETAILS SAVED ");
//}
50

/*else{
JOptionPane.showMessageDialog(null,
allowancename+" DETAILS IS ALREADY SAVED");
}*/
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void deletecompany(Object cmpid){

String deletestatement = "DELETE FROM hrcompanydetails


WHERE companyid='"+cmpid+"'";
//String deletestatement2 = "DELETE FROM hremployeeleave
WHERE leaveId='"+cmpid+"'";
try {

int opt=JOptionPane.showConfirmDialog(null,"ARE YOU


SURE YOU WANT TO DELETE "+cmpid+"?");
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.execute(deletestatement);
JOptionPane.showMessageDialog(null, cmpid+" HAS BEEN
DELETED FROM THE SYSTEM");
//DBconnect.stmt.execute(deletestatement2);
//JOptionPane.showMessageDialog(null,"All assignment
associated with this allowance have been removed");

}
}
catch(SQLException e){
System.out.print(e.getMessage());
}

}
public static void updatecompany(Object companyid,String
companyname,String legalname,String address,String city,Object
countryid,String phone ,String fax,String email,String website){
String updatestatement=("UPDATE hrcompanydetails SET
companyName='"+companyname+"',legalName='"+legalname+"',address='"+addr
ess+"',city='"+city+"',countryId='"+countryid+"',phoneNumber='"+phone+"
',faxNumber='"+fax+"',emailaddress='"+email+"',website='"+website+"'
WHERE companyid='"+companyid+"'");

try{
DBconnect.stmt.executeUpdate(updatestatement);
JOptionPane.showMessageDialog(null, companyid+" HAS BEEN
UPDATED");
}
catch(SQLException e){
System.out.print(e.getMessage());
}
}
public static void viewall(){
51

String oneemployees =("SELECT


employeeid,firstname,initials,surname FROM hrempoyeedetails ");//WHERE
employeeid='"+employeeid.getSelectedItem()+"'");
databaseconstants.registerDriver();
try{

Class.forName(databaseconstants.driver).newInstance();
Connection con =
DriverManager.getConnection(databaseconstants.url+databaseconstants.db,
databaseconstants.user, databaseconstants.pass);
try{
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(oneemployees);
// ResultSetMetaData md = rs.getMetaData();
int columnCount =4;// md.getColumnCount();

DefaultTableModel tablemodel = new DefaultTableModel();


JTable tableemployees = new JTable(tablemodel);
Jpaneltable = new javax.swing.JPanel();
Jpaneltable.add(new JScrollPane(tableemployees,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));

tablemodel.addColumn("EMPLOYEE_ID");
tablemodel.addColumn("NAME");
tablemodel.addColumn("INITIALS");
tablemodel.addColumn("SURNAME");
/* tablemodel.addColumn("D.O.B");
tablemodel.addColumn("NATIONAL_ID");
tablemodel.addColumn("GENDER");
tablemodel.addColumn("ADDRESS");
tablemodel.addColumn("CITY");
tablemodel.addColumn("COUTRYCODE");
tablemodel.addColumn("LANDLINE");
tablemodel.addColumn("MOBILE PHONE");
tablemodel.addColumn("EMAIL");
tablemodel.addColumn("NATIONALITY");
tablemodel.addColumn("PASSPORT #");
tablemodel.addColumn("PASSPORT VALIDTO");
tablemodel.addColumn("MARITAL STATUS");
tablemodel.addColumn("GRADE_ID");
tablemodel.addColumn("FREQUENCY ID");
tablemodel.addColumn("QUALIFICATION");
tablemodel.addColumn("DESCRIPTION");
*/
Vector<String> row ;
while(rs.next())
{
row = new Vector<String>(columnCount);

for(int i=1; i<=columnCount; i++)


{

row.add(rs.getString(i));
}
tablemodel.addRow(row);
52

}
//tableemployees.setCellSelectionEnabled(true);

}
catch(SQLException e){
System.err.println(e.getMessage());
}
} catch (Exception e){
e.printStackTrace();
}

public static void viewone(Object employeeid){


String oneemployees =("SELECT
employeeid,firstname,initials,surname FROM hrempoyeedetails WHERE
employeeid='"+ employeeid+"'");//WHERE
employeeid='"+employeeid.getSelectedItem()+"'");
databaseconstants.registerDriver();
try{

Class.forName(databaseconstants.driver).newInstance();
Connection con =
DriverManager.getConnection(databaseconstants.url+databaseconstants.db,
databaseconstants.user, databaseconstants.pass);
try{
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(oneemployees);
// ResultSetMetaData md = rs.getMetaData();
int columnCount = 4;//md.getColumnCount();

DefaultTableModel tablemodel = new DefaultTableModel();


JTable tableemployees = new JTable(tablemodel);
Jpaneltable = new javax.swing.JPanel();
Jpaneltable.setVisible(true);
Jpaneltable.add(new JScrollPane(tableemployees,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));

tablemodel.addColumn("EMPLOYEE_ID");
tablemodel.addColumn("NAME");
tablemodel.addColumn("INITIALS");
tablemodel.addColumn("SURNAME");
/* tablemodel.addColumn("D.O.B");
tablemodel.addColumn("NATIONAL_ID");
tablemodel.addColumn("GENDER");
tablemodel.addColumn("ADDRESS");
tablemodel.addColumn("CITY");
tablemodel.addColumn("COUTRYCODE");
tablemodel.addColumn("LANDLINE");
tablemodel.addColumn("MOBILE PHONE");
tablemodel.addColumn("EMAIL");
tablemodel.addColumn("NATIONALITY");
tablemodel.addColumn("PASSPORT #");
tablemodel.addColumn("PASSPORT VALIDTO");
tablemodel.addColumn("MARITAL STATUS");
53

tablemodel.addColumn("GRADE_ID");
tablemodel.addColumn("FREQUENCY ID");
tablemodel.addColumn("QUALIFICATION");
tablemodel.addColumn("DESCRIPTION");
*/
Vector<String> row ;
while(rs.next())
{
row = new Vector<String>(columnCount);

for(int i=1; i<=columnCount; i++)


{

row.add(rs.getString(i));
}
tablemodel.addRow(row);

}
//tableemployees.setCellSelectionEnabled(true);

}
catch(SQLException e){
System.err.println(e.getMessage());
}
} catch (Exception e){
e.printStackTrace();
}

public static double ToLong(String text){


double newnumber = -1;
try{
newnumber=Double.parseDouble(text);
}
catch(NumberFormatException e)
{

}
return newnumber;
}

}
package hms;
import java.sql.*;

import javax.swing.JOptionPane;

public class hrvactions extends properties{

public static void insertcustomerdetails(String fname,String


sname,Object dob,Object gender,String nationality,String
idnumber,String passportnumber,
54

Object cpsptissue,Object psptexpiry,String


carreg,String address,String city,Object country,long phone,
long fax,String email) {

String tname="hrvcustomers";String name ="customerId";


String select = "SELECT * FROM hrvcustomers WHERE
nationalIdnumber='"+idnumber+"'";
String insert="INSERT INTO hrvcustomers VALUES
('"+Getids.getnewid(tname,name)
+"','"+fname+"','"+sname+"','"+dob+"','"+gender+"','"+nationality+"','"
+idnumber+"','"+passportnumber+"','"+cpsptissue+"','"+psptexpiry+"','"+
carreg+"','"+address+"','"+city+"','"+country+"','"+phone+"','"+email+"
','"+fax+"','0.0','')";
try {
ResultSet rs = DBconnect.stmt.executeQuery(select);
System.out.println(insert);
long count=0;
while(rs.next()) {
count++;
}
if(count==0) {
DBconnect.stmt.execute(insert);
JOptionPane.showMessageDialog(null, idnumber+"
"+fname+" "+sname+" HAS BEEN SAVED INTO THE SYSTEM");

}
else {
indatabase(idnumber);
}

}
catch(SQLException e) {
System.out.print(e.getMessage());
}

public static void insertorgdetails(String Oname,String


address,Object country,long phone,long fax,String email) {
String tname="hrvorganisation";String name
="organisationId";
String insert ="INSERT INTO hrvorganisation
VALUES('"+Getids.getnewid(tname,name)
+"','"+Oname+"','"+address+"','"+country+"','"+phone+"','"+fax+"','"+em
ail+"')";
String select = "SELECT * FROM hrvorganisation WHERE
name='"+Oname+"'";
try {
ResultSet rs = DBconnect.stmt.executeQuery(select);
long count=0;
while(rs.next()) {
55

count++;
}
if(count==0) {
DBconnect.stmt.execute(insert);

}
else {
indatabase(Oname);
}

}
catch(SQLException e) {
System.out.print(e.getMessage());
}

}////********************
//insert into hrvcustomerorganisation
public static void savrorgcust(String customer,String
organisation) {
System.out.print(customer+" .... "+organisation);
String save = "INSERT INTO hrvcustomerorganisation
values('"+Getids.getid("customerId","hrvcustomers","nationalIdnumber",c
ustomer)
+"','"+Getids.getid("organisationId","hrvorganisation","name",organisat
ion)+"')";
String check = "SElECT * FROM hrvcustomerorganisation WHERE
customerId='"+Getids.getid("customerId","hrvcustomers","nationalIdnumbe
r",customer)+"' AND
organisationId='"+Getids.getid("organisationId","hrvorganisation","name
",organisation)+"' ";
try {
ResultSet rs = DBconnect.stmt.executeQuery(check);
long count=0;
while(rs.next()) {
count++;
}
if(count==0) {
DBconnect.stmt.execute(save);
System.out.println(save);
}

}
catch(SQLException e) {
System.out.println(e.getMessage());
}

}
//////////***********************

//update customer details


public static void updatecustomerdetails(String fname,String
sname,Object dob,Object gender,String nationality,String
idnumber,String passportnumber,
Object cpsptissue,Object psptexpiry,String
carreg,String address,String city,Object country,long phone,
long fax,String email) {
56

String update ="UPDATE hrvcustomers SET


firstname='"+fname+"',Surname='"+sname+"',dateOfBirth='"+dob+"',gender=
'"+gender+"',nationality='"+nationality+"',passportNumber='"+passportnu
mber+"',dateOfissuePassport='"+cpsptissue+"',dateOfexpiryPassport='"+ps
ptexpiry+"',carRegistrationNumber='"+carreg+"',address='"+address+"',ci
ty='"+city+"',country='"+country+"',phoneNumber='"+phone+"',emailAddres
s='"+email+"',faxNumber='"+fax+"' WHERE nationalIdNumber='"+idnumber+"'
";
int opt=JOptionPane.showConfirmDialog(null,"ARE SURE YOU
WANT TO UPDATE "+idnumber,"HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){
try{
DBconnect.stmt.execute(update);
JOptionPane.showMessageDialog(null,idnumber+" HAS
BEEN UPDATED");

}catch(SQLException e){
System.out.print(e.getMessage());

}
}
else{
}

}/////////////////****************************

public static void updateorganisation(String Oname,String


address,Object country,long phone,long fax,String email) {
String update ="UPDATE hrvorganisation SET
address='"+address+"',country='"+country+"',phoneNumber='"+phone+"',ema
ilAddress='"+email+"',faxNumber='"+fax+"' WHERE name='"+Oname+"'";
int opt=JOptionPane.showConfirmDialog(null,"ARE SURE YOU
WANT TO UPDATE "+Oname,"HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){
try{
DBconnect.stmt.execute(update);
JOptionPane.showMessageDialog(null,Oname+" HAS BEEN
UPDATED");

}catch(SQLException e){
System.out.print(e.getMessage());

}
}
else{
}

////////////////////////////****************************

public static void removefromorg(String customer,String org) {


String remove ="DELETE FROM hrvcustomerorganisation WHERE
customerId='"+Getids.getid("customerId","hrvcustomers","nationalIdnumbe
r",customer)+"' AND
57

organisationId='"+Getids.getid("organisationId","hrvorganisation","orga
nisationId",org)+"' ";
String select ="SElECT * FROM hrvcustomerorganisation WHERE
customerId='"+Getids.getid("customerId","hrvcustomers","nationalIdnumbe
r",customer)+"' AND
organisationId='"+Getids.getid("organisationId","hrvorganisation","orga
nisationId",org)+"' ";
try {
ResultSet rs = DBconnect.stmt.executeQuery(select);
System.out.println(remove);;
long count=0;
while(rs.next()) {
count++;
}
if(count!=0) {
DBconnect.stmt.execute(remove);
//System.out.println(remove);
}
else {
System.out.println("not available");
}
}
catch(SQLException e) {
System.out.println(e.getMessage());
}
}
//*********************

//save location

public static void savelocation(Object location){


String save ="INSERT INTO hrvlocation
VALUES('"+Getids.getnewid("hrvlocation","locationId")
+"','"+location+"','1')";
String check = "SELECT * FROM hrvlocation where
name='"+location+"'";
try{
int count=0;
int status=0;
ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()){
count++;
status=rs.getInt("status");
}
if(count==0){
DBconnect.stmt.execute(save);
JOptionPane.showMessageDialog(null,location+"
saved","HMS",JOptionPane.INFORMATION_MESSAGE);
hrvlocation .location.addItem(location);
}
else{
if(status==0){
int
opt=JOptionPane.showConfirmDialog(null,location+" is already in the
system would you like to activate it","HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){
58

DBconnect.stmt.executeUpdate("UPDATE hrvlocation SET status='1'


where name='"+location+"'");

JOptionPane.showMessageDialog(null,location+" has been


activated","HMS",JOptionPane.INFORMATION_MESSAGE);

hrvlocation.location.addItem(location);
hrvrooms.location.addItem(location);
}

}else{
indatabase(""+location);
}
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
}
//*****************
//delete location
public static void deletelocation(Object location){
String delete = "UPDATE hrvlocation SET status='0' WHERE
name='"+location+"'";
try{
int opt=JOptionPane.showConfirmDialog(null,"ARE YOU
SURE YOU WANT TO DELETE "+location+"\nYOU CAN REACTIVATE IT IF YOU
CONTINUE WITH HE PROCESS");
if(opt==JOptionPane.YES_OPTION){
DBconnect.stmt.executeUpdate(delete);
JOptionPane.showMessageDialog(null,location+"
has been removed");
hrvlocation.location.removeItem(""+location);
hrvrooms.location.removeItem(location);
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}

}///********************************

//save service
public static void saveservice(String name,String
description,double price){
String save ="INSERT INTO hrvservices
VALUES('"+Getids.getnewid("hrvservices","serviceId")
+"','"+name+"','"+description+"','"+price+"','1')";
String check = "SELECT * FROM hrvservices WHERE
name='"+name+"'";
int count=0;
int status = 0;
try{
ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()){
count++;
status=rs.getInt("status");
59

}
if(count==0){
DBconnect.stmt.execute(save);
JOptionPane.showMessageDialog(null,name+"
saved","HMS",JOptionPane.INFORMATION_MESSAGE);
hrvservices.search.addItem(""+name);
hrvroomtype.service.addItem(name);
}
else{
if(status==0){
int
opt=JOptionPane.showConfirmDialog(null,name+" is already in the system
would you like to activate it","HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.executeUpdate("UPDATE hrvservices SET status='1'


where name='"+name+"'");

JOptionPane.showMessageDialog(null,name+" has been


activated","HMS",JOptionPane.INFORMATION_MESSAGE);
hrvservices.search.addItem(""+name);
hrvroomtype.service.addItem(name);
}

}else{
indatabase(""+name);
}
}
}
catch(SQLException e){
System.out.print(e.getMessage());
}
}//**********************

//delete service
public static void deactivateservice(String name){
String delete = "UPDATE hrvservices SET status='0' WHERE
name='"+name+"'";
try{
int opt=JOptionPane.showConfirmDialog(null,"ARE YOU
SURE YOU WANT TO DELETE "+name+"\nYOU CAN REACTIVATE IT IF YOU CONTINUE
WITH HE PROCESS");
if(opt==JOptionPane.YES_OPTION){
DBconnect.stmt.executeUpdate(delete);
JOptionPane.showMessageDialog(null,name+" has
been removed");
hrvservices.search.removeItem(""+name);
hrvroomtype.service.removeItem(name);
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
}//*********************************

//update service
60

public static void updateservice(String name,String


description,double price){
String update = "UPDATE hrvservices SET
description='"+description+"',pricePerUnit='"+price+"' WHERE
name='"+name+"'";
int opt=JOptionPane.showConfirmDialog(null,"ARE SURE YOU
WANT TO UPDATE "+name,"HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){
try{
DBconnect.stmt.execute(update);
JOptionPane.showMessageDialog(null,name+" HAS BEEN
UPDATED");

}catch(SQLException e){
System.out.print(e.getMessage());

}
}
else{

}
}//////////*******************
//SAVE ROOMTYPE
public static void saveroomtype(String roomtype,Object service) {
String save="INSERT INTO hrvroomtype
VALUES('"+Getids.getnewid("hrvroomtype","roomTypeId")
+"','"+roomtype+"','"+Getids.getid("serviceId","hrvservices","name",""+
service+"")+"','1')";
String check="(SELECT * FROM hrvroomtype WHERE
name='"+roomtype+"')";

long count=0;
int status = 0;
try{
ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()){
count++;
status=rs.getInt("status");
}
if(count==0){
DBconnect.stmt.execute(save);
JOptionPane.showMessageDialog(null,roomtype+"
saved","HMS",JOptionPane.INFORMATION_MESSAGE);
hrvroomtype.search.addItem(roomtype);
hrvrooms.roomtype.addItem(roomtype);

}
else{
if(status==0){
int
opt=JOptionPane.showConfirmDialog(null,roomtype+" is already in the
system would you like to activate it","HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.executeUpdate("UPDATE hrvroomtype SET status='1'


where name='"+roomtype+"'");
61

JOptionPane.showMessageDialog(null,roomtype+" has been


activated","HMS",JOptionPane.INFORMATION_MESSAGE);

hrvroomtype.search.addItem(roomtype);
hrvrooms.roomtype.addItem(roomtype);
}

}else{
indatabase(""+roomtype);
}
}
}
catch(SQLException e){
System.out.print(e.getMessage()+"error on insert
query");
}

}//**************************
public static void deleteroomtype(String name){
String delete = "UPDATE hrvroomtype SET status='0' WHERE
name='"+name+"'";
try{
int opt=JOptionPane.showConfirmDialog(null,"ARE YOU
SURE YOU WANT TO DELETE "+name+"\nYOU CAN REACTIVATE IT IF YOU CONTINUE
WITH HE PROCESS");
if(opt==JOptionPane.YES_OPTION){
DBconnect.stmt.executeUpdate(delete);
JOptionPane.showMessageDialog(null,name+" has
been removed");
hrvroomtype.search.removeItem(""+name);
hrvrooms.roomtype.removeItem(name);
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
}//*********************************

//SAVE ROOM
public static void saveroom(long roomnumber,Object
roomtype,Object location) {
String save ="INSERT INTO hrvrooms VALUES
('"+roomnumber+"','"+Getids.getid("roomTypeId","hrvroomtype","name",""+
roomtype+"")
+"','"+Getids.getid("locationId","hrvlocation","name",""+location+"")
+"','1')";
String check="SELECT * FROM hrvrooms WHERE
roomNumber='"+roomnumber+"'";
int count=0;
int status = 0;
try{
ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()){
count++;
status=rs.getInt("status");
}
if(count==0){
62

DBconnect.stmt.execute(save);
JOptionPane.showMessageDialog(null,roomnumber+"
saved","HMS",JOptionPane.INFORMATION_MESSAGE);
hrvrooms.search.addItem(""+roomnumber);
}
else{
if(status==0){
int
opt=JOptionPane.showConfirmDialog(null,roomnumber+" is already in the
system would you like to activate it","HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){

DBconnect.stmt.executeUpdate("UPDATE hrvrooms SET status='1'


where roomNumber='"+roomnumber+"'");

JOptionPane.showMessageDialog(null,roomnumber+" has been


activated","HMS",JOptionPane.INFORMATION_MESSAGE);

hrvrooms.search.addItem(""+roomnumber);
}

}else{
indatabase(""+roomnumber);
}
}
}
catch(SQLException e){
System.out.print(e.getMessage());
}
}//**********************
//delete room
public static void deleteroom(long rnumber){
String delete = "UPDATE hrvrooms SET status='0' WHERE
roomNumber='"+rnumber+"'";
try{
int opt=JOptionPane.showConfirmDialog(null,"ARE YOU
SURE YOU WANT TO DELETE "+rnumber+"\nYOU CAN REACTIVATE IT IF YOU
CONTINUE WITH HE PROCESS");
if(opt==JOptionPane.YES_OPTION){
DBconnect.stmt.executeUpdate(delete);
JOptionPane.showMessageDialog(null,rnumber+"
has been removed");
hrvrooms.search.removeItem(rnumber);
}
}
catch(SQLException e){
System.out.println(e.getMessage());
}
}//*********************************
//update rooms
public static void updateroom(long rnumber,Object roomtype,Object
location){
String update = "UPDATE hrvrooms SET
roomTypeId='"+Getids.getid("roomTypeId","hrvroomtype","name",""+roomtyp
e+"")
+"',locationId='"+Getids.getid("locationId","hrvlocation","name",""+loc
ation+"")+"' WHERE roomNumber='"+rnumber+"'";
63

int opt=JOptionPane.showConfirmDialog(null,"ARE SURE YOU


WANT TO UPDATE ROOM "+rnumber,"HMS",JOptionPane.YES_NO_OPTION);
if(opt==JOptionPane.YES_OPTION){
try{
DBconnect.stmt.execute(update);
JOptionPane.showMessageDialog(null,rnumber+" HAS BEEN
UPDATED");

}catch(SQLException e){
System.out.print(e.getMessage());

}
}
else{
}
}//////////*******************

///make booking + other services


public static void saveintobooking(Object customerid,Object
checkindate,String checkoutdate,Object roomnumber,double
numofadults,double numofchildren,Object tagent,String event,String
equip,String tablearrangment) {
String save = "INSERT INTO hrvbooking
VALUES('"+Getids.getnewid("hrvbooking","bookingId")
+"','"+customerid+"','"+todaysdate+"','"+checkindate+"','"+checkoutdate
+"','"+roomnumber+"','"+numofadults+"','"+numofchildren+"','"+gettravel
agentid(""+tagent)
+"','"+event+"','"+equip+"','"+tablearrangment+"','0') ";
String check = "SELECT * FROM hrvbooking WHERE
customerId='"+customerid+"' AND status='0' AND preferredCheckinDate
BETWEEN '"+checkindate+"' AND '"+checkoutdate+"' or
preferredCheckinDate='"+checkindate+"' ";

try {int count = 0;


ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()) {
count++;
}
if(count==0) {
DBconnect.stmt.execute(save);
hrvbooking.checksuccesbentry=1;
ResultSet rss =
DBconnect.stmt.executeQuery("select max(bookingId) from hrvbooking
WHERE customerId='"+customerid+"' and status='0'");
while(rss.next()) {

hrvbooking.newbookingid=rss.getLong("max(bookingId)");
}
}
else {

}
catch(SQLException e) {
System.out.print("database error..save into booking
error"+e.getMessage());
64

}
}

public static void saveintopayment(String bookingid,double


amount) {
String save = "INSERT INTO hrvpayments
values('"+Getids.getnewid("hrvpayments","paymentsId")
+"','"+bookingid+"','"+amount+"','"+todaysdate+"')";
String save2="INSERT INTO acctransactions
VALUES('"+Getids.getnewid("acctransactions","idtransactions")+"','HOTEL
BOOKING booking id"+bookingid+"','"+amount+"','0','0')";
String save3="INSERT INTO accjournal VALUES
('"+Getids.getnewid("accjournal","idjournal")
+"','"+todaysdate+"','','"+amount+"','DEBIT')";
try {
DBconnect.stmt.execute(save);
DBconnect.stmt.execute(save2);
DBconnect.stmt.execute(save3);
hrvbooking.checksuccespentry=1;
}
catch(SQLException e) {
System.out.print(e.getMessage());
}
}

public static void savebooking_rooms(long bookingid,Object


roomnumber,String datefrom,String dateto) {
String save = "INSERT INTO hrvbooking_rooms
VALUES('"+bookingid+"','"+roomnumber+"','"+datefrom+"','"+dateto+"')";
//String check = "SELECT * FROM hrvbooking WHERE
roomnumber='"+roomnumber+"' AND ((datefrom BETWEEN '"+datefrom+"' AND
'"+dateto+"') OR( dateto BETWEEN '"+datefrom+"' AND '"+dateto+"')";
try {
DBconnect.stmt.execute(save);

}
catch(SQLException e) {
System.out.print("savebooking savebooking--
rooms"+e.getMessage());
}

public static boolean isAvailable(Object roomtype,String


checkindate,String checkoutdate) {
boolean a=true;
long taken=0;
long available=0;
long roomtypeid= Getids.getid("roomTypeId", "hrvroomtype",
"name",""+roomtype);
String findroomstaken = "SELECT * FROM
hrvbooking,hrvrooms,hrvroomtype WHERE
hrvbooking.roomNumber=hrvrooms.roomNumber AND
hrvroomtype.roomTypeId='"+roomtypeid+"' AND hrvbooking.status='0' AND
preferredCheckinDate BETWEEN '"+checkindate+"' AND '"+checkoutdate+"' ";
String findtotroomsava = "SELECT * FROM hrvavailablerooms
WHERE roomtype='"+roomtypeid+"' ";
65

try {
ResultSet rs=
DBconnect.stmt.executeQuery(findroomstaken);
while(rs.next()) {
taken++;
}

ResultSet rs1 =
DBconnect.stmt.executeQuery(findtotroomsava);
while(rs1.next()) {
available=rs1.getLong("available");
}

if((available-taken)<=0) {
a=false;
}
else {
a=true;
}

}
catch(SQLException e) {
System.out.println(e.getMessage());
}

return a;
}

public static void cancelbooking() {

}
public static void deletebookedrooms() {

public static void saveintoservicesoffered() {

public static long gettravelagentid(String agent) {


long id=0;
id
=Getids.getid("travelAgentId","hrvtravelagents","name",""+agent+"");

return id;

public static long getlastbooking(){


long id = 0;
try {
ResultSet rs = DBconnect.stmt.executeQuery("Select
max(bookingId) FROM hrvbooking");
66

while(rs.next()) {
id=rs.getLong("max(bookingId)");
}
}
catch(SQLException e) {
System.out.println(e.getMessage());
}
return id;
}

//checkin details
public static void saveintocheckinout(Object bookingid,String
datein,Object roomnumber) {
String save = "INSERT INTO hrvcheckinout VALUES
('"+Getids.getnewid("hrvcheckinout", "id")
+"','"+bookingid+"','"+datein+"','0000-00-00
00:00:00','"+roomnumber+"','0')";
String check = "SELECT * FROM hrvcheckinout WHERE
bookingid='"+bookingid+"'";
try {long count=0;
ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()) {
count++;
}
if(count==0) {
DBconnect.stmt.execute(save);
hrvcheckin.checkinsuccess=1;
}

}
catch(SQLException e) {
System.out.println(e.getMessage());
}

public static void saveserviceoffered(long serviceid,long


bookingid,long units) {

String save = "INSERT INTO hrvserviceoffered


VALUES('"+Getids.getnewid("hrvserviceoffered", "serviceOfferedId")
+"','"+serviceid+"','"+bookingid+"','"+units+"')";
try {
DBconnect.stmt.execute(save);
}
catch(SQLException e) {
System.out.println(e.getMessage());
}

public static void savecostsencuredbycustomer(long


bookingid,double total,double balance) {
String save ="INSERT INTO hrvcostsencuredbycustomer
VALUES('"+bookingid+"','"+total+"','"+balance+"')";
String check = "SELECT * FROM hrvcostsencuredbycustomer
WHERE bookingId='"+bookingid+"'";
67

int count=0;
try {
ResultSet rs = DBconnect.stmt.executeQuery(check);
while(rs.next()) {
count++;
}
if(count==0) {
DBconnect.stmt.execute(save);

}
catch(SQLException e) {
System.out.println(e.getMessage());
}System.out.println(save);
}

5.6 System verification/ testing


Testing of the system was done so that errors can be discovered and fixed before the
system is put to use. This is very crucial so that we make sure that the system is perfect
and does not give problems to the end users. JAVA provides for interactive program
development thereby blurring the distinction between code writing compiling and testing.
This ensures that the programs are able to recognize any errors in the program code as
one writes it rather than during compilation.

5.6.2 Verification and Validation


Verification and validation is the generic name given to checking that the software
conforms to its specifications and meet the needs of the software customer. Validation is
68

mainly concerned with building the right product while verification is concerned with
building the product right. Verification involves running the system in stimulated
environment using simulated data while validation involves running the system on a live
environment using real data. We can say verification involves checking that the program
conforms to its specification while validation involves checking that the program as
implemented meets the expectations of the software user.

5.6.3 Testing Process

The essence of this stage is to make sure that the system function as prescribed by the
users hence a need to detect syntax and logical errors and obtain a clear compilation is
needed. This ensures that the system will be ready to be accepted and implemented.

Testing stages to be followed:


Unit
Unit
Testing
Testing

Module
Module
Test allall44main
Test main
modulesofofsystem
system
modules

Subsystem
Subsystem
Testing
Testing

System
System
Testing
Testing
69

Unit testing
This involved individual programs (functions or methods) of the system being tested
independently to ensure its functionality and integrity.

Module testing
In this case each of the five modules: login, products and inventory, orders, suppliers and
user were tested using bottom up design testing. Each module was created separately and
tested separately then linked to form one. This testing strategy was instrumental in the
understanding of all the validation that needed to be coded as per module. Module testing
was rather the test of related unit components of the system. Execution paths, error-
handling paths, normal, abnormal and extreme data were thoroughly tested.

Subsystem testing
System modules that were related formed system subsystems these were tested for data,
stress, and error integrity. Database was also tested as a subsystem of its own. The new
project information subsystem was the major subsystem tested ahead of other sub
systems

System testing
The integrated system was then tested on the system testing stage. Methods used to test
the whole system were:

Black Box Testing


70

In this type of testing no reference was made to the code. The whole integrated system
was tested by inputting all relevant data to test the correctness of data input, to test also
the correctness of output as well as the correctness of data and systems validation rules.
System is taken as a black box that requires inputs and produce outputs with not much
knowledge of what goes on inside. Output results were compared with the expected
results.

White Box Testing


Reference was done to the code. Step by step
running of system was conducted with report and output at each step of the execution
and validation and verification was done at each significant code segment.

Stress Testing
In stress testing, the system was exercised beyond its maximum design load. Stressing the
system often causes defects to come to light. Many tasks were operated on the system at
once and the system showed signs of robustness.

5.6.4 Interface Testing


In interface testing errors were detected especially linked to data saving operations. In
this method faults due to interface errors or invalid assumption of errors are detected.

Access to system modules


71

Before a user can use the system resources the user has to login. The above image shows
the login page. If the user has no rights to access the appropriate module or resource the
image below shows the error page that will show the resource that the user must acquire
from the administrator.

The users of the system upon supplying the correct login details will be able to access
modules that are only related to their roles or privileges on the system. When a valid
username and password is supplied by the user, the menu appears.

5.6.5 Test Results

 System can sustain multiple tasks when using the system, however it tends to be
slow in retrieving data and saving data to the database if multiple tasks are saving
or retrieving data from the system.
 Data saving because of wrong interface component used was detected, this was
rectified by changing the component being used to a combo box. This resolved
the data saving problem that had risen because of the interface design.
 Expected results were produced and necessary debugging was done on modules
whose results were at variance with the expected set of data.
 The requirements as postulated in the Requirements Specification were
completely satisfied by the system, although new issues outside the parameters of
the specified requirements were raised, these were incorporated into the new
system. Users accepted the system and its functionalities in totality although the
testing process for the users is an ongoing process.
 Errors emanated mostly from users inputting wrong data in particular fields; this
however was resolved by using combo boxes, which restricted users to a specified
data range.
72

Installation
This is a technical process where a system replaces the old system and will take effect
after the establishment of the operational environment and training has been established.

Operational Environment
This facilitates the examining of all system components that affect the system
performance. Changes arising will be verified and user approval obtained. Examining of
the production environment will include:
Hardware and software configurations
- Operating system programs and utilities
- Network resources

Training
Training is going to facilitate delivery of the right training to the right people at the right
time in order for efficient and proper use of the system to be achieved. Specific training
will be necessary for the System administrator (who will operate as systems
administrator) and all the stock data clerks.
In-house training
The systems analyst will have the responsibility for conducting training of users on how
to use the system. The training techniques to be used are:
- Demonstrations
- Charts

Demonstrations
These will enable the systems analyst to demonstrate to the users how to use the system.
He will demonstrate the procedures for prompting the password, entering data, checking
records, and printing of various reports.

Charts
73

The same procedure will be followed only that the training will be shown on charts for
procedure of use. The trainer will be tabulating data on charts for use to be applied to the
real system.

Proposed set-up
Is a technical process where a new system replaces the old system? The users in the
organization will be transferred from using the “as is” business process to the “to be”
new system process offered by the new system.

The approach that is easy and feasible considering the business value, parallel
conversion will maintain the integrity of old system data while new system is being
implemented so when a process cannot be done on the new system, business does not
stop, and old system takes over. Having both the new and the old system working at the
same time can also provide extra time for the new system testing with real data.

Parallel running

Current System
Proposed
system
74

Unfreeze

Analysis design Move

Migration Support
Technical conversion and
Change management Maintenanc

Migration
Specifies what will be performed by people and it includes technical aspects such as
installing hardware and software and converting data from current system to the proposed
system. There are 3 major steps in migration process and these are:
- Installation of hardware and should be tested and certified.
- Software is installed.
- Convert data from the “as-is” system to the “to-be” system.

Parallel Conversion
The conversion method to be used is parallel conversion. This method allows both the
new and old system to operate fully for a specified period of time. Both systems operate
side by side until the project development team and end-users agree to switch over to the
new system after satisfaction that the new system will be able to run independently
without complexities. Data will be input to both systems and results will be compared
and verified. Errors will be identified and corrected without having to disrupt the daily
operations of the business. This method facilitates the solving of operating problems
before the old system is abandoned.
The main advantage:
- It gives the end –user enough time to verify the efficiency and effectiveness of the
new system.
- Risk is relatively low because results can be verified and a backup option exists.
75

However the weaknesses of this method are that:


- Costs are high because both systems will be operating for a certain period of time.
- Employees will be expected to perform twice the usual work because they have to
enter the same data into both systems thus its time consuming because it requires
the input of data in both systems and evaluating the performance for verification
purposes.
- It takes too long because the advantage of the new system does not become
available until the old system is abandoned.
- It is impractical if the systems are dissimilar or cannot be supported together.

5.7 Conclusion

During testing, the old and the new system were run in parallel so that any
anomalies in the new system could not affect the usual flow of business.
Modifications were made to the new system until it met the user requirements.
Evaluation of the new system was then done.

CHAPTER SIX

6. Conclusions

6.1 Summary
76

The newly computerized system works satisfactorily so as to say, and has


achieved the following objectives as originally specified:
• Reduction in data movement
The movement of data between has been reduced from the users straight to
the computer so this objective has been achieved by reducing the number of
people who carry out the data circulation system.
• Reduction in cost
The cost of stationery will be minimized since information can be added,
altered, deleted without the use of stationery or book records. This means the
objective of reducing cost was successfully achieved.
• Reduction in manual processes in the system

This objective has been achieved since there is complete


reduction of manual processes in data manipulation, that is,
deleting, adding and modification. The computer now
undertakes most of the manual processes carried by the
administrators.
• Reduction in errors
Errors within the system have been reduced since data can be verified by the
before being entered into database.
• Reduction in calculation
The new system caters for most of the calculation that are to be done. These
include the total premiums.

• Reduction in time
Time is reduced since reports, which were written manually, are now being
created and printed automatically.
• User friendliness of the system
This objective has been achieved. The system is highly user friendly that even a
newly employed person can operate the system without difficulties. The system
77

has a user manual imbedded in it. The graphics makes the system look
presentable.

6.2 Problems Encountered and Solved

 The development of the system had its own problems that requested the
developers to go out of their way to overcome them. The major problem
faced was of little time allocated for the project. This led to rushing of most
system modules thus compromising on the quality of the finished product.

 Lack of adequate resources, on the part of the University, required to host


the development platform and environment also came as a hindrance.
This meant outsourcing all the indispensable resources, leading to a
longer turnaround time to a project with little time allocated to it already.

 However, due to hard work and good planning, the developer successfully
managed to complete the project on time.

6.3 Suggestions for Better Approaches to Problem/Project

• A network system should be introduced such that different offices are able to
communicate so as to manipulate the centrally stored database

6.4 Suggestions for Future Extensions to Project


Introduction of a conferencing system to improve communication within
the hotel.
78

Das könnte Ihnen auch gefallen