我想要的效果是这样的,我做的系统的像网站一样,用户名是有管理员管理的,每个用户名绑定一台电脑,我在users表中加了一列”MAC“用于保存主板信息,有系统自带的变量ComputerId,获取, 甚至不需要“用户管理窗口“,直接在Users表中,添加,清除密码,清除绑定的主板信息,用户名是管理员人工派发的,只要一个登陆窗口就行了。
设计思路,登录窗口还是帮助里的不变,确定代码如下:
1,用户名是否为空,
不为空,查找到到一行,
2,判断MAC是否为空,如果为空,获取的ComputerId值,保存在MAC中,
如果MAC不为空,判断密码是否为空,
如果为空,把为本框的密码保存在password中,
密码不为空时,判断密码是否正确。。。和帮助一样了
不知道ComputerId可以直接用吗?在保存数据的代码,提示代码出错,原代码是3列数据,我设计的每次保存一列,把其他列剪掉后,不知道怎么改? 另外其他的还有错吗?
Dim UserName As String = e.Form.Controls("UserName").Value
Dim cmd As New SQLCommand
Dim dt As DataTable
Dim dr As DataRow
cmd.C
If UserName = "" Then
Messagebox.show("请选择用户!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
End If
cmd.CommandText = "Select * From {Users} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
dr = dt.DataRows(0)
Dim nm As String = ComputerId
If dr("MAC")= "" Then 判断主板信息是否存在
cmd.CommandText = "Insert Into {Users} ([MAC]) Values ('"
cmd.CommandText = cmd.CommandText & nm & "')"
Else
If nm = dr("MAC") Then 对主板信息判断
If dr("Password")= "" Then
cmd.CommandText = "Insert Into {Users} ([Password]) Values ('"
cmd.CommandText = cmd.CommandText & Passwod & "')"
Else
If e.Form.Controls("PassWord").Value = dr("Password") Then 对密码判断
_UserName = UserName
_UserGroup = dr("Group")
e.Form.Close
Else
Messagebox.show("密码错误!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If
End if
Else
Messagebox.show("请珍惜你的账号,不要借给他人使用","提 示",MessageBoxButtons.OK,MessageBoxIcon.Informat
End if
End if