0% found this document useful (0 votes)
248 views18 pages

Hotel Management System Source Code - C#, JAVA, PHP, Programming, Source Code

This document provides details about a hotel management system project created in Visual Basic.NET with a MySQL database. The project includes 4 classes and 4 forms to manage hotel clients, rooms, and reservations. Key features include a login form, main menu form, client management form with add/edit/delete functions, room management form with room types and availability, and reservation management. The source code for the full project is available for download.

Uploaded by

Benny Bav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
248 views18 pages

Hotel Management System Source Code - C#, JAVA, PHP, Programming, Source Code

This document provides details about a hotel management system project created in Visual Basic.NET with a MySQL database. The project includes 4 classes and 4 forms to manage hotel clients, rooms, and reservations. Key features include a login form, main menu form, client management form with add/edit/delete functions, room management form with room types and availability, and reservation management. The source code for the full project is available for download.

Uploaded by

Benny Bav
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 18

VB.

Net Hotel Management System Source Code

Hotel
1 Management System In Visual Basic.Net And
MySQL Database With Source Code
Shares

(https://1bestcsharp.sellfy.store/p/vbnet-hotel-management-system-source-code/)

in this visual basic .net project tutorial we will see how to create a simple desktop application
with winforms to manage hotel reservations using vb.net programming language and mysql
database.

goals of this project:


- give students / curious persons an example so they can learn from.
- give beginners a step by step project so they can create their own.
- help people to learn vb.net by making projects.
- sharing knowledge with others.

tools:
- visual basic .net programming language.
- visual studio express 2013.
- mysql database.
- xampp server.
- phpmyadmin.
Watch The Full Project Tutorial

1
Shares
VB.Net Project Tutorial for Beginners - Full VB.Net Programming…
Programming…

if you want the source code click on the download button below

(https://1bestcsharp.sellfy.store/p/vbnet-hotel-management-system-source-code/)

in this project we will create 4 classes and 4 forms:


- classes:
* CONNECTION > create the connection with mysql database.
* ClIENT > where we will add functions for the client.
* ROOMS > where we will add functions for the room.
* RESERVATIONS > where we will add functions for the reservation.
- forms:
* Login > where the user can enter his username to login.
* Manage Clients > where we will manage the hotel client informations.
* Manage Rooms > where we will mange the hotel's rooms.
* Manage Reservations > where we will add functions for the reservation.
> and you need to download mysql connector from here ->
https://dev.mysql.com/downloads/connector/net/8.0.html

1
Shares
1 - The Login Form
before getting access to the main form the user need to login first by entering his
username
1
and password.
and we will check if the username/password textbox are empty.
and if the user enter the wrong username or password or this user doesn't exists at
all.
The Login Button:
Private Sub ButtonLogin_Click(sender As Object, e As EventArgs) Handles ButtonLogin.Click

Dim connection As New CONNECTION()


Dim adapter As New MySqlDataAdapter()
Dim command As New MySqlCommand()
Dim table As New DataTable()
Dim username As String = TextBoxUsername.Text
Dim password As String = TextBoxPassword.Text
Dim selectQuery As String = "SELECT * FROM `users` WHERE `username`=@un AND
`password`=@pass"

command.CommandText = selectQuery
command.Connection = connection.getConnection()

command.Parameters.Add("@un", MySqlDbType.VarChar).Value = username


command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password

adapter.SelectCommand = command
adapter.Fill(table)

If table.Rows.Count > 0 Then

Dim mainForm As New MainForm()


mainForm.Show()
Me.Hide()

Else

MessageBox.Show("Invalid Username Or Password", "Login Error", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End If

End Sub
1
Shares

(https://1.bp.blogspot.com/-
rJuQXooMChI/XK8k_3kwxBI/AAAAAAAAF2M/yNs_uzjBo_crA5RqCiC8AcwtLIc3YAajQCLcBGAs/s1600/vb.net
%2Bhotel%2Bmanagement%2Bsystem%2B-%2Blogin%2Bform.PNG)

if the user enter the correct username and password we will show him the main form.
2 - The Main Form
this is a quick and easy from with a menu created with a panel and labels to take the
user to the selected form on label click.

Private Sub LabelMClients_Click(sender As Object, e As EventArgs) Handles LabelMClients.Click

Dim manage_Cl_Form As New ManageClientsForm()


manage_Cl_Form.ShowDialog()

End Sub

Private Sub LabelMRooms_Click(sender As Object, e As EventArgs) Handles LabelMRooms.Click


Dim manage_Rm_Form As New ManageRoomsForm()
manage_Rm_Form.ShowDialog()

End Sub

1
Private Sub LabelMReservastions_Click(sender As Object, e As EventArgs) Handles
Shares

LabelMReservastions.Click
1
Dim manage_Rv_Form As New ManageReservationsForm()
manage_Rv_Form.ShowDialog()

End Sub

(https://2.bp.blogspot.com/-67Xy6nnGfME/XK8oc-

dZh2I/AAAAAAAAF2Y/jNVOL0aRCIY9nePNrxk6X_tFnCSCx2J9ACLcBGAs/s1600/vb.net%2Bhotel%2Bmanag
ement%2Bsystem%2B-%2Bmain%2Bform.PNG)

3 - The Manage Hotel Clients Form

this form allow the user to manage the hotel clients.


this form contains a datagridview filled with all clients data.
this form call functions from the class "CLIENT".

- Add New Client Button

Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.Click

Dim fname As String = TextBoxFname.Text


Dim lname As String = TextBoxLname.Text
Dim phone As String = TextBoxPhone.Text
Dim email As String = TextBoxEmail.Text

If fname.Trim().Equals("") Or lname.Trim().Equals("") Or phone.Trim().Equals("") Then

MessageBox.Show("Required First & Last Name, Phone", "Missing Information",


1
MessageBoxButtons.OK, MessageBoxIcon.Error)
Shares

1
Else

If client.addClient(fname, lname, phone, email) Then

MessageBox.Show("New Client Added Successfully", "Add Client", MessageBoxButtons.OK,


MessageBoxIcon.Information)
DataGridView1.DataSource = client.getAllClients()

Else

MessageBox.Show("Client Not Added", "Add Client", MessageBoxButtons.OK,


MessageBoxIcon.Warning)

End If

End If

End Sub

- Edit The Selected Client Button

Private Sub ButtonEdit_Click(sender As Object, e As EventArgs) Handles ButtonEdit.Click

Dim fname As String = TextBoxFname.Text


Dim lname As String = TextBoxLname.Text
Dim phone As String = TextBoxPhone.Text
Dim email As String = TextBoxEmail.Text

If TextBoxId.Text.Trim().Equals("") Then

MessageBox.Show("Select The User You Want to Edit", "Missing ID", MessageBoxButtons.OK,


MessageBoxIcon.Error)

Else
If fname.Trim().Equals("") Or lname.Trim().Equals("") Or phone.Trim().Equals("") Then

MessageBox.Show("Required First & Last Name, Phone", "Missing Information",


MessageBoxButtons.OK, MessageBoxIcon.Error)
1
Shares

Else
1
Dim id As Integer = Convert.ToInt32(TextBoxId.Text)

If client.editClient(id, fname, lname, phone, email) Then

MessageBox.Show("Client Updated Successfully", "Edit Client", MessageBoxButtons.OK,


MessageBoxIcon.Information)
DataGridView1.DataSource = client.getAllClients()

Else

MessageBox.Show("Client Not Updated", "Edit Client", MessageBoxButtons.OK,


MessageBoxIcon.Warning)

End If

End If

End If

End Sub

- Delete The Selected Client Button

Private Sub ButtonRemove_Click(sender As Object, e As EventArgs) Handles ButtonRemove.Click

If TextBoxId.Text.Trim().Equals("") Then

MessageBox.Show("Enter The Client Id", "Missing ID", MessageBoxButtons.OK,


MessageBoxIcon.Error)

Else
Dim id As Integer = Convert.ToInt32(TextBoxId.Text)
If client.removeClient(id) Then

MessageBox.Show("Client Deleted Successfully", "Delte Client", MessageBoxButtons.OK,


MessageBoxIcon.Information)
1
Shares DataGridView1.DataSource = client.getAllClients()

1
' clear boxes
TextBoxId.Text = ""
TextBoxFname.Text = ""
TextBoxLname.Text = ""
TextBoxPhone.Text = ""
TextBoxEmail.Text = ""

Else

MessageBox.Show("Client Not Deleted", "Delete Client", MessageBoxButtons.OK,


MessageBoxIcon.Warning)

End If

End If

End Sub

(https://3.bp.blogspot.com/-
bRbMtsZPwmI/XK8wGTy0jSI/AAAAAAAAF2k/yLUkTV9tz1w3x0nJnqbhb5PLAY4qX5WbwCLcBGAs/s1600/v
b.net%2Bhotel%2Bmanagement%2Bsystem%2B-%2Bmanage%2Bclients%2Bform.PNG)

4 - The Manage Hotel Rooms Form


1
Shares

here the user can add a new room to the hotel system.
when
1 you add a new room you need to select the type of room (single, double, family,
suite).

and like the client form you can view all rooms in a datagridview + how many rooms
this hotel have, and add, edit, remove the selecte one + a combobx populated with all
room's categories.

(https://4.bp.blogspot.com/-

LZX0gbTHhpU/XK8zm0WExdI/AAAAAAAAF2w/n1Fr8sC-
u3cLDrcKanTNAF6w4N00NmUnQCLcBGAs/s1600/vb.net%2Bhotel%2Bmanagement%2Bsystem%2B-
%2Brooms%2Btypes.png)

- Add New Room Button


when you add a new room the "reserved" column will be set to no by default.

Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.Click

Try

Dim type As Integer = Convert.ToInt32(ComboBoxType.SelectedValue)


Dim phone As String = TextBoxPhone.Text
Dim reserved As String = ""

If RadioButtonYes.Checked Then

reserved = "Yes"

ElseIf RadioButtonNo.Checked Then


reserved = "No"

End If

If TextBoxNumber.Text.Trim().Equals("") Or TextBoxPhone.Text.Trim().Equals("") Then


1
Shares

MessageBox.Show("Make Sure to Enter The Room Number and The Phone Number", "Empty
Fields",
1
MessageBoxButtons.OK, MessageBoxIcon.Error)

Else

Dim number As Integer = Convert.ToInt32(TextBoxNumber.Text)

If room.addRoom(number, type, phone, reserved) Then

MessageBox.Show("Room Added Successfully", "Add Room", MessageBoxButtons.OK,


MessageBoxIcon.Information)
DataGridView1.DataSource = room.getAllRooms()
' display the number of rooms on the LabelRoomsCount
LabelRoomsCount.Text = room.getAllRooms().Rows.Count.ToString() + " Room"

Else

MessageBox.Show("Room Not Added", "Add Room", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End If

End If

Catch ex As Exception

MessageBox.Show(ex.Message, "Duplicate Room Number", MessageBoxButtons.OK,


MessageBoxIcon.Warning)

End Try

End Sub

- Edit The Selected Room Button


Private Sub ButtonEdit_Click(sender As Object, e As EventArgs) Handles ButtonEdit.Click

Try

Dim type As Integer = Convert.ToInt32(ComboBoxType.SelectedValue)


1
Shares Dim phone As String = TextBoxPhone.Text
Dim reserved As String = ""
1
If RadioButtonYes.Checked Then

reserved = "Yes"

ElseIf RadioButtonNo.Checked Then

reserved = "No"

End If

If TextBoxNumber.Text.Trim().Equals("") Or TextBoxPhone.Text.Trim().Equals("") Then

MessageBox.Show("Make Sure to Enter The Room Number and The Phone Number", "Empty
Fields", MessageBoxButtons.OK, MessageBoxIcon.Error)

Else

Dim number As Integer = Convert.ToInt32(TextBoxNumber.Text)

If room.editRoom(number, type, phone, reserved) Then

MessageBox.Show("Room Updated Successfully", "Edit Room", MessageBoxButtons.OK,


MessageBoxIcon.Information)
DataGridView1.DataSource = room.getAllRooms()

Else

MessageBox.Show("Room Not Updated", "Edit Room", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End If

End If
Catch ex As Exception

MessageBox.Show(ex.Message)

End Try
1
Shares

End Sub
1
- Delete The Selected Room Button

Private Sub ButtonRemove_Click(sender As Object, e As EventArgs) Handles ButtonRemove.Click

Try

Dim number As Integer = Convert.ToInt32(TextBoxNumber.Text)

If room.removeRoom(number) Then

MessageBox.Show("Room Deleted Successfully", "Delete Room", MessageBoxButtons.OK,


MessageBoxIcon.Information)
DataGridView1.DataSource = room.getAllRooms()

' reset and clear fields


TextBoxNumber.Text = ""
ComboBoxType.SelectedIndex = 0
TextBoxPhone.Text = ""
RadioButtonYes.Checked = True

' display the number of rooms on the LabelRoomsCount


LabelRoomsCount.Text = room.getAllRooms().Rows.Count.ToString() + " Room"

Else

MessageBox.Show("Room Not Deleted", "Delete Room", MessageBoxButtons.OK,


MessageBoxIcon.Warning)

End If

Catch ex As Exception

MessageBox.Show(ex.Message)
End Try

End Sub

1
Shares

(https://2.bp.blogspot.com/-ukUp8O1IH9M/XK828l-sj1I/AAAAAAAAF28/jPuREJXMsKoBtHV4_ArD-
HCTZJSSuB8WwCLcBGAs/s1600/vb.net%2Bhotel%2Bmanagement%2Bsystem%2B-
%2Bmanage%2Brooms%2Bform.PNG)

5 - The Manage Hotel Reservations Form


This form allow the user to manage the clients room reservations.
to create a reservation you need: 1) enter the reservation id, 2) select the client who
will reserve, 3) you need to select the room where the client will stay.

when you add a new reservation the system will check:


- if the user enter all required informations.
- if the user enter a date in that is equal or come after the current day date.
- if the user enter a date out that is equal or come after the date in.

- Add a New Reservation Button

Private Sub ButtonAdd_Click(sender As Object, e As EventArgs) Handles ButtonAdd.Click

Try

Dim clientId As Integer = Convert.ToInt32(TextBoxClientID.Text)


Dim roomNumber As Integer =
Convert.ToInt32(ComboBoxRoomNumber.SelectedValue.ToString())
Dim dateIn As Date = DateTimePickerIN.Value
Dim dateOut As Date = DateTimePickerOUT.Value

If DateTime.Compare(dateIn.Date, DateTime.Now.Date) < 0 Then

1
Shares MessageBox.Show("The Date In Must be = Or > to Today Date", "Invalid Date IN",
MessageBoxButtons.OK, MessageBoxIcon.Error)
1
ElseIf DateTime.Compare(dateOut.Date, dateIn.Date) < 0 Then

MessageBox.Show("The Date Out Must be = Or > to The Date In", "Invalid Date OUT",
MessageBoxButtons.OK, MessageBoxIcon.Error)

Else

If reservation.addReservation(roomNumber, clientId, dateIn, dateOut) Then

MessageBox.Show("Reservation Added Successfully", "Add Reservation",


MessageBoxButtons.OK, MessageBoxIcon.Information)
DataGridView1.DataSource = reservation.getAllReservations()
' we need to refresh the combobox to show only the not reserved rooms
ComboBoxType.DataSource = room.getAllRoomsType()

Else

MessageBox.Show("Reservation NOT Added", "Add Reservation", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End If

End If

Catch ex As Exception

MessageBox.Show(ex.Message, "Add Reservation Error", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End Try

End Sub
- Edit The Selected Reservation Button

Private Sub ButtonEdit_Click(sender As Object, e As EventArgs) Handles ButtonEdit.Click

Try
1
Shares

Dim reservationId As Integer = Convert.ToInt32(TextBoxReservationID.Text)


1
Dim clientId As Integer = Convert.ToInt32(TextBoxClientID.Text)
Dim roomNumber As Integer =
Convert.ToInt32(DataGridView1.CurrentRow.Cells(2).Value.ToString())
Dim dateIn As Date = DateTimePickerIN.Value
Dim dateOut As Date = DateTimePickerOUT.Value

If DateTime.Compare(dateIn.Date, DateTime.Now.Date) < 0 Then

MessageBox.Show("The Date In Must be = Or > to Today Date", "Invalid Date IN",


MessageBoxButtons.OK, MessageBoxIcon.Error)

ElseIf DateTime.Compare(dateOut.Date, dateIn.Date) < 0 Then

MessageBox.Show("The Date Out Must be = Or > to The Date In", "Invalid Date OUT",
MessageBoxButtons.OK, MessageBoxIcon.Error)

Else

If reservation.editReservation(reservationId, roomNumber, clientId, dateIn, dateOut) Then

MessageBox.Show("Reservation Updated Successfully", "Edit Reservation",


MessageBoxButtons.OK, MessageBoxIcon.Information)
DataGridView1.DataSource = reservation.getAllReservations()

Else

MessageBox.Show("Reservation NOT Updated", "Edit Reservation", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End If

End If

Catch ex As Exception
MessageBox.Show(ex.Message, "Edit Reservation Error", MessageBoxButtons.OK,
MessageBoxIcon.Error)

End Try

1
SharesEnd Sub

- 1Remove The Selected Reservation Button

Private Sub ButtonRemove_Click(sender As Object, e As EventArgs) Handles ButtonRemove.Click

Try

Dim reservationId As Integer = Convert.ToInt32(TextBoxReservationID.Text)


Dim roomNumber As Integer =
Convert.ToInt32(DataGridView1.CurrentRow.Cells(2).Value.ToString())

If reservation.removeReservation(reservationId, roomNumber) Then

MessageBox.Show("Reservation Deleted Successfully", "Remove Reservation",


MessageBoxButtons.OK, MessageBoxIcon.Information)
DataGridView1.DataSource = reservation.getAllReservations()

Else

MessageBox.Show("Reservation NOT Deleted", "Remove Reservation", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End If

Catch ex As Exception

MessageBox.Show(ex.Message, "Remove Reservation Error", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End Try

End Sub
1
Shares

(https://2.bp.blogspot.com/-Iqi6MMh-
dKI/XK9AZuHHXHI/AAAAAAAAF3I/b6dp684UPswNg0SDBkikqlhWxe2JhhxHACLcBGAs/s1600/vb.net%2Bh
otel%2Bmanagement%2Bsystem%2B-%2Bmanage%2Breservations%2Bform.PNG)

if you want the source code click on the download button below

(https://1bestcsharp.sellfy.store/p/vbnet-hotel-management-system-source-code/)

Delivery: Instant Source Code Download.

More VB.NET Projects:


- VB.Net Contact Information Management System Source Code
(http://1bestcsharp.blogspot.com/2018/08/vbnet-contact-management-system-source.html)
- VB.Net Inventory System Source Code (https://1bestcsharp.blogspot.com/2018/04/vbnet-inventory-
system-source-code.html)
- VB.Net Students Management System Source Code (https://1bestcsharp.blogspot.com/2019/04/vbnet-
students-information-system-source-code.html)
- VB.Net Real Estate Management System Source Code
(https://1bestcsharp.blogspot.com/2019/07/vbnet-real-estate-management-system.html)
- Download All VB.Net Projects Source Code (https://1bestcsharp.blogspot.com/p/vbnet-projects-source-
code-bundle.html)

1
Shares

You might also like