Imports System.Data.OleDb
Imports System.IO

Public Class Form1

    Private Sub cmdEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEdit.Click
        If txtFirstDate.Text = "" Or TxtLastDate.Text = "" Then
            MessageBox.Show("Please Enter First SNo and Last SNo", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Exit Sub
        End If

        Dim msg As DialogResult = MessageBox.Show("Do you want to delete this Record? ", "Response", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If (msg = vbYes) Then



            Try
                With OleCn
                    If .State <> ConnectionState.Open Then
                        .ConnectionString = StrConnection()
                        .Open()
                    End If
                End With
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try

            Try
                Dim dap As OleDbDataAdapter = New OleDbDataAdapter("select * from Table1 where [Dat] between  '" & Me.txtFirstDate.Text & "' and '" & Me.TxtLastDate.Text & "'", OleCn)
                Dim ds As DataSet = New DataSet
                dap.Fill(ds, "table1")
                MsgBox("( " & Me.BindingContext(ds, "Table1").Count & " ) Records Deleted Successfully", MsgBoxStyle.Information, "Records Deleted")
                OleCn.Close()
                MainFrm.cmdRefresh.PerformClick()
                Me.Close()

            Catch ex As Exception
                MessageBox.Show(ex.Message.ToString(), "Deletion Error")
                Exit Sub
            End Try
        End If

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.LblTimeCabin1.Text = Now.ToLongTimeString.ToString()
        Me.TxtLogoutTimeCabin1.Enabled = True
        'Me.TimerCabin1.Enabled = True
        Me.Timer1.Enabled = True
    End Sub

    Private Sub TimerCabin1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TimerCabin1.Tick
        TxtLogoutTimeCabin1.Text = Now.ToLongTimeString.ToString
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Try
            Dim StartTime As DateTime = Me.LblTimeCabin1.Text
            Dim EndTime As DateTime = Now.ToLongTimeString.ToString
            Dim TotalTime As TimeSpan = EndTime - StartTime
            Me.LblDurationCabin1.Text = (TotalTime).ToString
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class