You are on page 1of 2

Imports System.Data.

SqlClient
Public Class LogIn
Dim sqlclasslib As New connectionlibrary
Public Sub sqldata()
Dim sqlReader As SqlDataReader
sqlReader = sqlcom.ExecuteReader
If sqlReader.HasRows = 0 Then
MsgBox("No match found!", MsgBoxStyle.Information, "ARMMC Hospital
Management System")
txtUsername.Focus()
txtPassword.Clear()
txtUsername.Clear()
cmbUsertype.Text = ""
End If
While sqlReader.Read
If Trim(txtUsername.Text) = sqlReader.Item("Username") And
Trim(txtPassword.Text) = sqlReader.Item("Password") And cmbUsertype.Text =
sqlReader.Item("Usertype") Then
'If objDataReader.Item("Access") = "Maintenance" Then
' MsgBox("Welcome " + txtUsername.Text + "!",
MsgBoxStyle.Information, "ARMMC Hospital Management System")

' 'MainMenu.MaintenanceToolStripMenuItem.Enabled = True


' txtPassword.Clear()
' txtUsername.Clear()
' MainMenu.Show()
' Me.Hide()

'Else
' MsgBox("Welcome " + txtuser.Text + "!",
MsgBoxStyle.Information, "COOlegium Guide")
' MainParent.MaintenanceToolStripMenuItem.Enabled = False
' MainParent.Show()
' Me.Hide()

' txtpass.Clear()
' txtuser.Clear()
'End If
Me.Hide()
MainMenu.Show()
End If
End While
End Sub

Private Sub btnCancel_Click_1(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnCancel.Click
End
End Sub

Private Sub btnLogin_Click_1(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnLogin.Click
If txtUsername.Text = "" Then
MsgBox("Please enter username")
txtUsername.Focus()
ElseIf txtPassword.Text = "" Then
MsgBox("Please enter password")
txtPassword.Focus()
End If

Dim strSQL As String = "SearchUser"


sqlclasslib = New connectionlibrary
sqlclasslib.openConnection(sqlconnstr)
sqlclasslib.openConnection(sqlconnstr)

If Not sqlclasslib.isconnectionopen() Then


Exit Sub

End If
sqlclasslib.initializeCommand(strSQL)
sqlclasslib.addParameter("@Username", SqlDbType.VarChar,
txtUsername.TextLength, Trim(txtUsername.Text))
sqlclasslib.addParameter("@Password", SqlDbType.VarChar,
txtPassword.TextLength, Trim(txtPassword.Text))
sqlclasslib.addParameter("@Usertype", SqlDbType.VarChar,
Val(cmbUsertype.ToString), Trim(cmbUsertype.Text))
sqldata()
End Sub
End Class

You might also like