📄 frmbooksel.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form FrmBookSel
BorderStyle = 1 'Fixed Single
ClientHeight = 4830
ClientLeft = 15
ClientTop = 15
ClientWidth = 6255
ControlBox = 0 'False
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4830
ScaleWidth = 6255
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 120
Top = 4080
Visible = 0 'False
Width = 1215
_ExtentX = 2143
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Books;Data Source=127.0.0.1"
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Books;Data Source=127.0.0.1"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = "sa"
Password = "sa"
RecordSource = "select * from bookinfo"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Cmd_Cancel
BackColor = &H80000004&
Caption = "取 消"
Height = 400
Left = 3317
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 3
Top = 4200
Width = 1300
End
Begin VB.CommandButton Cmd_OK
BackColor = &H80000004&
Caption = "确 定"
Default = -1 'True
Height = 400
Left = 1637
MousePointer = 99 'Custom
Style = 1 'Graphical
TabIndex = 2
Top = 4200
Width = 1300
End
Begin MSDataListLib.DataList DataList1
Bindings = "FrmBookSel.frx":0000
Height = 3840
Left = 2880
TabIndex = 0
Top = 120
Width = 3255
_ExtentX = 5741
_ExtentY = 6773
_Version = 393216
ListField = "BookName"
BoundColumn = "BookNo"
End
Begin MSComctlLib.ImageList ImageList3
Left = 5160
Top = 4080
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483628
ImageWidth = 16
ImageHeight = 16
MaskColor = 16777215
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 5
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FrmBookSel.frx":0015
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FrmBookSel.frx":29A7
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FrmBookSel.frx":5339
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FrmBookSel.frx":7CCB
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "FrmBookSel.frx":A65D
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.TreeView TreeView1
Height = 3840
Left = 120
TabIndex = 1
Top = 120
Width = 2655
_ExtentX = 4683
_ExtentY = 6773
_Version = 393217
HideSelection = 0 'False
LabelEdit = 1
Sorted = -1 'True
Style = 7
HotTracking = -1 'True
SingleSel = -1 'True
ImageList = "ImageList3"
BorderStyle = 1
Appearance = 1
MousePointer = 99
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "FrmBookSel"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public nTypeId As Long '分类编号
Public bHaveSon As Boolean '是否有子节点
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_OK_Click()
'如果没有选择图书,则提示重新选择
If MyBookInfo.BookNo = "" Then
MsgBox "请选择图书"
Exit Sub
End If
'将选择图书的数据保存在SelBookInfo变量中
SelBookInfo.BookNo = MyBookInfo.BookNo
SelBookInfo.GetInfo (SelBookInfo.BookNo)
Unload Me
End Sub
Private Sub DataList1_Click()
'如果没有选择图书,则对MyBookInfo对象初始化,然后返回
If DataList1.BoundText = "" Then
MyBookInfo.Init
Exit Sub
End If
'读取当前图书信息到MyBookInfo
MyBookInfo.GetInfo (DataList1.BoundText)
End Sub
Private Sub Form_Load()
Dim TmpNode As Node
'设置根结点
Set TmpNode = TreeView1.Nodes.Add(, , "a0", "图书分类", 1, 3)
TmpNode.Selected = True
TmpNode.ExpandedImage = 2
'调用函数将所有图书分类添加到TreeView1中
Call AddtoTree(TreeView1, "a0")
'调用TrieView_Click过程,把此分类下的所有图书信息都添加到列表中
TreeView1_Click
End Sub
Private Sub TreeView1_Click()
Dim Focuskey As String
'根据关键字获取图书分类信息
Focuskey = TreeView1.SelectedItem.Key
CurBookType.TypeName = TreeView1.SelectedItem.Text
CurBookType.TypeId = Val(Right(TreeView1.SelectedItem.Key, Len(TreeView1.SelectedItem.Key) - 1))
If Focuskey = "a0" Then '根结点
nTypeId = -1
Exit Sub
End If
'如果包含子结点,则设置图像格式
bHaveSon = CurBookType.HaveSon(CurBookType.TypeId)
If bHaveSon = False Then
TreeView1.SelectedItem.ExpandedImage = 4
TreeView1.SelectedItem.Image = 4
TreeView1.SelectedItem.SelectedImage = 5
End If
nTypeId = CurBookType.TypeId
'读取CurBookType中的所有图书分类信息
CurBookType.GetInfo (CurBookType.TypeId)
'根据图书分类刷新图书列表
ListRefresh
End Sub
Private Sub ListRefresh()
If nTypeId = -1 Then '表示为根目录
strSearch = ""
ElseIf bHaveSon = True Then '表示为有子节点的分类,显示此分类下的所有图书
strSearch = " ,BookType t WHERE b.TypeId=t.TypeId AND t.UpperId=" + Trim(Str(nTypeId))
Else '表示为子节点
strSearch = " WHERE b.TypeId=" + Trim(Str(nTypeId))
End If
'设置ADO控件的连接字符串
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
+ App.Path + "\Books.mdb;Persist Security Info=False"
'刷新记录
Adodc1.RecordSource = "SELECT b.BookNo,b.BookName FROM BookInfo b " + strSearch
' MsgBox (Adodc1.RecordSource)
Adodc1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -