Public Class frmReserve
    Public Sub save()
        'sql = "UPDATE `tblreservation` SET `STATUS` = 'BOOKED' WHERE `TRANSNUM`=" & dtgList.CurrentRow.Cells(0).Value
        'result = CUD(sql)
        'If result = False Then
        '    MsgBox("ERROR TO UPDATE tblreservation", MsgBoxStyle.Exclamation)
        'End If

        sql = "UPDATE `tblpayment` SET `STATUS` = 'BOOKED' ,`TENDERED`=`TENDERED`+ " & frmPopRPayment.txttender.Text & ", `CHANGED`=" & Double.Parse(frmPopRPayment.txtChange.Text) & " WHERE `TRANSNUM`=" & dtgList.CurrentRow.Cells(0).Value
        result = CUD(sql)
        If result = False Then
            MsgBox("ERROR TO UPDATE tblpayment", MsgBoxStyle.Exclamation)
        Else
            MsgBox("Guest has been checked-in.")
        End If

    End Sub
    Private Sub frmReserve_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Disable_previous_date(dtpCheckin, dtpCheckout)
        Load_Room_Type_reserve()

        Call btnAvailSeach_Click(sender, e)

    End Sub

    Private Sub btnAvailSeach_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAvailSeach.Click
        Availability_Search_reserve()
        lblMessage.Text = "Available Room(s) from " & dtpCheckin.Text & " to " & dtpCheckout.Text
    End Sub

    Private Sub lstRoomType_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstRoomType.Click
        Try
            Availability_Search_Type_Reserve()
            '  lblMessage.Text = lstRoomType.SelectedValue
        Catch ex As Exception

        End Try
    End Sub

    Private Sub btnReserve_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReserve.Click
        Try
            With Form1.FrmBookingDetails1
                Dim tot As Double
                sql = bookingDetails(dtpCheckin, dtpCheckout) & " AND ROOMID =" & dtgList.CurrentRow.Cells(0).Value
                reloadDtg(sql, .dtgList)
                For Each r As DataGridViewRow In .dtgList.Rows
                    tot += r.Cells(9).Value * r.Cells(3).Value
                Next
                .txtSubtotal.Text = tot.ToString("n2")
                .txtTotal.Text = .txtSubtotal.Text
                .lblTitle.Text = "Reservation Details"
                .btnSave.Text = "Reserve"

                .dtgAddons.Rows.Clear()

                .txtfname.Clear()
                .txtlname.Clear()
                .txtAddress.Clear()
                .txtage.Clear()
                .txtContact.Clear()
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
        Form1.addContent(Form1.FrmBookingDetails1, Form1.btnReserveaRoom)

    End Sub

End Class
