第六章 系统功能简介 第一部分:系统用户管理 copyright paper51.com
要求:用户分四类:超级用户[一切功能可用]、管理员[不可添加系统用户、修改用户密码、不可实现收费功能]、 内容来自www.paper51.com
内容来自www.paper51.com
源代码如下: paper51.com PublicmiCount As Integer 内容来自www.paper51.com
PrivateSub cmdCancel_Click() ''退出程序 paper51.com End copyright paper51.com
EndSub paper51.com PrivateSub cmdOK_Click() ''进入..确定 内容来自www.paper51.com
OnError GoTo Err http://www.paper51.com Dim txtSql As String 内容来自www.paper51.com UserName = "" 内容来自www.paper51.com If Trim(txtUserName.Text) ="" Then ''判断用户名是否为空 内容来自论文无忧网 www.paper51.com MsgBox "请输入帐号!", vbOKOnly + vbExclamation, "警告" 内容来自论文无忧网 www.paper51.com txtUserName.SetFocus paper51.com ExitSub copyright paper51.com End If paper51.com If Trim(txtPassword.Text) ="" Then '判断密码是否为空 copyright paper51.com MsgBox "请输入密码!", vbOKOnly + vbExclamation, "警告" http://www.paper51.com
txtPassword.SetFocus http://www.paper51.com ExitSub 内容来自论文无忧网 www.paper51.com End If http://www.paper51.com paper51.com ''判断是否有这个用户 http://www.paper51.com
txtSql = "select * from系统用户where 用户名 = '" & txtUserName.Text &"'" paper51.com If rs.State Then rs.Close copyright paper51.com
rs.Open txtSql, CN,adOpenStatic, adLockOptimistic http://www.paper51.com
If rs.EOF = True Then ''如果没有这个用户 内容来自www.paper51.com MsgBox "没有这个帐号,请重新输入帐号!", vbOKOnly + vbExclamation, "警告" 内容来自www.paper51.com txtUserName.Text = "" paper51.com txtPassword.Text = "" paper51.com
txtUserName.SetFocus 内容来自论文无忧网 www.paper51.com Else ''如果有用户 内容来自www.paper51.com
内容来自www.paper51.com
IfTrim(rs.Fields(1)) = Trim(txtPassword.Text) Then paper51.com ''判断权限 http://www.paper51.com UserPrivs = "" copyright paper51.com If Trim(rs.Fields(2)) = "管理员" Then ''管理员权限 paper51.com IsUserMode = 1 http://www.paper51.com ElseIf Trim(rs.Fields(2)) = "普通用户" Then ''普通用户权限 paper51.com IsUserMode = 2 内容来自论文无忧网 www.paper51.com Else ''无权 paper51.com
IsUserMode = 0 内容来自www.paper51.com MsgBox "你没有权限!", vbExclamation, "警告" 内容来自www.paper51.com End http://www.paper51.com End If copyright paper51.com
UserPrivs = Trim(rs.Fields(2)) paper51.com UserName = Trim(txtUserName.Text) paper51.com
Unload Me paper51.com Mainfrm.Show copyright paper51.com
内容来自论文无忧网 www.paper51.com
Exit Sub 内容来自论文无忧网 www.paper51.com Else copyright paper51.com
MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "警告" http://www.paper51.com txtPassword.SetFocus copyright paper51.com txtPassword.Text = "" copyright paper51.com EndIf paper51.com End If http://www.paper51.com rs.Close 内容来自论文无忧网 www.paper51.com miCount = miCount + 1 http://www.paper51.com If miCount = 3 Then ''三次错误,自动退出程序 内容来自www.paper51.com End http://www.paper51.com End If copyright paper51.com ExitSub 内容来自论文无忧网 www.paper51.com Err: 内容来自www.paper51.com MsgBox "登录出错,请找管理员!", vbExclamation copyright paper51.com
Ok = False paper51.com End 内容来自论文无忧网 www.paper51.com EndSub copyright paper51.com PrivateSub Form_Activate() http://www.paper51.com txtUserName.SetFocus http://www.paper51.com EndSub 内容来自www.paper51.com |