Imports MySql.Data.MySqlClient

Module mod_Rooms 
    Public con As MySqlConnection = mysqldb()
    Public Function edit_Rooms(ByVal roomid As Integer) As Boolean
        Try
            With Form1.FrmRooms1
                fillcbo("SELECT * FROM `tblroomtype`  ", .cboroomType, "ROOMTYPE", "ROOMTYPEID", "Select")
                sql = "SELECT * FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND `ROOMID`=" & roomid
                result = RETRIEVESINGLE(sql)
                If result = True Then
                    .txtRoomid.Text = dt.Rows(0).Item("ROOMID")
                    .cboroomType.Text = dt.Rows(0).Item("ROOMTYPE")
                    .txtRoomNum.Text = dt.Rows(0).Item("ROOMNUM")
                    .txtRoomName.Text = dt.Rows(0).Item("ROOM")
                    .txtRoomPrice.Text = dt.Rows(0).Item("PRICE")
                    .txtPerson.Text = dt.Rows(0).Item("NUMPERSON")
                End If
            End With
        Catch ex As Exception

        End Try
    End Function
    Public Function delete_Rooms(ByVal roomid As Integer) As Boolean
        Try
            sql = "DELETE FROM tblroom WHERE ROOMID=" & roomid
            result = CUD(sql)
            If result = True Then
                MsgBox("Room has been deleted.")
                load_Rooms()
            End If
        Catch ex As Exception

        End Try
    End Function
    Public Function load_Rooms()
        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price' FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID`"
        reloadDtg(sql, Form1.FrmRooms1.dtgList)
        With Form1.FrmRooms1
            .dtgList.SelectionMode = DataGridViewSelectionMode.FullRowSelect
            .dtgList.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
            .dtgList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

        End With
        Return sql
    End Function
    Public Function Edit_or_New(ByVal action As String) As Boolean
        Try
            Select Case action
                Case "Edit"
                    edit_Rooms(Form1.FrmRooms1.dtgList.CurrentRow.Cells(0).Value)

                Case "New"
                    Form1.FrmRooms1.txtRoomid.Text = loadautonumberWithKey("ROOMID")
                    fillcbo("SELECT * FROM `tblroomtype`  ", Form1.FrmRooms1.cboroomType, "ROOMTYPE", "ROOMTYPEID", "Select")
            End Select
        Catch ex As Exception

        End Try
    End Function
    Public Function Save_OR_Update_Rooms(ByVal roomid As Integer) As Boolean
        Try
            With Form1.FrmRooms1
                sql = "SELECT * FROM `tblroom` WHERE ROOMID= " & roomid
                result = RETRIEVESINGLE(sql)
                If result = True Then
                    sql = "UPDATE `tblroom` SET `ROOMNUM`=" & .txtRoomNum.Text & ", `ROOMTYPEID`=" & .cboroomType.SelectedValue &
                    ", `ROOM`='" & .txtRoomName.Text & "',`NUMPERSON`=" & .txtPerson.Text & ", `PRICE`=" & .txtRoomPrice.Text &
                    " WHERE ROOMID= " & roomid
                    result = CUD(sql)
                    If result = True Then
                        MsgBox("Room has been updated.")
                    End If
                    cleartext(Form1.FrmRooms1)
                    Edit_or_New("New")
                Else
                    sql = "INSERT INTO `tblroom` (ROOMID,`ROOMNUM`, `ROOMTYPEID`, `ROOM`,`NUMPERSON`, `PRICE`)  " &
                             " VALUES (" & .txtRoomid.Text & " ," & .txtRoomNum.Text & "," & .cboroomType.SelectedValue & ",'" & .txtRoomName.Text &
                             "'," & .txtPerson.Text & "," & .txtRoomPrice.Text & ")"
                    result = CUD(sql)
                    If result = True Then
                        MsgBox("New room has been saved.")
                    End If

                    updateautonumberWithKey("ROOMID")
                    cleartext(Form1.FrmRooms1)
                    Edit_or_New("New")
                End If
            End With

        Catch ex As Exception
        End Try

    End Function
    Public Function Load_Room_Type() As Boolean
        Try
            sql = "SELECT * FROM tblroomtype"
            Fill_lstBox(sql, Form1.FrmBooking1.lstRoomType, "ROOMTYPE", "ROOMTYPEID")
        Catch ex As Exception

        End Try
    End Function
    Public Function Load_Room_Type_reserve() As Boolean
        Try
            sql = "SELECT * FROM tblroomtype"
            Fill_lstBox(sql, Form1.FrmReserve1.lstRoomType, "ROOMTYPE", "ROOMTYPEID")
        Catch ex As Exception

        End Try
    End Function
    Public Function Availability_Search_reserve() As Boolean
        Try
            con.Open()

            With Form1.FrmReserve1
                sql = "SELECT GROUP_CONCAT(  `ROOMID` ,  '' )  FROM `tblreservation` r,`tblpayment` p " &
                        " WHERE  r.`TRANSNUM`=p.`TRANSNUM` AND (('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                         "'>= DATE(`ARRIVAL`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                         "' <= DATE(`DEPARTURE`)) OR ('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                         "' >= DATE(`DEPARTURE`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                         "' <= DATE(`DEPARTURE`) )   OR (DATE(`ARRIVAL`) >='" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                         "' AND DATE(`ARRIVAL`) <='" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                         "'))  AND NOT p.STATUS='CHECKED-OUT'"

                cmd = New MySqlCommand
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                da = New MySqlDataAdapter
                da.SelectCommand = cmd
                dt = New DataTable
                da.Fill(dt)
                Dim max As Integer = dt.Rows.Count

                If max > 0 Then
                    If dt.Rows(0).Item(0).ToString = "" Then
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                           " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` "
                        reloadDtg(sql, .dtgList)
                    Else
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                              " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND ROOMID NOT IN  (" & dt.Rows(0).Item(0) & ")"
                        reloadDtg(sql, .dtgList)
                    End If
                    ' MsgBox(dt.Rows(0).Item(0).ToString)


                Else
                    sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                             " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` "
                    reloadDtg(sql, .dtgList)
                End If

            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
            da.Dispose()
        End Try
    End Function
    Public Function Availability_Search_Type_Reserve() As Boolean
        Try
            con.Open()

            With Form1.FrmReserve1
                sql = "SELECT GROUP_CONCAT(  `ROOMID` ,  '' )  FROM `tblreservation` r,`tblpayment` p " &
                        " WHERE  r.`TRANSNUM`=p.`TRANSNUM` AND (('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                         "'>= DATE(`ARRIVAL`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                         "' <= DATE(`DEPARTURE`)) OR ('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                         "' >= DATE(`DEPARTURE`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                         "' <= DATE(`DEPARTURE`) )   OR (DATE(`ARRIVAL`) >='" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                         "' AND DATE(`ARRIVAL`) <='" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                         "')) AND NOT p.STATUS='CHECKED-OUT'"

                cmd = New MySqlCommand
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                da = New MySqlDataAdapter
                da.SelectCommand = cmd
                dt = New DataTable
                da.Fill(dt)
                Dim max As Integer = dt.Rows.Count

                If max > 0 Then
                    If dt.Rows(0).Item(0).ToString = "" Then
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                           " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND r.`ROOMTYPEID`= " & .lstRoomType.SelectedValue
                        reloadDtg(sql, .dtgList)
                    Else
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                              " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND r.`ROOMTYPEID`= " & .lstRoomType.SelectedValue & " AND ROOMID NOT IN  (" & dt.Rows(0).Item(0) & ")"
                        reloadDtg(sql, .dtgList)
                    End If
                    ' MsgBox(dt.Rows(0).Item(0).ToString)


                Else
                    sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                             " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND r.`ROOMTYPEID`= " & .lstRoomType.SelectedValue & ""
                    reloadDtg(sql, .dtgList)
                End If

            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
            da.Dispose()
        End Try
    End Function
    Public Function Availability_Search() As Boolean
        Try
            con.Open()

            With Form1.FrmBooking1
                sql = "SELECT GROUP_CONCAT(  `ROOMID` ,  '' )  FROM `tblreservation`r,`tblpayment` p " &
                        " WHERE  r.`TRANSNUM`=p.`TRANSNUM` AND (('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                        "'>= DATE(`ARRIVAL`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                        "' <= DATE(`DEPARTURE`)) OR ('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                        "' >= DATE(`DEPARTURE`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                        "' <= DATE(`DEPARTURE`) )   OR (DATE(`ARRIVAL`) >='" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                        "' AND DATE(`ARRIVAL`) <='" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                        "'))  AND NOT p.STATUS='CHECKED-OUT'"


                cmd = New MySqlCommand
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                da = New MySqlDataAdapter
                da.SelectCommand = cmd
                dt = New DataTable
                da.Fill(dt)
                Dim max As Integer = dt.Rows.Count

                If max > 0 Then
                    If dt.Rows(0).Item(0).ToString = "" Then
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                           " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` "
                        reloadDtg(sql, .dtgList)
                    Else
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                              " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND ROOMID NOT IN  (" & dt.Rows(0).Item(0) & ")"
                        reloadDtg(sql, .dtgList)
                    End If
                    ' MsgBox(dt.Rows(0).Item(0).ToString)


                Else
                    sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                             " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` "
                    reloadDtg(sql, .dtgList)
                End If
            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
            da.Dispose()
        End Try
    End Function
    Public Function Availability_Search_Type() As Boolean
        Try
            con.Open()

            With Form1.FrmBooking1
                sql = "SELECT GROUP_CONCAT(  `ROOMID` ,  '' )  FROM `tblreservation` r,`tblpayment` p " &
                        " WHERE  r.`TRANSNUM`=p.`TRANSNUM` AND (('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                        "'>= DATE(`ARRIVAL`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                        "' <= DATE(`DEPARTURE`)) OR ('" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                        "' >= DATE(`DEPARTURE`) AND '" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                        "' <= DATE(`DEPARTURE`) )   OR (DATE(`ARRIVAL`) >='" & INSERTMYSQLDATE(.dtpCheckin, "yyyy-MM-dd") &
                        "' AND DATE(`ARRIVAL`) <='" & INSERTMYSQLDATE(.dtpCheckout, "yyyy-MM-dd") &
                        "'))  AND NOT p.STATUS='CHECKED-OUT' "

                cmd = New MySqlCommand
                With cmd
                    .Connection = con
                    .CommandText = sql
                End With
                da = New MySqlDataAdapter
                da.SelectCommand = cmd
                dt = New DataTable
                da.Fill(dt)
                Dim max As Integer = dt.Rows.Count

                If max > 0 Then
                    If dt.Rows(0).Item(0).ToString = "" Then
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                           " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID`  AND r.`ROOMTYPEID`= " & .lstRoomType.SelectedValue
                        reloadDtg(sql, .dtgList)
                    Else
                        sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                              " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND r.`ROOMTYPEID`= " & .lstRoomType.SelectedValue & " AND ROOMID NOT IN  (" & dt.Rows(0).Item(0) & ")"
                        reloadDtg(sql, .dtgList)
                    End If
                    ' MsgBox(dt.Rows(0).Item(0).ToString)


                Else
                    sql = "SELECT  `ROOMID`,`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price'  " &
                             " FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID` AND r.`ROOMTYPEID`= " & .lstRoomType.SelectedValue
                    reloadDtg(sql, .dtgList)
                End If


            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
            da.Dispose()
        End Try
    End Function
    Public Function bookingDetails(ByVal ARRIVAL As DateTimePicker, ByVal DEPARTURE As DateTimePicker)

        Dim night As Integer
        night = DateDiff(DateInterval.Day, ARRIVAL.Value, DEPARTURE.Value)
        If night = 0 Then
            night = 1 
        End If
        sql = "SELECT  `ROOMID`, '" & INSERTMYSQLDATE(ARRIVAL, "yyyy-MM-dd") & "'   AS 'Arrival'" & _
        ",'" & INSERTMYSQLDATE(DEPARTURE, "yyyy-MM-dd") & "'   AS 'Departure'," & night & " as 'Nights',`ROOMTYPE` as 'Type', `ROOMNUM` as 'Room No.', `ROOM` as 'Room', `NUMPERSON` as 'Person', `PRICE` as 'Price',(PRICE*" & night & ") as 'Subtotal' FROM `tblroom` r, `tblroomtype` t WHERE r.`ROOMTYPEID`=t.`ROOMTYPEID`"
        Return sql

    End Function
    Public Function BookedRooms()
        sql = "SELECT p.`TRANSNUM` as 'TransactionNo.',concat(`G_FNAME`,' ', `G_LNAME`) as 'Name', `ROOMNUM` AS 'RoomNo.', `ROOM` as 'Room', date(`ARRIVAL`) as 'Checked-in', `DEPARTURE` as 'Checked-out', `SPRICE` AS 'TotalPrice', p.`STATUS` as 'Status'  FROM  `tblroom` rm,`tblreservation` r, `tblpayment` p , `tblguest` g WHERE rm.`ROOMID` = r.`ROOMID` and r.`TRANSNUM`=p.`TRANSNUM` AND p.`GUESTID`=g.`GUESTID` AND  p.STATUS='BOOKED' "
        RETRIEVEDTG(Form1.FrmBookingHistory1.dtgList, sql)
        Return sql
    End Function
    Public Function ReservedRooms()
        sql = "SELECT p.`TRANSNUM` as 'TransactionNo.',concat(`G_FNAME`,' ', `G_LNAME`) as 'Name', `ROOMNUM` AS 'RoomNo.', `ROOM` as 'Room', date(`ARRIVAL`) as 'Checked-in', DATE(`DEPARTURE`) as 'Checked-out', `SPRICE` AS 'TotalPrice',`TENDERED` as 'PayedAmount', `CHANGED` as 'Balanced', p.`STATUS` as 'Status'  FROM  `tblroom` rm,`tblreservation` r, `tblpayment` p , `tblguest` g WHERE rm.`ROOMID` = r.`ROOMID` and r.`TRANSNUM`=p.`TRANSNUM` AND p.`GUESTID`=g.`GUESTID` AND p.STATUS='RESERVED' "
        RETRIEVEDTG(Form1.FrmReservationHistory1.dtgList, sql)
        Return sql
    End Function
    Public Function Availability_Room() As Boolean
        Try
            con.Open()

            With Form1.FrmRooms1
                '=========================================[Displaying to Gridview]======================================================================================='
                cmd = New MySqlCommand
                With cmd
                    .Connection = con
                    .CommandText = "SELECT rm.`ROOMID` ,  `ROOMTYPE` AS  'Type',  `ROOMNUM` AS  'Room No.',  `ROOM` AS  'Room',  `NUMPERSON` AS  'Person',  `PRICE` AS  'Price', p.STATUS AS  'Status' " &
                                    " FROM  `tblroomtype` rt,  `tblroom` rm,  `tblreservation` r,  `tblpayment` p " &
                                    " WHERE rt.`ROOMTYPEID` = rm.`ROOMTYPEID`  " &
                                    " AND rm.`ROOMID` = r.`ROOMID`  " &
                                    " AND r.`TRANSNUM` = p.`TRANSNUM`  " &
                                    " AND DATE( p.`TRANSDATE` ) = DATE( NOW( ) ) AND  NOT p.STATUS='CHECKED-OUT'"
                End With
                da = New MySqlDataAdapter
                da.SelectCommand = cmd
                dt2 = New DataTable
                da.Fill(dt2)

                '==============================================[Adding to Gridview]=================================================================================='

                sql = " SELECT GROUP_CONCAT(`ROOMID` ,  '' )  " &
                        " FROM  `tblreservation` r,  `tblpayment` p " &
                        " WHERE r.`TRANSNUM` = p.`TRANSNUM`  " &
                        " AND DATE( p.`TRANSDATE` ) = CURDATE( )  " &
                        " AND NOT p.STATUS =  'CHECKED-OUT' "

                RETRIEVESINGLE(sql)
                If dt.Rows(0).Item(0).ToString <> "" Then
                    cmd = New MySqlCommand
                    With cmd
                        .Connection = con
                        .CommandText = "SELECT  `ROOMID` ,  `ROOMTYPE` ,  `ROOMNUM` ,  `ROOM` ,  `NUMPERSON` AS  'Person' ,  `PRICE` ,  'Available' " &
                                        "FROM  `tblroomtype` rt,  `tblroom` rm  " &
                                        " WHERE rt.`ROOMTYPEID` = rm.`ROOMTYPEID`  " &
                                        " AND  ROOMID NOT IN  " &
                                        " (  " & dt.Rows(0).Item(0) & " )"
                    End With
                    da = New MySqlDataAdapter
                    da.SelectCommand = cmd
                    dt1 = New DataTable
                    da.Fill(dt1)
                    Dim max As Integer = dt1.Rows.Count
                    If max > 0 Then
                        '==========================================================================================================================================='
                        For Each r As DataRow In dt1.Rows
                            Dim row As String() = New String() {r.Item(0).ToString,
                                                                 r.Item(1).ToString,
                                                                 r.Item(2).ToString,
                                                                 r.Item(3).ToString,
                                                                 r.Item(4).ToString,
                                                                 r.Item(5).ToString,
                                                                 r.Item(6).ToString}


                            With dt2.Rows
                                .Add(row)
                            End With

                        Next

                    End If
                    .dtgList.DataSource = dt2
                Else
                    sql = "SELECT  `ROOMID` ,  `ROOMTYPE` AS  'Type',  `ROOMNUM` AS  'Room No.',  `ROOM` AS  'Room',  `NUMPERSON` AS  'Person',  `PRICE` AS  'Price', ('Available') AS  'Status'  " &
                                        "FROM  `tblroomtype` rt,  `tblroom` rm  " &
                                        " WHERE rt.`ROOMTYPEID` = rm.`ROOMTYPEID`  "
                    reloadDtg(sql, .dtgList)
                End If

                .dtgList.SelectionMode = DataGridViewSelectionMode.FullRowSelect
                .dtgList.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells
                .dtgList.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill

            End With
        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            con.Close()
            da.Dispose()
        End Try
    End Function

End Module
