📄 frmbooktypeedit.frm
字号:
VERSION 5.00
Begin VB.Form FrmBookTypeEdit
BorderStyle = 1 'Fixed Single
Caption = "编辑图书分类信息"
ClientHeight = 2175
ClientLeft = 45
ClientTop = 330
ClientWidth = 4680
Icon = "FrmBookTypeEdit.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2175
ScaleWidth = 4680
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Cmd_Cancel
Cancel = -1 'True
Caption = "取 消"
Height = 400
Left = 2640
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 2
Top = 1560
Width = 1300
End
Begin VB.CommandButton Cmd_Ok
Caption = "确 定"
Height = 400
Left = 888
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 1
Top = 1560
Width = 1300
End
Begin VB.Frame Frame1
BackColor = &H80000004&
Height = 1335
Left = 240
TabIndex = 3
Top = 120
Width = 4215
Begin VB.TextBox txtType
Height = 270
Left = 1080
MaxLength = 20
TabIndex = 0
Top = 795
Width = 2895
End
Begin VB.Label lblUpper
AutoSize = -1 'True
BackColor = &H00FFC0C0&
BackStyle = 0 'Transparent
Caption = "lblUpper"
Height = 180
Left = 1080
TabIndex = 6
Top = 360
Width = 720
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H00FFC0C0&
BackStyle = 0 'Transparent
Caption = "上级分类"
Height = 180
Left = 120
TabIndex = 5
Top = 360
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H00FFC0C0&
BackStyle = 0 'Transparent
Caption = "分类名称"
Height = 180
Left = 120
TabIndex = 4
Top = 840
Width = 720
End
End
End
Attribute VB_Name = "FrmBookTypeEdit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Boolean
Public TmpUId As Long
Private Sub Cmd_OK_Click()
Dim Bh As Long
'检查用户录入数据的有效性
If Trim(txtType) = "" Then
MsgBox "请输入图书分类名称"
Exit Sub
End If
'将新输入的数据保存到类变量中
With MyBookType
.TypeName = MakeStr(txtType)
'根据变量Modify决定是插入新数据,还是修改已有的数据
If Modify = False Then '插入
'调用In_DB()函数判断用户输入的名称是否已经存在
If .In_DB(.TypeName) = True Then
MsgBox Trim(txtType) + " 已经存在"
Exit Sub
End If
'CurBookType中保存在图书分类管理窗体中选中的图书分类信息
'当插入新记录时,新记录将做为当前图书分类的下级图书分类
.UpperId = TmpUId
Bh = .Insert
'生成TreeView中一个结点的关键字
Tmp_Key = "a" + Trim(Str(Bh))
'设置结点的图像
FrmBookType.TreeView1.SelectedItem.Image = 1
FrmBookType.TreeView1.SelectedItem.ExpandedImage = 2
FrmBookType.TreeView1.SelectedItem.SelectedImage = 3
'在树中添加一个结点
Set TmpNode = FrmBookType.TreeView1.Nodes.Add(FrmBookType.TreeView1.SelectedItem.Key, _
tvwChild, Tmp_Key, .TypeName, 4, 5)
TmpNode.Selected = True
Else '修改
If CurBookType.TypeName <> Trim(txtType) Then
If .In_DB(Trim(txtType)) = True Then
MsgBox Trim(txtType) + " 已经存在"
Exit Sub
End If
End If
'当修改记录时,不能改变上下级之间的关系
.UpperId = CurBookType.UpperId
.Update (CurBookType.TypeId)
If CurBookType.TypeName <> Trim(txtType) Then
FrmBookType.TreeView1.SelectedItem.Text = Trim(txtType)
End If
'设置CurBookType变量
CurBookType.TypeName = Trim(txtType)
End If
End With
'关闭窗口
Unload Me
End Sub
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub txtType_KeyPress(KeyAscii As Integer)
EnterTAB (KeyAscii)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -