You are on page 1of 105

Apartment Management

INTRODUCTION

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 1


Apartment Management

CHAPTER-1
INTRODUCTION

1.1 Objectives.

 Main objective of this project is to design a software application for a


construction companies.
 It manages different apartments and there maintenance on monthly basis.
 This software covers modules like handling request for apartment owners
maintaining monthly expenses for every apartment, billing details,
hardware used etc…

1.2 Existing System

 Every year the company is designing new apartments and it’s a difficult
to manage the records of each and every apartment in the manual system.

 It will not only take a lot of time but also it increases the chances of errors.

 Its create problem when you need details of any particular project all
these problems lead to the rise of an alternate option.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 2


Apartment Management

1.3 Proposed System


The proposed system is designed to eliminate the disadvantages of the existing
system. The proposed system is mentioned for tracing the problems in the existing
system.
 Easier access and to use
 Provide accurate information to the user for taking necessary decisions.
 Accuracy - The information will be correct, accurate and unambiguous.
 Efficiency - Information can be collected, processed and communicated
more quickly and efficiently. Systems ensure that right information reaches
the right person at the right time
 Reliability - Since systems are free from boredom and tiredness, they work
constantly on data to produce more reliable outputs.
 Accessibility, Usability and Understand ability.
 The options used can be easily accessed, used and realized.

1.4 Brief Introduction Of The Project

The project is developed best on the windows application, the capable of


registering residents, employees and vehicles and also enabling to get information
about apartment maintenance. In order to track the vehicles and visitors some
objectives were defined. It is with great experience that I present this final review
of the system is successfully been developed using a number of tools earlier
discussed Computer and software like My SQL. Meanwhile, the careful
application of these tools and have led to development of a system that meets the
defined objectives.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 3


Apartment Management

SOFTWARE COMPONENTS

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 4


Apartment Management

CHAPTER-2
SOFTWARE COMPONENTS

2.1Introduction to Microsoft Visual Basic 2010 Edition

Visual Basic 2010 Express Edition is a no-cost, streamlined, easy-to-use


development tool for hobbyists, students, and novices. The Express Edition
makes Windows programming with Visual Basic fun and easy to learn. It's also
the perfect way for experienced Visual Basic developers to try out new features.

Features:
 Easily design great-looking and easy-to-use applications using an intuitive,
drag-and-drop interface designer.
 Built-in support for Windows XP Themes lets you easily create
applications with a Windows XP look and feel.
 Over 30 new controls simplify development.
 In-place menu editor enables quick and easy creation of main menus and
right-click context menus.
 My namespace provides intuitive access to common functions working
with files, accessing the registry, and utilizing applications settings and
resources.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 5


Apartment Management

 Code colorization, syntax checking, and IntelliSense provide an intuitive


development experience.
 AutoCorrect can suggest and apply fixes for more than 230 common
programming error.
 Don't write that code yourself! Visual Basic Express can write it for you
with over 400 built-in IntelliSense code snippets that provide templates for
common coding tasks.
 Drag and drop data from your database onto your Windows application to
easily create fully-functional data-driven applications.
 Create data-enabled applications using SQL Server 2005 Express.
 Visually design queries and databases using the built-in database design
tools.

2.2 Introduction to SQL Server 2008


Microsoft SQL Server 2008 Express Edition (SQL Server Express) is a
powerful and reliable data management product that delivers rich features, data
protection, and performance for embedded application clients, light Web
applications, and local data stores. Designed for easy deployment and rapid
prototyping, SQL Server Express is available at no cost, and you are free to
redistribute it with applications. SQL Server Express is designed to integrate
seamlessly with your other server infrastructure investments.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 6


Apartment Management

Supported Operating System


 Windows 2000 Service Pack 4, Windows Server 2003 Service Pack 1,
Windows XP Service Pack 2
 Computer with Intel or compatible Pentium III 600 MHz or faster
processor (1 GHz or faster is recommended.)
 Minimum of 192 MB of RAM (512 MB or more is recommended.) and
525 MB of available hard disk space.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 7


Apartment Management

REQUIREMENT AND SPECIFICATIONS

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 8


Apartment Management

CHAPTER 3
REQIREMENTS AND SPECIFICATIONS

3.1 Requirement Specification

The Software requirement specification provides a complete


description of all the function and specification of the “APPARTMENT
MANAGEMENT”. The expected audience of this document is to provide the
Security and Details of the Apartment Management to the residents and
employees.

3.1.1 Scope

The “APARTMENT MANAGEMENT ” Main objective of this project


is to design a software application for a construction companies. It manages
different apartments and there maintenance on monthly basis. This software
covers modules like handling request for apartment owners, maintaining
monthly expenses for every apartment, billing details, hardware used etc…

3.2 Software Requirements

Front End Tool : Microsoft Visual Basic 2010 Basic Edition(VB.Net).


Programmer Tool : Microsoft Visual Basic 2010 Basic Edition(VB.Net).
Back End Tool : Microsoft SQL Server 2008
Operating System : Windows 8 or Windows 10.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 9


Apartment Management

3.3 Hardware Requirements

Processor : Intel Core Duo 2.0 GHz or more.

RAM : 1 GB or more.

Hard Disk : 80 GB or more.

Monitor : 1024*765 pixel colour monitor.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 10


Apartment Management

SYSTEM DESIGN

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 11


Apartment Management

CHAPTER-4
SYSTEM DESIGN

A Blue Print for the development and analysis of the “APARTMENT


MANAGEMENT”.

4.1 System Design

System design provides the understandings and procedural details


necessary for implementing the system recommended in the system study.
Emphasis is on translating the performance requirements into design
specifications. The design phase is a transition from a user-oriented document
(System proposal) to a document oriented to the programmers or database
personnel.

System design goes through two phases of development:


 Logical Design
 Physical Design
A data flow diagram shows the logical flow of the system. For a system it
describes the input (source), output (destination), database (data stores) and
procedures (data flows) all in a format that meet’s the user’s requirement. When
analysis prepares the logical design, they specify the user needs at the level of
detail that virtually determines the information flow into an out of the system

and the required data resources. The logical design also specifies input forms and
screen layouts.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 12


Apartment Management

The activities following logical design are the procedure followed in the physical
design e.g., producing programs, software, file and a working system. Design
specifications instruct the user about what system should do.

Five Objectives of design input focus on:


 Controlling the amount of input required.
 Avoid delay.
 Avoiding errors in data.
 Avoiding extra Steps.
 Keeping the process simple.

4.2 Modules of the Project

“APARTMENT MANAGENT” has in all 2 modules and shall be


implemented in phases. The number of phases and the modules will be
implemented as follows.

 Admin Module: Allows the Administrator to access the


Application without any limitations.

 Employee Module: Allows employees to have a look over the


application, to take care of the customers.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 13


Apartment Management

4.3 Design of Data Flow Diagram

Level 0:

Admin or Employee Input Output


System
Database

Level 1:

Admin or Employee

Not Valid Login

Valid

Main Screen

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 14


Apartment Management

ERDIAGRAM

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 15


Apartment Management

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 16


Apartment Management

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 17


Apartment Management

APARTMENT MANAGEMENT

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 18


Apartment Management

4.4 Table Design

4.4.1 Admin Login:

4.4.2 Employee login:

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 19


Apartment Management

4.6 Technology / Tools Selection:

The system should be developed using an application and should be


developed as such that deployment of the system is easy and effortless. Also the
technology used should be as such that interactions for the customers are very
easy and user friendly.

We had plenty of options to select the technology and tools. The selection
criteria we set are as detailed below:
 The technology and upgrading the system very easy and less costly.
 The technology selected should be platform independent.
 The language should be easy and robust; making is simpler to learn
for the new members.
 The application must be browser independent.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 20


Apartment Management

TESTING

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 21


Apartment Management

CHAPTER-5
TESTING

5.1 TESTING
The development of software systems involves a series of production
activities where opportunities for injections of human fallibilities are enormous.
Errors may begin to occur at very inception of the process where the objectives,
may be erroneously or imperfectly specified, as well as in later design and
development stages. Because of human inability to perform and communicate in
perfection, software development is accompanied by quality assurance activity.

Software testing is a critical element of software quality assurance and


represents the Ultimate review of specification, design and coding. In general,
testing starts with test plan. The test plan identifies all testing related activities
that need to be performed along with the scheduled and guidelines for testing.
The plan also specifies the levels of testing that need to be done, by identifying
the different testing units. Based on the plan, the testing commences. For each
unit specified in the plan, first the test cases and reports are produced. Testing
presents an Interesting anomaly for a software engineer.

5.2 Testing is basically classified into

 Black Box Testing


 White Box Testing

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 22


Apartment Management

Black Box Testing


Black box testing focuses in the functional requirements of the software. It
enables software engineer to derive sets of inputs conditions that will fully
exercise all functional requirements for a program.

Black Box testing attempts to find errors in the following categories:

 Incorrect or missing function


 Interface errors
 Errors in data structures or external database access
 Performance errors
 Initialisation and termination error

Generally Black Box testing is applied for high level testing such as system
testing, acceptance testing.

White Box Testing


White box testing, sometimes called glass box testing is a test case design
method which uses the control structure of the procedural design to derive test
cases.

White Box Testing is applied to:

 Exercise all logical decision on their true and false sides


 Exercise all loops at their boundaries and within their operational bounds
 Exercise internal data structures to assure their validity.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 23


Apartment Management

5.3 Testing Strategies

 Unit Testing
 Integration Testing
 Acceptance Testing

Unit Testing:

Unit testing focuses on the verification effort on the smallest unit of


software design module. Using the detailed design description as a guide,
important control parts are tested to uncover errors within the boundary of the
modules. The relative complexity of tests and the errors detected as a result is
limited by constraint scope established for unit testing. The unit test is always
white box oriented, and the step can be conducted in parallel for multiple
modules.

Integrated Testing:

With unit testing the modules may function properly, but at time they may
have inadvertent, adverse effect on another; sub function, when combined, may
not produce the desired major function; Individually acceptable impression may
be magnified to unacceptable level; global data structures may present problems.
Integration testing is symmetric technique for constructing the program
structure while at the same time conducting tests to uncover errors associated

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 24


Apartment Management

with interfacing. The objective is to take unit tested modules and builds a program
structure that has been dictated by the design.

Acceptance Testing:

System under consideration is tested for acceptance by constantly keeping


in touch with the prospective system. Series of acceptance test are conducted to
enable the user to validate all requirements. Acceptance testing involves planning
and execution of
 Functional Test
 Performance Test
 Stress Test

Functional test is the exercising of the code with nominal input values for which
the expected values for which the expected values for which the expected values
are known.

Performance test determines the amount of execution time spent in various parts
of the unit, program throughput and response time. This test is productive at the
subsystem and system level.
Stress test is designed to intentionally break the unit and the strength and the
limitation of the program are examined.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 25


Apartment Management

CHAPTER 6
I/O SCREENS

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 26


Apartment Management

6.1 FLASH SCREEN

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 27


Apartment Management

6.2 LOGIN SCREEN

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 28


Apartment Management

6.3 ADMIN LOGIN

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 29


Apartment Management

6.4 MDI PARENT1

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 30


Apartment Management

6.5 EMPLOYEE LOGIN

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 31


Apartment Management

6.6 RESIDENT REGISTRATION

6.7 REGISTER NEW RESIDENT

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 32


Apartment Management

6.8 EMPLOYEE REGISTRATION

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 33


Apartment Management

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 34


Apartment Management

6.9 DUE ENTRY

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 35


Apartment Management

6.10RESIDENT REPORTS

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 36


Apartment Management

6.11 EMPLOYEE REPORT

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 37


Apartment Management

6.12 VEHICLE REPORT

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 38


Apartment Management

6.13 VIEW VISITORS

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 39


Apartment Management

6.14 MDI PARENT 2

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 40


Apartment Management

6.15 VEHCILE REGISTRATION

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 41


Apartment Management

6.16 VISITOR TRACKING

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 42


Apartment Management

6.17 DUE DISPLAY

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 43


Apartment Management

6.18 TRACK VEHICLES

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 44


Apartment Management

VALIDATION

CHAPTER-7

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 45


Apartment Management

Validation

7.1 Flash Screen:

Public Class Flash


Dim i As Integer
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
i=i+1
If i > 5 Then
Timer1.Enabled = False
Me.Hide()

loginform1.show()

End If
End Sub

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


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

7.2 Login Screen

Imports System.Data.SqlClient
Public Class LoginForm1

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


System.EventArgs) Handles OK.Click

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 46


Apartment Management

If conn.State = ConnectionState.Open Then conn.Close()


conn.Open()
Dim Cmd0 As New SqlCommand("select * from login where username='"
& (UsernameTextBox.Text) & "' and password='" & PasswordTextBox.Text &
"'", conn)
Dim D1 As SqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then
MDIParent1.Show()
Me.Hide()
If conn.State = ConnectionState.Open Then conn.Close()
Else
MsgBox("Username or Password is not correct please check")
End If

End Sub

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


System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub

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


System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Maximized
End Sub
End Class

7.3 Main Screen:

Imports System.Windows.Forms

PublicClassMDIParent1

PrivateSubShowNewForm(ByVal sender AsObject, ByVal e


AsEventArgs)
' Create a new instance of the child form.

Dim ChildForm AsNew System.Windows.Forms.Form

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 47


Apartment Management

' Make it a child of this MDI form before showing it.


ChildForm.MdiParent = Me

m_ChildFormNumber += 1
ChildForm.Text = "Window "& m_ChildFormNumber

ChildForm.Show()
EndSub

