Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
76 views65 pages

Design and Implementation of An Intruder Detector in Homes With Audio and Sms Alert Using GSM Module

This document describes the design and implementation of an intruder detector system for homes using audio and SMS alerts with a GSM module. The system aims to remotely monitor a home even when the owner is away by detecting intruders using a PIR sensor, processing the sensor data with a microcontroller, and sending SMS alerts to the owner's phone via a connected GSM module. The system design involves three main phases - sensing with the PIR sensor, processing with the microcontroller, and triggering an action by sending SMS alerts through the GSM module. The system is intended to provide convenient home security monitoring without needing a watchman onsite.

Uploaded by

LANGAT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views65 pages

Design and Implementation of An Intruder Detector in Homes With Audio and Sms Alert Using GSM Module

This document describes the design and implementation of an intruder detector system for homes using audio and SMS alerts with a GSM module. The system aims to remotely monitor a home even when the owner is away by detecting intruders using a PIR sensor, processing the sensor data with a microcontroller, and sending SMS alerts to the owner's phone via a connected GSM module. The system design involves three main phases - sensing with the PIR sensor, processing with the microcontroller, and triggering an action by sending SMS alerts through the GSM module. The system is intended to provide convenient home security monitoring without needing a watchman onsite.

Uploaded by

LANGAT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

DESIGN AND IMPLEMENTATION OF AN INTRUDER DETECTOR IN HOMES WITH

AUDIO AND SMS ALERT USING GSM MODULE

A PROJECT SUBMITTED

TO THE

DEPARTMENT OF COMPUTER SCIENCE

FACULTY OF SCIENCE

NATIONAL OPEN UNIVERSITY OF NIGERIA,

McCARTHY STUDY CENTRE

IN PARTIAL FULFILMENT OF THE REQUIREMENT FOR

THE AWARD OF BACHELOR IN SCIENCE (B.SC)

IN COMPUTER SCIENCE

LAWAL OLAYINKA MUDASHIRU

NOU149417271

OCTOBER, 2017
ii
DECLARATION

I Lawal Olayinka Mudashiru humbly declare that this work entitled ‘Design and Implementation Of an
Intruder Detector In Homes With Audio And Sms Alert System Using Gsm Module’ is as a result of my
research effort carried in the Faculty of Science and Technology, National Open University of
Nigeria.
I further wish to declare that, to the best knowledge and belief, it contains no material previously

published either written by another person or material which to a substantial extent has been

accepted for the award of other degree or diploma of any university or other institution of higher

learning, except one acknowledgement has been made in text.

……………………..

Lawal Olayinka Mudashiru

iii
APPROVAL

This is to certify that the research project entitled “Design and Implementation of an Intruder

Detector in Homes with Audio and Sms Alert System Using Gsm Module” was carried out by

Lawal Olayinka Mudashiru in the Faculty of Science, National Open University of Nigeria, Lagos

for the award of Bachelor of Science in Computer Science.

DR. OGUDE U. CYRIL ------------------------


(Project Supervisor) Signature & Date

DR. GREGORY ONWODI -------------------------


(Head of Department) Signature & Date

PROF. MONIOLUWA O. OLANIYI


-----------------------
(Dean, Faculty of Science) Signature & Date

DEDICATION

Dedicated to all Computer Science Student at National Open University of Nigeria for making my

learning experience one to remember.

iv
v
ACKNOWLEDGEMENT

My utmost gratitude goes to Almighty God; the instructor and innovator. I am grateful to all

members of my immediate family as well as my friends, students and well-wishers, too numerous to

be named for their wonderful support and encouragement.

I would like to appreciate my project supervisor, for her mentorship and academic support. I also

wish to express my gratitude to my other lecturers for the privilege of allowing me to benefit from

their wealth of knowledge.

May I also register my sincere gratitude to the entire Faculty of Science and Technology for making

it easier for me to embark on this project successfully.

vi
ABSTRACT

The comfort of being able to secure your house through a sensory system is imperative as it
saves a lot of time and effort. Ordinary, human body motion detective security system without GSM
Module has drawbacks of limited working alert range; however, the incorporation of GSM
module overcomes this limitation. It provides comfort of being able to secure your house
through a sensory, control over certain things that required constant attention. Instead of
using a watchman that might eventually sleep off on post. Remotely the system allows the user to
effectively monitor the house even when the house owner is at work; he can easily put his mind
at rest. This paper presents dependable security system that is able to recognize human body
(intruder) motion and send a notification text message to inform the owner(at any location
in the world where there is GSM mobile network coverage) The system design is in three main
phases: generally, the sensory, processing and the task. The sensory is the perception section
that is done through PIR sensor mounted at watch-area, the processing is done by a
programmed microcontroller, and the action (task) is done through an interaction of an
attached GSM module to the processor (the microcontroller) that then send an SMS alert to the
user.

TABLE OF CONTENTS
vii
DECLARATION.........................................................................................................................i

CERTIFICATION...................................................................................................................ii

DEDICATION..........................................................................................................................iii

ACKNOWLEDGEMENT........................................................................................................iv

ABSTRACT...............................................................................................................................v

TABLE OF CONTENTS..........................................................................................................vi

CHAPTER ONE........................................................................................................................1

INTRODUCTION......................................................................................................................1

1.1 BACKGROUND OF THE STUDY............................................................................1

1.2 STATEMENT OF THE PROBLEM...........................................................................2

1.3 PURPOSE OF STUDY...............................................................................................3

1.4 OBJECTIVES OF THE STUDY................................................................................3

1.5 SCOPE OF THE STUDY............................................................................................4

1.6 LIMITATION OF THE STUDY.................................................................................4

CHAPTER TWO........................................................................................................................7

LITERATURE REVIEW...........................................................................................................7

2.1 EVALUATION OF VOTING EQUIPMENT..............................................................7

2.2 EFFECTIVENESS OF E-VOTING AMONG DIFFERENT COUNTRIES..............8

2.3 THE SECURITY ISSUES OF E-VOTING................................................................9

CHAPTER THREE..................................................................................................................10

RESEARCH METHODOLOGY.............................................................................................10

3.2 SYSTEM DESIGN....................................................................................................10

3.3 SELECTING THE BEST SYSTEM.........................................................................11

3.4 METHODS OF DATA COLLECTION.....................................................................11

3.5 ANALYSIS OF THE EXISTING SYSTEM.............................................................12

viii
3.6 TECHNICAL DETAILS AND SOLUTION SOLUTIONS OF THE EXISTING

PROBLEM...........................................................................................................................13

3.7 FLOWCHART AND SYSTEM FLOWCHART.......................................................14

3.8 SYSTEM DESIGN AND SPECIFICATION............................................................20

3.9 INPUT SPECIFICATION.........................................................................................20

3.10 OUTPUT SPECIFICATION..................................................................................21

CHAPTER FOUR....................................................................................................................22

SYSTEM IMPLEMENTATION..............................................................................................22

4.1 SYSTEM REQUIREMENTS AND IMPLEMENTATION OF SYSTEM SPECIFICATION

..............................................................................................................................................22

4.2 SOFTWARE REQUIREMENT................................................................................22

4.4 REVIEW OF PROGRAM LANGUAGE IN USE....................................................23

4.5 SUBSYSTEM SELECTION.....................................................................................24

4.6 SYSTEM CONVERSION.........................................................................................25

4.7 TESTING..................................................................................................................25

4.7.1 Test Strategy.......................................................................................................26

4.7.2 Test Priorities......................................................................................................26

4.7.3 Test Techniques......................................................................................................27

CHAPTER FIVE......................................................................................................................28

SUMMARY AND CONCLUSION.........................................................................................28

LIMITATION.......................................................................................................................29

REFERENCES.........................................................................................................................30

ix
CHAPTER ONE

INTRODUCTION

1.1 BACKGROUND OF THE STUDY

Security is the degree of protection against danger, damage, loss or any criminal
activity. Security can also be seen as a condition so that one can develop and progress
freely. An important aspect of security includes Home Security. It is very important, because
crime rate is increasing day by day. The advancement of technology has increased the safety
and security of people along with their belongings. One of the reasons for the rise of the
smart home is the increasing risk of burglary and robbery and the busy lifestyle.

The busy lifestyle of people is leading to the necessity of controlling the devices at
home remotely and increasing the necessity of keeping surveillance over their homes.
Mobile phones today are not just used to make calls. The use of mobile phones is changing
with the development of technology and they can be used for different purposes. They can be
used as clocks, calendars or controllers instead of being used just as phones. Today smart
phones are available in the market with different applications and hardware which can
be implemented without any further development or enhancement.

With the help of the GSM network, a mobile can be used to implement a smart home by
controlling devices and getting alerts on robbery and burglary.

Traditional household security systems often require installation and detect based on opening
of doors and windows. The increasing number of the stealing and house breaking cases
especially when the people are not at home need a system that can tell them if anyone
has attempted or trying to break into their home. Therefore the idea of a smart home system
was proposed, to overcome the limitations of the systems already available in the market. The
user can choose the number of sensors, types of sensors, the area of coverage of the systems
along with the number. The goal of the project is to implement a smart home system by
controlling the electronic devices at home remotely with the help of a mobile device and
getting alerts on intrusion or movement around the restricted premises. The SIM900 –
GPRS module and the microcontroller are used to communicate between the mobile phone
and the devices and sensors installed at home. The mobile phone can be used as a
controller from anywhere in the world if the GSM network is available. In addition,
three sensors are used as a heat detector, motion detector and intrusion detector which
trigger the alarm upon reaching the critical limit. The system is limited to the area with the
GSM network available and the whole system does not work without the network
.

1.2 STATEMENT OF THE PROBLEM

The inefficiency of voting process in Enugu has resulted in a lot of problems. These problems

have continued to obstruct the peace of democracy in Enugu because the choice of a capable

candidate is not encouraged by the current system. The problems could be emendated as

follows.

 The high incidence of multiple voting massive transferred of ballot papers and

forging of electoral papers using fictitious names. Indiscrete manipulation and

inflation of election figures by electoral commission officers to suit the interest of

their favoured candidates.

 Thuggery operation, fear of intimidation and victimization and smuggling of

ballot papers into the ballot boxes.

 The fragile nature of some ballot boxes makes them vulnerable to destruction

 Loss of votes due to either wrong voting or the case of any of accident occurring

during transporting of the statement of result forms and other electoral materials to

the collation centers.

 The delay in the generation and announcement of the results which gives room for

other manipulations.

Therefore, there should be change for data handling.

2
1.3 PURPOSE OF STUDY

The purpose of design and implementation of an online voters registration system is to:

i. Design a voter registration system which will help to improve the votering system

ii. Implement an online voter’s registration system.

iii. Improve the standard of voter registration

iv. Avoid unnecessary delay in voter’s registration.

v. Update the voter’s registration roll without bribery and forgery.

1.4 OBJECTIVES OF THE STUDY

The main objectives of this project work is to design a fully web voter’s registration system

