各位老师,
设计了自己的用户及权限管理,但更改用户窗口的部门列会出现原来foxtable默认的用户管理中的内容,如下图
此主题相关图片如下:qq截图20120831190754.jpg
代码如下:
Dim UserName As String
Dim UserGroup As String
Dim UserRole As String
Dim PassWord As String
Dim cmd As New SQLCommand
Dim dt As DataTable
If Forms("用户管理").Opened Then '说明是通过用户管理再打开更改用户窗口的,区别于用户自己更改密码.
UserName = Forms("用户管理").Controls("ListBox1").SelectedItem
Else
UserName = _UserName '_UserName为全局变量,用于保存当前用户名
e.Form.Controls("UserName").Enabled = False
e.Form.Controls("UserGroup").Enabled = False
e.Form.Controls("UserRole").Enabled = False
End If
e.Form.Text = e.Form.Text & "-" & UserName '窗口显示窗口名称及用户名
cmd.C
cmd.CommandText = "Select * From {用户} Where [Name] = '" & UserName & "'"
dt = cmd.ExecuteReader
If dt.DataRows.Count = 1 Then
e.Form.Controls("UserName").Value = UserName
e.Form.Controls("UserGroup").Value = dt.DataRows(0)("Group")
e.Form.Controls("UserRole").Value = dt.DataRows(0)("Role")
e.Form.Controls("PassWord").Value = dt.DataRows(0)("PassWord")
Else
MessageBox.Show("用户不存在或者已经被删除!","提示",MessageBoxButtons.OK)
e.Form.Close()
End If
'从部门角色表生成部门组合框的列表内容
Dim cb As WinForm.ComboBox = e.Form.Controls("UserGroup")
Dim drs As New List(of String)
drs = DataTables("部门角色").GetUniqueValues("","部门")
For Each dr As String In drs
cb.Items.Add(dr)
Next
'从部门角色表生成角色复选框的列表内容
Dim ccb As WinForm.CheckedComboBox = e.Form.Controls("UserRole")
Dim nms As New List(of String)
nms = DataTables("部门角色").GetUniqueValues("","角色")
For Each nm As String In nms
ccb.Items.Add(nm)
Next
ccb.ComboList = String.Join("|", nms.Toarray) '形成列表项目
不知道是什么原因?请大家指点
谢谢!