Opened 10 years ago

Last modified 10 years ago

#33 new enhancement

Objasnuvanje na kod za formata login

Reported-by: 139037 Owned by:
Priority: major Milestone:
Component: component1 Version:
Keywords: Cc:

Description

(the code of OK button in login forma)
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

(the code for lebe username)

If UsernameTextBox.Text = Nothing Then
( the code-for empty text box of username "Please enter username" will be shown if text box not fulfill by use)

MsgBox("Please enter username")

Exit Sub

(the code for lebe passworname)

ElseIf PasswordTextBox.Text = Nothing Then

(the code if password is unrecorded this msg will appear)

MsgBox("Please enter password")

Exit Sub

Dim con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source = ..\medical_system.mdb")

Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM tblAdmin WHERE Usernam='" & UsernameTextBox.Text & "' AND Passwor = '" & PasswordTextBox.Text & "' ", con)
con.Open()
Dim sdr As OleDbDataReader = cmd.ExecuteReader()

(the code connect login forum with database)

If (sdr.Read() = True) Then

MessageBox.Show("The user is valid!")
Form1.Show()
Me.Hide() ( if the text is true the msg "The user is valid will appear)

Else

MessageBox.Show("Invalid username or password")

(if its not true then the msg "Invalid username or password" will appear)

End If

End Sub

(cancel button code)
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

Me.Close()

End Sub

Change History (1)

comment:1 by 139037, 10 years ago

Type: defectenhancement
Note: See TracTickets for help on using tickets.