which should be able to:

 Effectively carryout the task of voting automatically and timely.

 Put to an end the indiscriminate alteration of election results by any officer of the

electoral commission. This will inculcate discipline in the commission and

promote their independence.

 Secure ballot papers and elections results from any accident what server and to

quickly detect any defaced ballot paper or a ballot paper that is wrongly plumb

printed.

 Stop multiple or double voting, forgery in any shape or form and smuggling of

ballot papers into ballot boxes. This will restore the integrity of votes cast.

 Generate accurate report and effect a stick knowledge of election results using an

on-line computer processing system.

3
1.5 SCOPE OF THE STUDY

The study covers voting processes as it is done at the ward councillorship elections, local

government chairmanship elections, the state house of assembly elections, the gubernatorial

elections the national house of parliamentary elections and presidential elections. It also

inculcates the voter’s personal records, candidate personal records and voting procedures it

covers election with at most five polling centers.

1.6 LIMITATION OF THE STUDY

This study is limited by the restricted nature of the number of polling centers it covers. It does

not represent a general election to cover the whole federation of Nigeria at the same time due

to time constraints. Also there was limited time to effectively combine the research work with

class study. It does not show the position (1st,2nd e.t.c) of candidate.

1.7 DEFINITION OF TERMS

BALLOT: - This refers to the system of voting in a country balloting could be open secret

or open secret.

COLLATION/RETURNING OFFICER: He or she collates data from the elections and

declares the results were required.

DEMOCRACY: - This is government of the people by the people and for the people. This

form of government places emphasis on the majority of people.

ELECTION: - This is a set of activities whereby members of a community choose their

leaders

ELECTORAL COMMISSION; - This refers to an independent responsibility to conduct all

election from the level of government election to the presidential election in the country.

ELECTORAL OFFICIALS: - personals who carryout election exercises.

4
INEC: - Independent National Electoral commission.

JUDICIARY: - The organ of government responsible for the interpretation of laws and

punishment of offenders for the the reach of law.

NOTICE IF ELECTION:- This is a notice issued not less than 90days before the date

appointed for holding of an election which is published in each state of the federation and the

federal capital territory.

POLITICAL CLERK:- A person who assists the presiding officer and deputizes in an event of

the letter’s absences.

POLITICAL PARTY: - Is a group of people who share common principles about the

management of their affairs, with the aim of capturing political power in a given polity.

POLLING: - A system of voting.

PRESIDING OFFICER: - He or she is the actual officer who conducts the election in the

polling station where he is in charge.

PUBLICATION OF THE LIST OF CANDIDATES: This is the publication by the electoral

commission of the final list of all candidates who stand nominated, to all candidates together

with the names of the persons nominating them, including their respective addresses and

occupations.

ROLL ASSISTANT/ORDERLY:- There may be one or more poll assistants or orderlies in a

polling center. Their duty is to assist in election duties and ensure orderliness in the station.

SUPERVISORY PRESIDING OFFICER: He or she charge of election in a ward usually

made up of about 10 polling stations.

VOTER: - A voter is a person who has a right to participate in an election as an elector

5
6
CHAPTER TWO

LITERATURE REVIEW

David Chaum addressed the concepts of untraceable electronic mail and digital pseudonyms,

which can apply for electronic voting for anonymity. In order to reduce the cost of human and

material, moreover, to enhance the convenience in the task of polling, E-voting has taken the

place of traditional voting in a considerable number of countries over the past few years. In

this section, I aim to review literature I consider relevant to E-voting.

2.1 EVALUATION OF VOTING EQUIPMENT

In the recent years, voting equipments which were widely adopted may be divided into five

types

Paper-based voting: The voter gets a blank ballot and use a pen or a marker to indicate

he want to vote for which candidate. Hand-counted ballots is a time and labor consuming

process, but it is easy to manufacture paper ballots and the ballots can be retained for

verifying, this type is still the most common way to vote.

Lever voting machine: Lever machine is peculiar equipment, and each lever is assigned

for a corresponding candidate. The voter pulls the lever to poll for his favorite candidate.

This kind of voting machine can count up the ballots automatically. Because its interface

is not user-friendly enough, giving some training to voters is necessary.

Direct recording electronic voting machine: This type, which is abbreviated to DRE,

integrates with keyboard; touch screen, or buttons for the voter press to poll. Some of

them lay in voting records and counting the votes is very quickly. But the other DRE

without keep voting records are doubted about its accuracy.

7
Punch card: The voter uses metallic hole-punch to punch a hole on the blank ballot. It

can count votes automatically, but if the voter’s perforation is incomplete, the result is

probably determined wrongfully.

Optical voting machine: After each voter fills a circle correspond to their favorite

candidate on the blank ballot, this machine selects the darkest mark on each ballot for the

vote then computes the total result. This kind of machine counts up ballots rapidly.

However, if the voter fills over the circle, it will lead to the error result of optical-scan.

2.2 EFFECTIVENESS OF E-VOTING AMONG DIFFERENT COUNTRIES

Recent years, a considerable number of countries has adopted E-voting for their official

elections. In this section, four empirical examples are enumerated as following.

America: Government of the United States hold election collaterally in several ways, in

other words, each state can choose the suitable way to hold elections independently.

Because there are some debates about E-voting, such as some vote casts were not

counted, or election system crashed during the Election Day. Secretary of State Kevin

Shelley established an “Ad Hoc Touch Screen Task Force” to research the debates on

DRE in February 2003. Shelly advanced that DRE should include voter verifiable paper

audit trails (VVPAT) to solve electoral debates.

Japan: Japan adopted E-voting for local election in 2002, such as mayor and councilor

election of Niimi city in Okayama prefecture in June 23, 2002; mayor election of

Hiroshima city in February 02, 2003; and mayor election of Kyoto city in February 08,

2004. Take mayor and councilor election of Niimi city for example, electoral center

surveyed the voters’ reliability when the election finished. There are 83% of voters

considered that E-voting system is trusted. 56% of them considered that the results of E-

voting and paper-based voting are the same therefore E-voting is sufficient for reliable.

8
The reasons why voters can’t trust the E-voting system are voters worried about the

abuses in E-voting system, and they cannot make sure their ballot are recorded correctly.

Belgium: Election for the Federal Parliament is held in May 18, 2003. In order to assist

voters in being familiar with E-voting system, electoral center held short-term training.

Counting efficiency in the election with E-voting system was faster than convention.

Belgium’s compulsory voting system and E-voting complement each other, voters’

satisfaction and attending willingness of join voting are improved obviously.

Brazil: Brazil used E-voting in 1998. When the voter reaches the polling place, he shows

his identity card for authenticating; if he is an eligible voter, he can get the ballot for E-

voting. Brazil’s E-voting system transmits votes to electoral center immediately, so that

the count of votes can announce rapidly while the voting finished

2.3 THE SECURITY ISSUES OF E-VOTING

Foreign experience revealed that they are often confronted by security issues while the

electronic voting system is running. The origin of the security issues happened was due to not

only outsider (such as voters and attackers) but also insider (such as system developers and

administrators), even just because the inheritance of some objects in the source code are

unsuitable. These errors caused the voting system crashed.

The proposed solutions were correspondingly outlined to hold back these attacks. For

example, to avoid hacker making incursion into the voting system via network, we can design

our system to transmit data without network. Another example is to limit voter to input

particular data, so that preventing the command injection from running

9
CHAPTER THREE

RESEARCH METHODOLOGY

In this chapter, the evaluation of the existing system and the organization structure of the

system problem are presented.

3.1 WHAT IS SYSTEM ANALYSIS?

A system is a collection of activities and elements organized to accomplish a goal. In system

analysis, data is collected about the present system. The data is then analyzed and new

requirements are determined. System analysis is on determining the requirement for a new

system. Three tasks of this phone are gathering data, Analyzing the data, and documenting the

analyses.

 Gathering data is done by observation, interviews, and questionnaire and looking at

documents, one of which is the organization chart which shows an organizers

foundations and levels of management.

 Analyzing data:- there are several tools for the analyzing of data which includes

checklist, decision tables and system flows charts

 Documenting system analysis. To document and to communicate the finding of phase

2, a system analysis report is prepared for higher management.

3.2 SYSTEM DESIGN

In system design, new or alternative information is designed. This phase consist of three

tasks.

An alternative information system is designed and each alternative is evaluating for:

 Economic feasibility: Costs and benefits, time for the system to pay for (itself)
10
 Technical feasibility: land ware and software reliability, available training

 Operational feasibility: the ability the system to work within the organization

3.3 SELECTING THE BEST SYSTEM.

Question is considered when selecting the best system:

i. Will the system fit into an overall information system?

ii. Will the system be flexible enough to be modified ad needed in the feature?

iii. Will it be secure against unauthorized use?

iv. Will the systems benefit exceed its costs?

v. Writing the system design report:- this is to document and it communicate the

finding of phase 3, a system design report is prepared for longer management.

3.4 METHODS OF DATA COLLECTION

Studying of Procedures Manuals: Written documents on voting System (Nigeria) was read

to obtain information on how the system works. This form of date collection was use full in

the sense that it sealed light into the present voting system an also enable the system.

Evaluation of forms: These provide information that is required within a section of the

system and what is contained in. The printed output form shade more knowledge on which

department representatives receive each document and where it is sent to after is has being

uses.

Interviewing of departmental representatives: After obtaining thorough understanding of

preset system through evaluation of present system through evaluation of forms and manuals.

I wert further to interview the representatives involve in the actual operation of the system.

11
These people explained more or the system and the basic reliable because the system put into

consideration the basic flows.

3.5 ANALYSIS OF THE EXISTING SYSTEM

The Independent National Electoral Commission (INEC) is a nonpartisans Nigerian

government agency charged with the conduct and supervision of elections. In the late 1990s,

the agency began modernizing its information technology infrastructure by migrating from an

outdated legacy voting system heavily dependent on inaccurate paper records and polling

cards to the newer Electronic voting system (EVS), at the heart of EVS is the electronic voter

register (EVR), which by capturing the names of all eligible voters, eliminates duplication

and there by minimizes discrepancies in the electrode process. As such, EVR is viewed as a

means of ensuring free and fair elections in Nigeria. As part of the modernization process.

INEC needed to inventory and spatially locate the agency’s 120,000 polling locations

scattered around the country, these locations and threat attributes needed to be linked to EVR.

GIS technology was identified as a potential solution to the problem, and TTi limited

(formerly Adorbel ltd.) a consultant responsible for the field data collection and project

management for INEC. Subcontracted Esri Business part to design and implement a polling

unit (PU) GIS. Geo-imaging proposed integrating GIS, digital photography, and DBMS

technologies to create a data collection tool capable of capturing the X, Y locations and

images of existing polling units. Since the clients budget constraints precluded the purchase

of GIS software, the use of an industry standard development environment to create an

application with GIS/mapping capabilities was also proposed. The application would then be

