frmarea.frm

来自「很好! 很实用! 免费!」· FRM 代码 · 共 373 行

FRM
373
字号
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmArea 
   ClientHeight    =   7755
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10020
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7755
   ScaleWidth      =   10020
   Begin VB.TextBox txtName 
      Height          =   375
      Left            =   6840
      TabIndex        =   5
      Top             =   2040
      Width           =   3015
   End
   Begin VB.TextBox txtNo 
      Height          =   375
      Left            =   6840
      TabIndex        =   3
      Top             =   1200
      Width           =   2535
   End
   Begin MSComctlLib.TreeView AreaTree 
      Height          =   6735
      Left            =   240
      TabIndex        =   1
      Top             =   720
      Width           =   5775
      _ExtentX        =   10186
      _ExtentY        =   11880
      _Version        =   393217
      HideSelection   =   0   'False
      Indentation     =   176
      LabelEdit       =   1
      Style           =   7
      Appearance      =   1
   End
   Begin MSComctlLib.Toolbar topToolbar 
      Align           =   1  'Align Top
      Height          =   555
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   10020
      _ExtentX        =   17674
      _ExtentY        =   979
      ButtonWidth     =   1138
      ButtonHeight    =   926
      Appearance      =   1
      Style           =   1
      ImageList       =   "toolbarImageList1"
      HotImageList    =   "toolbarImageList2"
      _Version        =   393216
      BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
         NumButtons      =   5
         BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "+\新加"
            Key             =   "Insert1"
            Object.ToolTipText     =   "+\新加"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "+新加"
            Key             =   "Insert2"
            Object.ToolTipText     =   "+新加"
            ImageIndex      =   1
         EndProperty
         BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "修改"
            Key             =   "Update"
            Object.ToolTipText     =   "修改"
            ImageIndex      =   3
         EndProperty
         BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   "删除"
            Key             =   "Delete"
            Object.ToolTipText     =   "删除"
            ImageIndex      =   4
         EndProperty
         BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
            Caption         =   " 退 出 "
            Key             =   "Exit"
            Object.ToolTipText     =   " 退 出"
            ImageIndex      =   11
         EndProperty
      EndProperty
      BorderStyle     =   1
      Begin MSComctlLib.ImageList toolbarImageList2 
         Left            =   8040
         Top             =   0
         _ExtentX        =   1005
         _ExtentY        =   1005
         BackColor       =   -2147483643
         ImageWidth      =   16
         ImageHeight     =   15
         MaskColor       =   12632256
         _Version        =   393216
         BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
            NumListImages   =   11
            BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":0000
               Key             =   ""
            EndProperty
            BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":0542
               Key             =   ""
            EndProperty
            BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":0A84
               Key             =   ""
            EndProperty
            BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":0FC6
               Key             =   ""
            EndProperty
            BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":1162
               Key             =   ""
            EndProperty
            BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":16A4
               Key             =   ""
            EndProperty
            BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":19F8
               Key             =   ""
            EndProperty
            BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":1D4C
               Key             =   ""
            EndProperty
            BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":228E
               Key             =   ""
            EndProperty
            BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":27D0
               Key             =   ""
            EndProperty
            BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":2D12
               Key             =   ""
            EndProperty
         EndProperty
      End
      Begin MSComctlLib.ImageList toolbarImageList1 
         Left            =   7320
         Top             =   0
         _ExtentX        =   1005
         _ExtentY        =   1005
         BackColor       =   -2147483643
         ImageWidth      =   16
         ImageHeight     =   15
         MaskColor       =   12632256
         _Version        =   393216
         BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
            NumListImages   =   11
            BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":2E1C
               Key             =   ""
            EndProperty
            BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":335E
               Key             =   ""
            EndProperty
            BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":38A0
               Key             =   ""
            EndProperty
            BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":3DE2
               Key             =   ""
            EndProperty
            BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":3F7C
               Key             =   ""
            EndProperty
            BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":44BE
               Key             =   ""
            EndProperty
            BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":4812
               Key             =   ""
            EndProperty
            BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":4B66
               Key             =   ""
            EndProperty
            BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":50A8
               Key             =   ""
            EndProperty
            BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":55EA
               Key             =   ""
            EndProperty
            BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
               Picture         =   "frmArea.frx":5B2C
               Key             =   ""
            EndProperty
         EndProperty
      End
   End
   Begin VB.Label lblName 
      AutoSize        =   -1  'True
      Caption         =   "名称"
      Height          =   195
      Left            =   6360
      TabIndex        =   4
      Top             =   2160
      Width           =   360
   End
   Begin VB.Label lblNo 
      AutoSize        =   -1  'True
      Caption         =   "编号"
      Height          =   195
      Left            =   6360
      TabIndex        =   2
      Top             =   1320
      Width           =   360
   End
