You are on page 1of 63

HOSTEL MANAGEMENT SYSTEM

Submitted to Bharathiar University in partial fulfillment of the


Requirements for the award of the Degree of
Bachelor of Science in Computer science
of Bharathiar University,
Coimbatore 641046
By
CHANDRU.M
(Reg.No: 1322K1283)
Under the guidance of
Mr.V.JAIGANESH MCA,M.Phil,Ph.D,MBA,
Assistant Professor

DEPARTMENT OF COMPUTER SCIENCE


Dr. N.G.P Arts and Science College (Autonomous)
(Affiliated to the Bharathiar University Accredited by NACC)
Coimbatore 641 048
OCTOBER-2015

DEPARTMENT OF COMPUTER SCIENCE


Dr. N.G.P Arts and Science College (Autonomous)
(Affiliated to the Bharathiar University Accredited by NACC)
Coimbatore 641 048
PROJECT REPORT
This is to certify that the project work entitled
HOSTEL MANAGEMENT SYSTEM
Is a bonafide record of work done
By
CHANDRU.M
(Reg.No: 1322k1283)
Submitted in partial fulfillment of the requirements for the degree of
BACHELOR OF SCIENCE IN COMPUTER SCIENCE
Of the Bharathiar University, Coimbatore 641 046
During fifth semester of the academic year 2015 2016

....................

....................

FACULTY GUIDE

HEAD OF THE DEPARTMENT

SUBMITTED FOR THE VIVA-VOICE EXAMINATION HELD ON . . . . . . . . . . . . . . . . .

....................
INTERNAL EXAMINER

....................
EXTERNAL EXAMINER

DECLARATION

DECLARATION
I, CHANDRU.M, hereby declare that this study entitled HOSTEL MANAGEMENT
SYSTEM submitted to

Dr.N.G.P. ARTS AND SCIENCE COLLEGE(Autonomous),

COIMBATORE in partial fulfillment of the requirements for the award of the degree of
Bachelor of Science in Computer science is a record of original project work, under the
supervision and guidance of Mr.V.JAIGANESHMca,Mphil,Ph.d,MBA, Assistant Professor
Department of Computer Science, Dr.N.G.P. Arts and Science College(Autonomous),
Coimbatore and it has not formed the basis for the award of any Degree/Diploma/Associate
Ship or Fellowship or other similar title to any candidate of any University.

Place: Coimbatore
Date:

CHANDRU.M
(Reg. No. : 1322k1283)

ACKNOWLEDGEMENT

ACKNOWLEDGEMENT
My deep sense of gratitude and thanks to our beloved chairman Dr. Nalla
G.Palaniswami M.D.A.B ( USA ) and ThavamaniD.Palaniswami, Secretary, Dr. N.G.P. Arts
and Science College, Coimbatore for giving me an opportunity to undergo my studies in this
prestigious institution.
I wish to express my profound thanks to Dr.P.R.Muthuswamy, MA.,MBA,FDPM.,
(IIM.A)., PGDMM., Ph.D., Principal, Dr. N.G.P. Arts and Science College for his permission
to undertake this study in this esteemed institution.
My heartfelt thanks to Dr. K. Durairaj, M.Com, M.Phil., Ph.D., Vice Principal, Dr.
N.G.P. Arts and Science College, Coimbatore for his inspiration and having permitted me to
make use of the infrastructure of this great institution of enduring excellence.
I am indebted to Mr. K. Khumaravel, MCA.,M.Phil., Ph.D., Head Department of
Computer Science, Dr. N.G.P. Arts and Science College, Coimbatore for his inspiration and
having permitted me to make use of the infrastructure of this great institution of enduring
excellence.
I express my sincere thanks to my guide Mr.V.JAIGANESH,Mca,Mphil,Phd,MBA,
Assistant Professor, Department of Computer Science, Dr. N.G.P. Arts and Science College,
Coimbatore for the successful completion and submission of my project.
I extend my sincere thanks to all the staff members of the Department of the Computer
Science for their support and guidance.
I wish to thank my Parents and Friends for their support and encouragement throughout
my study.
Success the destiny of hard work and pain is achieved only with the help of my most
gracious and ever loving Almighty without whose blessing, nothing would come to pass. I
dedicate to Him this humble endeavor of mine.

CONTENTS

CONTENTS

S.NO.

PARTICULARS
SYNOPSIS

INTRODUCTION
1.1 OVERVIEW OF THE PROJECT
1.1.1 DESCRIPTION OF MODULES
1.2 SYSTEM SPECIFICATION
1.2.1 HARDWARE SPECIFICATION
1.2.2 SOFTWARE SPECIFICATION
1.3 SOFTWARE FEATURES

SYSTEM STUDY
2.1 EXISTING SYSTEM
2.1.1 DRAWBACKS
2.2 PROPOSED SYSTEM
2.2.1 ADVANTAGES OF PROPOSED SYSTEM

SYSTEM DESIGN AND DEVELOPMENT


3.1 INPUT DESIGN
3.2 OUTPUT DESIGN
3.3 DATABASE DESIGN
3.3.1 DATAFLOW DIAGRAM

PAGE NO.

3.3.2 TABLE STRUCTURE

3.3.3 ENTITY RELATIONSHIP DIAGRAM


TESTING AND IMPLEMENTATION
4.1 SYSTEM TESTING
4.2 SYSTEM IMPLEMENTATION

CONCLUSION

SCOPE OF FUTURE ENHANCEMENT


BIBLIOGRAPHY
APPENDIX
A. SCREEN SHOTS
B. SAMPLE CODING

SYNOPSIS

SYNOPSIS
As the name specifies HOSTEL MANAGEMENT SYSTEM is software
developed for managing various activities in the hostel. For the past few years the number of
educational institutions is increasing rapidly. Thereby the number of hostels is also increasing for
the accommodation of the students studying in this institution. And hence there is a lot of strain
on the person who are running the hostel and softwares are not usually used in this context. This
particular project deals with the problems on managing a hostel and avoids the problems which
occur when carried manually. Identification of the drawbacks of the existing system leads to the
designing of computerized system that will be compatible to the existing system with the system
Which is more user friendly and more GUI oriented. We can improve the efficiency of the
system, thus overcome the drawbacks of the existing system.

Less human error


Strength and strain of manual labor can be reduced
High security
Data redundancy can be avoided to some extent
Data consistency
Easy to handle
Easy data updating
Easy record keeping
Backup data can be easily generated

1. INTRODUCTION
This system is designed in favor of the hostel management which helps them to
save the records of the students about their rooms and other things. It helps them from the
manual work from which it is very difficult to find the record of the students and the mess bills
of the students, and the information of about the those ones who had left the hostel. All the
hostels at present are managed manually by the hostel office. The Registration form verification
to the different data processing is done manually. Thus there are a lot of repetitions which can be
easily avoided. And hence there is a lot of strain on the person who are running the hostel and
softwares are not usually used in this context. This particular project deals with the problems on
managing a hostel and avoids the problems which occur when carried manually Identification of
the drawbacks of the existing system leads to the designing of computerizedsystem that will be
compatible to the existing system with the system which is more user friendly . We can improve
the efficiency of the system, thus overcome the drawbacks of the existing system. We design this
system of the hostel management especially for the college hostel, through this they cannot
require so efficient person to handle and calculate the things. This system automatically
calculates all the bills and issued the notifications for those students who are against some rules.

1.1 OVERVIEW OF THE PROJECT


This software product the hostel management to improve their services for all the students of the
hostel. This also reduce the manual work of the persons in admin penal and the bundle of
registers that were search when to find the information of a previous student, because through
this system you can store the data of those students who had left the hostel . Through this you
can check the personal profile of all the current students within few minutes the data base of the
system will help you to check a particular one. The system will help you to check the mess bills
of every student and the students hostel dues. The students of the hostel will be recognized from
the ID number allocated at the room rental time. In the last this system will improve the
management work in the hostel.

1.2 DESCRIPTION OF MODULES

Login

Admin can create User-id and password for Students


Admin will organize the whole management system
Student
Student report gets details about particular student who is at hostel.
Get abstract details about a student including personal details

Room Allocation
Room report gets details about things in the room.
Total no vacancy and room allocation for a student is calculated by admin.

Fees Details
Billing report get bill details report about a particular student and fees pending.

Outing Details
Report of Student outing time includes in and out time

1.3 SYSTEM SPECIFICATION


1.3.1 HARDWARE CONFIGURARTION
System

HCL

Processor

Pentium IV

Processor Speed

2.80GHz

Main Storage

512MB RAM

Hard Disk Capacity

80GB

Floppy Disk Drive

1.44MB

CD-ROM Drive

LG 52X Reader

Keyboard

104 Keys

Mouse

Logitech

Monitor

Samsung 17 Color

1.3.2 SOFTWARE CONFIGURARTION


Operating System

Windows XP

Front end

Visual Basic.Net

Back End

SQL Server 2008

1.4 SOFTWARE FEATURES


VISUAL BASIC.NET
Visual

Baic.Net

has

revolutionized

windows

programming

windows

programming and with an object based, event driven approach to software designs. Visual

basic.Net applications act as a front end to the database. Visual basic.Net application provides the
interface between the user and the database. Sophisticated features that make the language truly
object oriented and interfaces it with the latest in the database technology.
.NET provides a new, object-oriented API as a set of classes that will be accessible from any
programming language. This book describes this framework of classes and provides a reference
to what is available and how you can use this framework to write Windows applications in the
brave new world of .NET.
Microsoft .NET Framework is a computing platform for developing distributed applications for
the Internet. Following are the design goals of Microsoft .NET Framework:
1. To provide a very high degree of language interoperability
2. To provide a runtime environment that completely manages code execution
3. To provide a very simple software deployment and versioning model
4. To provide high-level code security through code access security and strong type
checking
5. To provide a consistent object-oriented programming model
6. To facilitate application communication by using industry standards such as SOAP and
XML.
7. To simplify Web application development
Visual basic.net lets the user to add menus, text boxes, command buttons, option buttons,
check boxes, list boxes, scroll bars, and file directory boxes to blank windows. Visual basic.net
has many different tools.

The Common Language Runtime

The CLR is the mechanism through which .NET code is executed. It is built upon a single,
common languageILinto which source languages are compiled and includes mechanisms for
executing the compiled code. This includes code verification and just-in-time (JIT) compilation,
garbage collection and enforcement of security policies, and the provision of profiling and
debugging services.
The CLR provides a lot of added value to the programs it supports. Because it controls
how a .NET program executes and sits between the program and the operating system, it can
implement security, versioning support, automatic memory management through garbage
collection, and provide transparent access to system services
IMPORTANT FEATURES:

The application is a graphical user interface.

Client-Server architecture benefits picture and image box can be easily


handled using bit mapped files and icons.

Bit mapped files and icons are used as simple debugging tools.

With the advent of .NET, Microsoft has introduced many new


technologies that make writing component-based distributed systems
easier, more flexible, and more powerful than ever before.

It is now easier than it has ever been to write components in any


programming language that can interoperate with components on other
machines, which may not be Windows-based at all.

SQL SERVER 2008

The purpose of this document is to help you migrate your applications when you are
migrating the underlying database from Microsoft SQL Server to Some other Database. Most of
the issues encountered when migrating applications to use an Sql Server Database are related to
database incompatibility. This paper presents these incompatibilities and provides solutions for
many issues.
You should familiarize yourself with this document prior to migrating your databases.
The choices made about how to migrate your application affect how you migrate the underlying
database from Microsoft SQL Server to some other Database.
If the application uses the Microsoft OLE DB Provider for SQL Server or a third-party
OLE DB Provider to connect the Microsoft SQL Server database, use the Sql Server Provider for
OLE DB (SQLOLEDB) to connect to the migrated Database.
SQL Server Security

Login Authentication.
Windows NT Authentication
SQL Server Authentication

Permissions validation on user database.

T-SQL statements sent to SQL Server.

SQL server checks user permissions on receipt of T-SQL statements

FEATURES

Created by Microsoft and Sybase in the 80s.

Is SQL Compliant - Uses ANSI SQL

Supports SQL 92 standards - Uses T-SQL

Stores data in a central location and delivers it to clients on request

New Server Architecture

Graphic Administration Tools

Maintains ANSI standards and 6.x Compatibility

Data integrity means reliability and accuracy of data.

Integrity rules keep data consistent.

Supports Client/Server model.

Request response dialog.

Workload is split between the client and the server.

Operating System compatibility.

Runs on Win 95/98 NT, Netware, UNIX, OS/2, AppleTalk, Banyan VINES.

SQL Server must have Service Pack 4 (SP4) to run on Windows NT 4.0.

Multiple protocol compatibility.

SQL Server supports these protocols - AppleTalk, TCP/IP.

SMP Compatibility and Scalability

Supports multiple processors. SMP leads to scalability.

2. SYSTEM STUDY AND ANALYSIS


2.1 EXISTING SYSTEM

The existing system is manual one .The major activities are related to clients or
customers are usually carried out in a hectic way. The number of customer's arrival is on an
alarming rate on the manual calculations always results in an error which are great loss to the
store. Even though mostly nowadays the computers find their place everywhere. Here, there has
been confusion on the installation of system and what kind of department store they were going
to use. And of lately this package which was proposed that they have thought of implementing a
change so the existing system has been manual one and it has been burden on various activities
where all needed to carry out the existing system.

2.2 DRAWBACKS OF EXISTING SYSTEM


Erroneous data entry due to human errors.
Searching and verifying of exact data are more time consuming.
Reports are not in a presentable form.
Loss of past records due to mishandling and improper storage facilities.
Slow processing.

2.3 PROPOSED SYSTEM


In "Online Tourism Management system" the admin has preloaded the information and
details which the user seeks. This Project enhance the user have a better information about their
Tour.
In order to conduct a success project we must understand the scope of work to be
done, the risk to be incurred the resources, the required task to be accomplished the mile stones
to be tracked the fort it be expended and the schedules to be followed. It begins before technical
work starts, continues as department store evaluates from the concept of reality and only on
the department store is retired.
The system use less amount of time to produce report. In the computerization of
the concern, the errors can be rectified. The proposed system is used mainly to
maintain the organization. The new system will replace the existing manual processing to
overcome the drawbacks. It maintains all the customer details, Area Entry details, parking
details, billing details and reserve details the checking process through the system.

ADVANTAGES OF PROPOSED SYSTEM:

It is very accurate

It can store larger amount of data i.e., memory is very large and can have a backup copy
when needed.

Very good at repeated calculations.


All the process has done at high speed.
It does the work very efficiently.

It is cost effective.

Reduced paper work.

3. SYSTEM DESIGN AND DEVELOPMENT


3.1 INPUT DESIGN
Input design is one of the most important phase of the system design. Input design is the
process where the input received in the system are planned and designed, so as to get necessary
information from the user, eliminating the information that is not required. The aim of the input
design is to ensure the maximum possible levels of accuracy and also ensures that the input is
accessible that understood by the user.
The input design is the part of overall system design, which requires very careful
attention. if the data going into the system is incorrect then the processing and output will
magnify the errors.
The objectives considered during input design are:

Nature of input processing.


Flexibility and thoroughness of validation rules.
Handling of properties within the input documents.
Screen design to ensure accuracy and efficiency of the input relationship with files.
Careful design of the input also involves attention to error handling, controls, batching
and validation procedures.
Input design features can ensure the reliability of the system and produce result from

accurate data or they can result in the production of erroneous information. The input design of
the system includes the following

3.2 OUTPUT DESIGN


Output design is very important concept in the computerized system, without reliable
output the user may feel the entire system is unnecessary and avoids using it. The proper output
design is important in any system and facilitates effective decision-making.
Computer output is the most important and direct source of information to the user.
Efficiently intelligible output design should be improve the system to the user and health
decision making.
Output design request to the results generated by the system. for many ends user on the basic
outputs the evaluate is the usefulness of the application.

3.3 DATABASE DESIGN


The data in the system has to be stored and retrieved from database. Designing the database is
part of system design. Data elements and data structures to be stored have been identified at
analysis stage. They are structured and put together to design the data storage and retrieval
system. A database is a collection of interrelated data stored with minimum redundancy to
serve many users quickly and efficiently. The general objective is to make database access
easy, quick, inexpensive and flexible for the user. Relationships are established between the
data items and unnecessary data items are removed. Normalization is done to get an internal
consistency of data and to have minimum redundancy and maximum stability. This ensures
minimizing data storage required, minimizing chances of data inconsistencies and optimizing
for updates.

3.3.1 DATA FLOW DIAGRAM

LEVEL 1

LOGIN
USER

DETAILS

HOSTEL MANAGEMENT
SYSTEM

LEVEL 2

3.4 ENTITY RELATIONSHIP DIAGRAM

3.3.2 TABLE DESIGN


TABLE NAME: Login

FIELD NAME

DATA TYPE

Username

Varchar

Password

Varchar

TABLE NAME: Student Details

FIELD NAME

DATA TYPE

Id

Int

Name

Varchar

Pname

Varchar

Address

Varchar

Age

Int

Dob

Date time

Lname

Varchar

Lrelation

Varchar

Ladders

Varchar

Occupation

Varchar

Doj

Date time

Resno

Int

Mobno

Int

Sem

Varchar

Branch

Varchar

Batch

Int

Roomno

Int

Status

Varchar

TABLE NAME: Room Details

FIELD NAME
Id
Roomno
Noofstudent
Vacancy
Roomrent

DATA TYPE
Int
Iny
Int
Int
Int

TABLE NAME: Details

FIELD NAME

DATA TYPE

Id

Int

Name

Varchar

Thumb

Int

TABLE NAME: Vacate details

FIELD NAME

DATA TYPE

Id

Int

Name

Varchar

Branch

Varchar

Sem

Varchar

Batch

Decimal

Roomno

Int

Status

Varchar

TABLE NAME: Account Details

FIELD NAME

DATA TYPE

Id

Int

Cautionfee

Decimal

Registerfee

Decimal

Room rent

Decimal

Fine

Decimal

Totalfee

Decimal

Refund

Decimal

Paid or not paid

Varchar

4. SYSTEM TESTING AND IMPLEMENTATION

4.1 SYSTEM TESTING


Testing is a series of different tests that whose primary purpose is to fully exercise the
computer based system. Although each test has a different purpose, all work should verify that all
system element have been properly integrated and performed allocated function. Testing is the
process of checking whether the developed system works according to the actual requirement
and objectives of the system.
The philosophy behind testing is to find the errors. A good test is one that has a high
probability of finding an undiscovered error. A successful test is one that uncovers the
undiscovered error. Test cases are devised with this purpose in mind. A test case is a set of data
that the system will process as an input. However the data are created with the intent of
determining whether the system will process them correctly without any errors to produce the
required output.
Types of Testing:

Unit testing

Integration testing

Validation testing

Output testing

User acceptance testing

Performance Testing

Unit Testing
All modules were tested and individually as soon as they were completed and were checked
for their correct functionality.

Integration Testing
The entire project was split into small program; each of this single programs gives a frame as an
output. These programs were tested individually; at last all these programs where combined
together by creating another program where all these constructors were used. It give a lot of
problem by not functioning is an integrated manner.
The user interface testing is important since the user has to declare that the arrangements made in
frames are convenient and it is satisfied. when the frames where given for the test, the end user
gave suggestion. Based on their suggestions the frames where modified and put into practice.

Validation Testing:
At the culmination of the black box testing software is completely assembled as a
package. Interfacing errors have been uncovered and corrected and a final series of test i.e.,
Validation succeeds when the software function in a manner that can be reasonably Accepted by
the customer.

