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

📄 frmphone.frm

📁 基于化工行业造气岗位的自动化监控系统
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmPhone 
   Caption         =   "电话号码薄"
   ClientHeight    =   6105
   ClientLeft      =   -1905
   ClientTop       =   450
   ClientWidth     =   10485
   Icon            =   "frmPhone.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   6105
   ScaleMode       =   0  'User
   ScaleWidth      =   12456.84
   StartUpPosition =   2  '屏幕中心
   Begin VB.PictureBox Picture1 
      Height          =   6135
      Left            =   8880
      ScaleHeight     =   6075
      ScaleWidth      =   1515
      TabIndex        =   12
      Top             =   0
      Width           =   1575
      Begin VB.CommandButton cmdHelp 
         BackColor       =   &H000080FF&
         Caption         =   "帮助&H"
         Height          =   375
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   8
         Top             =   5160
         Width           =   1335
      End
      Begin VB.CommandButton cmdAdd 
         BackColor       =   &H000080FF&
         Caption         =   "添加&A"
         Height          =   375
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   3120
         Width           =   1335
      End
      Begin VB.CommandButton cmdEdit 
         BackColor       =   &H000080FF&
         Caption         =   "修改&E"
         Enabled         =   0   'False
         Height          =   375
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   6
         Top             =   4080
         Width           =   1335
      End
      Begin VB.CommandButton cmdDelete 
         BackColor       =   &H000080FF&
         Caption         =   "删除&D"
         Enabled         =   0   'False
         Height          =   375
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   7
         Top             =   4560
         Width           =   1335
      End
      Begin VB.CommandButton cmdClose 
         BackColor       =   &H000080FF&
         Caption         =   "关闭&C"
         Height          =   375
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   9
         Top             =   5640
         Width           =   1335
      End
      Begin VB.TextBox txtName 
         Height          =   315
         Left            =   120
         TabIndex        =   0
         Top             =   360
         Width           =   1335
      End
      Begin VB.TextBox txtUnit 
         Height          =   315
         Left            =   120
         TabIndex        =   1
         Top             =   960
         Width           =   1335
      End
      Begin VB.TextBox txtTel 
         Height          =   315
         Index           =   0
         Left            =   120
         TabIndex        =   2
         Top             =   1560
         Width           =   1335
      End
      Begin VB.TextBox txtTel 
         Height          =   315
         Index           =   1
         Left            =   120
         TabIndex        =   3
         Top             =   2160
         Width           =   1335
      End
      Begin VB.TextBox txtTel 
         Height          =   315
         Index           =   2
         Left            =   120
         TabIndex        =   4
         Top             =   2760
         Width           =   1335
      End
      Begin VB.CommandButton cmdSave 
         BackColor       =   &H000080FF&
         Caption         =   "保存&S"
         Enabled         =   0   'False
         Height          =   375
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   5
         Top             =   3600
         Width           =   1335
      End
      Begin VB.Label Label1 
         BackColor       =   &H000080FF&
         Caption         =   "姓名:"
         Height          =   255
         Left            =   120
         TabIndex        =   17
         Top             =   120
         Width           =   1335
      End
      Begin VB.Label Label2 
         BackColor       =   &H000080FF&
         Caption         =   "单位:"
         Height          =   255
         Left            =   120
         TabIndex        =   16
         Top             =   720
         Width           =   1335
      End
      Begin VB.Label Label3 
         BackColor       =   &H000080FF&
         Caption         =   "办公电话"
         Height          =   255
         Left            =   120
         TabIndex        =   15
         Top             =   1320
         Width           =   1335
      End
      Begin VB.Label Label4 
         BackColor       =   &H000080FF&
         Caption         =   "家庭电话"
         Height          =   255
         Left            =   120
         TabIndex        =   14
         Top             =   1920
         Width           =   1335
      End
      Begin VB.Label Label5 
         BackColor       =   &H000080FF&
         Caption         =   "移动电话"
         Height          =   255
         Left            =   120
         TabIndex        =   13
         Top             =   2520
         Width           =   1335
      End
   End
   Begin MSComctlLib.ListView lstvPhone 
      Height          =   6135
      Left            =   0
      TabIndex        =   11
      Top             =   0
      Width           =   8895
      _ExtentX        =   15690
      _ExtentY        =   10821
      View            =   3
      Arrange         =   2
      LabelEdit       =   1
      LabelWrap       =   0   'False
      HideSelection   =   -1  'True
      FullRowSelect   =   -1  'True
      PictureAlignment=   5
      _Version        =   393217
      ForeColor       =   16711680
      BackColor       =   16777215
      BorderStyle     =   1
      Appearance      =   1
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      NumItems        =   5
      BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Text            =   "姓名"
         Object.Width           =   2646
      EndProperty
      BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   2
         SubItemIndex    =   1
         Text            =   "单  位"
         Object.Width           =   4939
      EndProperty
      BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   2
         SubItemIndex    =   2
         Text            =   "办公电话"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   2
         SubItemIndex    =   3
         Text            =   "家庭电话"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628} 
         Alignment       =   2
         SubItemIndex    =   4
         Text            =   "移动电话"
         Object.Width           =   2540
      EndProperty
   End
End
Attribute VB_Name = "frmPhone"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim EditType As Long
'Dim Conn As New ADODB.Connection
'Dim Cmd As New ADODB.Command
Dim rs As New ADODB.Recordset