PrivateSubOpenFile(ByVal sender AsObject, ByVal e


AsEventArgs)
Dim OpenFileDialog AsNewOpenFileDialog
OpenFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
OpenFileDialog.Filter = "Text Files
(*.txt)|*.txt|All Files (*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName AsString = OpenFileDialog.FileName
' TODO: Add code here to open the file.
EndIf
EndSub

PrivateSub SaveAsToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Dim SaveFileDialog AsNewSaveFileDialog
SaveFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files
(*.txt)|*.txt|All Files (*.*)|*.*"

If (SaveFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName AsString = SaveFileDialog.FileName
' TODO: Add code here to save the current contents of the
form to a file.
EndIf
EndSub

PrivateSub ExitToolsStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 48


Apartment Management

Me.Close()
EndSub

PrivateSub CutToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Use My.Computer.Clipboard to insert the selected text or
images into the clipboard
EndSub

PrivateSub CopyToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Use My.Computer.Clipboard to insert the selected text or
images into the clipboard
EndSub

PrivateSub PasteToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
'Use My.Computer.Clipboard.GetText() or
My.Computer.Clipboard.GetData to retrieve information from
the clipboard.
EndSub

PrivateSub ToolBarToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Me.ToolStrip.Visible =
Me.ToolBarToolStripMenuItem.Checked
EndSub

PrivateSub StatusBarToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Me.StatusStrip.Visible =
Me.StatusBarToolStripMenuItem.Checked
EndSub

PrivateSub CascadeToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Me.LayoutMdi(MdiLayout.Cascade)
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 49


Apartment Management

PrivateSub TileVerticalToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Me.LayoutMdi(MdiLayout.TileVertical)
EndSub

PrivateSub TileHorizontalToolStripMenuItem_Click(ByVal
sender AsObject, ByVal e AsEventArgs)
Me.LayoutMdi(MdiLayout.TileHorizontal)
EndSub
PrivateSub ArrangeIconsToolStripMenuItem_Click(ByVal sender
AsObject, ByVal e AsEventArgs)
Me.LayoutMdi(MdiLayout.ArrangeIcons)
EndSub

PrivateSub CloseAllToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Close all child forms of the parent.
ForEach ChildForm AsFormInMe.MdiChildren
ChildForm.Close()
Next
EndSub

Privatem_ChildFormNumberAsInteger

PrivateSub
ResidentRegistrationToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ResidentRegistrationToolStripMenuItem.Click
ResidentRegistration.MdiParent = Me
ResidentRegistration.Show()
EndSub

PrivateSub
EmployeeRegistrationToolStripMenuItem_Click(ByVal sender
AsSystem.Object, ByVal e As System.EventArgs) Handles
EmployeeRegistrationToolStripMenuItem.Click
EmpRegistration.MdiParent = Me
EmpRegistration.Show()
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 50


Apartment Management

PrivateSub ResidentReportToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles ResidentReportToolStripMenuItem.Click
ResidentReport.MdiParent = Me
ResidentReport.Show()
EndSub

PrivateSub EmployeeReportToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles EmployeeReportToolStripMenuItem.Click

EmployeeReport.MdiParent = Me
EmployeeReport.Show()
EndSub

PrivateSub VehicleReportToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles VehicleReportToolStripMenuItem.Click
VehicleReport.MdiParent = Me
VehicleReport.Show()
EndSub

PrivateSub ViewVisitorsToolStripMenuItem_Click(ByVal sender


As System.Object, ByVal e As System.EventArgs) Handles
ViewVisitorsToolStripMenuItem.Click
ViewVisitors.MdiParent = Me
ViewVisitors.Show()
EndSub

PrivateSub DueEntryToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
DueEntryToolStripMenuItem.Click
DueEntry.MdiParent = Me
DueEntry.Show()
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 51


Apartment Management

PrivateSub LogoutToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
LogoutToolStripMenuItem.Click

Logins.Show()
Me.Hide()

EndSub

PrivateSub MDIParent1_Load(ByVal sender As System.Object,


ByVal e As System.EventArgs) HandlesMyBase.Load

EndSub

PrivateSub PictureBox1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs)

EndSubEndClass

7.4 ADMIN LOGIN

PublicClassLogins

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
LoginForm1.Show()
EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click

EmpLogin.Show()
EndSub

EndClass

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 52


Apartment Management

EMPLOYEE LOGIN

PublicClassLogins

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
LoginForm1.Show()
EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
EmpLogin.Show()
EndSub
EndClass

7.5 MAIN FORM2

Imports System.Windows.Forms
PublicClassMDIParent2

PrivateSubShowNewForm(ByVal sender AsObject, ByVal e


AsEventArgs)
' Create a new instance of the child form.
Dim ChildForm AsNew System.Windows.Forms.Form
' Make it a child of this MDI form before showing it.
ChildForm.MdiParent = Me

m_ChildFormNumber += 1
ChildForm.Text = "Window "& m_ChildFormNumber

ChildForm.Show()
EndSub

PrivateSubOpenFile(ByVal sender AsObject, ByVal e


AsEventArgs)

Dim OpenFileDialog AsNewOpenFileDialog

OpenFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 53


Apartment Management

OpenFileDialog.Filter = "Text Files (*.txt)|*.txt|All


Files (*.*)|*.*"

If (OpenFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then

Dim FileName AsString = OpenFileDialog.FileName


' TODO: Add code here to open the file.
EndIf
EndSub

PrivateSub SaveAsToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Dim SaveFileDialog AsNewSaveFileDialog
SaveFileDialog.InitialDirectory =
My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files
(*.txt)|*.txt|All Files (*.*)|*.*"

If (SaveFileDialog.ShowDialog(Me) =
System.Windows.Forms.DialogResult.OK) Then
Dim FileName AsString = SaveFileDialog.FileName
' TODO: Add code here to save the current contents of the
form to a file.
EndIf
EndSub

PrivateSub ExitToolsStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Me.Close()
EndSub

PrivateSub CutToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)

' Use My.Computer.Clipboard to insert the selected text or


images into the clipboard

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 54


Apartment Management

EndSub

PrivateSub CopyToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Use My.Computer.Clipboard to insert the selected text or
images into the clipboard
EndSub

PrivateSub PasteToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)

'Use My.Computer.Clipboard.GetText() or
My.Computer.Clipboard.GetData to retrieve information from
the clipboard.
EndSub

PrivateSub ToolBarToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Me.ToolStrip.Visible =
Me.ToolBarToolStripMenuItem.Checked
EndSub

PrivateSub StatusBarToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
' Me.StatusStrip.Visible =
Me.StatusBarToolStripMenuItem.Checked

EndSub

PrivateSub CascadeToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Me.LayoutMdi(MdiLayout.Cascade)
EndSub

PrivateSub TileVerticalToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 55


Apartment Management

Me.LayoutMdi(MdiLayout.TileVertical)
EndSub

PrivateSub TileHorizontalToolStripMenuItem_Click(ByVal

sender AsObject, ByVal e AsEventArgs)


Me.LayoutMdi(MdiLayout.TileHorizontal)
EndSub

PrivateSub ArrangeIconsToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)
Me.LayoutMdi(MdiLayout.ArrangeIcons)
EndSub

PrivateSub CloseAllToolStripMenuItem_Click(ByVal sender


AsObject, ByVal e AsEventArgs)

' Close all child forms of the parent.


ForEach ChildForm AsFormInMe.MdiChildren
ChildForm.Close()
Next
EndSub

Privatem_ChildFormNumberAsInteger

PrivateSub
VehicleRegistrationToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
VehicleRegistrationToolStripMenuItem.Click
' VehicleRegistration.MdiParent2 = Me
VehicleRegistration.Show()
EndSub

PrivateSub TrackVehiclesToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles TrackVehiclesToolStripMenuItem.Click

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 56


Apartment Management

' TrackVehicles.MdiParent2 = Me
TrackVehicles.Show()

EndSub

PrivateSub VisitorTrackingToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs)
Handles VisitorTrackingToolStripMenuItem.Click
' VisitorTracking.MdiParent2 = Me

VisitorTracking.Show()
EndSub

PrivateSub DueEntryToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
DueEntryToolStripMenuItem.Click
' DueEntry.MdiParent2 = Me
DueEntry.Show()
EndSub

PrivateSub LogoutToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
LogoutToolStripMenuItem.Click

Logins.Show()
Me.Hide()
EndSub
RESIDENT REGISTRATION

Imports System.Data.SqlClient
Imports System.Text.RegularExpressions

PublicClassResidentRegistration1
Dim pkvar AsString
PrivateSub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click

If vbNo = MsgBox("Are you sure you want modify this record",


MsgBoxStyle.YesNo, "Delete") ThenExit Sub
If Conn.State = ConnectionState.Open ThenConn.Close()

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 57


Apartment Management

Conn.Open()

