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

📄 form2.frm

📁 简单的VB信息管理系统 SQL数据库 简单的查询,删除,添加功能 并能生成报表
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form2 
   Caption         =   "Form2"
   ClientHeight    =   7125
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   7935
   LinkTopic       =   "Form2"
   ScaleHeight     =   7125
   ScaleWidth      =   7935
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command8 
      Caption         =   "返回"
      Height          =   495
      Left            =   6720
      TabIndex        =   20
      Top             =   6480
      Width           =   735
   End
   Begin VB.CommandButton Command7 
      Caption         =   "报表"
      Height          =   495
      Left            =   5400
      TabIndex        =   19
      Top             =   6480
      Width           =   735
   End
   Begin VB.CommandButton Command6 
      Caption         =   "清除"
      Height          =   495
      Left            =   4200
      TabIndex        =   18
      Top             =   6480
      Width           =   735
   End
   Begin VB.CommandButton Command5 
      Caption         =   "删除"
      Height          =   495
      Left            =   2880
      TabIndex        =   17
      Top             =   6480
      Width           =   735
   End
   Begin VB.CommandButton Command4 
      Caption         =   "修改"
      Height          =   495
      Left            =   1680
      TabIndex        =   16
      Top             =   6480
      Width           =   735
   End
   Begin VB.CommandButton Command3 
      Caption         =   "添加"
      Height          =   495
      Left            =   360
      TabIndex        =   15
      Top             =   6480
      Width           =   735
   End
   Begin VB.ComboBox Cmbcontacts 
      Height          =   300
      Left            =   1680
      TabIndex        =   14
      Text            =   "Combo1"
      Top             =   5880
      Width           =   1935
   End
   Begin VB.Frame Frame2 
      Caption         =   "备注"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2175
      Left            =   4080
      TabIndex        =   9
      Top             =   3000
      Width           =   3615
      Begin VB.TextBox txtcontactNote 
         Height          =   1815
         Left            =   120
         TabIndex        =   10
         Text            =   "Text6"
         Top             =   240
         Width           =   3375
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "电话号码"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   2655
      Left            =   360
      TabIndex        =   8
      Top             =   2880
      Width           =   3255
      Begin VB.ListBox LstPhoneNumbers 
         Height          =   1860
         Left            =   120
         TabIndex        =   21
         Top             =   240
         Width           =   3015
      End
      Begin VB.CommandButton Command2 
         Caption         =   "删除"
         Height          =   375
         Left            =   1800
         TabIndex        =   12
         Top             =   2160
         Width           =   855
      End
      Begin VB.CommandButton Command1 
         Caption         =   "添加"
         Height          =   375
         Left            =   480
         TabIndex        =   11
         Top             =   2160
         Width           =   855
      End
   End
   Begin VB.TextBox txtEmailAddress 
      Height          =   375
      Left            =   2040
      TabIndex        =   7
      Text            =   "Text4"
      Top             =   2280
      Width           =   5535
   End
   Begin VB.TextBox txtZipCode 
      Height          =   375
      Left            =   1920
      TabIndex        =   5
      Text            =   "Text3"
      Top             =   1680
      Width           =   2655
   End
   Begin VB.TextBox txtAddress 
      Height          =   375
      Left            =   1920
      TabIndex        =   3
      Text            =   "Text2"
      Top             =   1080
      Width           =   5535
   End
   Begin VB.TextBox txtname 
      Height          =   375
      Left            =   1920
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   480
      Width           =   2535
   End
   Begin VB.Label Label5 
      Caption         =   "联系人列表"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   10.5
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   360
      TabIndex        =   13
      Top             =   5880
      Width           =   1215
   End
   Begin VB.Label Label4 
      Caption         =   "电子邮箱"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   720
      TabIndex        =   6
      Top             =   2280
      Width           =   1095
   End
   Begin VB.Label Label3 
      Caption         =   "邮编"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   960
      TabIndex        =   4
      Top             =   1680
      Width           =   735
   End
   Begin VB.Label Label2 
      Caption         =   "联系人地址"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   2
      Top             =   1080
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "联系人姓名"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   480
      TabIndex        =   0
      Top             =   480
      Width           =   1215
   End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private currentid As Long

Private Sub Cmbcontacts_Click()
    DisplayContact Cmbcontacts.ItemData(Cmbcontacts.ListIndex)
End Sub