Private Sub cmdAdd_Click()
    EditType = 1
    DataRefresh
    txtName = ""
    txtUnit = ""
    txtTel(0) = ""
    txtTel(1) = ""
    txtTel(2) = ""
    txtName.SetFocus
    cmdAdd.Enabled = False
    cmdSave.Enabled = True
End Sub

Private Sub cmdClose_Click()
    Unload Me
End Sub

Private Sub cmdDelete_Click()
    EditType = 3
    lstvPhone.ListItems.Remove lstvPhone.SelectedItem.Index
    cmdEdit.Enabled = False
    cmdDelete.Enabled = False
    DataRefresh
End Sub

Private Sub cmdEdit_Click()
    EditType = 2
    DataRefresh
    txtName.SetFocus
    lstvPhone.ListItems.Remove lstvPhone.SelectedItem.Index
    cmdEdit.Enabled = False
    cmdDelete.Enabled = False
End Sub

Private Sub cmdSave_Click()
    DataRefresh
    cmdSave.Enabled = False
    cmdAdd.Enabled = True
End Sub

Private Sub Form_Load()
    EditType = 0
    DataRefresh
End Sub

Private Sub Form_Resize()
    If Me.Height < 6570 Or Me.Width < 10550 Then
        Me.Move Me.Left, Me.Top, 10550, 6570
    End If
    lstvPhone.Move 0, 0, ScaleWidth - Picture1.Width, ScaleHeight - 40
    Picture1.Move ScaleWidth - Picture1.Width, 0, Picture1.Width, ScaleHeight - 40
    cmdClose.Move 120, Picture1.Height - cmdClose.Height - 120
    cmdHelp.Move 120, cmdClose.Top - cmdHelp.Height - 120
End Sub

Private Sub lstvPhone_ItemClick(ByVal Item As MSComctlLib.ListItem)
    cmdEdit.Enabled = True
    cmdDelete.Enabled = True
    txtName.Text = lstvPhone.SelectedItem.Text
    txtUnit.Text = lstvPhone.SelectedItem.SubItems(1)
    txtTel(0) = lstvPhone.SelectedItem.SubItems(2)
    txtTel(1) = lstvPhone.SelectedItem.SubItems(3)
    txtTel(2) = lstvPhone.SelectedItem.SubItems(4)
End Sub

Private Sub txtTel_DblClick(Index As Integer)
    Set ControlLink = txtTel(Index)
    frmDataIn.Show
End Sub

Private Sub DataRefresh()
    Dim xItem As ListItem
    On Error GoTo N
    If rs.State = 1 Then
       rs.Close
    End If
    Select Case EditType
        Case 1
            Cmd.CommandText = "Select*from Telephone"
            rs.OPEN Cmd, , adOpenDynamic, adLockOptimistic
            rs.AddNew
            rs("name") = txtName
            rs("unit") = txtUnit
            rs("OfficeTEL") = txtTel(0)
            rs("HomeTEL") = txtTel(1)
            rs("MobileTEL") = txtTel(2)
            rs.UpDate
            rs.Close
            Set rs = Nothing
            Set xItem = lstvPhone.ListItems.Add(, , txtName.Text)
            xItem.SubItems(1) = txtUnit.Text
            xItem.SubItems(2) = txtTel(0).Text
            xItem.SubItems(3) = txtTel(1).Text
            xItem.SubItems(4) = txtTel(2).Text
            
        Case 2
            Cmd.CommandText = "Select*from Telephone where name='" & txtName.Text & "'"
            rs.OPEN Cmd, , adOpenDynamic, adLockOptimistic
            rs("name") = txtName
            rs("unit") = txtUnit
            rs("OfficeTEL") = txtTel(0)
            rs("HomeTEL") = txtTel(1)
            rs("MobileTEL") = txtTel(2)
            rs.UpDate
            rs.Close
            Set rs = Nothing
            Set xItem = lstvPhone.ListItems.Add(, , txtName.Text)
            xItem.SubItems(1) = txtUnit.Text
            xItem.SubItems(2) = txtTel(0).Text
            xItem.SubItems(3) = txtTel(1).Text
            xItem.SubItems(4) = txtTel(2).Text
        Case 3
            Cmd.CommandText = "Delete from Telephone where Name='" & Trim(txtName.Text) & "'and unit='" & Trim(txtUnit.Text) & "'"
            Conn.Execute Cmd.CommandText
        Case 0
            Cmd.CommandText = "Select*from Telephone"
            rs.OPEN Cmd, , adOpenDynamic, adLockOptimistic
            If rs.RecordCount = 0 Then
                frmMain.Statur.Caption = "记录集为空!"
                rs.Close
                Set rs = Nothing
                Exit Sub
            End If
'            rs.MoveFirst
            Do While Not rs.EOF
                Set xItem = lstvPhone.ListItems.Add(, , rs("Name"))
                xItem.SubItems(1) = rs("unit")
                xItem.SubItems(2) = rs("OfficeTEL")
                xItem.SubItems(3) = rs("HomeTEL")
                xItem.SubItems(4) = rs("MobileTEL")
                rs.MoveNext
            Loop
            rs.Close
            Set rs = Nothing
    End Select
Exit Sub
N:
    Err.Clear
    If rs.State = 1 Then
        rs.Close
        Set rs = Nothing
    End If
End Sub


⌨️ 快捷键说明

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