Public Sub Loggin() If Login.txtUsername.Text = "" Or Login.txtPassword.Text = "" Then MsgBox("Please enter Username and Password!") Login.txtUsername.Focus() Else Try With cmd conn.Open() .Connection = conn .CommandText = "Select * From Accounts WHERE Accname = @GetLogin and Accpass = @GetPass" .Parameters.AddWithValue("@GetLogin", Login.txtUsername.Text) If Encr >= 1 Then .Parameters.AddWithValue("@GetPass", Encrypt.EncryptPassword(Login.txtPassword.Text)) ElseIf Encr = 0 Then .Parameters.AddWithValue("@GetPass", Login.txtPassword.Text) End If 'Starting The Query Adapter.SelectCommand = cmd Reader = cmd.ExecuteReader .Parameters.Clear() 'Validate User If Reader.HasRows = 0 Then 'Login.ProgressBar1.Value = 0 Login.txtUsername.Text = "" Login.txtPassword.Text = "" Login.txtUsername.Focus() Return Else Dim authorityid = 0 While Reader.Read() authorityid = Reader.Item("Admin") End While If authorityid = 1 Then 'Login Admin User 'AdminMenu.Show() Login.Close() ElseIf authorityid = 0 Then 'Login Normal User MainCP.Show() Login.Close() ElseIf authorityid > 1 Then MessageBox.Show("Error in Database User Information", "Visual WMS", MessageBoxButtons.OK, MessageBoxIcon.Warning) return Else 'Login.ProgressBar1.Value = 0 Login.txtUsername.Text = "" Login.txtPassword.Text = "" Login.txtUsername.Focus() End If End If End With Catch ex As Exception MsgBox(ex.Message) 'MsgBox("Please check your Settings.ini File") Finally Reader.Close() Adapter.Dispose() cmd.Dispose() If conn IsNot Nothing Then conn.Close() End If End Try End If End Sub
If authorityid = 1 Then 'Login Admin User 'AdminMenu.Show() My.Settings.isAdmin = 1 Login.Close()
Shared
My.Settings.isAdmin = True
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)