Imports System.Data.OleDb
Public Class IP
    Dim conn As OleDbConnection
    Dim SQL As OleDbCommand
    Dim RSet As OleDbDataReader
    Private Sub Panel3_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel3.Paint

       
    End Sub

    Private Sub IP_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Try
            ListView1.View = View.Details
            ListView1.SmallImageList = ImageList1
            Dim lSingleItem As ListViewItem

            conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "progdb.mdb;")
            conn.Open()
            SQL = New OleDbCommand("select* From IP_Detection order by DD ASC", conn)


            RSet = SQL.ExecuteReader
            'If RSet.HasRows = False Then
            'End If
            While RSet.Read

                lSingleItem = ListView1.Items.Add(RSet("Ident").ToString, 0)
                lSingleItem.SubItems.Add(RSet("IP").ToString)
                lSingleItem.SubItems.Add(RSet("Status").ToString)

            End While

        Catch ex As Exception
            Functions.CreateError(ex.Message, 1111)
        End Try
        RSet.Close()
        conn.Close()

    End Sub

    Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim objDrawingPoint As Drawing.Point
        Dim objListViewItem As ListViewItem

        objDrawingPoint = ListView1.PointToClient(Cursor.Position)

        If Not IsNothing(objDrawingPoint) Then
            With objDrawingPoint
                objListViewItem = ListView1.GetItemAt(.X, .Y)
            End With

            If Not IsNothing(objListViewItem) Then
                MsgBox(objListViewItem.Text)
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)



    End Sub

    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)


    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs)


    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim Adddetect As New AddMethod
        Form1.Panel3.Controls.Clear()
        Form1.Panel3.Controls.Add(Adddetect)
    End Sub

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub ListView1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged

    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Dim Entry As String = ""
        Dim Ans As String = ""
        Try
            Entry = ListView1.SelectedItems(0).Text.ToString
            If ListView1.SelectedItems.Count <= 0 Then
                Exit Sub
            End If
            If Entry = "Default Detection Method" Then
                MsgBox("You cant remove the Default Detection Method.", MsgBoxStyle.Information)
                Exit Sub
            End If

            Ans = MsgBox("Are you sure you want to remove this detection method?", MsgBoxStyle.YesNo + MsgBoxStyle.Question)
            If Ans = vbNo Then Exit Sub



            conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "progdb.mdb;")
            conn.Open()
            SQL = New OleDbCommand("Delete From IP_Detection where Ident = '" & Entry & "'", conn)
            RSet = SQL.ExecuteReader
            RSet.Close()
            SQL = New OleDbCommand("Update Domains SET Method = 'Default Detection Method' WHERE Method = '" + Entry + "'", conn)
            RSet = SQL.ExecuteReader
            'ListView1.Items.Remove(ListView1.SelectedItems.Item)
            ListView1.SelectedItems(0).Remove()
        Catch
            MsgBox(Err.Description)
        End Try
    End Sub
End Class
