⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 foruser.frm

📁 输入个人联系方式
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   ""
      OLEDBString     =   ""
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   ""
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
End
Attribute VB_Name = "ForUser"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub ComAdm_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserA.Text = "" Then
       MsgBox ("要修改的用户名不能为空,请先找到所要修改的用户")
       Exit Sub
    End If
    
       If TextFind.Text = "" Then
           MsgBox ("请输入用户名!")
       Exit Sub
    End If
    
    Temp = 0
    '注释:查找用户
    Adodc1.Refresh
       Adodc1.Recordset.MoveFirst '指向第一条记录
       For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
           If TextFind.Text = Adodc1.Recordset("用户名") Then
                 Temp = 1
                 Adodc1.Recordset("权限") = "管理员"
                 Adodc1.Recordset.Update
                 DoEvents
                 MsgBox ("权限修改成功!")
                 Exit For                '注释:跳出For
           End If
              Adodc1.Recordset.MoveNext   '注释:指向下一条记录
              DoEvents
       Next I
       If Temp = 0 Then
          Temp = MsgBox("找不到该用户,请确定所要修改的用户名没错!!!", vbOKOnly, "错误")
              '注释:提示用户:"找不到该用户,请确定所要修改的用户名没错!!!"
       End If
       
End Sub

Private Sub ComAdmC_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserC.Text <> "" Then
       If TextPassC.Text <> "" Then
          If TextPassC.Text = TextPassCA.Text Then
             
                 Temp = 0
                 '注释:查找用户
                 Adodc1.Refresh
                 Adodc1.Recordset.MoveFirst '指向第一条记录
                 For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
                     If TextUserC.Text = Adodc1.Recordset("用户名") Then
                         Temp = 1
                         MsgBox ("该用户已经存在,请重新输入用户名!!!")
                         Exit Sub               '注释:跳出Sub
                      End If
                      Adodc1.Recordset.MoveNext   '注释:指向下一条记录
                      DoEvents
                 Next I
                 
                 If Temp = 0 Then
                    Adodc1.Recordset.MoveLast
                    Adodc1.Recordset.AddNew
                    Adodc1.Recordset("用户名") = TextUserC.Text
                    Adodc1.Recordset("密码") = TextPassC.Text
                    Adodc1.Recordset("权限") = "管理员"
                    Adodc1.Recordset.Update
                    DoEvents
                    MsgBox ("添加用户: " & TextUserC.Text & " 成功!" & "权限为:" & "管理员")
                    TextUserC.Text = ""
                    TextPassC.Text = ""
                    TextPassCA.Text = ""
                 End If
       
          Else
              MsgBox ("密码不一致,请重新输入!")
              Exit Sub
          End If
       Else
          MsgBox ("密码不能为空!")
          Exit Sub
       End If
    Else
       MsgBox ("用户名不能为空!")
       Exit Sub
    End If

    
End Sub

Private Sub ComDel_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserA.Text = "" Then
       MsgBox ("要删除的用户名不能为空,请先找到所要删除的用户")
       Exit Sub
    End If
    
        If TextFind.Text = "" Then
       MsgBox ("请输入用户名!")
       Exit Sub
    End If
    
    Temp = 0
    '注释:查找用户
    Adodc1.Refresh
       Adodc1.Recordset.MoveFirst '指向第一条记录
       For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
           If TextFind.Text = Adodc1.Recordset("用户名") Then
                 Temp = 1
                 Adodc1.Recordset.Delete
                 Adodc1.Recordset.Update
                 DoEvents
                 MsgBox ("删除成功!")
                 Exit For                '注释:跳出For
           End If
              Adodc1.Recordset.MoveNext   '注释:指向下一条记录
              DoEvents
       Next I
       If Temp = 0 Then
          Temp = MsgBox("找不到该用户,请确定所要查找的用户名没错!!!", vbOKOnly, "错误")
              '注释:提示用户:"找不到该用户,请确定所要查找的用户名没错!!!"
       End If
       
End Sub

Private Sub ComFind_Click()
Dim Temp As Integer
Dim I As Integer

    If TextFind.Text = "" Then
       MsgBox ("请输入用户名!")
       Exit Sub
    End If
    
    Temp = 0
    '注释:查找用户
    Adodc1.Refresh
       Adodc1.Recordset.MoveFirst '指向第一条记录
       For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
           If TextFind.Text = Adodc1.Recordset("用户名") Then
                 Temp = 1
                 TextUserA.Text = Adodc1.Recordset("用户名")
                 TextPassA.Text = Adodc1.Recordset("密码")
                 TextPowerA.Text = Adodc1.Recordset("权限")
                 Exit For                '注释:跳出For
           End If
              Adodc1.Recordset.MoveNext   '注释:指向下一条记录
              DoEvents
       Next I
       If Temp = 0 Then
          Temp = MsgBox("找不到该用户,请确定所要查找的用户名没错!!!", vbOKOnly, "错误")
              '注释:提示用户:"找不到该用户,请确定所要查找的用户名没错!!!"
       End If
End Sub