linked to EVR.

A number of problems associated with each phase of the electoral process are discussed

below. The problems include but not limited to:

12
Invalid votes: A vote is considered to be invalid if the thumbprint has not been placed at the

right spot. Also, a ballot paper which is improperly folded can be the cause of an invalid vote.

(The EC has published that an average of 2 to 2.5% of invalid votes are recorded during

every election.)

Long voting process: The manual voting exercise involves a number of steps that result in

long queues. This is because each voter takes a considerable amount of time to vote.

Delays in result publication: It has been gathered that it takes the EC about three days to

eventually publish a presidential election result. High cost of High High cost of election

organizing: The procurement of materials that ensure the validity of the voter’s registration,

as well as the complete success of the electoral process make election costs very high.

Indelible ink, ballot boxes and papers as well as other logistics, despite being expensive, are

indispensable in a manual voting system.

Too much paper work: The process involves too much paper work and paper storage which

is difficult as papers become bulky with the population size

3.6 TECHNICAL DETAILS AND SOLUTION SOLUTIONS OF THE EXISTING

PROBLEM

a) A sable solution to these problems is the use of computerized system (online voting

system) for high processing speed, minimum number of staff.

b) Change of attitude by all- election anomalies that we all experience now are rooted in

attitude of all stakeholders in the electoral system. Voters should change their attitude

of believing in money polities.

c) Credible election can be conducted by reforming the Nigeria police force.

d) Adoption of a tow party system.

e) Appointment not credible individuals into INEC.

13
3.7 FLOWCHART AND SYSTEM FLOWCHART

Flowchart symbols are graphic tools in which symbols and shapes are used to document the

flow of control within a program or system. This also involves use in the logical processing

of the system. It shows the step-by-step sequence of computer operations necessary in solving

problems.

This is a pictorial representation of how the hardware components work with the programs of

the system. It uses conventional symbols to represent its action and flow of control between

the hardware components as show below, yet flowchart involves creating a flow model that

illustrate and analyzes the overall flow activities in producing a product or services.

The two major types of flowchart include

i. the program flowchart

ii. the system flowchart

There may be some variations on these symbols are linked with directed lines (lines with

arrows) showing the flow of data through the system. Transactions are input, validated and

sorted and then used to update a master filer.

NOTE: - the arrows show the flow of data through the system. The dotted line shows that the

updated master file is then used as input for the next update process. This is a pictorial

representation of how the hardware components work with the programs of the system. It

uses conventional system to represent its action and flow of control between the hardware the

hardware components as show below, yet flowchart involves creating a flow model that

illustrate and analyzes the overall flow activities in producing a product or services.

14
Start

Welcome screen

Input password

Is Error in Password
Password

Ok ?

Stop

Main Menu Form

Choose From

Form List

Perform Operation 15
Figure 3.1: Program flowchart

16
Voter’s Registration Flowchart

Start

Enter Voters ID

Enter Names

Enter Party

Enter State of origin


YES
Has
Error Message

Mat No “Cannot

Been Register Twice”

NO
Registered?

Process Registration
Database

Generate Voters ID

Generate PIN code

Display PIN code

Stop
Figure 3.2: Voter’s Registration Flowchart

17
Voting Process Flowchart

Start

Enter Voters

ID

And PIN
Is Login

Correct

Verify if Error Message


Yes

the Voter “Cannot Vote

has Twice”

Voted
No
Before

Allow to

Vote

Stop

Figure 3.3: voter’s process flowchart

18
Candidates Registration Form

Start

Enter Names

Enter Political party

Enter State of Origin

Process

Registration

Stop

Figure 3.4: Candidates Registration Form

19
View Results Process

Start

Enter Username

and Password

Is Login No
Correct?

Yes

Display Results

Figure 3.5: view result process

20
3.8 SYSTEM DESIGN AND SPECIFICATION

System design is the process or art of defining the architecture, components, modules,

interfaces, and data for a system to satisfy specified requirements. One could see it as the

application of system theory to product, and development.

Systems design is therefore the process of defining and developing a system to satisfy

specified requirements of the market or customer. Until the 1990s system design had a crucial

and respected role in the data processing industry. In the 1990s standardization of hardware

and software resulted in the ability to build modular system.

Object – oriented analysis and design methods are becoming the most widely used methods

for computer system design. The UML has become the standard language used in Object-

oriented analysis and design. It is widely used for modeling software systems and is

increasing used for designing non-software systems and organizations.

After analysis, and discovering the problem of the existing system, there is need to produces

a new produce a new system, which will eliminate these problems design.

3.9 INPUT SPECIFICATION

In the input specification we made use of the keyboard to enter the password, and user name

which allows early if right and refuses when wrong. We also made use of the keyboard to

supply text, or number through the application and supply text program when working with a

high- level program.

All other input data for the system execution are present at menu options and is selected by

sticking easily identifiable keys, example the arrows keys, example the arrow keys the

alphabetic character keys, enter and escape keys.

21
3.10 OUTPUT SPECIFICATION

In this system, all outputs are retrieved from disk storage where information resulting from

both input and processing operations has been previously stored.

In designing a system, one should bear in mind to minimize complexity and platform.

22
CHAPTER FOUR

SYSTEM IMPLEMENTATION

4.1 SYSTEM REQUIREMENTS AND IMPLEMENTATION OF SYSTEM

SPECIFICATION

The purpose of this section is to highlight on the implementation environment of the system.

This covers the hardware and software environments for the implementation phase of the

system design and development. A top-down design approach was used in structuring the

program. The system consists of modules and sub-modules which are linked up to facilitate

easy flow of data and control.

4.2 SOFTWARE REQUIREMENT

Software is a collection of programs or instructions written in any computer language, which

enables flexibility to do whatever the user wants.

This package can only be run and developed with the following minimum software

requirements;-

i. Windows XP, Vista or Window 7

ii. Php and Wamp Server

iii. Mysql server

4.3 HARDWARE REQUIREMENT

The system functions well with a good computer compatible with a hard disk drive of 20GB.

This is needed to save the program so that it can be made available any time. It requires a

23
visual display unit (VDU) of high resolution and graphic ability for good display of all

outputs.

A functional floppy dive is needed to be used as backup or disk in case the programs served

on hard disk is eventually destroyed by a virus. An uninterrupted power supply (UPS) is

needed to sustain power failure for sometimes whenever PHCH puts of power supply.

The following minimum hardware for its development and running:

 Pentium 266HZ – 566HZ

 512MB RAM

 14’ super video graphic adapter monitor (SVGA)

 20GB of hard disk

 A mouse or mouse sensitive used on laptops

 Window XP, vista or window 7

 Uninterrupted power supply (UPS), lasting for at least 24 hours.

4.4 REVIEW OF PROGRAM LANGUAGE IN USE

There are several Program languages currently is used and they include Vsual- BASIC, C++,

C#, Visual Basic and Java etc. However, this project was done to suit interacting processing

rather than batch processing, also immediately response expected from the computer as

output or feedback to the input in an online processing simplifies and makes the work faster.

It is a high-level language that can be translated into a machine language and can be

understood by most computers easily.

The PhP is the language used in designing the program for the system PhP programming

language offers the best in terms of its availability, easy to understand server side construct,

flexibility and machine independence. The program can run on web servers where wamp

server is installed.

24
System selection to select a module (subsystem) when the main is displayed on the screen,

the cursor is passed to choose on optional and enter to select it. If this is done, control is

passed to the main program after a subro9utine is completed depending on the task that needs

to be1accomplished by the user choosing the exit do terminate a subroutine, this returns

control to the calling program and to terminate the system is by closing exit application from

the main menu.

4.5 SUBSYSTEM SELECTION

RETRIEVING/ OPEN A SAVED DOCUMENT: With the file menu you can retrieve

document into memory by clicking the file menu’s open command you can also click on the

icon on the toolbar. When you click the open command, notepad displays the open dialog box

with a list of all the names of document to be retrieved. Notice that the open dialog box has a

text where you have the mouse pointer already positioned.

You can type the name of the document to be retrieved other until you get to your desired

filename. To retrieve, click the open button. This is just one of the several ways to open

documents.

THE PRINT PREVIEW OPTION: Before printing your document (voting result) you may

wish to have an idea of how it will look when you finally print it. The print preview feature is

used to achieve this. In the print preview window, you can see the overall appearance of one

page, or all the pages. Previewing the document can save you time and paper, because it

reduces the number of times you print the document before it looks exactly the way you

want. To preview a document either click on the print preview button on the standard toolbar

or choose print preview from the file menu.

25
THE PRINT OPTION: You can click the print button on the standard toolbar to print the

entire document using default settings, or you can use the print command to select different

printing options.

4.6 SYSTEM CONVERSION.

This involves the procedure used in changing from the old to the new system and are;

* Direct Conversion:

The old system is continued and the new system becomes effectively immediately.

* Phased Conversion:

The new system is implemented gradually over a period of time. The entire implementation

process is broken down into different process. This phase ensures that the new system is fully

in perfect operation before discarding the old are completely.

* Pilot Conversion.

The new system (reverting) is tried out using the local government selection first. Once the

system is running smoothly in that part, then it is implemented throughout the rest of the

election in Nigeria

4.7 TESTING

This document describes the user acceptance test plan for the System. The complete test

strategy for the System is to perform the following kinds of tests, in sequence:

1. Component testing of each component that makes up the System

2. Integration testing of the, to ensure the correct interworking of its components

3. Validation testing of the, to ensure that it works correctly in a pseudo-live

environment

26
4. User acceptance testing of the, to ensure that its function is acceptable to its users

Acceptance testing is the last set of tests to be performed before the application goes

officially live.

4.7.1 Test Strategy

The basis of user acceptance testing is that other tests were completed successfully, so the

application and its required infrastructure are considered to be stable and reliable.

Acceptance testing concentrates on the application from the user’s perspective, that is,

how the application is used and whether it meets the necessary quality criteria.

Change requests will be sent to the development team as the actionable documentation.

Change criteria will be determined by the Test team and the Development team prior to the

beginning of testing. For instance, criteria may include impact to desired functionality,

amount of code impacted by proposed change, and design required by proposed change.

The tester will evaluate the criteria. The test lead will determine Change Required or not.

Once a bug has been determined as Change Required, the bug report will be translated into

a Change Request and passed on to development.

4.7.2 Test Priorities

During testing of the E-Billing and Invoice System, the following qualities will be tested

in order of priority:

 Functionality—whether the required functions are available and working as

expected

 Usability—how user-friendly and intuitive the E-Billing and Invoice System is

 Security—how well-protected and guaranteed corporate and user data is

 Performance—whether the response times are within acceptable limits

27
 Customization—how straightforward it is to use the application in new,

unpredicted ways

4.7.3 Test Techniques

The following techniques will be applied:

 Scripted tests—sequences of user interactions (based on the use case and usage

scenarios) using predefined data sets against predicted results

 Unscripted tests—based on scripted tests, the tester tries to modify the scenarios to

explore what-if possibilities

 Penetration tests—scripted tests to attempt unauthorized entry into the system

 Usability checklists—tests to determine the complexity of interactions

 Performance statistics—generation of performance information to check against

desired performance criteria

28
CHAPTER FIVE

SUMMARY AND CONCLUSION

5.1 SUMMARY

The main aspect behind online voting system (OVS) is that it enabled us to bring out the new

ideas that were sustained within us for many days. This project offers the voters to cast easily

through internet. Vote counting is also made easy by online voting system (OVS) since it’s

just a matter of querying the database. Online voting system (OVS) is used by a number of

countries today. Developing a good system is critical to the success of the system to prevent

system failures and to gain wide acceptance as the best method available. A good OVS

system requires ten characteristics which this system already has. These are: Accuracy,

Convenience, Reliability Verifiability Flexibility Consistency Democracy Mobility Social

Acceptance Privacy in analyzing, designing, implementing, and maintaining standards, we

considered these characteristics as the foundation. These standards were made national. OVS

will be an inexpensive, and less time consuming method once a system exhibiting national

standards and the above mentioned characteristics is implemented.

5.2 CONCLUSIONS

This project clarifies the requirements and key elements of Online voting system, and my

implementation provides the following features. To begin with, the accuracy of voter’s

identity and ballot card are ensured with this voting system. Next, voter’s identities are not

written in the ballot card to protect voter’s privacy and confidentiality. This system will

validate whether the ballot card is authorized or not, to make sure only legal user can vote,

and voter’s authorities are limited in order to prevent his violation. Furthermore, this system

29
fits in with the parts of principles proposed by IPI, including secrecy, non-coercibility,

integrity, and uniqueness.

But because of the limitation of incomplete laws and regulations, absentee voting can’t be

held. It still needs to be discussed in legislative systems. In the future, to eliminate

maladministration and human destruction, setting up a strongly secure E-voting system is

necessary. It can speed up the electoral procedures, make ballot counting efficaciously, and

use resource effectively.

5.3 LIMITATION

Time factor was the greatest barrier to the successful completion of this exercise since it had

to be done within the semester. I also had financial constraints since all the activities involved

were self-sponsored.

5.4 RECOMMENDATION

I highly recommend that the online voting system (OVS) be put in use especially in the 21st

century where human beings are embracing technology and where there is malicious struggle

for power by leaders all over the world. This struggle for power has resulted in the use of all

approaches by the leaders in power to remain in their positions at whatever costs even if it

means applying vote rigging to win elections.

30
REFERENCES

Anderson C. (2006). How to Rig a Democracy: A Timeline of Electronic Voting in the

United States. The Independent. Retrieved November 28, 2006 from:

http://www.indypendent.org/?p=608

Baje, E.N. (1998). Records Management Program. Ibadan: Adeyomi printing press.

Brown, P.T and Payne L.C. (1975). Computer application. New York, Addison Wesley

publishing.

Celestine, C. N.(1989). Management theory and practices. Africana first publisher’s Ltd.

Chiazor, I. k. N.(2008). Design and implement of a hospital management Enugu:

Unpublished ( Project work). pp30-37

Cranor, L.F., & Cytron, R.K. (1996). Design and Implementation of a Security-Conscious

Electronic Polling System. Washington University Computer Science Technical

Report (WUCS). Retrieved October 9, 2006 from:

http://www.acm.org/crossroads/ords2-4/voting.html

Electronic Voting and Counting – Development of the System. (2005). Elections ACT.

Retrieved February 11, 2007 from: http://www.elections.act.gov.au/EVACS.html

Francis, M (2001). Computer and process control. Aba: Machitouch Industrial Nigeria.

Penny, H. (2000). Process control system. Britain: John Murry Publication Ltd

APPENDIX

31
Source Codes

<?xml version="1.0" encoding="utf-8" ?>


<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="Bio.My.MySettings.MainConnectionString" connectionString="Data
Source=NUEPC2\SQLSERVER2008R2;Initial Catalog=CovenantBioRegDB;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your
application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener"
initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
</configuration>

CADDBCLASS.VB

Imports System.Linq
Imports System.Runtime.InteropServices

' Template data

Public Class CADDBClass


Implements ICADBioDB

Dim AdStd As New MainDataTableAdapters.StudentListTableAdapter


' Add template to database. Returns added template ID.
Public Function AddTemplate(ByRef template As TTemplate, ByVal OwnerID As Integer, FingerName As
FingerNameEnum, FingerImage As Image) As Long Implements ICADBioDB.AddTemplate
Using Ad As New MainDataTableAdapters.StudentListTableAdapter, Ds As New MainData
Ad.FillByStudentID(Ds.StudentList, OwnerID)
Dim dr As MainData.StudentListRow = Nothing
If Ds.StudentList.Count > 0 Then
dr = Ds.StudentList(0)
dr.FingerPrint = CType(template.tpt, Byte())
32
dr.FPImage = TBExplorer2.CADImageLib.GetByteFromImage(FingerImage,
System.Drawing.Imaging.ImageFormat.Jpeg)
dr.EntryDate = Now
dr.EnrolledFinger = FingerName.ToString
dr.EndEdit()
Ad.Update(Ds.StudentList)
End If
Ad.ClearBeforeFill = False
Ad.FillByStudentID(CacheDSInv.StudentList, OwnerID)
TemplatesLoaded = False

Return dr.StudentID
End Using
End Function

Dim ttpts As TTemplates()


Dim Lstttpts As Generic.List(Of TTemplates)
Dim TemplatesLoaded As Boolean = False

' Returns a DataTable with all enrolled templates from database.


Public Function getTemplates() As TTemplates() Implements ICADBioDB.getTemplates
If TemplatesLoaded = False Then
Using ds As New MainData
'Dim i As Integer
ds.StudentList.Merge(CacheDSInv.StudentList)
Lstttpts = CType(ds.StudentList.Select("FingerPrint is not null"),
MainData.StudentListRow()).Select(Function(d)
Dim tt As TTemplates
tt.template = New TTemplate
tt.ID = d.StudentID
tt.template.tpt = d.FingerPrint
tt.template.Size =
tt.template.tpt.Length
tt.template.fingerPicture =
TBExplorer2.CADImageLib.GetImageFromByte(d.FPImage)
Return tt
End Function).ToList

ttpts = Lstttpts.ToArray

TemplatesLoaded = True
Return ttpts
End Using
Else
Return ttpts
End If

End Function

' Returns template with supplied ID.


Public Function getTemplate(ByVal id As Long) As Byte() Implements ICADBioDB.getTemplate
Using ds As New MainData
Dim tpt As New TTemplate
Using Ad As New MainDataTableAdapters.StudentListTableAdapter
Ad.FillByStudentID(ds.StudentList, CInt(id))
End Using
If ds.StudentList.Count > 0 Then
Return ds.StudentList(0).FingerPrint
33
Else
Return Nothing
End If
End Using
End Function

#Region "Biometrics"

Public Property MatchingTechnology As MatchingTechnologyEnum Implements


ICADBioDB.MatchingTechnology
Get
Return MySetting.MatchingTechnology
End Get
Set(value As MatchingTechnologyEnum)
MySetting.MatchingTechnology = value
End Set
End Property

Public Property MatchingSecurityLevelEnroll As Integer Implements


ICADBioDB.MatchingSecurityLevelEnroll
Get
Return MySetting.MatchingSecurityLevelEnroll
End Get
Set(value As Integer)
MySetting.MatchingSecurityLevelEnroll = value
End Set
End Property
Public Property MatchingSecurityLevelVerify As Integer Implements
ICADBioDB.MatchingSecurityLevelVerify
Get
Return MySetting.MatchingSecurityLevelVerify
End Get
Set(value As Integer)
MySetting.MatchingSecurityLevelVerify = value
End Set
End Property
#End Region

End Class

frmAutoAttendance.vb

Imports System.Linq

Imports Microsoft.VisualBasic
Public Class frmAutoAttendance
Dim myUtil As CADUtil
Dim ReadyToEnroll As Boolean = False
Private Sub txtCode_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
LoadEmp()
End If
End Sub
Dim MainDs As New MainData
Sub LoadEmp()
'Me.PictureBox1.Image = Nothing
'Me.empPix.Image = Nothing
34
'If MainDs.Employees.Select("Code='" & Me.txtCode.Text & "'").Length > 0 Then
' ReadyToEnroll = True
' Me.txtName.Text = MainDs.Employees.Select("Code='" & Me.txtCode.Text & "'")(0).Item("name")
' Dim s As String = IO.Path.Combine(My.MySettings.Default.EmployeePixFolder, Me.txtCode.Text &
".jpg")
' If IO.File.Exists(s) = True Then
' Me.empPix.Image = Image.FromFile(s)
' Else
' Me.empPix.Image = Nothing
' End If
'Else
' MessageBox.Show("Employee with Code '" & Me.txtCode.Text & "' can not be found")
' ReadyToEnroll = False
'End If

End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
LoadEmp()
End Sub

Dim Dbb As New CADDBClass

