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

📄 frmtype.frm

📁 一个日程管理和通讯录管理的软件
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmType 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "类别"
   ClientHeight    =   4365
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4110
   Icon            =   "frmType.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4365
   ScaleWidth      =   4110
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdCancel 
      Caption         =   "取消"
      Height          =   285
      Left            =   2880
      TabIndex        =   7
      Top             =   3960
      Width           =   1050
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确定"
      Height          =   285
      Left            =   2880
      TabIndex        =   6
      Top             =   3555
      Width           =   1050
   End
   Begin VB.CommandButton cmdDel 
      Caption         =   "删除"
      Height          =   285
      Left            =   2880
      TabIndex        =   5
      Top             =   1440
      Width           =   1050
   End
   Begin VB.CommandButton cmdEdit 
      Caption         =   "编辑"
      Height          =   285
      Left            =   2880
      TabIndex        =   4
      Top             =   1035
      Width           =   1050
   End
   Begin VB.CommandButton cmdAddType 
      Caption         =   "添至列表"
      Height          =   285
      Left            =   2880
      TabIndex        =   2
      Top             =   360
      Width           =   1050
   End
   Begin VB.ListBox lstType 
      Height          =   3210
      Left            =   135
      Style           =   1  'Checkbox
      TabIndex        =   3
      Top             =   1035
      Width           =   2535
   End
   Begin VB.TextBox txtType 
      Height          =   270
      Left            =   135
      TabIndex        =   1
      Top             =   360
      Width           =   2535
   End
   Begin VB.Label Label2 
      Caption         =   "项目所属类别:"
      Height          =   195
      Left            =   135
      TabIndex        =   8
      Top             =   810
      Width           =   1320
   End
   Begin VB.Label Label1 
      Caption         =   "新类别:"
      Height          =   195
      Left            =   135
      TabIndex        =   0
      Top             =   135
      Width           =   915
   End
End
Attribute VB_Name = "frmType"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*****************************************************
'*
'*             选择任务或计划的类别
'*
'*****************************************************

Private strTypeLib As String    '区别是任务或计划的类别

Public Property Let TypeLib(newValue As String)

    strTypeLib = newValue
    
End Property

'添加新类别
Private Sub cmdAddType_Click()
    
    If Trim(txtType.Text) <> "" Then
        
        '类别名文本框不为空则添加新的类别
        strQry = "select * from " & strTypeLib & " where ID='" & UserID & "'"
        Set rstCustomers = GetRecordSet(cnnConnection, strQry)
        rstCustomers.AddNew
        rstCustomers!ID = UserID
        rstCustomers!TypeName = Trim(txtType.Text)
        rstCustomers.Update
        lstType.AddItem rstCustomers!TypeName
        lstType.ItemData(lstType.NewIndex) = rstCustomers!type_ID
        
    End If
    
    If lstType.ListCount = 1 Then
        cmdEdit.Enabled = True
        cmdDel.Enabled = True
    End If
    
End Sub

Private Sub cmdCancel_Click()
    
    '放弃所做的类别选择
    frmType.Tag = "cancel"
    frmType.Visible = False
    
End Sub

Private Sub cmdDel_Click()
    
    '删除选定的类别
    strQry = "delete from " & strTypeLib & " where type_ID=" & Trim(Str(lstType.ItemData(lstType.ListIndex)))
    cnnConnection.Execute strQry
    lstType.RemoveItem lstType.ListIndex
    
    If lstType.ListCount = 0 Then
        cmdEdit.Enabled = False
        cmdDel.Enabled = False
    End If
    
End Sub

'编辑类别名
Private Sub cmdEdit_Click()

    Dim strTypeName As String
    
    '输入新的类别名
    strTypeName = InputBox("请输入修改后类别的名称:", SYSTEMCAPTION, lstType.List(lstType.ListIndex))
    
    '取消输入新的类别名或输入的类别名为空时,不作更改
    If strTypeName = "" Then
        Exit Sub
    End If
    
    '更改类别名
    lstType.List(lstType.ListIndex) = strTypeName
    strQry = "update " & strTypeLib & " set typename='" & lstType.List(lstType.ListIndex) & "' where type_ID=" & Trim(Str(lstType.ItemData(lstType.ListIndex)))
    cnnConnection.Execute strQry
    
End Sub

Private Sub cmdOK_Click()

    Dim i As Long
    
    frmType.Tag = ""
    frmCalendar.SelectedType = ""
    
    For i = 0 To lstType.ListCount - 1
    
        If lstType.Selected(i) Then
        
            '将选中类别的ID加入Tag
            frmType.Tag = frmType.Tag & Trim(Str(lstType.ItemData(i))) & ","
            
            '将选中类别的名字加入字符串
            frmCalendar.SelectedType = frmCalendar.SelectedType & lstType.List(i) & "、"
        End If
        
    Next i
    
    If frmType.Tag <> "" Then
    
        '去除尾部的顿号和逗号
        frmType.Tag = Left(frmType.Tag, Len(frmType.Tag) - 1)
        frmCalendar.SelectedType = Left(frmCalendar.SelectedType, Len(frmCalendar.SelectedType) - 1)
    End If
    
    frmType.Visible = False
    
End Sub

Private Sub Form_Resize()

    Dim i As Long
    
    '装载可选类别
    strQry = "select type_ID,typename from " & strTypeLib & " where ID='" & UserID & "'"
    Set rstCustomers = GetRecordSet(cnnConnection, strQry)

    If rstCustomers.RecordCount <> 0 Then
        rstCustomers.MoveFirst

        While rstCustomers.EOF = False

            '将类别名加入lstType
            lstType.AddItem rstCustomers!TypeName

            '将类别ID加入ItemData
            lstType.ItemData(lstType.NewIndex) = rstCustomers!type_ID
            rstCustomers.MoveNext
        Wend

    End If
    
    For i = 0 To lstType.ListCount - 1
        
        '判断一个类别是否在已选类别ID串中
        If InStr(frmType.Tag, Trim(Str(lstType.ItemData(i)))) <> 0 Then
        
            '存在,则将该类别标为选中
            lstType.Selected(i) = True
        End If
        
    Next i
    
End Sub

⌨️ 快捷键说明

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