|
各位好:
一直用着红尘大哥的通用系统,但是因为权限问题,我最近在里面要增加到用户组的使用,费了半天劲终于可以注册时附带用户组了,可是注册后发现用户组一栏的数据在用户表中显示乱码,好像是日文的样子。是不是ACCESS版本问题?我的是access2003.
我修改的内容:把原来users表和usergroup表的关系删除,然后ok_click内容如下:
有时间的哥哥姐姐们帮忙看看吧,公司网络不允许上传文件,所以没有附件,各位不好意思。
另外,急切盼望红尘大哥重出江湖!!
Private Sub cmdOK_Click()
On Error GoTo Err_cmdOK_Click
Dim strSQL As String '操作查询SQL语句
Dim lngUserId As Long '系统自动分配给注册用户的用户ID
Dim lngRecordsAffected As Long '操作查询影响的记录行数
If IsNull(Me.txtUserName) Then
MsgBox "请输入用户名。", vbInformation
Me.txtUserName.SetFocus
ElseIf IsNull(Me.txtPassword) Then
MsgBox "请输入密码。", vbInformation
Me.txtPassword.SetFocus
ElseIf IsNull(Me.txtConfirmPwd) Then
MsgBox "请确认密码。", vbInformation
Me.txtConfirmPwd.SetFocus
ElseIf IsNull(Me.cboPrompt) Then
MsgBox "请输入密码提示问题。", vbInformation
Me.cboPrompt.SetFocus
ElseIf IsNull(Me.txtUserGroup) Then
MsgBox "请输入您所在CELL。", vbInformation
Me.txtUserGroup.SetFocus
ElseIf IsNull(Me.txtAnswer) Then
MsgBox "请输入密码提示问题的答案。", vbInformation
Me.txtAnswer.SetFocus
ElseIf StrComp(Me.txtPassword, Me.txtConfirmPwd, vbBinaryCompare) <> 0 Then
MsgBox "两次输入的密码不一致,请重新输入。", vbCritical
'Me.txtPassword = Null
' Me.txtConfirmPwd = Null
Me.txtPassword.SetFocus
ElseIf DCount("[FUserName]", "USysUsers", "[FUserName]='" & Me.txtUserName & "'") > 0 Then
MsgBox "用户名已经存在,请换一个其它用户名。", vbCritical
'Me.txtUserName = Null
Me.txtUserName.SetFocus
Else
If GetKeyState(VK_CAPITAL) <> 0 Then
If MsgBox("密码区分大小写,目前大写锁定键处于打开状态,请确保您知道密码的正确大小写形式。" & _
"是否继续?", vbQuestion + vbOKCancel) = vbOK Then Exit Sub
End If
strSQL = " INSERT INTO USysUsers(FUserName,FPassword,FPrompt,FAnswer,FUserGroup)" & _
" SELECT '" & Me.txtUserName & "','" & RC4(Me.txtPassword) & "','" & Me.cboPrompt & "','" & _
RC4(Me.txtAnswer) & "','" & RC4(Me.txtUserGroup) & "'"
CurrentProject.Connection.Execute strSQL, lngRecordsAffected
If lngRecordsAffected <> 0 Then
'向权限表中添加记录
lngUserId = DLookup("[FUserId]", "USysUsers", "[FUserName]='" & Me.txtUserName & "'")
strSQL = " INSERT INTO USysUserRights(FUserId,FItemId)" & _
" SELECT " & lngUserId & ",FItemId" & _
" FROM USysMenuItems"
CurrentProject.Connection.Execute strSQL, lngRecordsAffected
If lngRecordsAffected <> 0 Then
MsgBox "注册成功!" & vbCr & "您的用户ID为:" & lngUserId, vbInformation
Call cmdCancel_Click
End If
End If
End If
Exit_cmdOK_Click:
Exit Sub
Err_cmdOK_Click:
MsgBox Me.Name & " cmdOK_Click" & vbCr & Err.Description, vbCritical
'写入错误日志
PutErrorLog acForm, Me.Name, "cmdOK_Click"
Resume Exit_cmdOK_Click
End Sub |
|