Private Sub frmEnroll_FormClosing(ByVal sender As Object, ByVal e As


System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'myUtil.FinalizeGrFinger()

End Sub
Private Sub frmEnroll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
Try
Me.MainDs.EnforceConstraints = False

If CacheDSInv.StudentList.Count = 0 Then
Using Ad As New MainDataTableAdapters.StudentListTableAdapter
Ad.Fill(CacheDSInv.StudentList)
End Using
End If
MainDs.StudentList.Merge(CacheDSInv.StudentList)
Using Ad As New MainDataTableAdapters.UsersTableAdapter
Ad.Fill(MainDs.Users)
End Using

Catch ex As Exception
MessageBox.Show(ex.Message, ex.Source)
End Try
Dim err As Integer

myUtil = New CADUtil(LogList, CadFingerprint1, ConStr)

err = myUtil.InitializeGrFinger(Dbb)
If err < 0 Then
myUtil.WriteError(err)
Exit Sub
Else
myUtil.WriteLog("**Initialized Successfull**")
End If

Try
'modAgent.LoadAgent(Me)
35
Speak("Welcome to CAD Biometric Attendance System")

Catch ex As Exception

End Try
CadFingerprint1.SecurityLevel = CType(Dbb.MatchingSecurityLevelVerify, SGFPMSecurityLevelEnum)
End Sub

Private Sub AxGrFingerXCtrl1_SensorPlug(ByVal sender As System.Object, ByVal e As SensorPlugEvent)


Handles CadFingerprint1.SensorPlug
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Plugged.")
'CadFingerprint1.CapStartCapture(e.idSensor)
End Sub

' A fingerprint reader was unplugged from system


Private Sub AxGrFingerXCtrl1_SensorUnplug(ByVal sender As System.Object, ByVal e As
SensorUnplugEvent) Handles CadFingerprint1.SensorUnplug
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Unplugged.")
CadFingerprint1.CapStopCapture(e.idSensor)
End Sub

' A finger was placed on reader


Private Sub AxGrFingerXCtrl1_FingerDown(ByVal sender As System.Object, ByVal e As
FingerDownEvent) Handles CadFingerprint1.FingerDown
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger Placed.")
End Sub

' A finger was removed from reader


Private Sub AxGrFingerXCtrl1_FingerUp(ByVal sender As System.Object, ByVal e As FingerUpEvent)
Handles CadFingerprint1.FingerUp
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger removed.")
End Sub

Private Sub AxGrFingerXCtrl1_ImageAcquired(ByVal sender As System.Object, ByVal e As


ImageAcquiredEvent) Handles CadFingerprint1.ImageAcquired
' Copying aquired image
myUtil.raw.height = e.height
myUtil.raw.width = e.width
myUtil.raw.res = e.res
myUtil.raw.img = e.rawImage

' Signaling that an Image Event occurred.


myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Image captured.")

' display fingerprint image


'myUtil.PrintBiometricDisplay(False, GRConstants.GR_DEFAULT_CONTEXT)
Me.empPix.Image = Nothing

' extracting template from image


If Extract() = True Then
Dim Code As Integer = 0
If Identify(Code) = True Then
'Save attd
Dim Msg As String = ""
Dim PeriodMode As String = ""
Dim DayDate As DateTime = Now.Date

Me.empPix.Image = Nothing
Dim Name As String = ""
Dim fName As String = Name
36
If Not MainDs.StudentList.FindByStudentID(CInt(Code)) Is Nothing AndAlso
MainDs.StudentList.FindByStudentID(CInt(Code)).IsFirstnameNull = False AndAlso
MainDs.StudentList.FindByStudentID(CInt(Code)).IsSurnameNull = False Then
Name = MainDs.StudentList.FindByStudentID(CInt(Code)).Surname & " " &
MainDs.StudentList.FindByStudentID(CInt(Code)).Firstname
fName = FormatName(MainDs.StudentList.FindByStudentID(CInt(Code)))
If fName = "" Then
fName = FormatName(Name)
If fName.Contains(" ") = True Then
fName = fName.Split(CChar(" "))(0)
End If
End If

If MainDs.StudentList.FindByStudentID(CInt(Code)).IsPictureNull = False AndAlso Not


MainDs.StudentList.FindByStudentID(CInt(Code)).Picture Is Nothing Then
Dim bt() As Byte = MainDs.StudentList.FindByStudentID(CInt(Code)).Picture
Using ms As New IO.MemoryStream(bt)
Me.empPix.Image = Image.FromStream(ms)
ms.Close()
End Using

End If
End If

MyMessageAgent.Show(fName & ", " & Msg)


myUtil.WriteLog(fName & ", " & Msg)

Me.Timer1.Enabled = True

End If
Else
Me.empPix.Image = Nothing
MyMessageAgent.Show("Please replace your finger")
End If

End Sub

Function Extract() As Boolean


Dim ret As Integer
' extract template
ret = myUtil.ExtractTemplate()
' write template quality to log
'If ret = GRConstants.GR_BAD_QUALITY Then
' myUtil.WriteLog("Template extracted successfully. Bad quality.")
'ElseIf ret = GRConstants.GR_MEDIUM_QUALITY Then
' myUtil.WriteLog("Template extracted successfully. Medium quality.")
'ElseIf ret = GRConstants.GR_HIGH_QUALITY Then
' myUtil.WriteLog("Template extracted successfully. High quality.")
'End If
If ret > 0 Then
' myUtil.PrintBiometricDisplay(True, GRConstants.GR_NO_CONTEXT)
Return True
Else
' write error to log
myUtil.WriteError(ret)
Return False
End If
End Function
Function GetStudentInfo(ByVal ID As Integer, ByRef StateCode As String) As String
37
Using Ad As New MainDataTableAdapters.StudentListTableAdapter, Dt As New
MainData.StudentListDataTable
Ad.FillByStudentID(Dt, ID)
If Dt.Count > 0 Then
Return Dt.FindByStudentID(ID).Firstname & " " & Dt.FindByStudentID(ID).Surname
Else
Return ""
End If

End Using
End Function

Function GetStudentCode(ByVal ID As Integer) As Integer


Using Ad As New MainDataTableAdapters.StudentListTableAdapter, Dt As New
MainData.StudentListDataTable
Ad.FillByStudentID(Dt, ID)
If Dt.Count > 0 Then
Return Dt(0).StudentID
Else
Return 0
End If
End Using
End Function

Function Identify(ByRef Code As Integer) As Boolean


Dim ret As Integer, score As Integer
Code = 0
score = 0
' identify it
Dim ArrList As New List(Of TTemplates)

ret = myUtil.Identify(score, ArrList, Me.CadFingerprint1.SecurityLevel, True)


' write result to log
If ret > 0 Then
Dim StateCode As String = ""
If GetStudentInfo(ret, StateCode) <> "" Then
myUtil.WriteLog("Fingerprint identified. It belongs to = " & GetStudentInfo(ret, StateCode) & ".
Score = " & score & ".")
'myUtil.PrintBiometricDisplay(True, GRConstants.GR_DEFAULT_CONTEXT)
Dim disp As String = "Please Confirm if you are '" & GetStudentInfo(ret, StateCode) & "'. To confirm
press the ENTER key, otherwise press ESC key and replace your finger"
Code = GetStudentCode(ret)
Me.lblDisp.Text = StateCode
Return True
Else
MyMessageAgent.Show("Fingerprint not Found")
myUtil.WriteLog("Fingerprint not Found")
Return False
End If
ElseIf ret = 0 Then
MyMessageAgent.Show("Fingerprint not Found")
myUtil.WriteLog("Fingerprint not Found")
Return False
Else
myUtil.WriteError(ret)
Return False
End If
End Function

38
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles
Timer1.Tick
Me.CadFingerprint1.ClearPrint()

Me.empPix.Image = Nothing
Me.lblDisp.Text = ""
Me.LogList.Items.Clear()
myUtil.WriteLog("Waiting for new finger.")

Me.Timer1.Enabled = False
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer2.Tick
Me.Timer2.Enabled = False
End Sub

Private Sub OptionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)
End Sub

Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)


'Dim Code As String = Me.TextBox1.Text
End Sub
Dim OrigPixRatio As Decimal = CDec(100 / 125)

Private Sub frmAutoAttendance_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Me.Resize
Me.CadFingerprint1.Width = CInt(OrigPixRatio * Me.CadFingerprint1.Height)
Me.empPix.Width = CInt(OrigPixRatio * Me.empPix.Height)
End Sub

Private Sub BarButtonItem1_ItemClick(sender As Object, e As XtraBars.ItemClickEventArgs) Handles


BarButtonItem1.ItemClick
Using Frm As New frmSetCaptureQuality(Me.CadFingerprint1,
frmSetCaptureQuality.UseModeEnum.Verify, Dbb)
Frm.ShowDialog(Me)
End Using
End Sub
End Class

FrmEnroo db
Imports System.Linq
Imports Microsoft.VisualBasic
Public Class frmEnroll
Dim myUtil As CADUtil
Dim ReadyToEnroll As Boolean = False
Dim Pix As PictureBox
Private Sub txtCode_KeyPress(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
LoadOwner()
End If
End Sub
Dim MainDs As New MainData
Public Function DbToPictureFormat(ByVal TheDbPic As Byte()) As Image
39
Dim arrPicture() As Byte = CType(TheDbPic, Byte())
Using ms As New IO.MemoryStream(arrPicture)
DbToPictureFormat = Image.FromStream(ms)
ms.Close()
End Using
End Function

Function GetEnrollStatus(OwnerID As Integer) As String


Dim fps() As MainData.StudentListRow = CType(CacheDSInv.StudentList.Select("FingerPrint is not null
and Studentid=" & OwnerID), CovenantBioReg.MainData.StudentListRow())
If fps.Length = 0 Or (fps.Length > 0 AndAlso fps(0).IsFingerPrintNull = False AndAlso Not
fps(0).FingerPrint Is Nothing) Then
Return "Not Enrolled"
Else
Return "Enrolled" ' " & String.Join(",", fps.AsEnumerable().Select(Function(d)
d.FingerPrint("FPFinger").ToString).ToArray) & " Fingers"
End If
End Function
Sub LoadOwner()
If Me.ComboBoxEdit1.EditValueStr = "" Then
MessageBox.Show("Please specify the finger to enroll")
Exit Sub
End If

Dim Msgg As String = ""


Me.Pix.Image = Nothing
Me.empPix.Image = Nothing
Me.lblStatus.Text = ""
If CInt(Me.txtCode.EditValue) > 0 Then

lblStatus.Text = GetEnrollStatus(Me.txtCode.EditValue)
If MainDs.StudentList.Select("Studentid=" & Me.txtCode.EditValue).Length > 0 Then
Dim dr As MainData.StudentListRow =
MainDs.StudentList.FindByStudentID(Me.txtCode.EditValue)
ReadyToEnroll = True
Me.txtName.Text = dr.Surname & ": " & dr.Firstname
'Msgg = "Please place your finger, \pau=900\" & Me.txtName.Text & ".\pau=900\"
Msgg = "Please place your finger, " & FormatName(dr.Firstname) & "."
'Dim s As String = IO.Path.Combine(My.MySettings.Default.EmployeePixFolder, Me.txtCode.Text &
".jpg")
'If IO.File.Exists(s) = True Then
' Me.empPix.Image = Image.FromFile(s)
'Else
' Me.empPix.Image = Nothing
'End If
If dr.IsPictureNull = False AndAlso Not dr.Picture Is Nothing Then
LoadingImage = True
Try
' Me.empPix.Image = TBExplorer2.CADImageLib.GetImageFromByte(dr.Picture)
Catch ex As Exception
End Try
LoadingImage = False
Else
Me.empPix.Image = Nothing
End If
lblStatus.Text = GetEnrollStatus(Me.txtCode.EditValue)
If dr.IsFPImageNull = False AndAlso Not dr.FPImage Is Nothing Then
' CadFingerprint1.PictureBox1.Image =
TBExplorer2.CADImageLib.GetImageFromByte(dr.FPImage)
40
End If
If dr.EnrolledFinger <> "" Then
ComboBoxEdit1.EditValue = dr.EnrolledFinger
End If
Else
Me.lblStatus.Text = ""

MessageBox.Show("Student '" & Me.txtCode.Text & "' can not be found")


ReadyToEnroll = False
End If
Else
MessageBox.Show("Please input Student code")
ReadyToEnroll = False
End If
If Msgg <> "" Then
Speak(Msgg)
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
LoadOwner()
End Sub

