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

📄 gdhoperator.frm

📁 齐鲁石化某分公司的数据采集管理系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form gdhOperator 
   Caption         =   "操作员设置"
   ClientHeight    =   3090
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3090
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton Command3 
      Caption         =   "删除"
      Height          =   375
      Left            =   1800
      TabIndex        =   10
      Top             =   2400
      Width           =   1215
   End
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   375
      Left            =   3360
      TabIndex        =   9
      Top             =   2400
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "添加"
      Height          =   375
      Left            =   240
      TabIndex        =   8
      Top             =   2400
      Width           =   1215
   End
   Begin VB.ComboBox Combo1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   1560
      TabIndex        =   7
      Top             =   1680
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      IMEMode         =   3  'DISABLE
      Index           =   2
      Left            =   1560
      PasswordChar    =   "*"
      TabIndex        =   6
      Top             =   1200
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      IMEMode         =   3  'DISABLE
      Index           =   1
      Left            =   1560
      PasswordChar    =   "*"
      TabIndex        =   5
      Top             =   720
      Width           =   1575
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Index           =   0
      Left            =   1560
      TabIndex        =   4
      Top             =   240
      Width           =   1575
   End
   Begin VB.Label Label1 
      Caption         =   "类型"
      Height          =   375
      Index           =   3
      Left            =   240
      TabIndex        =   3
      Top             =   1680
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "确认密码"
      Height          =   375
      Index           =   2
      Left            =   240
      TabIndex        =   2
      Top             =   1200
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "密码"
      Height          =   375
      Index           =   1
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "用户名"
      Height          =   375
      Index           =   0
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   975
   End
End
Attribute VB_Name = "gdhOperator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
    Dim db As New Adodb.Connection
    Dim rs As New Adodb.Recordset
    Dim Query As String
    Dim GLUser As Boolean
    Dim strNOw As String
    On Error GoTo ok
    
    If Checking = False Then
        Exit Sub
    End If
    db.CursorLocation = adUseClient
    db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\admin.mdb;Jet OLEDB:Database Password=dfrwadmin;"
    If db.State <> 1 Then
        Exit Sub
    End If
    
    If Combo1.text = "管理员" Then
        GLUser = True
    Else
        GLUser = False
    End If
    
    Query = "select * from users where 用户名='" & Text1(0).text & "'"
    rs.Open Query, db, adOpenDynamic, adLockOptimistic
    If Not rs.BOF And Not rs.EOF Then
        MsgBox "此用户名已存在,请更改用户名"
        rs.Close
        db.Close
        Exit Sub
    End If
    
    strNOw = Format(Now, "yyyy-mm-dd hh:mm:ss")
    Query = "insert into users(用户名,密码,类型,创建时间)"
    Query = Query & "values('" & Text1(0).text & "','" & Text1(1).text & "'," & GLUser & ",'" & strNOw & "')"
    db.Execute Query
    db.Close
    MsgBox "添加成功"
ok:
    If db.State = 1 Then
        db.Close
    End If
End Sub

Function Checking() As Boolean
    
    If Trim(Text1(0).text) = "" Then
        MsgBox "用户名不能为空"
        Exit Function
    End If
    If Trim(Text1(1).text) = "" Then
        MsgBox "密码不能为空"
        Exit Function
    End If
    If Trim(Text1(1).text) <> Trim(Text1(2).text) Then
        MsgBox "密码前后输入不一致"
        Exit Function
    End If
    
    Checking = True
End Function

Function Initialize_()
    Combo1.AddItem "操作员"
    Combo1.AddItem "管理员"
    Combo1.text = "操作员"
End Function

Private Sub Command2_Click()
    Unload Me
End Sub

Private Sub Command3_Click()
    Dim db As New Adodb.Connection
    Dim rs As New Adodb.Recordset
    Dim Query As String
    Dim GLUser As Boolean
    Dim strNOw As String
    On Error GoTo ok
    
    If MsgBox("确实要删除此用户吗?", vbYesNo + vbDefaultButton2) <> vbYes Then
        Exit Sub
    End If
    
    db.CursorLocation = adUseClient
    db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\admin.mdb;Jet OLEDB:Database Password=dfrwadmin;"
    If db.State <> 1 Then
        Exit Sub
    End If
    
    Query = "delete from users where 用户名='" & Text1(0).text & "'"
    db.Execute Query
    db.Close
    MsgBox "用户已删除"
    Exit Sub
ok:
    MsgBox "未能删除"
End Sub

Private Sub Form_Load()
    Call setCenter
    Call Initialize_
End Sub

Function setCenter()
    Dim X0 As Long
    Dim Y0 As Long
    X0 = Screen.Width
    Y0 = Screen.Height
    X0 = (X0 - Me.Width) / 2
    Y0 = (Y0 - Me.Height) / 2
    Me.Move X0, Y0
End Function

Private Sub Form_Unload(Cancel As Integer)
    gdhMain.Enabled = True
End Sub

⌨️ 快捷键说明

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