0

我通过创建用户名和密码区域来设置管理员登录,该区域使管理员可以访问典型用户看不到的表单。

假设有 4 人正在使用此应用程序,我想让 4 人中只有 3 人可以以管理员身份登录。

我该怎么做呢 ?

这就是我创建登录功能的方式。

在我的应用程序的设置区域中,我创建了两个名称DBUsername并将DBPassword它们的范围设置为User

PasswordField并且NameField是文本框,这是登录区域的照片及其背后的代码。该功能完美运行。

不注意User Login按钮

在此处输入图像描述

Public Class login
Private Property username As String = ""
Private Property password As String = ""

Dim Setting As New My.MySettings

Private Sub AdminLoginButton_Click(sender As Object, e As EventArgs) Handles AdminLoginButton.Click

    If NameField.Text = "" And PasswordField.Text = "" Then
        Label3.Text = "PLEASE ENTER A USERNAME AND PASSWORD"
    End If
    If NameField.Text = "" And PasswordField.Text.Length > 0 Then
        Label3.Text = "PLEASE ENTER A NAME"
    End If
    If PasswordField.Text = "" And NameField.Text.Length > 0 Then
        Label3.Text = "PLEASE ENTER A PASSWORD"
    End If

    'generage first password 
    If Setting.DBpassword = "" Then
        'save password here
        password = PasswordField.Text
        Setting.DBpassword = password
        Setting.Save()
    Else
    End If

    'generate first username
    If Setting.DBUsername = "" Then
        username = NameField.Text
        Setting.DBUsername = username
        Setting.Save()
    Else
    End If
    'check if correct name and password are entered 
    If PasswordField.Text = Setting.DBpassword And NameField.Text = Setting.DBUsername Then

        Label3.Text = ("WELCOME " & NameField.Text)
        Dim itm As Control
        Me.Close()
        For Each itm In MLGMain.Controls
            itm.Enabled = True
        Next

    End If

    If NameField.Text.Length >= 1 And NameField.Text <> Setting.DBUsername And PasswordField.Text.Length >= 1 And NameField.Text <> Setting.DBpassword Then
        Label3.Text = "INCORRECT USERNAME AND PASSWORD COMBINATION"
        NameField.Clear()
        PasswordField.Clear()
    End If
End Sub

结束类

4

1 回答 1

0

您需要某种机制来计算管理员登录次数。您可以在 LAN 上设置所有计算机都可以访问的 SQL 服务器表。该表将维护有关谁登录到系统的信息。您需要确保他们在会话结束时正确注销。

于 2013-07-17T01:02:08.630 回答