Private Sub frmEnroll_FormClosing(ByVal sender As Object, ByVal e As


System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'myUtil.FinalizeGrFinger()

End Sub
Dim lastsun As DateTime
Dim FormLoaded As Boolean = False

Dim Dbb As New CADDBClass

Private Sub frmEnroll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


MyBase.Load
'TODO: This line of code loads data into the 'Maindata.Customers' table. You can move, or remove it, as
needed.

Try
CadFingerprint1.SpeakThankyouMessageWhenone = True
Me.lblStatus.Text = ""
Try
Me.Maindata.EnforceConstraints = False
Me.Maindata1.EnforceConstraints = False
If CacheDSInv.StudentList.Count = 0 Then
Using Ad As New MainDataTableAdapters.StudentListTableAdapter
Ad.Fill(CacheDSInv.StudentList)
End Using
End If
MainDs.StudentList.Merge(CacheDSInv.StudentList)
Using Ad As New MainDataTableAdapters.UsersTableAdapter
Ad.Fill(MainDs.Users)
End Using

Me.Maindata.Merge(MainDs.StudentList)
Me.Maindata1.Merge(MainDs.StudentList)

Me.Maindata.Merge(MainDs.Users)
Me.Maindata1.Merge(MainDs.Users)

41
Catch ex As Exception
MessageBox.Show(ex.Message, ex.Source)
End Try
Dim err As Integer

myUtil = New CADUtil(LogList, CadFingerprint1, My.MySettings.Default.MainConnectionString)

err = myUtil.InitializeGrFinger(Dbb)
If err < 0 Then
myUtil.WriteError(err)
Exit Sub
Else
myUtil.WriteLog("**Initialized Successfull**")
End If

Speak("Start Enrollment of biometric finger prints")

FormLoaded = True
Me.Pix = CadFingerprint1.PictureBox1 ' Me.PictureBox1

Catch ex As Exception

End Try
CadFingerprint1.SecurityLevel = CType(Dbb.MatchingSecurityLevelEnroll, SGFPMSecurityLevelEnum)

End Sub
Dim NormShift As Integer = 0
Private Sub CadFingerprint1_SensorPlug(ByVal sender As System.Object, ByVal e As SensorPlugEvent)
Handles CadFingerprint1.SensorPlug
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Plugged.")
'AxGrFingerXCtrl1.CapStartCapture(e.idSensor)

End Sub

' A fingerprint reader was unplugged from system


Private Sub CadFingerprint1_SensorUnplug(ByVal sender As System.Object, ByVal e As
SensorUnplugEvent) Handles CadFingerprint1.SensorUnplug
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Unplugged.")
CadFingerprint1.CapStopCapture(e.idSensor)
End Sub

' A finger was placed on reader


Private Sub CadFingerprint1_FingerDown(ByVal sender As System.Object, ByVal e As FingerDownEvent)
Handles CadFingerprint1.FingerDown
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger Placed.")
End Sub

' A finger was removed from reader


Private Sub CadFingerprint1_FingerUp(ByVal sender As System.Object, ByVal e As FingerUpEvent)
Handles CadFingerprint1.FingerUp
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Finger removed.")
End Sub
Private Sub CadFingerprint1_ImageAcquired(ByVal sender As System.Object, ByVal e As
ImageAcquiredEvent) Handles CadFingerprint1.ImageAcquired
' Copying aquired image
myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Starting Image captured.")
myUtil.raw.height = e.height
myUtil.raw.width = e.width
42
myUtil.raw.res = e.res
myUtil.raw.img = e.rawImage

' Signaling that an Image Event occurred.


myUtil.WriteLog("Sensor: " & e.idSensor & ". Event: Image captured.")

' display fingerprint image


'myUtil.PrintBiometricDisplay(False, GRConstants.GR_DEFAULT_CONTEXT)

' extracting template from image


If ReadyToEnroll = True Then
If Extract() = True Then
If Identify() = True Then
Me.Timer1.Enabled = True
End If
End If
Else
MessageBox.Show("Please provide an appropriate Employee Code")
End If

' identify fingerprint


End Sub
' Dim PixQryList As New MaindataTableAdapters.QueriesTableAdapter
Function GetPicByte() As Byte()
If Not Me.empPix.Image Is Nothing Then
Dim img As Image = CType(Me.empPix.Image.Clone, Image)
Dim bitmp As New Bitmap(img)
Dim bt() As Byte
Try
Using ms As New IO.MemoryStream
bitmp.Save(ms, Imaging.ImageFormat.Jpeg)

bt = ms.GetBuffer
ms.Close()
End Using
'Dim jgpEncoder As Imaging.ImageCodecInfo = GetEncoder(Imaging.ImageFormat.Jpeg)

Catch ex As Exception
bt = Nothing
End Try
Return bt
'Return TBExplorer2.cPicture.ToByteArray '(Me.empPix.Image)
Else
Return Nothing
End If
End Function
Public Event Enrolled(FPImage As Image, FPImageBytes() As Byte, EnrolledFinger As String)
Public Event ImageChanged(Image As Image, ImageBytes() As Byte)

Sub Enroll()
Dim id As Integer
If Me.txtCode.EditValue > 0 Then
' add fingerprint
id = myUtil.Enroll(Me.txtCode.EditValue, CType([Enum].Parse(GetType(FingerNameEnum),
ComboBoxEdit1.EditValueStr), FingerNameEnum))
' write result to log
If id >= 0 Then

myUtil.WriteLog("Fingerprint enrolled with id = " & id)


ReadyToEnroll = False
43
Me.txtCode.EditValue = Nothing
Me.txtName.Text = ""
Me.empPix.Image = Nothing
If Not myUtil.raw.img Is Nothing Then
RaiseEvent Enrolled(CType(myUtil.raw.img, Image),
TBExplorer2.CADImageLib.GetByteFromImage(CType(myUtil.raw.img, Image), Imaging.ImageFormat.Jpeg),
ComboBoxEdit1.EditValueStr)
Else

End If
Beep()
Else
myUtil.WriteLog("Error: Fingerprint not enrolled")
End If

End If
End Sub

Function Extract() As Boolean


Dim ret As Integer
' extract template
ret = myUtil.ExtractTemplate()
'' write template quality to log
'If ret = GRConstants.GR_BAD_QUALITY Then
' myUtil.WriteLog("Template extracted successfully. Bad quality.")
'ElseIf ret = GRConstants.GR_MEDIUM_QUALITY Then
' myUtil.WriteLog("Template extracted successfully. Medium quality.")
'ElseIf ret = GRConstants.GR_HIGH_QUALITY Then
' myUtil.WriteLog("Template extracted successfully. High quality.")
'End If
If ret > 0 Then
If ret = 1 Then
If MessageBox.Show("You have a medium quality print, do you want to repeat the capture?", "Print
not good enough", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Return False
End If
End If
'myUtil.PrintBiometricDisplay(True, GRConstants.GR_NO_CONTEXT)
Return True
Else
' write error to log
myUtil.WriteError(ret)
Return False
End If
End Function
Function GetOwnerInfo(ByVal ID As Integer) As String
Using Ad As New MainDataTableAdapters.StudentListTableAdapter
Ad.ClearBeforeFill = False
If Me.MainDs.StudentList.FindByStudentID(ID) Is Nothing Then
Ad.FillByStudentID(Me.MainDs.StudentList, ID)
End If

If Not Me.MainDs.StudentList.FindByStudentID(ID) Is Nothing Then


Dim Dr As MainData.StudentListRow = Me.MainDs.StudentList.FindByStudentID(ID)
Dim DrCr As MainData.StudentListRow = MainDs.StudentList.FindByStudentID(Dr.StudentID)
If DrCr IsNot Nothing Then
Return DrCr.Surname & ": " & DrCr.Firstname
Else
Return ""
44
End If
Else
Return ""
End If
End Using
End Function

Function GetOwnerCode(ByVal ID As Integer) As Integer


Using Ad As New MainDataTableAdapters.StudentListTableAdapter
Ad.ClearBeforeFill = False
If Me.MainDs.StudentList.FindByStudentID(ID) Is Nothing Then
Ad.FillByStudentID(Me.MainDs.StudentList, ID)
End If
If Not Me.MainDs.StudentList.FindByStudentID(ID) Is Nothing Then
Dim Dr As MainData.StudentListRow = Me.MainDs.StudentList.FindByStudentID(ID)
Return Dr.StudentID
Else
Return 0
End If
End Using
End Function
Function Identify() As Boolean
Dim ret As Integer, score As Integer

score = 0
' identify it
Dim ArrList As New Generic.List(Of TTemplates)
ret = myUtil.Identify(score, ArrList, SGFPMSecurityLevelEnum.NORMAL, False)
' write result to log
If ret > 0 Then
If GetOwnerInfo(ret) <> "" Then
If GetOwnerCode(ret) <> Me.txtCode.EditValue Then
myUtil.WriteLog("Fingerprint identified. It belongs to = " & GetOwnerInfo(ret) & ". Score = " &
score & ".")
'myUtil.PrintBiometricDisplay(True, GRConstants.GR_DEFAULT_CONTEXT)
MessageBox.Show("Fingerprint identified. It belongs to = " & GetOwnerInfo(ret) & ". Score = " &
score & ".")
Return False
Else
myUtil.WriteLog("Fingerprint identified. It belongs to = " & GetOwnerInfo(ret) & ". Score = " &
score & ".")
' myUtil.PrintBiometricDisplay(True, GRConstants.GR_DEFAULT_CONTEXT)
If MessageBox.Show("Fingerprint identified. It belongs to = " & GetOwnerInfo(ret) & ". Score = "
& score & ". Do you want to replace with his new enrollment?", "Current Enrollee want to replace his print",
MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Return True
Else
Return False
End If
End If
Else
myUtil.WriteLog("Fingerprint not Found.")
Return True
End If
ElseIf ret = 0 Then
myUtil.WriteLog("Fingerprint not Found.")
Return True
Else
myUtil.WriteError(ret)
Return False
45
End If
End Function

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer1.Tick
Enroll()
Me.Timer1.Enabled = False
Me.Timer2.Enabled = True
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles


Timer2.Tick
Me.CadFingerprint1.ClearPrint()
Me.LogList.Items.Clear()
Me.lblStatus.Text = ""

myUtil.WriteLog("Saved successfully, Waiting for new finger.")


Me.Timer2.Enabled = False
End Sub
'Dim OptionsForm1 As New OptionsForm

Private Sub OptionToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs)

'Dim pinfo As SGFPMDeviceInfoParam = CadFingerprint1.GetConfig

End Sub

Dim OrigPixRatio As Decimal = CDec(100 / 125)

Private Sub frmEnroll_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize


Me.CadFingerprint1.Width = CInt(OrigPixRatio * Me.CadFingerprint1.Height)
' Me.empPix.Width = OrigPixRatio * Me.empPix.Height

'Me.empPix.Width = (Panel2.Width - 30) / 2


Me.CadFingerprint1.Width = Me.empPix.Width
End Sub

Private Sub C1Combo1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

End Sub

Private Sub txtStateCode_KeyPress(ByVal sender As System.Object, ByVal e As


System.Windows.Forms.KeyPressEventArgs)
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
LoadOwnerByState()
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


LoadOwnerByState()
End Sub

Sub LoadOwnerByState()
'If txtStateCode.Text <> "" AndAlso TBExplorer2.RunScalar("select count(*) from employees where
idcardno='" & txtStateCode.Text & "'", My.MySettings.Default.MainPayConnectionString) > 0 Then

46
' Me.txtCode.Text = TBExplorer2.RunScalar("select employeeid from employees where idcardno='" &
txtStateCode.Text & "'", My.MySettings.Default.MainPayConnectionString)
' LoadOwner()
'Else
' MessageBox.Show("Please select an employee using the central state code")
'End If
End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs)