Private Sub ComAddu_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserC.Text <> "" Then
       If TextPassC.Text <> "" Then
          If TextPassC.Text = TextPassCA.Text Then
             
                 Temp = 0
                 '注释:查找用户
                 Adodc1.Refresh
                 Adodc1.Recordset.MoveFirst '指向第一条记录
                 For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
                     If TextUserC.Text = Adodc1.Recordset("用户名") Then
                         Temp = 1
                         MsgBox ("该用户已经存在,请重新输入用户名!!!")
                         Exit Sub               '注释:跳出Sub
                      End If
                      Adodc1.Recordset.MoveNext   '注释:指向下一条记录
                      DoEvents
                 Next I
                 
                 If Temp = 0 Then
                    Adodc1.Recordset.MoveLast
                    Adodc1.Recordset.AddNew
                    Adodc1.Recordset("用户名") = TextUserC.Text
                    Adodc1.Recordset("密码") = TextPassC.Text
                    Adodc1.Recordset("权限") = TextPowerC.Text
                    Adodc1.Recordset.Update
                    DoEvents
                    MsgBox ("添加用户: " & TextUserC.Text & " 成功!" & "权限为:" & TextPowerC.Text)
                    TextUserC.Text = ""
                    TextPassC.Text = ""
                    TextPassCA.Text = ""
                 End If
       
          Else
              MsgBox ("密码不一致,请重新输入!")
              Exit Sub
          End If
       Else
          MsgBox ("密码不能为空!")
          Exit Sub
       End If
    Else
       MsgBox ("用户名不能为空!")
       Exit Sub
    End If

End Sub

Private Sub ComPass_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserA.Text = "" Then
       MsgBox ("要修改的用户名不能为空,请先找到所要修改的用户")
       Exit Sub
    End If
    
       If TextFind.Text = "" Then
           MsgBox ("请输入用户名!")
       Exit Sub
    End If
    
    Temp = 0
    '注释:查找用户
    Adodc1.Refresh
       Adodc1.Recordset.MoveFirst '指向第一条记录
       For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
           If TextFind.Text = Adodc1.Recordset("用户名") Then
                 Temp = 1
                 If TextPassA.Text = "" Then
                    MsgBox ("密码不能为空")
                    Exit Sub
                 End If
                 Adodc1.Recordset("密码") = TextPassA.Text
                 Adodc1.Recordset.Update
                 DoEvents
                 MsgBox ("密码修改成功!")
                 Exit For                '注释:跳出For
           End If
              Adodc1.Recordset.MoveNext   '注释:指向下一条记录
              DoEvents
       Next I
       If Temp = 0 Then
          Temp = MsgBox("找不到该用户,请确定所要修改的用户名没错!!!", vbOKOnly, "错误")
              '注释:提示用户:"找不到该用户,请确定所要修改的用户名没错!!!"
       End If
       
End Sub

Private Sub ComPub_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserA.Text = "" Then
       MsgBox ("要修改的用户名不能为空,请先找到所要修改的用户")
       Exit Sub
    End If
    
       If TextFind.Text = "" Then
           MsgBox ("请输入用户名!")
       Exit Sub
    End If
    
    Temp = 0
    '注释:查找用户
    Adodc1.Refresh
       Adodc1.Recordset.MoveFirst '指向第一条记录
       For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
           If TextFind.Text = Adodc1.Recordset("用户名") Then
                 Temp = 1
                 Adodc1.Recordset("权限") = "一般用户"
                 Adodc1.Recordset.Update
                 DoEvents
                 MsgBox ("权限修改成功!")
                 Exit For                '注释:跳出For
           End If
              Adodc1.Recordset.MoveNext   '注释:指向下一条记录
              DoEvents
       Next I
       If Temp = 0 Then
          Temp = MsgBox("找不到该用户,请确定所要修改的用户名没错!!!", vbOKOnly, "错误")
              '注释:提示用户:"找不到该用户,请确定所要修改的用户名没错!!!"
       End If
       
End Sub

Private Sub ComPubC_Click()
Dim I As Integer
Dim Temp As Integer

    If TextUserC.Text <> "" Then
       If TextPassC.Text <> "" Then
          If TextPassC.Text = TextPassCA.Text Then
             
                 Temp = 0
                 '注释:查找用户
                 Adodc1.Refresh
                 Adodc1.Recordset.MoveFirst '指向第一条记录
                 For I = 1 To Adodc1.Recordset.RecordCount  '记录的数量.
                     If TextUserC.Text = Adodc1.Recordset("用户名") Then
                         Temp = 1
                         MsgBox ("该用户已经存在,请重新输入用户名!!!")
                         Exit Sub               '注释:跳出Sub
                      End If
                      Adodc1.Recordset.MoveNext   '注释:指向下一条记录
                      DoEvents
                 Next I
                 
                 If Temp = 0 Then
                    Adodc1.Recordset.MoveLast
                    Adodc1.Recordset.AddNew
                    Adodc1.Recordset("用户名") = TextUserC.Text
                    Adodc1.Recordset("密码") = TextPassC.Text
                    Adodc1.Recordset("权限") = "一般用户"
                    Adodc1.Recordset.Update
                    DoEvents
                    MsgBox ("添加用户: " & TextUserC.Text & "成功!" & "权限为: " & "一般用户")
                    TextUserC.Text = ""
                    TextPassC.Text = ""
                    TextPassCA.Text = ""
                 End If
       
          Else
              MsgBox ("密码不一致,请重新输入!")
              Exit Sub
          End If
       Else
          MsgBox ("密码不能为空!")
          Exit Sub
       End If
    Else
       MsgBox ("用户名不能为空!")
       Exit Sub
    End If
    
End Sub

Private Sub Form_Load()
'------------------------
    '注释:'连接到数据库.(管理员)
    With Adodc1
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Jing.mdb;Mode=ReadWrite;Persist Security Info=False"
        .CommandType = adCmdTable
        .RecordSource = "用户"        '注释:'连接到表"用户"
        .Refresh                      '注释:刷新
    End With
'------------------------
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -