Design and Implementation of An Intruder Detector in Homes With Audio and Sms Alert Using GSM Module
Design and Implementation of An Intruder Detector in Homes With Audio and Sms Alert Using GSM Module
A PROJECT SUBMITTED
TO THE
FACULTY OF SCIENCE
IN COMPUTER SCIENCE
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
……………………..
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
DEDICATION
Dedicated to all Computer Science Student at National Open University of Nigeria for making my
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
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
May I also register my sincere gratitude to the entire Faculty of Science and Technology for making
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
CHAPTER TWO........................................................................................................................7
LITERATURE REVIEW...........................................................................................................7
CHAPTER THREE..................................................................................................................10
RESEARCH METHODOLOGY.............................................................................................10
viii
3.6 TECHNICAL DETAILS AND SOLUTION SOLUTIONS OF THE EXISTING
PROBLEM...........................................................................................................................13
CHAPTER FOUR....................................................................................................................22
SYSTEM IMPLEMENTATION..............................................................................................22
..............................................................................................................................................22
4.7 TESTING..................................................................................................................25
CHAPTER FIVE......................................................................................................................28
LIMITATION.......................................................................................................................29
REFERENCES.........................................................................................................................30
ix
CHAPTER ONE
INTRODUCTION
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
.
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
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 delay in the generation and announcement of the results which gives room for
other manipulations.
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
The main objectives of this project work is to design a fully web voter’s registration system
Put to an end the indiscriminate alteration of election results by any officer of the
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
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
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.
BALLOT: - This refers to the system of voting in a country balloting could be open secret
or open secret.
DEMOCRACY: - This is government of the people by the people and for the people. This
leaders
election from the level of government election to the presidential election in the country.
4
INEC: - Independent National Electoral commission.
JUDICIARY: - The organ of government responsible for the interpretation of laws and
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
POLITICAL CLERK:- A person who assists the presiding officer and deputizes in an event of
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.
PRESIDING OFFICER: - He or she is the actual officer who conducts the election in the
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.
polling center. Their duty is to assist in election duties and ensure orderliness in the station.
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
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
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
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
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
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.
Recent years, a considerable number of countries has adopted E-voting for their official
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
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’
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
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
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
9
CHAPTER THREE
RESEARCH METHODOLOGY
In this chapter, the evaluation of the existing system and the organization structure of the
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.
Analyzing data:- there are several tools for the analyzing of data which includes
In system design, new or alternative information is designed. This phase consist of three
tasks.
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
ii. Will the system be flexible enough to be modified ad needed in the feature?
v. Writing the system design report:- this is to document and it communicate the
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.
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
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
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
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
Too much paper work: The process involves too much paper work and paper storage which
PROBLEM
a) A sable solution to these problems is the use of computerized system (online voting
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
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.
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
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
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
Mat No “Cannot
NO
Registered?
Process Registration
Database
Generate Voters ID
Stop
Figure 3.2: Voter’s Registration Flowchart
17
Voting Process Flowchart
Start
Enter Voters
ID
And PIN
Is Login
Correct
has Twice”
Voted
No
Before
Allow to
Vote
Stop
18
Candidates Registration Form
Start
Enter Names
Process
Registration
Stop
19
View Results Process
Start
Enter Username
and Password
Is Login No
Correct?
Yes
Display Results
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
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
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
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.
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
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
21
3.10 OUTPUT SPECIFICATION
In this system, all outputs are retrieved from disk storage where information resulting from
In designing a system, one should bear in mind to minimize complexity and platform.
22
CHAPTER FOUR
SYSTEM IMPLEMENTATION
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
This package can only be run and developed with the following minimum software
requirements;-
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
needed to sustain power failure for sometimes whenever PHCH puts of power supply.
512MB RAM
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
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
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
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
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.
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
* 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:
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.
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
During testing of the E-Billing and Invoice System, the following qualities will be tested
in order of priority:
expected
27
Customization—how straightforward it is to use the application in new,
unpredicted ways
Scripted tests—sequences of user interactions (based on the use case and usage
Unscripted tests—based on scripted tests, the tester tries to modify the scenarios to
28
CHAPTER FIVE
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,
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
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,
But because of the limitation of incomplete laws and regulations, absentee voting can’t be
necessary. It can speed up the electoral procedures, make ballot counting efficaciously, and
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
30
REFERENCES
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.
Cranor, L.F., & Cytron, R.K. (1996). Design and Implementation of a Security-Conscious
http://www.acm.org/crossroads/ords2-4/voting.html
Electronic Voting and Counting – Development of the System. (2005). Elections ACT.
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
CADDBCLASS.VB
Imports System.Linq
Imports System.Runtime.InteropServices
Return dr.StudentID
End Using
End Function
ttpts = Lstttpts.ToArray
TemplatesLoaded = True
Return ttpts
End Using
Else
Return ttpts
End If
End Function
#Region "Biometrics"
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
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
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
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
End If
End If
Me.Timer1.Enabled = True
End If
Else
Me.empPix.Image = Nothing
MyMessageAgent.Show("Please replace your finger")
End If
End Sub
End Using
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
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
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 = ""
End Sub
Dim lastsun As DateTime
Dim FormLoaded As Boolean = False
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
err = myUtil.InitializeGrFinger(Dbb)
If err < 0 Then
myUtil.WriteError(err)
Exit Sub
Else
myUtil.WriteLog("**Initialized Successfull**")
End If
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
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
End If
Beep()
Else
myUtil.WriteLog("Error: Fingerprint not enrolled")
End If
End If
End Sub
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
End Sub
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
End Sub
End Sub
End Sub
Me.ComboBoxEdit1.Properties.Items.AddRange([Enum].GetNames(GetType(FingerNameEnum)))
Me.ComboBoxEdit1.EditValue = FingerNameEnum.LeftThumb.ToString
End Sub
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
End Class
Module1
Imports DevExpress.XtraBars.Ribbon
Imports DevExpress.XtraBars
Imports DevExpress.XtraNavBar
Imports System.ComponentModel
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
End Sub
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
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
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
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
' 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)
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
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
#Region "Biometrics"
End Module
56