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

📄 frmdepedit.frm

📁 vb与access数据库的操作实例
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmDepEdit 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "编辑部门信息"
   ClientHeight    =   3195
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4680
   Icon            =   "FrmDepEdit.frx":0000
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Cmd_Cancel 
      Cancel          =   -1  'True
      Caption         =   "取 消"
      Height          =   400
      Left            =   2493
      MouseIcon       =   "FrmDepEdit.frx":0CCA
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   3
      Top             =   2640
      Width           =   1300
   End
   Begin VB.CommandButton Cmd_Ok 
      Caption         =   "确 定"
      Height          =   400
      Left            =   888
      MouseIcon       =   "FrmDepEdit.frx":0FD4
      MousePointer    =   99  'Custom
      Style           =   1  'Graphical
      TabIndex        =   2
      Top             =   2640
      Width           =   1300
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H80000004&
      Height          =   2295
      Left            =   240
      TabIndex        =   4
      Top             =   120
      Width           =   4215
      Begin VB.TextBox txtDescribe 
         Height          =   855
         Left            =   1080
         MultiLine       =   -1  'True
         ScrollBars      =   2  'Vertical
         TabIndex        =   1
         Text            =   "FrmDepEdit.frx":12DE
         Top             =   1320
         Width           =   2895
      End
      Begin VB.TextBox txtDep 
         Height          =   270
         Left            =   1080
         MaxLength       =   20
         TabIndex        =   0
         Top             =   795
         Width           =   2895
      End
      Begin VB.Label Label3 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         BackStyle       =   0  'Transparent
         Caption         =   "功能描述"
         Height          =   180
         Left            =   120
         TabIndex        =   8
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label lblUpper 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         BackStyle       =   0  'Transparent
         Caption         =   "上级部门"
         Height          =   180
         Left            =   1080
         TabIndex        =   7
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         BackStyle       =   0  'Transparent
         Caption         =   "上级部门"
         Height          =   180
         Left            =   120
         TabIndex        =   6
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackColor       =   &H00FFC0C0&
         BackStyle       =   0  'Transparent
         Caption         =   "部门名称"
         Height          =   180
         Left            =   120
         TabIndex        =   5
         Top             =   840
         Width           =   720
      End
   End
End
Attribute VB_Name = "FrmDepEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean

Private Sub Cmd_OK_Click()
  If Trim(txtDep) = "" Then
    MsgBox "请输入部门名称"
    Exit Sub
  End If
  '将新输入的数据保存到类变量中
  With MyDep
  .DepName = MakeStr(txtDep)
  .Describes = MakeStr(txtDescribe)
  
  If Modify = False Then '插入
    If .In_DB(.DepName, .UpperId) = True Then
      MsgBox Trim(txtDep) + " 已经存在"
      Exit Sub
    End If
    'CurDep中保存在部门管理窗体中选中的部门信息
    '当插入新记录时,新记录将做为当前部门的下级部门
    .UpperId = CurDep.DepId
    Bh = .Insert
    '生成TreeView中一个结点的关键字
    Tmp_Key = "a" + Trim(Str(Bh))
    '设置结点的图像
    FrmDepMan.TreeView1.SelectedItem.Image = 1
    FrmDepMan.TreeView1.SelectedItem.ExpandedImage = 2
    FrmDepMan.TreeView1.SelectedItem.SelectedImage = 3
    '在树中添加一个结点
    Set TmpNode = FrmDepMan.TreeView1.Nodes.Add(FrmDepMan.TreeView1.SelectedItem.Key, _
          tvwChild, Tmp_Key, .DepName, 4, 5)
    TmpNode.Selected = True
  Else '修改
    If CurDep.DepName <> Trim(txtDep) Then
      If .In_DB(Trim(txtDep), .UpperId) = True Then
        MsgBox Trim(txtDep) + " 已经存在"
        Exit Sub
      End If
    End If
    '当修改记录时,不能改变上下级之间的关系
    .UpperId = CurDep.UpperId
    .Update (CurDep.DepId)
    If CurDep.DepName <> Trim(txtDep) Then
      FrmDepMan.TreeView1.SelectedItem.Text = Trim(txtDep)
    End If
    '设置CurDep变量
    CurDep.DepName = Trim(txtDep)
  End If
  End With
  '关闭窗口
  Unload Me
End Sub

Private Sub Cmd_Cancel_Click()
  Unload Me
End Sub

Private Sub txtDep_KeyPress(KeyAscii As Integer)
  EnterTAB (KeyAscii)
End Sub

⌨️ 快捷键说明

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