End Sub

Private Sub Panel2_Paint(sender As Object, e As PaintEventArgs)

End Sub

Private Sub wkFingReload_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)


Handles wkFingReload.DoWork

End Sub

Public Sub New()

' This call is required by the designer.


InitializeComponent()

' Add any initialization after the InitializeComponent() call.

Me.ComboBoxEdit1.Properties.Items.AddRange([Enum].GetNames(GetType(FingerNameEnum)))
Me.ComboBoxEdit1.EditValue = FingerNameEnum.LeftThumb.ToString

End Sub

Private Sub BarButtonItem1_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs)


Handles BarButtonItem1.ItemClick
Using Frm As New frmSetCaptureQuality(Me.CadFingerprint1,
frmSetCaptureQuality.UseModeEnum.Enroll, Dbb)
Frm.ShowDialog(Me)
End Using
End Sub

Private Sub SimpleButton1_Click(sender As Object, e As EventArgs) Handles SimpleButton1.Click


LoadOwner()
End Sub

Private Sub SearchLookUpEdit1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


txtCode.KeyPress
If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
LoadOwner()
End If
End Sub

Private Sub SimpleButton2_Click(sender As Object, e As EventArgs) Handles SimpleButton2.Click


Me.Hide()
End Sub
Public LoadingImage As Boolean = False
Private Sub PictureEdit1_ImageChanged(sender As Object, e As EventArgs) Handles empPix.ImageChanged
47
If LoadingImage = True Then Exit Sub
If empPix.Image Is Nothing Then Exit Sub

If CInt(RunScalar("select count(*) from StudentList where studentid=" & Me.txtCode.EditValue, ConStr))


> 0 Then
Using Ad As New MainDataTableAdapters.QueriesTableAdapter
Ad.UpdateQuery(TBExplorer2.CADImageLib.GetByteFromImage(Me.empPix.Image,
Imaging.ImageFormat.Jpeg), Me.txtCode.EditValue)
End Using

End If
If Not MainDs.StudentList.FindByStudentID(Me.txtCode.EditValue) Is Nothing Then
MainDs.StudentList.FindByStudentID(Me.txtCode.EditValue).Picture =
TBExplorer2.CADImageLib.GetByteFromImage(Me.empPix.Image, Imaging.ImageFormat.Jpeg)
MainDs.StudentList.FindByStudentID(Me.txtCode.EditValue).AcceptChanges()
End If
If Not CacheDSInv.StudentList.FindByStudentID(Me.txtCode.EditValue) Is Nothing Then
CacheDSInv.StudentList.FindByStudentID(Me.txtCode.EditValue).Picture =
TBExplorer2.CADImageLib.GetByteFromImage(Me.empPix.Image, Imaging.ImageFormat.Jpeg)
CacheDSInv.StudentList.FindByStudentID(Me.txtCode.EditValue).AcceptChanges()
End If
If Not Me.empPix.Image Is Nothing Then
RaiseEvent ImageChanged(Me.empPix.Image,
TBExplorer2.CADImageLib.GetByteFromImage(Me.empPix.Image, Imaging.ImageFormat.Jpeg))
End If

End Sub

Private Sub txtCode_CustomDisplayText(sender As Object, e As


DevExpress.XtraEditors.Controls.CustomDisplayTextEventArgs) Handles txtCode.CustomDisplayText
If Not e.Value Is Nothing AndAlso e.Value.ToString <> "" AndAlso ISNullInt(e.Value) > 0 AndAlso Not
Me.Maindata1.StudentList.FindByStudentID(CInt(e.Value)) Is Nothing Then
Dim dr As MainData.StudentListRow = Me.Maindata1.StudentList.FindByStudentID(CInt(e.Value))
e.DisplayText = dr.Surname & " " & dr.Firstname
End If
End Sub

Private Function SecuGen() As Object


Throw New NotImplementedException
End Function

End Class

Module1

Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars
Imports DevExpress.XtraNavBar
Imports System.ComponentModel

Public Module Module1

Enum PCRoleEnum
Server
Client
End Enum
Function GetPCRole() As PCRoleEnum

48
Dim s As String = CStr(IsNullIsNothing(ConfigurationManager.Item(ConStr, "ComputerRole",
"ConnectionSetting"), "Client"))
Return CType([Enum].Parse(GetType(PCRoleEnum), s), PCRoleEnum)

End Function

Public RibbonList As Generic.Dictionary(Of String, RibbonContainer)


Public MainMDIForm As MDIParent1
Class RibbonContainer
Enum RibbonComponentType
Page
Item
ToolStrip
End Enum
Public RibbonObjectType As RibbonComponentType
Public RibbonObject As Object
Public RoleData As MainData.UserRolesRow, IniVisibley As Boolean, AppVisible As Boolean = False,
SecurityVisible As Boolean = False
Public NavBarGroup As NavBarGroup, ObjectName As String = ""
Public AvailableRoles As String = ""
Sub New(_RibbonObject As ToolStripMenuItem, _RoleData As MainData.UserRolesRow)
RibbonObjectType = RibbonComponentType.ToolStrip
RibbonObject = _RibbonObject
RoleData = _RoleData
AvailableRoles = RoleData.AvailableRoles
IniVisibley = CType(RibbonObject, ToolStripMenuItem).Visible
ObjectName = CType(RibbonObject, ToolStripMenuItem).Name
End Sub

Sub New(_RibbonObject As RibbonPage, _RoleData As MainData.UserRolesRow)


RibbonObjectType = RibbonComponentType.Page
RibbonObject = _RibbonObject
RoleData = _RoleData
AvailableRoles = RoleData.AvailableRoles

IniVisibley = CType(RibbonObject, RibbonPage).Visible

ObjectName = CType(RibbonObject, RibbonPage).Name

End Sub

Sub New(_RibbonObject As BarItem, _RoleData As MainData.UserRolesRow)


RibbonObjectType = RibbonComponentType.Item
RibbonObject = _RibbonObject
RoleData = _RoleData
AvailableRoles = RoleData.AvailableRoles

IniVisibley = CBool((Function(v As BarItemVisibility) IIf(v = BarItemVisibility.Always, True, False))


(CType(RibbonObject, BarItem).Visibility))
ObjectName = _RibbonObject.Name

End Sub

Function GetImage() As Image


Select Case RibbonObjectType
Case RibbonComponentType.ToolStrip
Return CType(RibbonObject, ToolStripMenuItem).Image
Case RibbonComponentType.Page
49
Return CType(RibbonObject, RibbonPage).Image
Case RibbonComponentType.Item
If CType(RibbonObject, BarItem).IsLargeImageExist = True Then
Return CType(RibbonObject, BarItem).LargeGlyph
Else
Return CType(RibbonObject, BarItem).Glyph
End If
End Select
End Function

Function GetCaption() As String


Select Case RibbonObjectType
Case RibbonComponentType.ToolStrip
Return CType(RibbonObject, ToolStripMenuItem).Text
Case RibbonComponentType.Page
Return CType(RibbonObject, RibbonPage).Text
Case RibbonComponentType.Item
Return CType(RibbonObject, BarItem).Caption
End Select
End Function
Function GetToolStrip() As String
Select Case RibbonObjectType
Case RibbonComponentType.ToolStrip
Return CType(RibbonObject, ToolStripMenuItem).ToolTipText
Case RibbonComponentType.Page
Return CType(RibbonObject, RibbonPage).KeyTip
Case RibbonComponentType.Item
If Not CType(RibbonObject, BarItem).SuperTip Is Nothing AndAlso CType(CType(RibbonObject,
BarItem).SuperTip, DevExpress.Utils.SuperToolTip).Items.Count > 0 Then
Return CType(CType(CType(RibbonObject, BarItem).SuperTip,
DevExpress.Utils.SuperToolTip).Items(0), DevExpress.Utils.ToolTipItem).Text
Else
Return ""
End If
End Select
End Function
Sub SetSecurityVisibility(Visible As Boolean)
If AvailableRoles = "ApplicationMenu" Or MemuIsAlwaysVisible(ObjectName) = True Then
SecurityVisible = True
Exit Sub
End If
If IniVisibley = True AndAlso AppVisible = True Then
SecurityVisible = Visible
Select Case RibbonObjectType
Case RibbonComponentType.ToolStrip
CType(RibbonObject, ToolStripMenuItem).Visible = Visible
Case RibbonComponentType.Page
CType(RibbonObject, RibbonPage).Visible = Visible
Case RibbonComponentType.Item
CType(RibbonObject, BarItem).Visibility = CType((Function(v As Boolean) IIf(v = True,
BarItemVisibility.Always, BarItemVisibility.Never))(Visible), BarItemVisibility)
End Select
End If
End Sub

End Class
Dim AlwaysVisibles As String = ""
'"RibbonPage1,BarMdiChildrenListItem1,BarButtonItem14,AboutToolStripMenuItem,SkinRibbonGalleryBarIt
em1,MenuItem56,MenuItem150,MenuItem131,MenuItem181,ToolStripMenuItem16,MenuItem3"
Public ExitLoader As Boolean = False
50
Dim MnList As New ArrayList
Function MemuIsAlwaysVisible(MnName As String) As Boolean
If MnList.Count = 0 Then
MnList.AddRange(AlwaysVisibles.Split(CChar(",")))
End If
Return MnList.Contains(MnName)
End Function

Public Wh As New TBExplorer2.cWhereField


Enum AppVersion
Standard = 1
End Enum
Public Enum AppModeEnum
STANDARD
End Enum
Public AppModeVersionNumber As Integer = 0, AppVersionLimitationNumber As Integer = 0
Function GetAppVersion() As AppVersion
Return CType([Enum].Parse(GetType(AppVersion), CStr(AppModeVersionNumber)), AppVersion)
End Function
Public AppMode As AppModeEnum
Public ForcedClose As Boolean = False
Public UserRolesListFile As String = IO.Path.Combine(My.Application.Info.DirectoryPath,
"Tools\userrolelist.xml")

<System.Diagnostics.DebuggerStepThrough()> Public Function ConStr() As String


Return My.MySettings.Default.MainConnectionString
End Function
<System.Diagnostics.DebuggerStepThrough()> Public Function DeNull(ByVal TheValue As Object, Optional
ByVal DatType As Type = Nothing) As Object
If IsDBNull(TheValue) = False Then
Return TheValue
Else
If DatType Is Nothing Then
Return Nothing
Else
Return Wh.Formated(DatType, TheValue)
End If
End If
End Function

<System.Diagnostics.DebuggerStepThrough()> Public Function DeNullToInt(ByVal TheValue As Object) As


Integer
If IsDBNull(TheValue) = False Then
Return CInt(TheValue)
Else
Return 0
End If
End Function

<System.Diagnostics.DebuggerStepThrough()> Public Function DeNullToDec(ByVal TheValue As Object)


As Decimal
If IsDBNull(TheValue) = False Then
Return CDec(TheValue)
Else
Return 0
End If
End Function

51
<System.Diagnostics.DebuggerStepThrough()> Public Function DeNullToString(ByVal TheValue As Object)
As String
If IsDBNull(TheValue) = False Then
Return CStr(TheValue)
Else
Return CStr(0)
End If
End Function

<System.Diagnostics.DebuggerStepThrough()> Public Function ISNull(ByVal TheValue As Object, ByVal


ReplacementValue As Object) As Object
If IsDBNull(TheValue) = False Then
Return TheValue
Else
Return ReplacementValue
End If
End Function
<System.Diagnostics.DebuggerStepThrough()> Public Function ISNullStr(ByVal TheValue As Object,
Optional ByVal ReplacementValue As String = "") As String
If IsDBNull(TheValue) = False Then
Return CStr(TheValue)
Else
Return ReplacementValue
End If
End Function
<System.Diagnostics.DebuggerStepThrough()> Public Function ISNullInt(ByVal TheValue As Object,
Optional ByVal ReplacementValue As Integer = 0) As Integer
If IsDBNull(TheValue) = False Then
Return CInt(TheValue)
Else
Return ReplacementValue
End If
End Function

<System.Diagnostics.DebuggerStepThrough()> Public Function ISNullDate(ByVal TheValue As Object,


Optional ByVal ReplacementValue As DateTime = #12:00:00 AM#) As DateTime
If IsDBNull(TheValue) = False Then
Return CDate(TheValue)
Else
Return ReplacementValue
End If
End Function

<System.Diagnostics.DebuggerStepThrough()> Public Function ISNullBool(ByVal TheValue As Object,


Optional ByVal ReplacementValue As Boolean = False) As Boolean
If IsDBNull(TheValue) = False Then
Return CBool(TheValue)
Else
Return ReplacementValue
End If
End Function
<System.Diagnostics.DebuggerStepThrough()> Public Function ISNullDbl(ByVal TheValue As Object,
Optional ByVal ReplacementValue As Double = 0) As Double
If IsDBNull(TheValue) = False Then
Return CDbl(TheValue)
Else
Return ReplacementValue
End If
End Function

52
<System.Diagnostics.DebuggerStepThrough()> Public Function ISNullDec(ByVal TheValue As Object,
Optional ByVal ReplacementValue As Decimal = 0) As Decimal
If IsDBNull(TheValue) = False Then
Return CDec(TheValue)
Else
Return ReplacementValue
End If
End Function

#Region "Navigation"
Sub ApplyNavigator(Nav As NavBarControl)
Nav.BeginUpdate()
Nav.Groups.Clear()
' MainMDIForm.ImageList1.Images.Add("MrDefault", My.Resources.t_web1)
For Each pg As RibbonPage In MainMDIForm.Ribbon.Pages
For Each RBPG As RibbonPageGroup In pg.Groups
If RBPG.Visible = True AndAlso RBPG.Text <> "Exit" AndAlso RBPG.Text <> "Skins" Then
Dim count As Integer = 0
Dim f As Boolean = PageHasDrop(RBPG, count)
Dim navgroup As MyNavBarGroup = CType(Nav.Groups.Add(New MyNavBarGroup(RBPG.Text,
count, Nav)), MyNavBarGroup)
'If f = True Then
' navgroup.GroupStyle = NavBarGroupStyle.ControlContainer
'Else
' 'navgroup.GroupStyle = NavBarGroupStyle.SmallIconsList
'End If
FixNavGroup(navgroup, RBPG, count)
End If
Next
Next
Nav.EndUpdate()

End Sub
Sub FixNavGroup(nvg As MyNavBarGroup, RBPG As RibbonPageGroup, Count As Integer)
Dim AddCount As Integer = 0

If RBPG.Visible = True Then


If AddCount > 0 Then
Dim sep As New NavBarSeparatorItem
nvg.ItemLinks.Add(sep)
End If
For Each barit As BarItemLink In RBPG.ItemLinks
If Not TypeOf barit Is DevExpress.XtraBars.SkinRibbonGalleryBarItemLink AndAlso
barit.Item.Visibility = BarItemVisibility.Always Then
nvg.AddLink(barit.Item, Nothing)
AddCount += 1
End If
Next
End If
If Not nvg.TreeView Is Nothing Then nvg.TreeView.ExpandAll()
End Sub

Function PageHasDrop(RBPG As RibbonPageGroup, ByRef Count As Integer) As Boolean


Dim ret As Boolean = False

For Each barit As BarItemLink In RBPG.ItemLinks

53
If Not TypeOf barit Is DevExpress.XtraBars.SkinRibbonGalleryBarItemLink AndAlso
barit.Item.Visibility = BarItemVisibility.Always Then
If TypeOf barit.Item Is BarSubItem Then
ret = True
End If
Count += 1
End If
Next
Return ret
End Function

'Sub FixNavGroup(nvg As NavBarGroup, Ds As OtherData, RbObj As RibbonContainer)


' For Each RBPG As RibbonPageGroup In CType(RbObj.RibbonObject, RibbonPage).Groups
' If RBPG.Visible = True Then

' End If
' Next
'End Sub

Class MyNavBarGroup
Inherits NavBarGroup
Public MyNavMenus As New Generic.Dictionary(Of NavBarItem, BarItem)
Public MyNodeMenus As New Generic.Dictionary(Of TreeNode, BarItem)
Public WithEvents TreeView As TreeView, Nav As NavBarControl
Sub AddLink(mn As BarItem, ParentNode As TreeNode)

Dim img As Image = Nothing


If Not mn.LargeGlyph Is Nothing Then
img = mn.LargeGlyph
ElseIf Not mn.Glyph Is Nothing Then
img = mn.Glyph
End If

Dim nvmn As New NavBarItem(mn.Caption)


If Me.GroupStyle = NavBarGroupStyle.LargeIconsList Or GroupStyle =
NavBarGroupStyle.LargeIconsText Then
If Not img Is Nothing Then
nvmn.LargeImage = img
'Else
' nvmn.LargeImage = My.Resources.t_web1
End If
Else
If Not img Is Nothing Then
nvmn.SmallImage = img
'Else
' nvmn.SmallImage = My.Resources.t_web1
End If
End If
MyNavMenus.Add(nvmn, mn)
Me.ItemLinks.Add(nvmn)

End Sub
Dim Count As Integer
Public Sub New(Caption As String, Count As Integer, Nav As NavBarControl)
MyBase.New(Caption)
Me.Count = Count
Me.Nav = Nav
Me.Expanded = True
'If Count <= 5 Then
54
' Me.GroupStyle = NavBarGroupStyle.LargeIconsText
'ElseIf Count = 6 Or Count = 8 Or Count = 10 Then
' Me.GroupStyle = NavBarGroupStyle.LargeIconsList
'End If
End Sub

Private Sub TreeView_DoubleClick(sender As Object, e As EventArgs) Handles TreeView.DoubleClick


Dim nd As TreeNode = Me.TreeView.SelectedNode
If Not nd Is Nothing Then
If Me.MyNodeMenus.ContainsKey(nd) = True Then
Me.MyNodeMenus(nd).PerformClick()
End If
End If
End Sub

Private Sub Nav_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles Nav.LinkClicked


If MyNavMenus.ContainsKey(e.Link.Item) = True Then
MyNavMenus(e.Link.Item).PerformClick()
End If
End Sub
End Class
#End Region
Function FormatName(Dr As MainData.StudentListRow) As String
If Dr.IsFirstNameNull = False AndAlso Dr.FirstName.Trim <> "" AndAlso Dr.FirstName.Trim.Length > 1
AndAlso Dr.FirstName.Trim.Contains(".") = False Then
Return FormatName(Dr.FirstName.Trim)
ElseIf Dr.IsSurnameNull = False AndAlso Dr.Surname.Trim <> "" Then
Return FormatName(Dr.Surname.Trim)
End If
End Function

Function FormatName(Name As String) As String

If Name.Trim <> "" Then


Dim ret As String = ""
For Each Str As String In Name.Trim.Split(CChar(" "))
Dim f As String = ""
If Str.Trim.Length > 1 Then
f = Str.Trim.Substring(0, 1) & Str.Trim.Substring(1, Str.Trim.Length - 1).ToLower
Else
f = Str.Trim
End If
If ret <> "" Then
ret &= " "
End If
ret &= f
Next
Return ret
Else
Return Name
End If

End Function
Sub Speak(msg As String)
Dim bkSpeak As New BackgroundWorker
AddHandler bkSpeak.DoWork, AddressOf bkSpeak_DoWork
AddHandler bkSpeak.RunWorkerCompleted, AddressOf bkSpeak_RunWorkerCompleted
bkSpeak.RunWorkerAsync(msg)
End Sub

55
Private Sub bkSpeak_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs)
'Handles bkSpeak.DoWork
Try
Dim SAPI As Object
SAPI = CreateObject("SAPI.spvoice")
CallByName(SAPI, "Speak", CallType.Method, New Object() {e.Argument}) ' SAPI.speak(e.Argument)
Catch ex As Exception

End Try

End Sub

Private Sub bkSpeak_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs)


'Handles bkSpeak.RunWorkerCompleted
RemoveHandler CType(sender, BackgroundWorker).DoWork, AddressOf bkSpeak_DoWork
RemoveHandler CType(sender, BackgroundWorker).RunWorkerCompleted, AddressOf
bkSpeak_RunWorkerCompleted
End Sub
Public CacheDSInv As New MainData

#Region "Biometrics"

'Public Property MatchingTechnology As MatchingTechnologyEnum


' Get
' Return MySetting.MatchingTechnology
' End Get
' Set(value As MatchingTechnologyEnum)
' MySetting.MatchingTechnology = value
' End Set
'End Property

'Public Property MatchingSecurityLevelEnroll As Integer


' Get
' Return MySetting.MatchingSecurityLevelEnroll
' End Get
' Set(value As Integer)
' MySetting.MatchingSecurityLevelEnroll = value
' End Set
'End Property
'Public Property MatchingSecurityLevelVerify As Integer
' Get
' Return MySetting.MatchingSecurityLevelVerify
' End Get
' Set(value As Integer)
' MySetting.MatchingSecurityLevelVerify = value
' End Set
'End Property
#End Region

End Module

56

You might also like