Dim cmd1 AsNewSqlCommand("Delete from ResidentReg where


Apartment_number='"& ComboBox1.Text &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()
SaveRecord()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""

ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox5.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""

TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
EndSub

SubSaveRecord()
If TextBox1.Text = ""Then
MsgBox("Please enter the necessary details")
Exit Sub
EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim Cmd0 AsNewSqlCommand("select Apartment_number from
ResidentReg where Apartment_number='"& ComboBox1.Text &"'",
Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then
MsgBox("This record is allready present in the database")

If Conn.State = ConnectionState.Open ThenConn.Close()


Exit Sub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 58


Apartment Management

EndIf
a = ComboBox1.Text
If Conn.State = ConnectionState.Open ThenConn.Close()

Conn.Open()
q1Var = "insert into ResidentReg("
q2Var = " values("
q1Var = q1Var &"Apartment_number"&","
q2Var = q2Var &"'"& a &"',"
q1Var = q1Var &"Name"&","
q2Var = q2Var &"'"& TextBox1.Text &"',"
q1Var = q1Var &"Age"&","

q2Var = q2Var &"'"& TextBox2.Text &"',"

q1Var = q1Var &"Parking_slot"&","


q2Var = q2Var &"'"& ComboBox3.Text &"',"
q1Var = q1Var &"Floor"&","
q2Var = q2Var &"'"& ComboBox4.Text &"',"
q1Var = q1Var &"Phone_number"&","
q2Var = q2Var &"'"& TextBox3.Text &"',"
q1Var = q1Var &"Occupation"&","
q2Var = q2Var &"'"& TextBox4.Text &"',"
q1Var = q1Var &"email"&","
q2Var = q2Var &"'"& TextBox5.Text &"',"
q1Var = q1Var &"Residents"&")"
q2Var = q2Var &"'"& ComboBox5.Text &"')"

'MsgBox(q1Var & q2Var)


Dim cmd1 AsNewSqlCommand(q1Var & q2Var, Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 59


Apartment Management

ComboBox3.Text = ""
ComboBox4.Text = ""

ComboBox5.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""

EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
If vbNo = MsgBox("Are you sure you want delete this record",
MsgBoxStyle.YesNo, "Delete") ThenExit Sub

If Conn.State = ConnectionState.Open ThenConn.Close()

Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from ResidentReg where
Apartment_number='"& ComboBox1.Text &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""

ComboBox3.Text = ""
ComboBox4.Text = ""
ComboBox5.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = "EndSub

PrivateSub ComboBox1_Leave(ByVal sender AsObject, ByVal e


As System.EventArgs) Handles ComboBox1.Leave

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 60


Apartment Management

TextBox1.Text = ""

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
Dim Cmd0 AsNewSqlCommand("select * from ResidentReg where
Apartment_number='"& ComboBox1.Text &"'", Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.Read Then
TextBox1.Text = D1(2)
TextBox2.Text = D1(3)
ComboBox3.Text = D1(4)
ComboBox4.Text = D1(5)
TextBox3.Text = D1(6)
TextBox4.Text = D1(7)
TextBox5.Text = D1(8)
ComboBox5.Text = D1(9)
EndIf

EndSub

PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged

EndSub

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
ResidentRegistration.Show()
EndSub

PrivateSub TextBox5_LostFocus(ByVal sender AsObject, ByVal


e As System.EventArgs) Handles TextBox5.LostFocus

Dim Expression
AsNewSystem.Text.RegularExpressions.Regex("\S+@\S+\.\S+")

IfExpression.IsMatch(TextBox5.Text) Then
MsgBox("The email address is valid.")
Else

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 61


Apartment Management

MsgBox("The email address is NOT valid.",


MsgBoxStyle.Critical, "Invalid Mail ID")

EndIf
EndSub

PrivateSub ResidentRegistration1_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load

EndSub

PrivateSub TextBox1_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
IfNotRegex.Match(TextBox1.Text, "^[a-z. ]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")

TextBox1.Text = ""
TextBox1.Focus()
EndIf
EndSub

PrivateSub TextBox1_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged

EndSub

PrivateSub TextBox4_KeyPress(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TextBox4.KeyPress
IfNotRegex.Match(TextBox4.Text, "^[a-z. ]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")
TextBox4.Text = ""
TextBox4.Focus()

EndIf
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 62


Apartment Management

PrivateSub TextBox2_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox2.KeyPress
IfNotRegex.Match(TextBox2.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox2.Text = ""
TextBox2.Focus()
EndIf
EndSub

PrivateSub TextBox2_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox2.TextChanged

EndSub

PrivateSub TextBox3_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox3.KeyPress

IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox3.Text = ""
TextBox3.Focus()
EndIf
EndSub

PrivateSub TextBox3_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox3.TextChanged

EndSub

PrivateSub Panel1_Paint(ByVal sender As System.Object,


ByVal e As System.Windows.Forms.PaintEventArgs) Handles
Panel1.Paint

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 63


Apartment Management

EndSub

PrivateSub Label9_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Label9.Click

EndSub
EndClass

7.6 EMPLOYEE LOGIN

Imports System.Data.SqlClient

PublicClassEmpLogin

' TODO: Insert code to perform custom authentication using


the provided username and password
' (See http://go.microsoft.com/fwlink/?LinkId=35339).
' The custom principal can then be attached to the current
thread's principal as follows:
' My.User.CurrentPrincipal = CustomPrincipal

' where CustomPrincipal is the IPrincipal implementation


used to perform authentication.
' Subsequently, My.User will return identity information
encapsulated in the CustomPrincipal object
' such as the username, display name, etc.

PrivateSub OK_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles OK.Click
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()

Dim Cmd0 AsNewSqlCommand("select * from Emplog where


username='"& UCase(UsernameTextBox.Text) &"' and
password='"& PasswordTextBox.Text &"'", Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 64


Apartment Management

If D1.HasRows Then
MDIParent2.Show()
Me.Hide()
If Conn.State = ConnectionState.Open ThenConn.Close()

Else
MsgBox("Username or Password is not correct please check")
EndIf
EndSub

PrivateSub Cancel_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
EndSub

PrivateSub EmpLogin_Load(ByVal sender As System.Object,


ByVal e As System.EventArgs) HandlesMyBase.Load

EndSub
EndClass

7.7 VECHICLE REGISTRATION

Imports System.Data.SqlClient
Imports System.Text.RegularExpressions

PublicClassVehicleRegistration1
Dim pkVar AsString

SubSaveRecord()
If TextBox1.Text = ""Then
MsgBox("Please enter the necessary details")
Exit Sub
EndIf

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
Dim Cmd0 AsNewSqlCommand("select empid from Employeetab
where empid='"& TextBox1.Text &"'", Conn)

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 65


Apartment Management

Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()


If D1.HasRows Then
MsgBox("This record is allready present in the database")
If Conn.State = ConnectionState.Open ThenConn.Close()
Exit Sub
EndIf

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
q1Var = "insert into Vehicletab("
q2Var = " values("
q1Var = q1Var &"cardno"&","
q2Var = q2Var &"'"& TextBox1.Text &"',"
q1Var = q1Var &"wheel"&","
q2Var = q2Var &"'"& ComboBox1.Text &"',"
q1Var = q1Var &"make"&","
q2Var = q2Var &"'"& TextBox2.Text &"',"
q1Var = q1Var &"registrationno"&","
q2Var = q2Var &"'"& TextBox3.Text &"',"
q1Var = q1Var &"model"&","

q2Var = q2Var &"'"& TextBox4.Text &"',"


q1Var = q1Var &"apartment_number"&","
q2Var = q2Var &"'"& ComboBox2.Text &"',"
q1Var = q1Var &"floor"&")"
q2Var = q2Var &"'"& ComboBox3.Text &"')"

'MsgBox(q1Var & q2Var)


Dim cmd1 AsNewSqlCommand(q1Var & q2Var, Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

disRecords()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 66


Apartment Management

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""

EndSub

SubdisRecords()
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim DS1 AsNewDataSet
Dim adp AsNewSqlDataAdapter("Select * From Vehicletab order
by cardno", Conn)
adp.Fill(DS1)
DataGridView1.DataSource = DS1.Tables(0)
If Conn.State = ConnectionState.Open ThenConn.Close()

EndSub
PrivateSub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
If vbNo = MsgBox("Are you sure you want modify this record",
MsgBoxStyle.YesNo, "Modify") ThenExit Sub
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from Vehicletab where
cardno='"& pkVar &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

SaveRecord()
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""

MsgBox("Record Saved Successfully")


EndSub

PrivateSub DataGridView1_CellContentClick(ByVal sender As


System.Object, ByVal e As

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 67


Apartment Management

System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
pkVar = DataGridView1.CurrentRow.Cells(0).Value
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim Cmd0 AsNewSqlCommand("select * from Vehicletab where
Cardno='"& pkVar &"'", Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then
D1.Read()
TextBox1.Text = D1(0).ToString
ComboBox1.Text = D1(1).ToString
TextBox2.Text = D1(2).ToString

TextBox3.Text = D1(3).ToString
TextBox4.Text = D1(4).ToString
ComboBox2.Text = D1(5).ToString
ComboBox3.Text = D1(6).ToString

Else
ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""

TextBox3.Text = ""
TextBox4.Text = ""

EndIf

If Conn.State = ConnectionState.Open ThenConn.Close()

EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 68


Apartment Management

PrivateSub VehicleRegistration1_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load

disRecords()
EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
If vbNo = MsgBox("Are you sure you want modify this record",
MsgBoxStyle.YesNo, "Modify") ThenExit Sub
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from Vehicletab where
cardno='"& pkVar &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()
disRecords()

ComboBox1.Text = ""
ComboBox2.Text = ""
ComboBox3.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""

MsgBox("Record Deleted Successfully")


EndSub

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
VehicleRegistration.Show()

EndSub

PrivateSub Label3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Label3.Click

EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 69


Apartment Management

PrivateSub TextBox1_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox3.Text = ""
TextBox3.Focus()
EndIf
EndSub

PrivateSub TextBox1_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged

EndSub
EndClass

7.8 EMPLOYEE REGISTRATION

Imports System.Data.SqlClient
Imports System.Text.RegularExpressions

PublicClassEmpRegistration
Dim pkvar AsString
Dim q1Var, q2Var AsString

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
SaveRecord()

EndSub

SubSaveRecord()
If TextBox1.Text = ""Then
MsgBox("Please enter the necessary details")
Exit Sub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 70


Apartment Management

EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()

Conn.Open()
Dim Cmd0 AsNewSqlCommand("select empid from Employeetab
where empid='"& TextBox1.Text &"'", Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then
MsgBox("This record is allready present in the database")
If Conn.State = ConnectionState.Open ThenConn.Close()
Exit Sub
EndIf

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
q1Var = "insert into Employeetab("
q2Var = " values("
q1Var = q1Var &"empid"&","
q2Var = q2Var &"'"& TextBox1.Text &"',"
q1Var = q1Var &"name"&","
q2Var = q2Var &"'"& TextBox2.Text &"',"
q1Var = q1Var &"age"&","

q2Var = q2Var &"'"& TextBox3.Text &"',"


q1Var = q1Var &"designation"&","
q2Var = q2Var &"'"& ComboBox1.Text &"',"
q1Var = q1Var &"date"&","
q2Var = q2Var &"'"&Format(DateTime.Today.Date,
"dd/MMM/yyyy") &"',"
q1Var = q1Var &"address"&","
q2Var = q2Var &"'"& RichTextBox1.Text &"',"
q1Var = q1Var &"phoneno"&","
q2Var = q2Var &"'"& TextBox7.Text &"',"

q1Var = q1Var &"salary"&")"


q2Var = q2Var &"'"& TextBox8.Text &"')"

'MsgBox(q1Var & q2Var)

Dim cmd1 AsNewSqlCommand(q1Var & q2Var, Conn)


cmd1.ExecuteNonQuery()

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 71


Apartment Management

If Conn.State = ConnectionState.Open ThenConn.Close()

disRecords()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
RichTextBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""

EndSub

SubdisRecords()
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim DS1 AsNewDataSet
Dim adp AsNewSqlDataAdapter("Select
empid,name,age,designation,date,address,phoneno,salary
From Employeetab order by empid", Conn)
adp.Fill(DS1)

DataGridView1.DataSource = DS1.Tables(0)
If Conn.State = ConnectionState.Open ThenConn.Close()

EndSub

PrivateSub EmpRegistration_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
Me.WindowState = FormWindowState.Maximized
disRecords()

EndSub

PrivateSub DataGridView1_CellContentClick(ByVal sender As


System.Object, ByVal e As

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 72


Apartment Management

System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick

pkvar = DataGridView1.CurrentRow.Cells(0).Value
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim Cmd0 AsNewSqlCommand("select * from Employeetab where
empid='"& pkvar &"'", Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then
D1.Read()
TextBox1.Text = D1(0).ToString
TextBox2.Text = D1(1).ToString
TextBox3.Text = D1(2).ToString
ComboBox1.Text = D1(3).ToString
RichTextBox1.Text = D1(5).ToString
TextBox7.Text = D1(6).ToString
TextBox8.Text = D1(7).ToString

Else
ComboBox1.Text = ""
RichTextBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""

TextBox7.Text = ""
TextBox8.Text = ""

EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()

EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 73


Apartment Management

If vbNo = MsgBox("Are you sure you want modify this record",


MsgBoxStyle.YesNo, "Delete") ThenExit Sub
If Conn.State = ConnectionState.Open ThenConn.Close()

Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from Employeetab where
empid='"& pkvar &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()
SaveRecord()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
RichTextBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
EndSub

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
If vbNo = MsgBox("Are you sure you want delete this record",
MsgBoxStyle.YesNo, "Delete") ThenExit Sub
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from Employeetab where
empid='"& pkvar &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()
disRecords()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
RichTextBox1.Text = ""
TextBox1.Text = ""

TextBox2.Text = ""
TextBox3.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 74


Apartment Management

EndSub

PrivateSub Button4_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()

EndSub

PrivateSub TextBox1_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox1.TextChanged

EndSub

PrivateSub TextBox2_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox2.KeyPress
IfNotRegex.Match(TextBox1.Text, "^[a-z. ]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")
TextBox1.Text = ""
TextBox1.Focus()
EndIf
EndSub

PrivateSub TextBox2_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox2.TextChanged

EndSub

PrivateSub TextBox3_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox3.KeyPress
IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then

MsgBox("Please enter numbers only.")


TextBox3.Text = ""
TextBox3.Focus()
EndIf

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 75


Apartment Management

EndSub

PrivateSub TextBox3_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox3.TextChanged

EndSub

PrivateSub TextBox7_KeyPress(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TextBox7.KeyPress
IfNotRegex.Match(TextBox7.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox7.Text = ""
TextBox7.Focus()
EndIf
EndSub

PrivateSub TextBox8_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox8.KeyPress
IfNotRegex.Match(TextBox8.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox8.Text = ""
TextBox8.Focus()
EndIf
EndSub

PrivateSub TextBox8_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox8.TextChanged

EndSub

PrivateSub TextBox7_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox7.TextChanged

EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 76


Apartment Management

PrivateSub RichTextBox1_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
RichTextBox1.TextChanged

EndSub
EndClass

7.9 DUE ENTRY

Imports System.Data.SqlClient
Imports System.Text.RegularExpressions

PublicClassDueEntry

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
SaveRecord()
EndSub
SubSaveRecord()
If TextBox1.Text = ""Then
MsgBox("Please enter the necessary details")
Exit Sub
EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim Cmd0 AsNewSqlCommand("select name from dueentry where
name='"& ComboBox1.Text &"'", Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then

MsgBox("This record is allready present in the database")


If Conn.State = ConnectionState.Open ThenConn.Close()
Exit Sub
EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()

Conn.Open()
q1Var = "insert into dueentry("
q2Var = " values("
q1Var = q1Var &"name"&","

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 77


Apartment Management

q2Var = q2Var &"'"& ComboBox1.Text &"',"

q1Var = q1Var &"elebill"&","


q2Var = q2Var &"'"& TextBox1.Text &"',"
q1Var = q1Var &"waterbill"&","
q2Var = q2Var &"'"& TextBox2.Text &"',"
q1Var = q1Var &"maintainancecharge"&","
q2Var = q2Var &"'"& TextBox3.Text &"',"
q1Var = q1Var &"parking"&","
q2Var = q2Var &"'"& TextBox4.Text &"',"
q1Var = q1Var &"rent"&")"
q2Var = q2Var &"'"& TextBox5.Text &"')"
'MsgBox(q1Var & q2Var)
Dim cmd1 AsNewSqlCommand(q1Var & q2Var, Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

disRecords()

MsgBox("Record Saved Successfully")

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""

EndSub
SubdisRecords()
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim DS1 AsNewDataSet

Dim adp AsNewSqlDataAdapter("Select * From dueentry order


by name", Conn)
adp.Fill(DS1)

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 78


Apartment Management

DataGridView1.DataSource = DS1.Tables(0)
If Conn.State = ConnectionState.Open ThenConn.Close()

EndSub

PrivateSub ComboBox1_KeyPress(ByVal sender AsObject, ByVal


e As System.Windows.Forms.KeyPressEventArgs) Handles
ComboBox1.KeyPress
IfNotRegex.Match(ComboBox1.Text, "^[a-z. ]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")
ComboBox1.Text = ""
ComboBox1.Focus()
EndIf
EndSub

PrivateSub TextBox1_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox3.Text = ""
TextBox3.Focus()
EndIf
EndSub

PrivateSub TextBox2_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox2.KeyPress

IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")

TextBox3.Text = ""
TextBox3.Focus()
EndIf

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 79


Apartment Management

EndSub

PrivateSub TextBox3_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox3.KeyPress
IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then

MsgBox("Please enter numbers only.")


TextBox3.Text = ""
TextBox3.Focus()
EndIf
EndSub

PrivateSub TextBox4_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox4.KeyPress
IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox3.Text = ""
TextBox3.Focus()
EndIf
EndSub

PrivateSub TextBox5_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox5.KeyPress
IfNotRegex.Match(TextBox3.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox3.Text = ""
TextBox3.Focus()
EndIf
EndSub

PrivateSub ComboBox1_SelectedIndexChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
ComboBox1.SelectedIndexChanged

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 80


Apartment Management

EndSub

PrivateSub TextBox5_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox5.TextChanged

TextBox6.Text = Val(TextBox1.Text) + Val(TextBox2.Text)


+ Val(TextBox3.Text) + Val(TextBox4.Text) +
Val(TextBox5.Text)
EndSub

PrivateSub DueEntry_Load(ByVal sender As System.Object,


ByVal e As System.EventArgs) HandlesMyBase.Load

EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
DueEntry1.Show()
EndSub

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
MDIParent2.Show()

EndSub
EndClass

7.10 DUE DISPLAY

Imports System.Data.SqlClient

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 81


Apartment Management

Imports System.Text.RegularExpressions
PublicClassDueDisplay

PrivateSub DueDisplay_Load(ByVal sender As System.Object,


ByVal e As System.EventArgs) HandlesMyBase.Load
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim cmd0 AsNewSqlCommand("select name from dueentry ", Conn)
Dim D1 AsSqlDataReader = cmd0.ExecuteReader()

If D1.HasRows Then
D1.Read()
ComboBox1.Text = D1(0).ToString
EndIf
EndSub

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
disrecords()
EndSub

Subdisrecords()
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim ds1 AsNewDataSet
Dim adp AsNewSqlDataAdapter("select * from dueentry where
name='"& ComboBox1.text &"'", Conn)
adp.Fill(ds1)
dg1.DataSource = ds1.Tables(0)
If Conn.State = ConnectionState.Open ThenConn.Close()
EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
MDIParent1.Show()
EndSub
EndClass

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 82


Apartment Management

7.11 DUE ENTRY1

Imports System.Data.SqlClient

PublicClassDueEntry1
PrivateSub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
If vbNo = MsgBox("Are you sure you want modify this record",
MsgBoxStyle.YesNo, "Delete") ThenExit Sub
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from dueentry where
name='"& ComboBox1.Text &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()
SaveRecord()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
EndSub
SubSaveRecord()
If TextBox1.Text = ""Then
MsgBox("Please enter the necessary details")
Exit Sub
EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()

Dim Cmd0 AsNewSqlCommand("select name from dueentry where


name='"& ComboBox1.Text &"'", Conn)

Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()


If D1.HasRows Then
MsgBox("This record is allready present in the database")
If Conn.State = ConnectionState.Open ThenConn.Close()
Exit Sub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 83


Apartment Management

EndIf
a = ComboBox1.Text
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
q1Var = "insert into dueentry("
q2Var = " values("
q1Var = q1Var &"name"&","
q2Var = q2Var &"'"& ComboBox1.Text &"',"
q1Var = q1Var &"elebill"&","
q2Var = q2Var &"'"& TextBox1.Text &"',"
q1Var = q1Var &"waterbill"&","
q2Var = q2Var &"'"& TextBox2.Text &"',"
q1Var = q1Var &"maintainancecharge"&","
q2Var = q2Var &"'"& TextBox3.Text &"',"
q1Var = q1Var &"parking"&","
q2Var = q2Var &"'"& TextBox4.Text &"',"
q1Var = q1Var &"rent"&","
q2Var = q2Var &"'"& TextBox5.Text &"',"

'MsgBox(q1Var & q2Var)


Dim cmd1 AsNewSqlCommand(q1Var & q2Var, Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""

TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""

EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
If vbNo = MsgBox("Are you sure you want delete this record",
MsgBoxStyle.YesNo, "Delete") ThenExit Sub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 84


Apartment Management

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
Dim cmd1 AsNewSqlCommand("Delete from dueentry where
name='"& ComboBox1.Text &"'", Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

MsgBox("Record Saved Successfully")


ComboBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""

EndSub

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
DueEntry.Show()
EndSub

PrivateSub DueEntry1_Load(ByVal sender As System.Object,


ByVal e As System.EventArgs) HandlesMyBase.Load

EndSub
EndClass

7.12 EMPLOYEE REPORT

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 85


Apartment Management

Imports System.Data.SqlClient

PublicClassEmployeeReport

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles butprint.Click
PrintPreviewDialog1.ShowDialog()
EndSub

PrivateSub PrintDocument1_PrintPage(ByVal sender As


System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Dim XPos, YPos AsLong
YPos = 50
Dim MyFont AsNewFont("Arial", 18)

XPos = 10
e.Graphics.DrawString("Cust Care Administration", MyFont,
Brushes.Black, XPos, YPos)
YPos += 50
MyFont = NewFont("Arial", 12)
e.Graphics.DrawString("No. 101, 4th floor, UB City,
Bangalore - 560001", MyFont, Brushes.Black, XPos, YPos)
YPos += 100
XPos = 10
e.Graphics.DrawString("Employee List Report", MyFont,
Brushes.Black, XPos, YPos)
YPos += 50
XPos = 10
MyFont = NewFont("Arial", 12)
e.Graphics.DrawString("empid", MyFont, Brushes.Black, XPos,
YPos)
XPos = XPos + 150
e.Graphics.DrawString("name", MyFont, Brushes.Black, XPos,
YPos)
XPos = XPos + 150

e.Graphics.DrawString("designation", MyFont, Brushes.Black,


XPos, YPos)

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 86


Apartment Management

XPos = XPos + 150


e.Graphics.DrawString("phoneno", MyFont, Brushes.Black,
XPos, YPos)
XPos = XPos + 150
e.Graphics.DrawString("salary", MyFont, Brushes.Black,
XPos, YPos)
XPos = XPos + 150

YPos += 25
ForEach r AsDataGridViewRowIn DataGridView1.Rows
XPos = 10
e.Graphics.DrawString(r.Cells(0).Value, MyFont,
Brushes.Black, XPos, YPos)

XPos = XPos + 150


e.Graphics.DrawString(r.Cells(1).Value, MyFont,
Brushes.Black, XPos, YPos)
XPos = XPos + 150
e.Graphics.DrawString(r.Cells(2).Value, MyFont,
Brushes.Black, XPos, YPos)
XPos = XPos + 150
e.Graphics.DrawString(r.Cells(3).Value, MyFont,
Brushes.Black, XPos, YPos)
XPos = XPos + 150
e.Graphics.DrawString(r.Cells(4).Value, MyFont,
Brushes.Black, XPos, YPos)
XPos = XPos + 150

YPos += 25
Next
EndSub

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles butdisplay.Click

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 87


Apartment Management

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
Dim DS1 AsNewDataSet
Dim adp AsNewSqlDataAdapter("Select
empid,name,designation,phoneno,salary From employeetab ",
Conn)
adp.Fill(DS1)
DataGridView1.DataSource = DS1.Tables(0)
If Conn.State = ConnectionState.Open ThenConn.Close()
EndSub

PrivateSub butclose_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles butclose.Click
Me.Close()
EndSub

PrivateSub EmployeeReport_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load

EndSub
EndClass

7.13 TRACK VECHILES

Imports System.Data.SqlClient
Imports System.Text.RegularExpressions

PublicClassTrackVehicles

PrivateSub TextBox1_Leave(ByVal sender AsObject, ByVal e As


System.EventArgs) Handles TextBox1.Leave
If Conn.State = ConnectionState.Open ThenConn.Close()

Conn.Open()
Dim cmd0 AsNewSqlCommand("select * from vehicletab where
cardno ='"& TextBox1.Text &"'", Conn)

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 88


Apartment Management

Dim D1 AsSqlDataReader = cmd0.ExecuteReader()


If D1.HasRows Then

D1.Read()
TextBox1.Text = D1(0).ToString
TextBox6.Text = D1(5).ToString
TextBox2.Text = D1(2).ToString
TextBox3.Text = D1(4).ToString
TextBox4.Text = D1(3).ToString
TextBox5.Text = D1(1).ToString

Me.BackColor = Color.Green

Else

TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""

TextBox6.Text = ""
Me.BackColor = Color.Red

EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()
EndSub

PublicSubFilterData(ByVal valueToSearch AsString)


'SELECT * From Users WHERE CONCAT(fname, lname, age) like
'%F%'
Dim searchQuery AsString = "SELECT * From vehicletab WHERE
cardno like '%"& valueToSearch &"%'"

Dim command AsNewSqlCommand(searchQuery, Conn)

Dim adapter AsNewSqlDataAdapter(command)


Dim table AsNewDataTable()

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 89


Apartment Management

adapter.Fill(table)

DataGridView1.DataSource = table

EndSub

PrivateSub TrackVehicles_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load

EndSub
EndClass

7.14 VECHILE REPORT

Imports System.Data.SqlClient

PublicClassVehicleReport

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click

Me.Close()
EndSub

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim DS1 AsNewDataSet
Dim adp As ImpNew SqlDataAdapter("Select
cardno,model,apartment_number From vehicletab ", Conn)
adp.Fill(DS1)
DataGridView1.DataSource = DS1.Tables(0)

If Conn.State = ConnectionState.Open ThenConn.Close()


EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 90


Apartment Management

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
PrintPreviewDialog1.ShowDialog()
EndSub

PrivateSub PrintDocument1_PrintPage(ByVal sender As


System.Object, ByVal e As
System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Dim XPos, YPos AsLong
YPos = 50
Dim MyFont AsNewFont("Arial", 18)
XPos = 10
e.Graphics.DrawString("Cust Care Administration", MyFont,
Brushes.Black, XPos, YPos)
YPos += 50
MyFont = NewFont("Arial", 12)
e.Graphics.DrawString("No. 101, 4th floor, UB City,
Bangalore - 560001", MyFont, Brushes.Black, XPos, YPos)
YPos += 100
XPos = 10
e.Graphics.DrawString("Vehicle List Report", MyFont,
Brushes.Black, XPos, YPos)

YPos += 50
XPos = 10
MyFont = NewFont("Arial", 12)
e.Graphics.DrawString("Card Number", MyFont, Brushes.Black,
XPos, YPos)
XPos = XPos + 150
e.Graphics.DrawString("Model", MyFont, Brushes.Black, XPos,
YPos)
XPos = XPos + 150

e.Graphics.DrawString("Apartment Number", MyFont,


Brushes.Black, XPos, YPos)
XPos = XPos + 150

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 91


Apartment Management

YPos += 25
ForEach r AsDataGridViewRowIn DataGridView1.Rows
q1Var = r.Cells(1).Value &" : "&
r.Cells(2).Value
XPos = 10
e.Graphics.DrawString(r.Cells(0).Value, MyFont,
Brushes.Black, XPos, YPos)
XPos = XPos + 150

e.Graphics.DrawString(r.Cells(1).Value, MyFont,
Brushes.Black, XPos, YPos)

XPos = XPos + 150


e.Graphics.DrawString(r.Cells(2).Value, MyFont,
Brushes.Black, XPos, YPos)

XPos = XPos + 150


YPos += 25

Next
EndSub

PrivateSub VehicleReport_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load

EndSub
EndClass

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 92


Apartment Management

7.15 VIEW VISITORS

Imports System.Data.SqlClient
PublicClassViewVisitors
PrivateSub Button2_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
MDIParent1.Show()

EndSub

PrivateSub ViewVisitors_Load(ByVal sender As System.Object,


ByVal e As System.EventArgs) HandlesMyBase.Load
disrecords()

EndSub
SubdisRecords()
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim DS1 AsNewDataSet
Dim adp AsNewSqlDataAdapter("Select
Name,Phone_Number,From1,Date From VisitorTrack order by
Name", Conn)
adp.Fill(DS1)
DataGridView1.DataSource = DS1.Tables(0)
If Conn.State = ConnectionState.Open ThenConn.Close()
EndSub

PrivateSub DataGridView1_CellContentClick(ByVal sender As


System.Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
DataGridView1.CellContentClick
EndSub
EndClass

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 93


Apartment Management

7.16 VISITOR TRACKING

Imports System.Data.SqlClient
Imports System.Text.RegularExpressions

PublicClassVisitorTracking

PrivateSub VisitorTracking_Load(ByVal sender As


System.Object, ByVal e As System.EventArgs)
HandlesMyBase.Load
SerialPort1.PortName = "COM3"
SerialPort1.BaudRate = "9600"
'SerialPort1.Open()

Label2.Hide()
Label3.Hide()

TextBox1.Hide()
TextBox2.Hide()
Button2.Hide()

Button3.Hide()

EndSub

PrivateSub Button1_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button1.Click
If ComboBox1.Text = "Phone Number"Then
Label2.Show()
TextBox1.Show()
Button2.Show()
Label3.Hide()
TextBox2.Hide()
Button3.Hide()

Else
Label3.Show()

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 94


Apartment Management

TextBox2.Show()
Button3.Show()
Label2.Hide()
TextBox1.Hide()
Button2.Hide()

EndIf

EndSub

PrivateSub Button2_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button2.Click
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim Cmd0 AsNewSqlCommand("select
Name,Block,Occupation,Apartment_number,Phone_number from
ResidentReg where Phone_Number='"& TextBox1.Text &"'",
Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()

If D1.HasRows Then
D1.Read()
TextBox3.Text = D1(0)
TextBox4.Text = D1(1)
TextBox5.Text = D1(2)
TextBox6.Text = D1(3)
TextBox10.Text = D1(4)

Else
MsgBox("Resident does not exist")
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox10.Text = ""

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 95


Apartment Management

EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()
EndSub

PrivateSub Button3_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button3.Click
If Conn.State = ConnectionState.Open ThenConn.Close()
Conn.Open()
Dim Cmd0 AsNewSqlCommand("select
Name,Block,Occupation,Apartment_number,Phone_number from
ResidentReg where Apartment_number='"& TextBox2.Text &"'",
Conn)
Dim D1 AsSqlDataReader = Cmd0.ExecuteReader()
If D1.HasRows Then
D1.Read()
TextBox3.Text = D1(0)
TextBox4.Text = D1(1)
TextBox5.Text = D1(2)
TextBox6.Text = D1(3)
TextBox10.Text = D1(4)

Else
MsgBox("Resident does not exist")
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox10.Text = ""

EndIf
If Conn.State = ConnectionState.Open ThenConn.Close()
EndSub

PrivateSub Label12_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs)

EndSub

PrivateSub Button4_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button4.Click

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 96


Apartment Management

SaveRecord()
EndSub

SubSaveRecord()
Dim b AsString
If TextBox7.Text = ""Then
MsgBox("Please enter the necessary details")
Exit Sub
EndIf

If Conn.State = ConnectionState.Open ThenConn.Close()


Conn.Open()
q1Var = "insert into VisitorTrack("
q2Var = " values("
q1Var = q1Var &"Name"&","
q2Var = q2Var &"'"&UCase(TextBox7.Text) &"',"
q1Var = q1Var &"Phone_Number"&","
q2Var = q2Var &"'"&UCase(TextBox8.Text) &"',"
q1Var = q1Var &"From1"&","

q2Var = q2Var &"'"&UCase(TextBox9.Text) &"',"


q1Var = q1Var &"Date"&","
q2Var = q2Var &"'"& DateTimePicker1.Value &"',"
q1Var = q1Var &"Flat_Number"&","
q2Var = q2Var &"'"& TextBox6.Text &"',"
q1Var = q1Var &"Block"&")"
q2Var = q2Var &"'"& TextBox4.Text &"')"

'MsgBox(q1Var & q2Var)


Dim cmd1 AsNewSqlCommand(q1Var & q2Var, Conn)
cmd1.ExecuteNonQuery()
If Conn.State = ConnectionState.Open ThenConn.Close()

a = TextBox7.Text
b = TextBox8.Text

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 97


Apartment Management

SerialPort1.WriteLine("AT"& vbCrLf)
Threading.Thread.Sleep(2000)
SerialPort1.WriteLine("AT+CMGF=1"& vbCrLf)
Threading.Thread.Sleep(2000)
SerialPort1.WriteLine("AT+CMGS="& TextBox10.Text &""&
vbCrLf) ' enter the mobile number whom you want to send the
SMS
Threading.Thread.Sleep(2000)
Threading.Thread.Sleep(2000)
SerialPort1.WriteLine("VISITOR : NAME : " + a + " PHONE
NUMBER :" + b + " IF UNKNOWN PERSON PLEASE CALL SECURITY"&
vbCrLf)
SerialPort1.WriteLine(Chr(26)) 'SMS sending
MsgBox("Message Sent")

MsgBox("record saved successfully")


TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()
TextBox7.Clear()
TextBox8.Clear()
TextBox9.Clear()

EndSub

PrivateSub Button5_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button5.Click
Me.Close()
ViewVisitors.Show()

EndSub

PrivateSub Button6_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles Button6.Click
SerialPort1.Close()
Me.Close()
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 98


Apartment Management

PrivateSub TextBox3_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox3.KeyPress
IfNotRegex.Match(TextBox1.Text, "^[a-z. ]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")
TextBox1.Text = ""
TextBox1.Focus()
EndIf
EndSub

PrivateSub TextBox3_Leave(ByVal sender AsObject, ByVal e As


System.EventArgs) Handles TextBox3.Leave

EndSub

PrivateSub TextBox3_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox3.TextChanged

EndSub

PrivateSub TextBox5_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox5.KeyPress

IfNotRegex.Match(TextBox5.Text, "^[a-z. ]*$",


RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")
TextBox5.Text = ""
TextBox5.Focus()
EndIf
EndSub

PrivateSub TextBox5_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox5.TextChanged

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 99


Apartment Management

EndSub

PrivateSub TextBox7_KeyPress(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles TextBox7.KeyPress
IfNotRegex.Match(TextBox7.Text, "^[a-z. ]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter alphabets only.")
TextBox7.Text = ""
TextBox7.Focus()
EndIf
EndSub

PrivateSub TextBox9_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox9.TextChanged

EndSub

PrivateSub TextBox4_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox4.KeyPress
IfNotRegex.Match(TextBox4.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox4.Text = ""
TextBox4.Focus()

EndIf
EndSub

PrivateSub TextBox4_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox4.TextChanged

EndSub

PrivateSub TextBox6_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox6.KeyPress

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 100


Apartment Management

IfNotRegex.Match(TextBox6.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")

TextBox6.Text = ""
TextBox6.Focus()
EndIf
EndSub

PrivateSub TextBox6_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox6.TextChanged

EndSub

PrivateSub TextBox10_KeyPress(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox10.KeyPress
IfNotRegex.Match(TextBox10.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox10.Text = ""
TextBox10.Focus()
EndIf
EndSub

PrivateSub TextBox8_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox8.KeyPress

IfNotRegex.Match(TextBox8.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then

MsgBox("Please enter numbers only.")


TextBox8.Text = ""
TextBox8.Focus()
EndIf
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 101


Apartment Management

PrivateSub TextBox8_TextChanged(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
TextBox8.TextChanged

EndSub

PrivateSub TextBox1_KeyPress(ByVal sender AsObject, ByVal e


As System.Windows.Forms.KeyPressEventArgs) Handles
TextBox1.KeyPress
IfNotRegex.Match(TextBox1.Text, "^[0-9]*$",
RegexOptions.IgnoreCase).Success Then
MsgBox("Please enter numbers only.")
TextBox1.Text = ""
TextBox1.Focus()
EndIf
EndSub

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 102


Apartment Management

CHAPTER-8
CONCLUSION

The project is developed best on the windows application, the capable of


registeringresidents, employees and vehicles and also enabling to get information
about apartment maintenance. In order to track the vehicles and visitors some
objectives were defined. It is with great experience that I present this final review
of the system is successfully been developed using a number of tools earlier
discussed Computer and software like My SQL. Meanwhile, the careful
application of these tools and have led to development of a system that meets the
defined objectives.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 103


Apartment Management

FUTURE ENHANCEMENT

Apartment Management Project deals with registering and tracking the residents
and vehicles. The main objective of this project is to track the visitors and
vehicles. Here the card numbers are entered manually. So in the future tracking
can be done easily by using RFID as residents will be provided with the unique
ID cards to track the vehicles and the visitors .As the visitors or vehicle holders
will tap the cards on the RFID, visitors or vehicles will be allowed if the card is
recognised.

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 104


Apartment Management

CHAPTER-9
BIBILOGRAPHY

The References used during the course

The following material was used as the references during the course of the project.

Text Books

 Complete Reference VB.Net

 Programming Microsoft VB.NET

www.google.co.in

BCA DEPARTMENT , OM SAI DEGREE COLLEGE 105

You might also like