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

📄 frmoperator.frm

📁 这是一本学习串口编程喝计算机监控的好书里面是用VB开发的源代码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
   Begin VB.TextBox txtPassword 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      IMEMode         =   3  'DISABLE
      Left            =   2640
      MaxLength       =   6
      PasswordChar    =   "*"
      TabIndex        =   1
      ToolTipText     =   "4到6位"
      Top             =   2880
      Width           =   975
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Caption         =   "确认"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   3720
      TabIndex        =   9
      Top             =   3000
      Width           =   615
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Caption         =   "工号"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   8
      Top             =   3000
      Width           =   615
   End
   Begin VB.Label Label3 
      Alignment       =   2  'Center
      Caption         =   "密码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   1920
      TabIndex        =   7
      Top             =   3000
      Width           =   615
   End
End
Attribute VB_Name = "frmOperator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdClear_Click()
    txtID.Text = ""
    txtPassword.Text = ""
    txtConfirm.Text = ""
End Sub

Private Sub cmdDel_Click()
    Dim nTmp As Integer
    Dim nRet As Integer
    On Error Resume Next 'CallerID
    
    With AdodcCaller.Recordset
        If .EOF Or .BOF Or .RecordCount < 1 Then
            cmdDel.Enabled = False
            Exit Sub
        End If
        
        nTmp = ![ID]
        nRet = MsgBox("确信删除工号" + Trim(Str(nTmp)) + "吗?", vbQuestion + vbYesNo, "提示")
        If nRet = 6 Then
            If nTmp = ID_SUPER Then
                MsgBox ts(ID_SUPER) + "为超级用户,不可删除!", vbCritical + vbOKOnly, "失败"
                Exit Sub
            End If
            .Delete
            .Requery
            AdjustNumber AdodcCaller, 0
        End If
    End With
End Sub

Private Sub cmdOK_Click()
    Dim nTmp As Integer
    Dim bAddNew As Boolean
    On Error Resume Next 'CallerID
    
    nTmp = Val(txtID.Text)
    If nTmp < ID_SUPER Or nTmp > 9999 Then
        MsgBox "工号必须在1001至9999之间!", vbQuestion + vbOKOnly, "提示"
        txtID.SetFocus
        Exit Sub
    End If
    
    If Len(txtPassword.Text) < 4 Then
        MsgBox "密码必须取4至6位!", vbQuestion + vbOKOnly, "提示"
        txtPassword.SetFocus
        Exit Sub
    End If
    
    If CheckLegalChars(txtPassword.Text, ALL_CHAR_SET) = False Then
        MsgBox "密码必须取数字或字母!", vbQuestion + vbOKOnly, "提示"
        txtPassword.SetFocus
        Exit Sub
    End If
    
    If txtPassword.Text <> txtConfirm.Text Then
        MsgBox "初始密码与确认密码必须一致!", vbQuestion + vbOKOnly, "提示"
        txtPassword.SetFocus
        Exit Sub
    End If
    
    With AdodcCaller.Recordset
        If .RecordCount < 1 Then
            bAddNew = True
        Else
            If nOperatorID <> ID_SUPER And nOperatorID <> nTmp Then
                MsgBox "您无权修改" + Trim(Str(![ID])) + "的密码!", vbCritical + vbOKOnly, "失败"
                Exit Sub
            End If
        End If
        
        If nOperatorID = ID_SUPER Then 'And nTmp <> nOperatorID Then
            .MoveFirst
            Do While Not .EOF
                If ![ID] = nTmp Then Exit Do
                .MoveNext
            Loop
            
            If .EOF Then
                bAddNew = True
            Else
                ![Password] = Base64_Encode(txtPassword.Text)  'ID_SUPER or others by ID_SUPER
                GoTo ENDMARK
            End If
        End If
        
        If bAddNew = True Then
            If .RecordCount < 1 And nTmp <> ID_SUPER Then
                MsgBox "初次建立员工信息,必须首先设置超级用户" + ts(ID_SUPER), vbCritical + vbOKOnly, "提示"
                Exit Sub
            End If
            
            On Error GoTo LAST_MARK
            .AddNew
            ![ID] = nTmp
            ![Password] = Base64_Encode(txtPassword.Text)
            If .RecordCount = 1 Then nOperatorID = nTmp
        End If
        
        If nOperatorID = nTmp Then                            'others by others
            ![Password] = Base64_Encode(txtPassword.Text)
            strOperatorPassword = txtPassword.Text
        End If
ENDMARK:
        .Update
    End With
    
    frmMain.GetCorpInfo
LAST_MARK:
End Sub

Private Sub cmdQuit_Click()
    Unload Me
End Sub

Private Sub DataGrid1_Click()
    On Error Resume Next 'CallerID
    
    With AdodcCaller.Recordset
        If .EOF Or .BOF Or .RecordCount < 1 Then Exit Sub
        txtID.Text = ![ID]
        txtPassword.Text = Base64_Decode(![Password])
        txtConfirm.Text = Base64_Decode(![Password])
    End With
End Sub

Private Sub Form_Load()
    On Error Resume Next 'CallerID
    
    With AdodcCaller
        .ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + _
                          strDataPath + ";Persist Security Info=False"
        .CommandType = adCmdUnknown
        .RecordSource = "select * from Operators order by [ID]"
        .Refresh
        With .Recordset
            If .RecordCount > 0 Then
                .MoveFirst
                Do While Not .EOF
                    If nOperatorID = ![ID] Then
                        txtID.Text = ![ID]
                        txtPassword.Text = Base64_Decode(![Password])
                        txtConfirm.Text = txtPassword.Text
                        Exit Do
                    End If
                    .MoveNext
                Loop
            Else
                txtID.Enabled = True
                GoTo END_MARK
            End If
        End With
    End With
    
    If nOperatorID = ID_SUPER Then
        cmdDel.Enabled = True
        txtID.Enabled = True
    Else
        cmdDel.Enabled = False
        txtID.Enabled = False
    End If
    
    Me.Caption = Me.Caption + " (操作员:" + Trim(Str(nOperatorID)) + ")"
END_MARK:
End Sub

⌨️ 快捷键说明

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