Enlistment System

Only available on StudyMode
  • Topic: User, Login, Source code
  • Pages : 5 (628 words )
  • Download(s) : 60
  • Published : February 14, 2013
Open Document
Text Preview
Imports System.Data.OleDb
Public Class Login
'this codes are the declarations for sql statement
Dim connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " & Application.StartupPath & "\enlistment.mdb;" Dim con As New OleDbConnection(connstring)
Dim com As OleDbCommand
Dim ds As New DataSet
Dim adapter As New OleDbDataAdapter
Dim reader As OleDbDataReader
Dim User As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AcceptButton = Me.Button1
'this codes will hide or disable a label, textbox and a button Me.Label4.Hide()
Me.Label7.Hide()
Me.Label8.Hide()
Me.Button3.Hide()
Me.TextBox1.Enabled = False
Me.TextBox2.Enabled = False
Me.Button1.Enabled = False
'this codes will show the current time in the form log in Me.Timer1.Enabled = True
Me.Timer1.Interval = 1

End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged 'this codes will show or hide a label and button, enable a button and textbox, and will clear a textbox and combobox If ComboBox1.Text = "Student" Then

Me.Label4.Show()
Me.TextBox1.Enabled = True
Me.TextBox2.Enabled = True
Me.Button1.Enabled = True
Me.Label7.Hide()
Me.Label8.Hide()
TextBox1.Clear()
ComboBox1.Text = ""
TextBox2.Clear()
Me.Button3.Hide()

ElseIf ComboBox1.Text = "Faculty" Then
Me.Label4.Show()
Me.TextBox1.Enabled = True
Me.TextBox2.Enabled = True
Me.Button1.Enabled = True
Me.Label7.Hide()
Me.Label8.Hide()
TextBox1.Clear()
ComboBox1.Text = ""
TextBox2.Clear()
Me.Button3.Hide()
Else
Me.Label4.Hide()
Me.TextBox1.Enabled = False
Me.TextBox2.Enabled = False
Me.Button1.Enabled = False
Me.Label7.Hide()
Me.Label8.Hide()
Me.Button3.Hide()
TextBox1.Clear()
ComboBox1.Text = ""
TextBox2.Clear()

End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'this codes are used for the log in process
Try
If ComboBox1.Text = "Student" Then
'this codes will open the database and will select a value from the table con.Open()
com = New OleDbCommand("Select * from [inventory] where [UserName] = '" & TextBox1.Text & "' AND [Password] = '" & TextBox2.Text & "' ", con) reader = com.ExecuteReader

'this code will read the table selected from its fields While reader.Read
User = reader(0).ToString() & " " & reader(1).ToString() End While

If reader.HasRows Then
Me.Label7.Hide()
Me.Label8.Hide()
Me.Button3.Hide()
Me.TextBox1.Enabled = False
Me.TextBox2.Enabled = False
Me.Button1.Enabled = False
successful.Show()
TextBox1.Clear()
ComboBox1.Text = ""
TextBox2.Clear()
Me.Label4.Hide()

Else
TextBox2.Clear()
Label7.Show()

End If
reader.Close()
con.Close()

ElseIf ComboBox1.Text = "Faculty" Then

con.Open()...
tracking img