Private Sub Command1_Click()
    '添加电话号码
    Dim PhoneType As String
    Dim PhoneNumber As String
    If currentid = 0 Then
        MsgBox "先保存当前记录,然后选择一个已存在的联系人记录添加电话号码"
    Else
        PhoneType = InputBox("请输入电话号码类型:")
        PhoneNumber = InputBox("请输入新的电话号码:")
        If PhoneType <> "" And PhoneNumber <> "" Then
            MyConnection.Execute "Exec ContactPhoneAdd " _
                & currentid & "," _
                & "'" & PhoneType & "'," _
                & "'" & PhoneNumber & "'"
                DisplayPhoneList
        End If
    End If
    
End Sub

Private Sub Command2_Click()
    '删除电话号码
    If LstPhoneNumbers.ListIndex = -1 Then
        MsgBox "先选中需删除的号码,然后单击删除按钮"
    Else
        MyConnection.Execute "Exec ContactPhoneDelete " _
            & LstPhoneNumbers.ItemData(LstPhoneNumbers.ListIndex)
        DisplayPhoneList
    End If
End Sub

Private Sub Command3_Click()
    '增加
    Dim RSAddNew As ADODB.Recordset
    On Error Resume Next
    Set RSAddNew = MyConnection.Execute("Exec ContactAdd " _
        & "'" & txtname.Text & "'," _
        & "'" & txtAddress.Text & "'," _
        & "'" & txtZipCode.Text & "'," _
        & "'" & txtEmailAddress.Text & "'," _
        & "'" & txtcontactNote.Text & "'")
    currentid = RSAddNew("TheNewID")
    Cmbcontacts.AddItem txtname.Text
    Cmbcontacts.ItemData(Cmbcontacts.NewIndex) = RSAddNew("TheNewID")
        
End Sub

Private Sub Command4_Click()
    '修改
    If currentid = 0 Then
        Command3_Click
    Else
        MyConnection.Execute "Exec ContactUpdate " _
        & currentid & "," _
        & "'" & txtname.Text & "'," _
        & "'" & txtAddress.Text & "'," _
        & "'" & txtZipCode.Text & "'," _
        & "'" & txtEmailAddress.Text & "'," _
        & "'" & txtcontactNote.Text & "'"
    End If
    UpdateNameCombo
End Sub

Private Sub Command5_Click()
    '删除
    If currentid = 0 Then
        Command6_Click
    Else
        MyConnection.Execute "Exec DeleteContact " & currentid
        UpdateNameCombo
        DisplayContact 0
    End If
End Sub

Private Sub Command6_Click()
    '清除
    currentid = 0
    txtname.Text = ""
    txtAddress.Text = ""
    txtZipCode.Text = ""
    txtEmailAddress.Text = ""
    txtcontactNote.Text = ""
End Sub

Private Sub Command7_Click()
    DataEnvironment1.Commands(1).Parameters(1).Value = currentid
    DataReport1.Show 1
    Set DataEnvironment1 = Nothing
End Sub

Public Sub DisplayContact(ID2Use As Long)
    Dim RSContact As ADODB.Recordset
    Set RSContact = MyConnection.Execute("Exec contactrecord " _
        & ID2Use)
    If RSContact.EOF Then
        Command6_Click
    Else
        currentid = RSContact("ContactID")
        txtname.Text = RSContact("name")
        txtAddress.Text = RSContact("Address")
        txtZipCode.Text = RSContact("ZipCode")
        txtEmailAddress.Text = RSContact("EmailAddress")
        txtcontactNote.Text = RSContact("contactNote")
        DisplayPhoneList
    End If
End Sub

Public Sub UpdateNameCombo()
    Dim RSNames As ADODB.Recordset
    Set RSNames = MyConnection.Execute("Exec ContactList")
    Cmbcontacts.Clear
    Do Until RSNames.EOF
        Cmbcontacts.AddItem RSNames("name")
        Cmbcontacts.ItemData(Cmbcontacts.NewIndex) = RSNames("COntactID")
        RSNames.MoveNext
    Loop
End Sub
    
Public Sub DisplayPhoneList()
    Dim RSPhoneList As ADODB.Recordset
    LstPhoneNumbers.Clear
    Set RSPhoneList = MyConnection.Execute("Exec ContactPhoneList " & currentid)
    Do Until RSPhoneList.EOF
        LstPhoneNumbers.AddItem RSPhoneList("ThePhone")
        LstPhoneNumbers.ItemData(LstPhoneNumbers.NewIndex) = RSPhoneList("ContactPhoneID")
        RSPhoneList.MoveNext
    Loop
End Sub


Private Sub Command8_Click()
    '返回
    Form3.Show
    Unload Me
End Sub

Private Sub Form_Load()
    DisplayContact 0
    UpdateNameCombo
End Sub


⌨️ 快捷键说明

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