0% found this document useful (0 votes)
37 views44 pages

Hotel Management System VB Final PDF

bla

Uploaded by

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

Hotel Management System VB Final PDF

bla

Uploaded by

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

Hotel Management System

* Abstract
The system aims at the maintenance and management of the
different Hotels that are available in the different parts of the
world. It mainly takes care of the Hotel management at the core
area of the database. The system provides the information regarding
the different Hotels that are available and their status specific to
availability. The guests can visit the site and register themselves
with the required information that is expected by the system. Each
registered guest can raise a request for the unit bookings. The
Guests are scheduled with the information of the availability of the
units for they have requested the time.
The total front end was dominated using HTML standards applied
with the dynamism of JAVA server pages. The communicating client
was designed using servlet and JSP’s. At all proper levels high care
was taken to check that the system manages the date consistency
with proper business validations. The database connectivity was
planned using the Java Data Base Connectivity , the authorization
and authorization was cross checked at all stages. The user level
accessibility has been restricted into two zones the administrative
and the normal user zone.
Introduction
The entire project has been develped keeping in view of the
Distributed client server computing technology in mind.The
specification have been normalized upto 3NF to eliminate all the
anomalies that may arise due to the database transactions that are
executed by the actual administration and users.The user interfaces
are browser specific to give distributed accessability for the overall
system.The internal database has beeb selected as Oracle 11g.
The basic constructs of the tablespaces,clusters and ridexes have
been exploited to provide higher consistency and reliability for the
data storage. The oracle 11g was a choice as it provides the
constructs of high level reliabiity and security.The total front end
was dominated using HTML standards applied with the dynamism of
JAVA server pages.
Thecommunicatin client was designed using servlets. At all proper
levels high care was taken to check that the system manages the
date consistency with proper business validations.The database
connectivity was planned using the Java DataBase Connectivity,the
authorization and authorization was cross checked at all stages.The
user level accessabiity has been restricted into two zones the
administrative and the normal user zone.
Project Design Description

Purpose: The main purpose for preparing this document is to


give a general insight into the analysis and requirements of
the existing system or situation and for determining the
operating characteristics of the system.
Scope: This Document plays a vital role in the development
life cycle (SDLC) As it describes the complete requirement of
the system. It is meant for use by the developers and will be
the basic during testing phase. Any changes made to the
requirements in the future will have to go through formal
change approval process.
Functional Requirements: Inputs: The major inputs for
Integration of Web based Accommodation Upholding
Maintenance System can be categorized module -wise.
Basically all the information is managed by the software and
in order to access the information one has to produce one's
identity by entering the user-id and password. Every user
has their own domain of access beyond which the access is
dynamically refrained rather denied. Output: The major
outputs of the system are tables and reports. Tables are
created dynamically to meet the requirements on demand.
Reports, as it is obvious ,carry the gist of the whole
information that flows across the institution. This application
must be able to produce output at different modules for
different inputs.

Performance Requirements: Performance is measured in terms


of reports generated weekly and monthly. Intended Audience
and Reading Suggestions The document is prepared keeping is
view of the academic constructs of my Bachelors Degree /
Masters Degree from university as partial fulfillment of my
academic purpose the document specifies the general procedure
that that has been followed by me, while the system was
studied and developed.
Scope of The Development Project

Database Tier: The concentration is applied by adopting the


Oracle 9i Enterprise versions. SQL is taken as the standard
query language. The overall business rules are designed by
using the power of PL/SQL components like stored procedures
stored functions and database triggers.
User Tier: The use interface is developed is a browses
specific environment to have distributed architecture. The
components are designed using HTML standards and Java
server pages power the dynamic of the page design.
Data Base Connectivity Tier: The communication architecture
is designed by concentrated on the standards of servlets and
JSP’s. The database connectivity is established using the Java
Database connectivity.
Software Requirement Specification

* Required Hardware
o Pentium IV Processor.
o 512 MB RAM.
o 20 GB Hard Disk space.
o Ethernet card with an Internet and Internet zone.
* Required Software
o Windows 8 operating system.
o Internet explorer11 and Netscape navigator.
o Oracle 11g.
o Servlets
o JSP
o TCP/IP Protocol suite.

* Modules Description Number of Modules:


• Accommodation Information Module
• Units Information Module.
• Bookings Information Module.
• Guests Information Module.
• Facilities Information Module
Windows Form Design & Program Code

Imports System.Data.OleDb
Public Class frmLogin
Private Sub OK_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles OK.Click
If Trim(UsernameTextBox.Text) = "" Or
Trim(PasswordTextBox.Text) = "" Then
MsgBox("Please Enter Both Fields!", vbInformation,
"Note")
Else
con.Open()
Dim sql = "SELECT * FROM tblUser WHERE username
= '" & SafeSqlLiteral(UsernameTextBox.Text, 2) & "' AND password
= '" & SafeSqlLiteral(PasswordTextBox.Text, 2) & "'"
Dim cmd = New OleDbCommand(sql, con)
Dim dr As OleDbDataReader = cmd.ExecuteReader
Try
If dr.Read = False Then
MsgBox("Login Failed!", vbCritical, "Note")
Else
MsgBox("Login Successful!", vbInformation,
"Note")
frmMain.status.Items(0).Text = "Login as : " &
Trim(UsernameTextBox.Text)
Dim datenow As Date = Now
frmMain.status.Items(2).Text = "Date and Time :
" & datenow.ToString("MMMM dd, yyyy") & " " & TimeOfDay
con.Close()
Me.Hide()
frmMain.ShowDialog()
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End If
End Sub
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Cancel.Click
Me.Close()
End
End Sub
Private Sub frmLogin_Load(sender As System.Object, e As
System.EventArgs) Handles MyBase.Load
End Sub
End Class
Public Class frmMain
Private Sub frmMain_FormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
Dim exit_app As String = MsgBox("Exit application?",
vbQuestion + vbYesNo, "Exit")
If exit_app = vbNo Then
e.Cancel = True
Else
End
End If
End Sub
Private Sub frmMain_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub toolbarCheckIn_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles toolbarCheckIn.Click
frmCheckin.ShowDialog()
End Sub
Private Sub ToolStripButton13_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ToolStripButton13.Click
Dim exit_app As String = MsgBox("Exit application?",
vbQuestion + vbYesNo, "Exit")
If exit_app = vbYes Then
End
End If
End Sub
Private Sub ToolStripButton12_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ToolStripButton12.Click
Dim out_app As String = MsgBox("Logout from
application?", vbQuestion + vbYesNo, "Logout")
If out_app = vbYes Then
con.Close()
Me.Hide()
End If
End Sub

Private Sub ToolStripButton10_Click(ByVal sender As System.Object,


ByVal e As System.EventArgs) Handles ToolStripButton10.Click
frmGuest.ShowDialog()
End Sub
Private Sub toolbarRoom_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles toolbarRoom.Click
frmRoom.ShowDialog()
End Sub
Private Sub toolbarReserve_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles toolbarReserve.Click
frmReserve.ShowDialog()
End Sub
Private Sub NewCheckInToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
NewCheckInToolStripMenuItem.Click
frmCheckin.ShowDialog()
End Sub
Private Sub NewReservationToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles
NewReservationToolStripMenuItem.Click
frmReserve.ShowDialog()
End Sub
Private Sub LogoutToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
LogoutToolStripMenuItem.Click
Dim out_app As String = MsgBox("Logout from
application?", vbQuestion + vbYesNo, "Logout")
If out_app = vbYes Then
Me.Hide()

End If
End Sub
Private Sub ExitToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub toolbarCheckOut_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
toolbarCheckOut.Click
frmCheckout.ShowDialog()
End Sub
Private Sub SettingsToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
SettingsToolStripMenuItem.Click
End Sub
Private Sub FileToolStripMenuItem1_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
FileToolStripMenuItem1.Click
End Sub
Private Sub CheckedInListToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
CheckedInListToolStripMenuItem.Click
frmCheckinListMonitor.ShowDialog()
End Sub
Private Sub RoomStatusToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
RoomStatusToolStripMenuItem.Click

frmRoomListMonitor.ShowDialog()
End Sub
Private Sub ReservedListToolStripMenuItem_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
ReservedListToolStripMenuItem.Click
frmReserveListMonitor.ShowDialog()
End Sub
Private Sub CheckedOutListToolStripMenuItem_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles
CheckedOutListToolStripMenuItem.Click
frmCheckOutList.ShowDialog()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Timer1.Tick
Dim datenow As Date = Now
status.Items(2).Text = "Date and Time : " &
datenow.ToString("MMMM dd, yyyy") & " " & TimeOfDay
End Sub
Private Sub DiscountToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DiscountToolStripMenuItem.Click
frmDiscount.ShowDialog()
End Sub
Private Sub RoomToolStripMenuItem_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
RoomToolStripMenuItem.Click
frmRoom.ShowDialog()
frmRoom.TabPage2.Select()
End Sub

Private Sub GuestToolStripMenuItem_Click(ByVal sender As


System.Object, ByVal e As System.EventArgs) Handles
GuestToolStripMenuItem.Click
frmGuest.ShowDialog()
End Sub
Private Sub ToolStrip1_ItemClicked(sender As System.Object, e
As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles
ToolStrip1.ItemClicked
End Sub
Private Sub SettingsToolStripMenuItem1_Click(sender As
System.Object, e As System.EventArgs) Handles
SettingsToolStripMenuItem1.Click
End Sub
Private Sub ToolStripMenuItem2_Click(sender As System.Object,
e As System.EventArgs) Handles ToolStripMenuItem2.Click
End Sub
Private Sub ToolStripMenuItem1_Click(sender As System.Object,
e As System.EventArgs) Handles ToolStripMenuItem1.Click
End Sub
Private Sub MenuStrip1_ItemClicked(sender As System.Object, e
As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles
MenuStrip1.ItemClicked
End Sub
Imports System.Data.OleDb
Public Class frmCheckin
Dim guestID, roomID, trans_ID As Integer
Private Sub frmCheckin_FormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
Dim a As String = MsgBox("Cancel Transaction?",
vbQuestion + vbYesNo, "Cancel")
If a = vbNo Then
e.Cancel = True
Else
clear_text()
End If
End Sub
Private Sub frmCheckin_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
clear_text()
Dim time As DateTime = DateTime.Now
Dim format As String = "MM/d/yyyy"
txtCheckInDate.Text = time.ToString(format)
dtCheckOutDate.Text = Now.AddDays(1D)
transID()
pop_discount()
display_checkin()
End Sub

Public Sub transID()


con.Open()
Dim dt As New DataTable("tblTransaction")
rs = New OleDbDataAdapter("SELECT * FROM
tblTransaction ORDER BY TransID DESC", con)
rs.Fill(dt)
If dt.Rows.Count = 0 Then
txtTransID.Text = "TransID - 0001"
Else
Dim value As Integer = Val(dt.Rows(0).Item("TransID"))
value = value + 1
txtTransID.Text = "TransID - " &
value.ToString("0000")
trans_ID = value
End If
rs.Dispose()
con.Close()
End Sub
Private Sub bttnCheckIn_Click_1(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles bttnCheckIn.Click
Dim children As Integer = Val(txtChildren.Text)
Dim adult As Integer = Val(txtAdults.Text)
Dim advance As Integer = Val(txtAdvance.Text)
Dim discount As Integer = Val(lblDiscountID.Text)
Dim reserve As String = "0"
Dim remarks As String = "Checkin"
Dim stat As String = "Active"
If lblGuestID.Text = "GuestID" Or lblGuestID.Text = Nothing Or
txtRoomNumber.Text = Nothing Or Val(children + adult) = Nothing
Or advance = Nothing Or discount = Nothing Then
MsgBox("Please Fill All Fields", vbInformation, "Note")
Else
If Val(Val(txtSubTotal.Text) * 0.5) >
Val(txtAdvance.Text) Then
MsgBox("Ops")
Exit Sub
End If
Dim a As String = MsgBox("Confirm Checkin
Transaction?", vbQuestion + vbYesNo, "Check In")
If a = vbYes Then
con.Open()
Dim checkin As New OleDbCommand("INSERT INTO
tblTransaction(GuestID,RoomNum,CheckInDate,CheckOutDate,NoOfChild,
NoOfAdult,AdvancePayment,DiscountID,Remarks,Status) values ('" &
lblGuestID.Text &
"','" &
txtRoomNumber.Text
& "','" &
txtCheckInDate.Text
& "','" &
dtCheckOutDate.Text
& "','" &
txtChildren.Text &
"','" &
txtAdults.Text &
"','" &
txtAdvance.Text &
"','" &
lblDiscountID.Text &
"','" &
remarks & "','" &
stat & "')", con)
checkin.ExecuteNonQuery()
Dim update_guest As New OleDbCommand("UPDATE
tblGuest SET Remarks = 'Checkin' WHERE ID = " & lblGuestID.Text
& "", con)
update_guest.ExecuteNonQuery()

Dim update_room As New OleDbCommand("UPDATE tblRoom SET


Status = 'Occupied' WHERE RoomNumber = " &
txtRoomNumber.Text & "", con)
update_room.ExecuteNonQuery()
If Val(txtSubTotal.Text) < Val(txtAdvance.Text) Or
Val(txtSubTotal.Text) = Val(txtAdvance.Text) Then
MsgBox("Guest Successfully Checkin! " &
"Change: Php " & Val(Val(txtAdvance.Text) -
Val(txtSubTotal.Text)).ToString("00.00"), vbInformation, "Check In")
Dim change As String = MsgBox("Return
change to customer?", vbQuestion + vbYesNo, "Change")
If change = vbYes Then
Dim update_trans As New
OleDbCommand("UPDATE tblTransaction SET AdvancePayment = "
& Val(txtSubTotal.Text) & " WHERE TransID = " & trans_ID & "",
con)
update_trans.ExecuteNonQuery()
End If
Else
MsgBox("Guest Successfully Checkin!",
vbInformation, "Check In")
End If
clear_text()
con.Close()
transID()
display_checkin()
End If
End If
End Sub
Private Sub bttnCancel_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles bttnCancel.Click
clear_text()
End Sub
Private Sub dtCheckOutDate_ValueChanged_1(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
dtCheckOutDate.ValueChanged
Dim T As TimeSpan = dtCheckOutDate.Value - Now
If T.Days < 1 Then
dtCheckOutDate.Text = Now.AddDays(1D)
txtDaysNumber.Text = "1"
Else
txtDaysNumber.Text = T.Days + 1
End If
lblTotal.Text = Val(txtRoomRate.Text) *
Val(txtDaysNumber.Text)
txtSubTotal.Text = Val(txtRoomRate.Text) *
Val(txtDaysNumber.Text)
End Sub
Private Sub bttnSearchGuest_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
bttnSearchGuest.Click
frmSelectGuest.ShowDialog()
End Sub
Private Sub bttnSearchRoom_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
bttnSearchRoom.Click
frmSelectRoom.ShowDialog()
End Sub
Private Sub txtRoomRate_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtRoomRate.TextChanged
lblTotal.Text = Val(txtRoomRate.Text) *
Val(txtDaysNumber.Text)
txtSubTotal.Text = (Val(txtRoomRate.Text) *
Val(txtDaysNumber.Text)).ToString("00.00")
End Sub
Private Sub bttnAddAdult_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles bttnAddAdult.Click
Dim tao As Integer
tao = Val(txtAdults.Text) + Val(txtChildren.Text)
If tao = Val(lblNoOfOccupancy.Text) Then
Else
txtAdults.Text = Val(txtAdults.Text) + 1
End If
End Sub
Private Sub bttnAddChildren_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles bttnAddChildren.Click
Dim tao As Integer
tao = Val(txtAdults.Text) + Val(txtChildren.Text)
If tao = Val(lblNoOfOccupancy.Text) Then
Else
txtChildren.Text = Val(txtChildren.Text) + 1
End If
End Sub
Private Sub bttnSubAdult_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles bttnSubAdult.Click
If Val(txtAdults.Text) = 0 Then
txtAdults.Text = Val(txtAdults.Text)
Else
txtAdults.Text = Val(txtAdults.Text) - 1
End If
End Sub
Private Sub bttnSubChildren_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
bttnSubChildren.Click
If Val(txtChildren.Text) = 0 Then
txtChildren.Text = Val(txtChildren.Text)
Else
txtChildren.Text = Val(txtChildren.Text) - 1
End If
End Sub
Private Sub pop_discount()
con.Open()
Dim dt As New DataTable
rs = New OleDbDataAdapter("SELECT * FROM tblDiscount",
con)
rs.Fill(dt)
cboDiscount.Items.Clear()
Dim i As Integer
For i = 0 To dt.Rows.Count - 1
cboDiscount.Items.Add(dt.Rows(i).Item("DiscountType"))
Next
rs.Dispose()
con.Close()
End Sub
Private Sub cboDiscount_TextChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles cboDiscount.TextChanged
con.Open()
Dim dt As New DataTable
rs = New OleDbDataAdapter("SELECT * FROM tblDiscount
WHERE DiscountType = '" & cboDiscount.Text & "'", con)
rs.Fill(dt)
lblDiscountID.Text = dt.Rows(0).Item("ID")
lblDiscountRate.Text = dt.Rows(0).Item("DiscountRate")
'lblTotal.Text = Val(txtSubTotal.Text) - (Val(txtSubTotal.Text)
* Val(lblDiscountRate.Text))
txtSubTotal.Text = (Val(lblTotal.Text) - (Val(lblTotal.Text) *
Val(lblDiscountRate.Text))).ToString("00.00")
lblAdvancePayment.Text = "Advance payment must be
atleast Php " & (Val(txtSubTotal.Text) * 0.5).ToString("00.00")
rs.Dispose()
con.Close()
End Sub
Private Sub txtAdvance_KeyPress(ByVal sender As Object, ByVal e
As System.Windows.Forms.KeyPressEventArgs) Handles
txtAdvance.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar
<> "." Then
'cancel keys
e.Handled = True
End If
End Sub
Private Sub txtAdvance_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtAdvance.TextChanged
If Val(txtSubTotal.Text) < Val(txtAdvance.Text) Or
Val(txtSubTotal.Text) = Val(txtAdvance.Text) Then
txtTotal.Text = "0.00"
Else
txtTotal.Text = (Val(txtSubTotal.Text) -
Val(txtAdvance.Text)).ToString("00.00")
End If
End Sub
Private Sub clear_text()
txtGuestName.Clear()
txtRoomNumber.Clear()
txtRoomType.Clear()
txtRoomRate.Clear()
txtChildren.Text = "0"
txtAdults.Text = "0"
cboDiscount.Refresh()
txtAdvance.Clear()
txtSubTotal.Clear()
txtTotal.Clear()
lblDiscountID.Text = ""
lblDiscountRate.Text = ""
lblGuestID.Text = ""
lblAdvancePayment.Text = ""
lblNoOfOccupancy.Text = "0"
Dim time As DateTime = DateTime.Now
Dim format As String = "MM/d/yyyy"
txtCheckInDate.Text = time.ToString(format)
dtCheckOutDate.Text = Now.AddDays(1D)
End Sub
Private Sub display_checkin()
con.Open()
Dim Dt As New DataTable("tblGuest")
Dim rs As OleDbDataAdapter
rs = New OleDbDataAdapter("Select * from tblTransaction,
tblGuest, tblDiscount, tblRoom WHERE tblTransaction.GuestID =
tblGuest.ID AND tblTransaction.DiscountID = tblDiscount.ID AND
tblTransaction.RoomNum = tblRoom.RoomNumber AND
tblTransaction.Remarks = 'Checkin' AND tblTransaction.Status =
'Active'", con)
rs.Fill(Dt)
Dim indx As Integer
lvlcheckin.Items.Clear()
For indx = 0 To Dt.Rows.Count - 1
Dim lv As New ListViewItem
Dim getdate As TimeSpan
Dim days, subtotal, total, rate As Integer
Dim discount As Double
Dim value As Integer =
Val(Dt.Rows(indx).Item("TransID"))

lv.Text = "TransID - " & value.ToString("0000")


lv.SubItems.Add(Dt.Rows(indx).Item("GuestFName") & " "
& Dt.Rows(indx).Item("GuestLName"))
lv.SubItems.Add(Dt.Rows(indx).Item("RoomNum"))
rate = Dt.Rows(indx).Item("RoomRate")
lv.SubItems.Add(Dt.Rows(indx).Item("CheckInDate"))
lv.SubItems.Add(Dt.Rows(indx).Item("CheckOutDate"))
dtIn.Value = Dt.Rows(indx).Item("CheckOutDate")
dtOut.Value = Dt.Rows(indx).Item("CheckInDate")
getdate = dtIn.Value - dtOut.Value
days = getdate.Days
lv.SubItems.Add(days)
lv.SubItems.Add(Dt.Rows(indx).Item("NoOfChild"))
lv.SubItems.Add(Dt.Rows(indx).Item("NoOfAdult"))

lv.SubItems.Add(Dt.Rows(indx).Item("AdvancePayment").ToString("00.0
0"))
lv.SubItems.Add(Dt.Rows(indx).Item("DiscountType"))
discount = Val(Dt.Rows(indx).Item("DiscountRate"))
subtotal = (days * rate) - ((days * rate) * discount)
total = (Val(subtotal) -
Val(Dt.Rows(indx).Item("AdvancePayment"))).ToString("00.00")
If Val(subtotal) >
Val(Dt.Rows(indx).Item("AdvancePayment")) Then
lv.SubItems.Add(Val(total))
Else
lv.SubItems.Add("0")
End If
lvlcheckin.Items.Add(lv)
Next
rs.Dispose()
con.Close()
End Sub
Private Sub cboDiscount_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
cboDiscount.SelectedIndexChanged
End Sub
Private Sub TabPage1_Click(sender As System.Object, e As
System.EventArgs) Handles TabPage1.Click
End Sub
End Class
Imports System.Data.OleDb
Public Class frmCheckout
Private Sub bttnSearchGuest_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
bttnSearchGuest.Click
frmCheckinList.ShowDialog()
End Sub
Private Sub txtRoomNumber_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtRoomNumber.TextChanged
If txtRoomNumber.Text = Nothing Then
Else
con.Open()
Dim dt As New DataTable("tblRoom")
rs = New OleDbDataAdapter("SELECT * FROM tblRoom
WHERE RoomNumber = " & txtRoomNumber.Text & "", con)
rs.Fill(dt)
txtRoomType.Text = dt.Rows(0).Item("RoomType")
txtRoomRate.Text =
Val(dt.Rows(0).Item("RoomRate")).ToString("N")
rs.Dispose()
con.Close()
End If
End Sub
Private Sub txtCash_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtCash.KeyPress
If (e.KeyChar < "0" OrElse e.KeyChar > "9") _
AndAlso e.KeyChar <> ControlChars.Back AndAlso e.KeyChar
<> "." Then
'cancel keys
e.Handled = True
End If
End Sub
Private Sub txtCash_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtCash.TextChanged
If Val(txtCash.Text) < Val(txtTotal.Text) Then
txtChange.Text = "0.00"
Else
txtChange.Text = (Val(txtCash.Text) -
Val(txtTotal.Text)).ToString("N")
End If
End Sub
Private Sub bttnCheckout_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles bttnCheckout.Click
If txtTransID.Text = Nothing Then
MsgBox("Please select transaction to checkout!",
vbExclamation, "Note")
Else
If Val(txtCash.Text) < Val(txtTotal.Text) Then
MsgBox("Insufficient cash!", vbExclamation, "Note")
Else
Dim out As String = MsgBox("Confirm Checkout",
vbQuestion + vbYesNo, "Checkout")
If out = vbYes Then
con.Open()
Dim update_trans As New
OleDbCommand("UPDATE tblTransaction SET Remarks = 'Checkout'
WHERE TransID = " & lblTransID.Text & "", con)
update_trans.ExecuteNonQuery()
Dim update_guest As New
OleDbCommand("UPDATE tblGuest SET Remarks = 'Available'
WHERE ID = " & lblGuestID.Text & "", con)
update_guest.ExecuteNonQuery()
Dim update_room As New
OleDbCommand("UPDATE tblRoom SET Status = 'Available' WHERE
RoomNumber = " & txtRoomNumber.Text & "", con)
update_room.ExecuteNonQuery()
MsgBox("Guest Checked out!", vbInformation,
"Checkout")
con.Close()
clear_text()
End If
End If
End If
End Sub
Public Sub clear_text()
txtTransID.Clear()
txtGuestName.Clear()
txtRoomNumber.Clear()
txtRoomRate.Clear()
txtRoomType.Clear()
txtCheckin.Clear()
txtCheckout.Clear()
txtChildren.Clear()
txtAdult.Clear()
txtAdvance.Clear()
txtDiscountType.Clear()
txtTotal.Clear()
txtSubTotal.Clear()
txtDays.Clear()
txtCash.Clear()
txtChange.Clear()
End Sub
Private Sub lblTransID_TextChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles lblTransID.TextChanged
End Sub
Private Sub frmCheckout_FormClosing(ByVal sender As Object,
ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
clear_text()
End Sub
Private Sub frmCheckout_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
txtRoomNumber.Clear()
dtOut.Value = Date.Now
End Sub
Private Sub txtAdvance_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtAdvance.TextChanged
End Sub
Private Sub txtTotal_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtTotal.TextChanged
End Sub
Private Sub txtDiscountType_TextChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
txtDiscountType.TextChanged
End Sub
End Class
Coding For Module

Imports System.Data.OleDb
Imports System.Text.RegularExpressions
Module Module1
Public con As New
OleDbConnection("Provider=MICROSOFT.ACE.OLEDB.12.0; Data
Source=|DataDirectory|/database.accdb")
Public rs As New OleDbDataAdapter
Function SafeSqlLiteral(ByVal strValue, ByVal intLevel) As String
'*** Written by user CWA, CoolWebAwards.com Forums. 2
February 2010
'*** http://forum.coolwebawards.com/threads/11-
Preventing-SQL-injection-attacks-using-VB-NET
' intLevel represent how thorough the value will be checked
for dangerous code
' intLevel (1) - Do just the basic. This level will already
counter most of the SQL injection attacks
' intLevel (2) - &nbsp; (non breaking space) will be added
to most words used in SQL queries to prevent unauthorized access
to the database. Safe to be printed back into HTML code. Don't use
for usernames or passwords
If Not IsDbNull(strValue) Then
If intLevel > 0 Then
strValue = replace(strValue, "'", "''") ' Most
important one! This line alone can prevent most injection attacks
strValue = replace(strValue, "--", "")
strValue = replace(strValue, "[", "[[]")
strValue = replace(strValue, "%", "[%]")
End If
If intLevel > 1 Then
Dim myArray As Array
myArray = Split("xp_ ;update ;insert ;select ;drop
;alter ;create ;rename ;delete ;replace ", ";")
Dim i, i2, intLenghtLeft As Integer
For i = LBound(myArray) To UBound(myArray)
Dim rx As New Regex(myArray(i), RegexOptions.Compiled Or
RegexOptions.IgnoreCase)
Dim matches As MatchCollection =
rx.Matches(strValue)
i2 = 0
For Each match As Match In matches
Dim groups As GroupCollection =
match.Groups
intLenghtLeft = groups.Item(0).Index +
len(myArray(i)) + i2
strValue = Left(strValue, intLenghtLeft - 1)
& "&nbsp;" & right(strValue, len(strValue) - intLenghtLeft)
i2 += 5
Next
Next
End If
'strValue = replace(strValue, ";", ";&nbsp;")
'strValue = replace(strValue, "_", "[_]")
Return strValue
Else
Return strValue
End If
End Function
End Module

You might also like