-
Notifications
You must be signed in to change notification settings - Fork 3
/
ChecckIn.txt
79 lines (71 loc) · 3.38 KB
/
ChecckIn.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
Imports System.Data.SqlClient
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")
Dim cmd As New SqlCommand("SELECT TOP 1 * FROM tblTransaction ORDER BY TransID DESC", con)
Dim da As New SqlDataAdapter(cmd)
da.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
da.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 SqlCommand("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 SqlCommand("UPDATE tblGuest SET Remarks = 'Checkin' WHERE ID = " & lblGuestID.Text & "", con)
update_guest.ExecuteNonQuery()
Dim update_room As New SqlCommand("UPDATE tblRoom SET Status = 'Occupied' WHERE