机房收费系统之登录

这部分  内容与 学生管理系统十分相似,唯一的一些差别就是在登录类型那里  分为,一般用户,操作员,管理员,再将表更新。

先看一下流程图吧。

注意事项

1.要限制用户控件的字符

2.要限制登录不同类型的人,有不同的权限。

3.密码输错三次,退出程序。

 

代码

Private Sub cmdOK_Click()

     Dim txtSQL As String '用来存放SQL 语句
     Dim txtsql1 As String
     Dim txtsql2 As String

     Dim mrc As ADODB.Recordset   '用来存放记录集对象
     Dim mrc1 As ADODB.Recordset
     Dim mrc2 As ADODB.Recordset
    
     Dim Msgtext As String   '用来存放返回消息
     Dim MsgText1 As String
     Dim MsgText2 As String

     UserName = ""

     If Trim(txtUserName.Text = "") Then  '判断输入用户名是否为空
       MsgBox "请输入用户名!", vbOKOnly + vbExclamation, "提示"
       txtUserName.SetFocus
       txtPassword.Text = ""
    Exit Sub
     Else


    If Trim(txtPassword.Text = "") Then  '判断输入用户名是否为空
       MsgBox "请输入密码!", vbOKOnly + vbExclamation, "提示"
       txtPassword.SetFocus
       txtPassword.Text = ""
     Exit Sub

    Else
    '查询指定用户名的记录
     txtSQL = "select * from user_Info where userID = '" & txtUserName.Text & "'"
     Set mrc = ExecuteSQL(txtSQL, Msgtext)
     
     txtsql2 = "select * from worklog_Info where userID = '" & txtUserName.Text & "'"
     Set mrc2 = ExecuteSQL(txtsql2, MsgText2)
    
     txtsql1 = "select * from onwork_Info where userID = '" & txtUserName.Text & "'"
     Set mrc1 = ExecuteSQL(txtsql1, MsgText1)


    If mrc.EOF Then
     MsgBox "没有这个用户,请重新输入用户名!", vbOKOnly + vbExclamation, "提示"
     txtUserName.SetFocus
     txtUserName.Text = ""
     Exit Sub
    Else

    '判断输入密码是否正确
    If Trim(mrc.Fields(0)) = txtUserName.Text And Trim(mrc.Fields(1)) = Trim(txtPassword.Text) Then
     OK = True
    
     UserName = Trim(txtUserName.Text)

    If Trim(mrc.Fields(2)) = "一般用户" Then '判断用户级别
        MsgBox "您是一般用户"
        frmMain.Operator.Enabled = False
        frmMain.Administrator.Enabled = False
    
    
     End If
    
     If Trim(mrc.Fields(2)) = "操作员" Then
       MsgBox "您是操作员"
    
   MDIForm1.Administrator_Menu.Enabled = False
    
    End If
     If Trim(mrc.Fields(2)) = "管理员" Then
    MsgBox "您是管理员"
    
     End If
        mrc1.AddNew
        mrc1.Fields(0) = Trim(txtUserName)
        mrc1.Fields(1) = Trim(mrc.Fields(2))
        mrc1.Fields(2) = Trim(Date)
        mrc1.Fields(3) = Time
        mrc1.Update
        mrc1.Close
    
        mrc2.AddNew  '添加记录到worklog_info表
        mrc2.Fields(1) = Trim(txtUserName)
        mrc2.Fields(2) = Trim(mrc.Fields(2))
        mrc2.Fields(3) = Trim(Date)
        mrc2.Fields(4) = Trim(Time)
        mrc2.Fields(7) = VBA.Environ("computername")
        mrc2.Fields(8) = True
        mrc2.Update
        mrc2.Close
         Me.Hide
        Print
        Else
    
    MsgBox "输入密码不正确,请重新输入!", vbOKOnly + vbExclamation, "提示"
    txtPassword.SetFocus
    txtPassword.Text = ""
    End If

    '记载输入密码次数
    miCount = miCount + 1
       If miCount = 3 Then
            MsgBox "超过登陆限制"
       End
       End If
     End If
   End If
 End If
 End Sub

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Tzk_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值