第一次机房收费系统之注册

刚接触机房收费系统,第一个要解决的问题就是登陆的问题,下面是我的登陆界面的E-R模型,这个界面还是相对来说比较简单的。

下面是我的代码部分

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 "您是操作员"
        frmMain.Administrator.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
            
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
 

猜你喜欢

转载自blog.csdn.net/weixin_44126152/article/details/86909870