Output Testing
After performing the validation testing the next step is output testing of the proposed
system. Since the system cannot be useful if it does not produce the required output. Asking the
user about the format in which the system is required tests the output displayed or generated by
the system under consideration. Here the output format is considered in two ways. one is on
screen and another one is printed format. The output format on the screen is found to be
corrected as the format was designed in the system phase according to the user needs. And for
the hardcopy the output comes according to the specifications requested by the user.
User Acceptance System
An acceptance test as the objective of selling the user on validity and reliability of the
system. It verifies that the procedures operate to system specification and mat the integrity of
vital is maintained.
Performance Testing
This project is a application based project, and the modules are interdependent with the
other modules, so the testing cannot be done module by module. So the unit testing is not
possible in the case of this driver. So this system is checked only with their performance to check
their quality.

4.2 IMPLEMAENTAION AND PROCEDURES


Software maintenance is a set of software engineering activities that occur after software
has been delivered for the customer and put into operation. The success of software and the
project relies and the maintenance procedure performed.
As with the venture of human, not a single one is perfect. The further modifications are
left to the followers. It is because, the opinion or vision of a thing differs from individual to
individual. The maintenance is performed at regular intervals to keep the project safe and
reliable.
Every time changes attempted on the software will cause serious and unexpected side
effects. So, the maintenance of the software should be considered seriously. Software
maintenance is of course fare more than fixing mistakes. Maintenance can be described as the
activities that are to be undertaken after software is released for the use.
The different of maintenance are:

Corrective maintenance
Adaptive maintenance
Perfective maintenance
The corrective maintenance deals with the problems that may occur to software and what

sort of corrective measure can be provided to the user on such situations. The 80 % is spent
adapting existing systems to change in their external environment since we have used an
platform independency the software will be adaptive to all hardware and software environment.

5. CONCLUSION
The Hostel Management System been developed to satisfy all proposed
requirements. The system is highly scalable and user friendly. Almost all the system objectives
have been met. The system has been tested under all criteria. The system minimizes the problem
arising in the existing manual system and it eliminates the human errors to zero level.
The new computerized system was found to be much faster and reliable and user
friendly than the existing system. The system has been designed and developed step by step and
each module has been developed and tested individually to obtain the necessary required output
in the desired form. The project has been done as user friendly software for easy handling of
transaction. The system developed has been designed and run to satisfy the requirements and
needs of the organization as well as the end users. The system reduces the manual work of
process. The entire system is documented and can be easily understood by the end users. The
forms are very user friendly and also easy to handle. The drawbacks in the existing system are
overcome in the proposed system which runs successfully and efficiently.

6. SCOPE FOR FUTURE ENHANCEMENT


The project could be implemented in an average sized organization. An average
company will not be very keen on spending loads of money on ledgers. Whereas our project will
greatly reduce the costs which is using common and cheap office items like database and desktop
application. And also there is no requirement to store books or accounts. The data is directly
stored in the database in the hard disk of the PC.This project has been done as user friendly
software for easy handling of transaction.
The system has been tested and implemented by giving the test data and no programming skill is
required to handle the system. The features of the system are improved security, data security and
reliability. The system can be made real time or online.
This involves provided new future such as

More number of item details can be inserted into the database.


It can be integrated with the web for universal access.
E-payment
Upgrading the performance.

Even though, the system is efficient for meeting user requirements, the scope of future
enhancement can be inevitable as the user requirements changes day by day.

7.BIBLIOGRAPHY

Elias Awath, SYSTEM ANALYSIS AND DESIGN, Tata McGraw Hill Publication, Sixth
Edition,2003

S.Ramachandran,COMPUTER AIDED DESIGN, Air Walk Publication, Third Edition,2003

.Richard Fairley, SOFTWARE ENGINEERING CONCEPTS, Tata McGraw Hill


Publication, Second Edition,1997

Distributed .NET Programming in VB .NET by Tom Barnaby

Professional VB.NET, 2nd Edition by Fred Barwell, et al

The .NET Languages: A Quick Translation Guide by Brian Bischof

Programming

VB.NET:

Guide

for

Experienced

Programmers

by Gary Cornell, Jonathan Morrison

Learning Visual Basic.NET Through Applications by Clayton Crooks II

Visual Basic .NET How to Program (2nd Edition) by Harvey M. Deitel, Paul J. Deitel,
Tem R. Nieto

8. APPENDIX
A.SCREEN SHOTS
COURSE DETAILS:

HOME PAGE

COURSE DETAILS

DEPARTMENT DETAILS

STUDENT DETAILS

HOSTEL DETAILS

ROOM ALLOCATION

HOSTEL RENT DETAILS

OUTING DETAILS

ROOM ALLOGATION REPORT

HOSTEL RENT REPORT

OUTING REPORT

HOSTEL DETAILS REPORT

STUDENT DETAILS REPORT

B. SAMPLE CODING
Imports System.Data
Imports System.Data.SqlClient

Public Class LoginForm

Dim con As New SqlConnection("Data Source=GOPIKRISHNA-PC\SQLEXPRESS;Initial


Catalog=HostelManagement;Integrated Security=True;")
Dim cmd As New SqlCommand
Dim drAsSqlDataReader
Dim id As String

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


Handles btnlogin.Click

Try
If (txtusername.Text<> "" And txtpassword.Text<> "") Then
con.Open()
cmd = New SqlCommand("Select UserName,Password from UserLogin where Username='"
&txtusername.Text& "' and Password='" &txtpassword.Text& "' ", con)
dr = cmd.ExecuteReader
If (dr.Read = True) Then
HostelManagementHomePage.Show()
Me.Hide()
Else
MsgBox("Please Check Username And Password!!!", MsgBoxStyle.OkOnly =
MsgBoxStyle.OkOnly, "LoginPage Message")
End If
ElseIf (txtusername.Text = "" And txtpassword.Text<> "") Then
MsgBox("Please enter the Username!!!", MsgBoxStyle.OkOnly = MsgBoxStyle.OkOnly,
"LoginPage Message")
txtusername.Focus()
ElseIf (txtusername.Text<> "" And txtpassword.Text = "") Then
MsgBox("Please enter the Password!!!", MsgBoxStyle.OkOnly = MsgBoxStyle.OkOnly,
"LoginPage Message")
txtpassword.Focus()
ElseIf (txtusername.Text = "" And txtpassword.Text = "") Then
MsgBox("Please enter Username and Password!!!", MsgBoxStyle.OkOnly =
MsgBoxStyle.OkOnly, "LoginPage Message")
txtusername.Focus()
End If

Catch ex As Exception

End Try
End Sub
End Class

Imports System.Data
Imports System.Data.SqlClient

Public Class StudentDetails

Dim con As New SqlConnection("Data Source=GOPIKRISHNA-PC\SQLEXPRESS;Initial


Catalog=HostelManagement;Integrated Security=True;")
Dim cmd As New SqlCommand
Dim drAsSqlDataReader
Dim id As String

Sub cbxfill()
cbxID.Items.Clear()
con.Open()
cmd = New SqlCommand("select StudentID from StudentDetails", con)
dr = cmd.ExecuteReader
While (dr.Read = True)
cbxID.Items.Add(dr(0).ToString)
End While

dr.Close()
con.Close()
End Sub

Sub cbxfill1()
cbxdepartment.Items.Clear()
con.Open()
cmd = New SqlCommand("select Department from Department", con)
dr = cmd.ExecuteReader
While (dr.Read = True)
cbxdepartment.Items.Add(dr(0).ToString)
End While
dr.Close()
con.Close()
End Sub

Sub cbxfill2()
cbxcourse.Items.Clear()
con.Open()
cmd = New SqlCommand("select Course from Course", con)
dr = cmd.ExecuteReader
While (dr.Read = True)
cbxcourse.Items.Add(dr(0).ToString)
End While
dr.Close()

con.Close()
End Sub

Sub clear()
txtaddress.Text = ""
txtmobileno.Text = ""
txtregisterno.Text = ""
txtstudentname.Text = ""
cbxdepartment.Text = "SELECT"
cbxcourse.Text = "SELECT"
cbxgender.Text = "SELECT"
cbxID.Text = "ID"
btnsave.Enabled = True
btnupdate.Enabled = False
End Sub

Sub autoincrementid()
con.Open()
cmd = New SqlCommand("SELECT max(convert(int,substring(StudentID,4,9999))) + 1 from
StudentDetails", con)
dr = cmd.ExecuteReader
If dr.HasRows = True Then
dr.Read()
If dr(0).ToString = "" Then
id = "STU1"

Else
id = "STU" &dr(0).ToString
End If
End If
dr.Close()
con.Close()
End Sub

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


System.EventArgs) Handles MyBase.Load
Try
cbxfill()
cbxfill1()
cbxfill2()
btnsave.Enabled = True
btnupdate.Enabled = False
Catch ex As Exception

End Try
End Sub

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


Handles btnsave.Click
Try
con.Close()

autoincrementid()
con.Open()
cmd = New SqlCommand("insert into StudentDetails
(StudentID,StudentName,Gender,Department,Course,RegisterNo,Address,MobileNo) values ('"
& id & "','" &txtstudentname.Text& "','" &cbxgender.Text& "','" &cbxdepartment.Text& "','"
&cbxcourse.Text& "','" &txtregisterno.Text& "','" &txtaddress.Text& "','" &txtmobileno.Text&
"')", con)
cmd.ExecuteNonQuery()
con.Close()
cbxfill()
clear()
btnsave.Enabled = False
btnupdate.Enabled = True
MsgBox("Student Details Submitted Successfully", MsgBoxStyle.OkCancel, "Hostel
Management")
Catch ex As Exception

End Try
End Sub

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


Handles btnupdate.Click
Try
con.Close()
con.Open()
cmd = New SqlCommand("update StudentDetails set StudentName='" &txtstudentname.Text&
"',Gender='" &cbxgender.Text& "',Department='" &cbxdepartment.Text& "',Course='"
&cbxcourse.Text& "',RegisterNo='" &txtregisterno.Text& "',Address='" &txtaddress.Text&
"',MobileNo='" &txtmobileno.Text& "' where StudentID='" &cbxID.SelectedItem& "'", con)

cmd.ExecuteNonQuery()
con.Close()
cbxfill()
clear()
btnsave.Enabled = True
btnupdate.Enabled = False
MsgBox("Student Details Updated Successfully", MsgBoxStyle.OkCancel, "Hostel
Management")
Catch ex As Exception

End Try
End Sub

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


Handles btndelete.Click
Try
con.Close()
con.Open()
cmd = New SqlCommand("delete from StudentDetails where StudentID='"
&cbxID.SelectedItem& "'", con)
cmd.ExecuteNonQuery()
con.Close()
cbxfill()
clear()
btnsave.Enabled = True
btnupdate.Enabled = False

MsgBox("Student Details Deleted Successfully", MsgBoxStyle.OkCancel, "Hostel


Management")
Catch ex As Exception

End Try
End Sub

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


Handles btnclear.Click
Try
clear()
Catch ex As Exception

End Try
End Sub

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


Handles btnclose.Click
HostelManagementHomePage.Show()
Me.Hide()
End Sub

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


System.EventArgs) Handles cbxID.SelectedIndexChanged
Try

con.Close()

con.Open()
cmd = New SqlCommand("select * from StudentDetails where StudentID='"
&cbxID.SelectedItem& "'", con)
dr = cmd.ExecuteReader
If (dr.Read = True) Then
txtstudentname.Text = dr("StudentName").ToString
cbxgender.Text = dr("Gender").ToString
cbxdepartment.Text = dr("Department").ToString
cbxcourse.Text = dr("Course").ToString
txtregisterno.Text = dr("RegisterNo").ToString
txtaddress.Text = dr("Address").ToString
txtmobileno.Text = dr("MobileNo").ToString
End If
dr.Close()
con.Close()
btnsave.Enabled = False
btnupdate.Enabled = True
Catch ex As Exception

End Try
End Sub
End Class

You might also like