#Region " #define "
Private dbconn As New Odbc.OdbcConnection("Driver={Microsoft access Driver (*.mdb)};DBQ=" & Application.StartupPath & "\UCSH1.mdb")
Private dbadapter As New Odbc.OdbcDataAdapter
Private dbdataset As New DataSet
Private userCommand As New Odbc.OdbcCommand
Public pass As String
Public result As Integer
#End Region
#Region " #Functions"
Sub TEMPOS()
dbadapter = New Odbc.OdbcDataAdapter("select * from login", dbconn)
dbdataset.Clear()
[B][U]dbadapter.Fill(dbdataset, "login")[/U][/B]
Me.DataGridView1.DataSource = dbdataset.Tables("login").DefaultView
End Sub
Sub ShowMsg()
MsgBox("Sorry, Incorrect UserName or Password" + vbCrLf + "Please try again...", MsgBoxStyle.Critical, "UCSH")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox1.Focus()
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim result As String
Dim pass As String
MAINFORM.PassedText = TextBox1.Text
dbadapter = New Odbc.OdbcDataAdapter("Select * from login where Username like '" & Me.TextBox1.Text.Trim & "' and Password like '" & Me.TextBox2.Text.Trim & "%'", dbconn)
dbdataset.Clear()
dbadapter.Fill(dbdataset, "login")
Me.DataGridView1.DataSource = dbdataset.Tables("login").DefaultView
result = dbdataset.Tables("login").DefaultView.Count
If result > 0 Then
pass = dbdataset.Tables("login").DefaultView.Item(Me.DataGridView1.CurrentRow.Index).Item(2)
If TextBox2.Text = pass Then
Try
userCommand.CommandText = "insert into userlog values ('" & _
Label6.Text & "', '" & _
Label5.Text & "', '" & _
Me.TextBox1.Text.Trim & "', '" & _
Button1.Text & "')"
userCommand.Connection = dbconn
dbconn.Open()
userCommand.ExecuteReader()
dbconn.Close()
Catch exp As Exception
MsgBox(exp.ToString())
End Try
Me.Close()
MAINFORM.Show()
Else
ShowMsg()
End If
Else
ShowMsg()
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End
End Sub
Private Sub login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Try
TEMPOS()
TextBox1.Clear()
TextBox2.Clear()
Catch ex As Exception
MessageBox.Show(ex.ToString)
End Try
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label6.Text = Date.Now.Date
Label5.Text = Date.Now.TimeOfDay.ToString
End Sub