Imports System.Data.OleDb

Public Class Form2



    Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing


        Try
            If CloseOrNot = "Dink" Then
                If e.CloseReason = CloseReason.UserClosing Then


                    End

                End If
            End If
        Catch
        End Try
    End Sub





    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        RadioButton1.Checked = True
        Try
            Dim User As String = ""
            Dim Pass As String = ""
            Dim Server As String = ""
            Dim Resp As String = ""
            Dim conn As OleDbConnection
            Dim SQL As OleDbCommand
            Dim RSet As OleDbDataReader
            conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "progdb.mdb;")
            conn.Open()
            SQL = New OleDbCommand("select Server, UserID, Pass From Settings", conn)
            RSet = SQL.ExecuteReader
            If RSet.HasRows = False Then
                Exit Sub
            End If
            While RSet.Read
                Server = RSet("Server").ToString
                User = RSet("UserID").ToString
                Pass = RSet("Pass").ToString

            End While
            RSet.Close()

            If User = "" Or Pass = "" Then
                Exit Sub
            Else
                Resp = Functions.Connect(Server + "/client/usercheck.asp", User, Pass)
                If Resp = "Offline" Then
                    Form1.Show()
                    Me.Opacity = 0
                End If
                If Resp = "baduser" Then
                    SQL = New OleDbCommand("UPDATE Settings SET UserID = '" + vbNull.ToString + "', Pass = '" + vbNull.ToString + "'", conn)
                    RSet = SQL.ExecuteReader
                    RSet.Close()
                End If
                If Resp = "okuser" Then
                    SQL = New OleDbCommand("UPDATE Settings SET UserID = '" + vbNull.ToString + "', Pass = '" + vbNull.ToString + "'", conn)
                    Form1.Show()
                    Me.Opacity = 0

                End If
            End If
            conn.Close()
        Catch
        End Try
    End Sub


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

    End Sub



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

    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Try
            If RadioButton1.Checked = True Then
                Me.Dispose()
                Form3.Show()
            End If
            If RadioButton2.Checked = True Then
                Dim conn As OleDbConnection
                Dim SQL As OleDbCommand
                Dim RSet As OleDbDataReader
                conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "progdb.mdb;")
                conn.Open()
                SQL = New OleDbCommand("select Server, UserID From Settings", conn)
                RSet = SQL.ExecuteReader
                If RSet.HasRows = False Then
                End If
                While RSet.Read
                    Process.Start(RSet("Server").ToString + "/reg.asp")
                End While
                RSet.Close()
                conn.Close()

            End If
        Catch
            MsgBox(Err.Description)
        End Try
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        End
    End Sub

    Private Sub Form2_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown

    End Sub
    Function onfinload() As String
        Try
            Dim User As String = ""
            Dim Pass As String = ""
            Dim Server As String = ""
            Dim Resp As String = ""
            Dim conn As OleDbConnection
            Dim SQL As OleDbCommand
            Dim RSet As OleDbDataReader
            conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "progdb.mdb;")
            'conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App_Path() & "progdb.mdb;")

            conn.Open()
            SQL = New OleDbCommand("select Server, UserID, Pass From Settings", conn)
            RSet = SQL.ExecuteReader
            If RSet.HasRows = False Then
                Exit Function
            End If
            While RSet.Read
                Server = RSet("Server").ToString
                User = RSet("UserID").ToString
                Pass = RSet("Pass").ToString

            End While
            RSet.Close()

            If User = "" Or Pass = "" Then
                Exit Function
            Else
                Resp = Functions.Connect(Server + "/client/usercheck.asp", User, Pass)
                If Resp = "Offline" Then
                    Form1.Show()
                    Me.Dispose()
                End If
                If Resp = "baduser" Then
                    SQL = New OleDbCommand("UPDATE Settings SET UserID = '" + vbNull.ToString + "', Pass = '" + vbNull.ToString + "'", conn)
                    RSet = SQL.ExecuteReader
                    RSet.Close()
                End If
                If Resp = "okuser" Then
                    SQL = New OleDbCommand("UPDATE Settings SET UserID = '" + vbNull.ToString + "', Pass = '" + vbNull.ToString + "'", conn)
                    Form1.Show()

                    Me.Dispose()
                End If
            End If
            conn.Close()
        Catch
        End Try
    End Function
End Class