VB+Access界面关于权限设定的问题
我做的是用户管理模块,就是添加用户,删除用户,我有三中用户类型:教师,普通管理员,超级管理员。三种用户全部在一个表里,教师还有一个classID字段,其他类型用户clas...
我做的是用户管理模块,就是添加用户,删除用户,我有三中用户类型:教师,普通管理员,超级管理员。三种用户全部在一个表里,教师还有一个classID字段,其他类型用户classID默认为0,用户添加页面有四个文本框,两个Combolist,一个combolist是用户类型,另一个是课程名。我希望在登录界面的登录的人如果是普通管理员的话,就不能在用户管理页面那边添加普通管理员和超级管理员,只能添加教师,我不知道怎么引用登录界面该登录用户的用户类型(我登录页面有一个Combolist来设置用户类型),把它传递到用户管理页面,哪位高手能教小妹一下,我将不胜感激,这是我的用户管理界面代码:
Public Sub Cmbfield_Click()
Dim gua As String
If Cmbclass.Text = "人力资源管理" Then
gua = 1
Else
gua = 2
End If
If Cmbfield.Text <> "教师" Then
Cmbclass.Visible = False
Cmbclass.Enabled = False
Label6.Visible = False
Else
Cmbclass.Visible = True
Cmbclass.Enabled = True
Label6.Visible = True
Adodc1.Recordset.Fields("classID") = gua
End If
End Sub
End Sub
Private Sub CmdAdd_Click()
If FrmLogin.UTypes.Text = "普通管理员" And Cmbfield.Text = Cmbfield.List(0) Then
Adodc1.RecordSource = "select * from t_user where userID='" & Trim(txtID.Text) & " '"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("userID") = Trim(txtID.Text)
Adodc1.Recordset.Fields("userName") = Trim(txtName.Text)
Adodc1.Recordset.Fields("userPassword") = Trim(txtPassword.Text)
Adodc1.Recordset.Fields("userType") = Trim(Cmbfield.Text)
Call Cmbfield_Click
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.RecordSource = "select * from t_user"
Adodc1.Refresh
MsgBox "添加用户成功", vbOKOnly + vbInformation, "提示"
Cmdclear_Click
Cmbfield.Text = Cmbfield.List(0)
txtID.SetFocus
Cmbfield.Text = ""
Else
Adodc1.Enabled = False
MsgBox "您无选择此用户类型的权限!请更换", , "警告"
End If
Else
MsgBox ("请更换ID!此ID已存在"), , "错误提示"
Cmdclear_Click
txtID.SetFocus
End If
End If
End Sub
Private Sub Form_Load()
txtID.TabIndex = 0
Cmbfield.AddItem "教师"
Cmbfield.AddItem "超级管理员"
Cmbfield.AddItem "普通管理员"
Cmbfield.Text = Cmbfield.List(0)
Adodc1.RecordSource = "select * from t_user"
Adodc1.Refresh
Cmbclass.AddItem "人力资源管理"
Cmbclass.AddItem "医学统计学"
Cmbclass.Text = Cmbclass.List(0)
End Sub
主要是 CmdAdd_Click()里的代码错了,哪位高手帮忙改一下,我直接把源码发给你,我的qq是714021479 展开
Public Sub Cmbfield_Click()
Dim gua As String
If Cmbclass.Text = "人力资源管理" Then
gua = 1
Else
gua = 2
End If
If Cmbfield.Text <> "教师" Then
Cmbclass.Visible = False
Cmbclass.Enabled = False
Label6.Visible = False
Else
Cmbclass.Visible = True
Cmbclass.Enabled = True
Label6.Visible = True
Adodc1.Recordset.Fields("classID") = gua
End If
End Sub
End Sub
Private Sub CmdAdd_Click()
If FrmLogin.UTypes.Text = "普通管理员" And Cmbfield.Text = Cmbfield.List(0) Then
Adodc1.RecordSource = "select * from t_user where userID='" & Trim(txtID.Text) & " '"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount = 0 Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("userID") = Trim(txtID.Text)
Adodc1.Recordset.Fields("userName") = Trim(txtName.Text)
Adodc1.Recordset.Fields("userPassword") = Trim(txtPassword.Text)
Adodc1.Recordset.Fields("userType") = Trim(Cmbfield.Text)
Call Cmbfield_Click
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.RecordSource = "select * from t_user"
Adodc1.Refresh
MsgBox "添加用户成功", vbOKOnly + vbInformation, "提示"
Cmdclear_Click
Cmbfield.Text = Cmbfield.List(0)
txtID.SetFocus
Cmbfield.Text = ""
Else
Adodc1.Enabled = False
MsgBox "您无选择此用户类型的权限!请更换", , "警告"
End If
Else
MsgBox ("请更换ID!此ID已存在"), , "错误提示"
Cmdclear_Click
txtID.SetFocus
End If
End If
End Sub
Private Sub Form_Load()
txtID.TabIndex = 0
Cmbfield.AddItem "教师"
Cmbfield.AddItem "超级管理员"
Cmbfield.AddItem "普通管理员"
Cmbfield.Text = Cmbfield.List(0)
Adodc1.RecordSource = "select * from t_user"
Adodc1.Refresh
Cmbclass.AddItem "人力资源管理"
Cmbclass.AddItem "医学统计学"
Cmbclass.Text = Cmbclass.List(0)
End Sub
主要是 CmdAdd_Click()里的代码错了,哪位高手帮忙改一下,我直接把源码发给你,我的qq是714021479 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询