End
Attribute VB_Name = "frmArea"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub AreaTree_Click()
    If AreaTree.SelectedItem Is Nothing Then Exit Sub
    
    txtNo.Text = AreaTree.SelectedItem.Tag
    txtName.Text = AreaTree.SelectedItem.Text
    
    If AreaTree.SelectedItem.Children > 0 Then topToolbar.Buttons("Delete").Enabled = False
    
    If AreaTree.SelectedItem.Children > 0 Then Exit Sub
    Call GetChildNode(AreaTree.SelectedItem.Key)
    
End Sub

Private Sub Form_Load()
'button
    If g_ButtonArrange Then
        topToolbar.TextAlignment = tbrTextAlignBottom
    Else
        topToolbar.TextAlignment = tbrTextAlignRight
    End If
'caption
    Me.Caption = "客户区域设置"
    
    Call GetChildNode("")
End Sub
Private Sub CheckButton()
    If AreaTree.SelectedItem Is Nothing Then
        topToolbar.Buttons("Insert2").Enabled = False
        topToolbar.Buttons("Update").Enabled = False
        topToolbar.Buttons("Delete").Enabled = False
    Else
        topToolbar.Buttons("Insert2").Enabled = True
        topToolbar.Buttons("Update").Enabled = True
        topToolbar.Buttons("Delete").Enabled = True
        If AreaTree.SelectedItem.Children > 0 Then topToolbar.Buttons("Delete").Enabled = False
        AreaTree.SelectedItem.Expanded = True
    End If
End Sub

Private Sub GetChildNode(ByVal sParentID As String)
Dim rs As ADODB.Recordset
Dim sSQL As String
Dim tmpNode As Node
    sSQL = "select ID,Name,No from plArea where ParentID "
    If sParentID = "" Then
        sSQL = sSQL + " is null"
    Else
        sSQL = sSQL + "=" + CheckString(sParentID)
    End If
    sSQL = sSQL + " order by No"
    Set rs = g_cn.Execute(sSQL)
    Do While Not rs.EOF
        If sParentID = "" Then
            Set tmpNode = AreaTree.Nodes.Add(, , rs.Fields("ID").value, rs.Fields("Name").value)
        Else
            Set tmpNode = AreaTree.Nodes.Add(AreaTree.Nodes.Item(sParentID).index, 4, rs.Fields("ID").value, rs.Fields("Name").value)
        End If
        tmpNode.Tag = rs.Fields("No").value
    rs.MoveNext
    Loop
    
    Call CheckButton
End Sub


Private Sub topToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
Dim objArea As New clsArea
Dim tmpNode As Node
    Select Case Button.Key
        Case "Exit"
            Unload Me
        Case "Insert1"
            With objArea
                .m_ID = newGUID
                .m_No = txtNo.Text
                .m_Name = txtName.Text
                If AreaTree.SelectedItem Is Nothing Then
                    .m_ParentID = ""
                Else
                    .m_ParentID = AreaTree.SelectedItem.Key
                End If
                If .Insert() Then
                        If AreaTree.SelectedItem Is Nothing Then
                            Set tmpNode = AreaTree.Nodes.Add(, , .m_ID, .m_Name)
                        Else
                            Set tmpNode = AreaTree.Nodes.Add(AreaTree.SelectedItem.index, 4, .m_ID, .m_Name)
                        End If
                        tmpNode.Tag = .m_No
                        If Not AreaTree.SelectedItem Is Nothing Then AreaTree.SelectedItem.Expanded = True
                End If
            End With
        Case "Insert2"
            With objArea
                .m_ID = newGUID
                .m_No = txtNo.Text
                .m_Name = txtName.Text
                .m_ParentID = AreaTree.SelectedItem.Key
                If .Insert() Then
                        Set tmpNode = AreaTree.Nodes.Add(AreaTree.SelectedItem.index, 2, .m_ID, .m_Name)
                        tmpNode.Tag = .m_No
                        AreaTree.SelectedItem.Expanded = True
                End If
            End With
        Case "Update"
            If AreaTree.SelectedItem.Children = 0 Then
                With objArea
                    .m_ID = newGUID
                    .m_No = txtNo.Text
                    .m_Name = txtName.Text
                    .m_ParentID = AreaTree.SelectedItem.Key
                    If .Update() Then
                            AreaTree.SelectedItem.Text = .m_Name
                            AreaTree.SelectedItem.Tag = .m_No
                    End If
                End With
            End If
        Case "Delete"
            With objArea
                .m_ID = newGUID
                .m_No = txtNo.Text
                .m_Name = txtName.Text
                .m_ParentID = AreaTree.SelectedItem.Key
                If .Delete() Then
                        AreaTree.Nodes.Remove AreaTree.SelectedItem.index
                End If
            End With
        
    End Select
    Set tmpNode = Nothing
    Set objArea = Nothing
End Sub


Private Sub Form_Resize()
On Error Resume Next
Err.Clear
    
End Sub

⌨️ 快捷键说明

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