📄 frmassortbook.frm
字号:
VERSION 5.00
Object = "{00028C01-0000-0000-0000-000000000046}#1.0#0"; "DBGRID32.OCX"
Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX"
Begin VB.Form frmAssortBook
Caption = "图书分类查询"
ClientHeight = 9090
ClientLeft = 60
ClientTop = 1560
ClientWidth = 15240
Icon = "frmAssortBook.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MDIChild = -1 'True
ScaleHeight = 9090
ScaleWidth = 15240
WindowState = 2 'Maximized
Begin TabDlg.SSTab SSTab1
Height = 8895
Left = 120
TabIndex = 0
Top = 120
Width = 15015
_ExtentX = 26485
_ExtentY = 15690
_Version = 393216
Tabs = 1
TabHeight = 520
ForeColor = 33023
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "华文行楷"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
TabCaption(0) = "图书分类查询"
TabPicture(0) = "frmAssortBook.frx":0442
Tab(0).ControlEnabled= -1 'True
Tab(0).Control(0)= "Label2"
Tab(0).Control(0).Enabled= 0 'False
Tab(0).Control(1)= "Label1"
Tab(0).Control(1).Enabled= 0 'False
Tab(0).Control(2)= "DBGrid1"
Tab(0).Control(2).Enabled= 0 'False
Tab(0).Control(3)= "comShort"
Tab(0).Control(3).Enabled= 0 'False
Tab(0).Control(4)= "Frame1"
Tab(0).Control(4).Enabled= 0 'False
Tab(0).Control(5)= "Data1"
Tab(0).Control(5).Enabled= 0 'False
Tab(0).Control(6)= "cmdClose"
Tab(0).Control(6).Enabled= 0 'False
Tab(0).Control(7)= "cmdQuery"
Tab(0).Control(7).Enabled= 0 'False
Tab(0).Control(8)= "comSort"
Tab(0).Control(8).Enabled= 0 'False
Tab(0).Control(9)= "txtContent"
Tab(0).Control(9).Enabled= 0 'False
Tab(0).ControlCount= 10
Begin VB.TextBox txtContent
Height = 270
Left = 1080
TabIndex = 9
Top = 600
Width = 1455
End
Begin VB.ComboBox comSort
Height = 300
Left = 3600
Style = 2 'Dropdown List
TabIndex = 8
Top = 585
Width = 1815
End
Begin VB.CommandButton cmdQuery
Caption = "查询(&Q)"
Default = -1 'True
Height = 375
Left = 7320
TabIndex = 7
Top = 555
Width = 975
End
Begin VB.CommandButton cmdClose
Cancel = -1 'True
Caption = "关闭(&C)"
Height = 375
Left = 8880
TabIndex = 6
Top = 555
Width = 975
End
Begin VB.Data Data1
Connect = "Access 2000;"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 375
Left = 240
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 8325
Width = 14535
End
Begin VB.Frame Frame1
Caption = "排序"
Height = 765
Left = 5640
TabIndex = 2
Top = 360
Width = 1215
Begin VB.OptionButton optAscending
Caption = "升序"
Height = 180
Left = 240
TabIndex = 4
Top = 240
Value = -1 'True
Width = 735
End
Begin VB.OptionButton optDescending
Caption = "降序"
Height = 180
Left = 240
TabIndex = 3
Top = 480
Width = 735
End
End
Begin VB.ComboBox comShort
Height = 300
ItemData = "frmAssortBook.frx":045E
Left = 1080
List = "frmAssortBook.frx":0460
Style = 2 'Dropdown List
TabIndex = 1
Top = 885
Visible = 0 'False
Width = 1455
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "frmAssortBook.frx":0462
Height = 6975
Left = 240
OleObjectBlob = "frmAssortBook.frx":0476
TabIndex = 5
Top = 1245
Width = 14535
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "查询内容:"
Height = 180
Left = 240
TabIndex = 11
Top = 645
Width = 810
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "选择类型:"
Height = 180
Left = 2760
TabIndex = 10
Top = 645
Width = 810
End
End
End
Attribute VB_Name = "frmAssortBook"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim db As Database, rs As Recordset
Dim strAppName, strSQL As String, strCardShort() As String
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdQuery_Click()
On Error GoTo QueryErr
If comSort.Text <> "图书种类" Then
If Trim(txtContent) = "" Then '检查有效性
MsgBox "查询内容不能为空!", vbExclamation + vbOKOnly
txtContent.SetFocus
Exit Sub
End If
If comSort.Text = "图书编号" Then
Dim strBookNo As String
strBookNo = Trim(txtContent)
strAppName = App.Path & "\图书库.mdb"
strSQL = "select 图书编号,条形码,ISBN,图书名称,作者,出版社,网址,图书种类,页数,出版时间,图书总数,现存数量,入馆时间,图书价格,借出次数 from 图书表 where 图书编号='" & strBookNo & "'"
Data1.DatabaseName = strAppName
Data1.RecordSource = strSQL
Data1.Refresh
ElseIf comSort.Text = "条形码" Then
Dim strBarCode As String
strBarCode = Trim(txtContent)
strAppName = App.Path & "\图书库.mdb"
strSQL = "select 图书编号,条形码,ISBN,图书名称,作者,出版社,网址,图书种类,页数,出版时间,图书总数,现存数量,入馆时间,图书价格,借出次数 from 图书表 where 条形码='" & strBarCode & "'"
Data1.DatabaseName = strAppName
Data1.RecordSource = strSQL
Data1.Refresh
ElseIf comSort.Text = "图书名称" Then
Dim strBookName As String
strBookName = Trim(txtContent)
strAppName = App.Path & "\图书库.mdb"
strSQL = "select 图书编号,条形码,ISBN,图书名称,作者,出版社,网址,图书种类,页数,出版时间,图书总数,现存数量,入馆时间,图书价格,借出次数 from 图书表 where 图书名称='" & strBookName & "'"
Data1.DatabaseName = strAppName
Data1.RecordSource = strSQL
Data1.Refresh
End If
Else
Dim blnOrdering As Boolean
If optAscending.Value = True Then blnOrdering = True '升序
If optDescending.Value = True Then blnOrdering = False '降序
strCardShort(0) = strCardShort(comShort.ListIndex + 1)
strAppName = App.Path & "\图书库.mdb"
strSQL = "select 图书编号,条形码,ISBN,图书名称,作者,出版社,网址,页数,出版时间,图书总数,现存数量,入馆时间,图书价格,借出次数 from 图书表 where 图书种类='" & comShort & "'"
strSQL = strSQL & " order by 图书编号"
If blnOrdering = False Then strSQL = strSQL & " desc"
Data1.DatabaseName = strAppName
Data1.RecordSource = strSQL
DBGrid1.Caption = "图书种类为" & strCardShort(0) & "的图书"
Data1.Refresh
End If
Exit Sub
QueryErr:
MsgBox Err.Description
End Sub
Private Sub comSort_Click()
If comSort.Text = "图书种类" Then
'给组合框赋初值和初始化
txtContent.Visible = False
comShort.Visible = True
comShort.Left = 1080
comShort.Top = 600
'清空组合框
comShort.Clear
'给组合框赋值
strAppName = App.Path & "\图书库.mdb"
Set db = DBEngine.OpenDatabase(strAppName, False, True) '共享、只读
strSQL = "select count(*) as 图书总数 from 图书类别表"
Set rs = db.OpenRecordset(strSQL)
Dim i, intCount As Integer
intCount = rs.Fields("图书总数")
rs.Close
Set rs = Nothing
ReDim Preserve strCardShort(intCount) As String
strSQL = "select * from 图书类别表"
Set rs = db.OpenRecordset(strSQL)
rs.MoveFirst
For i = 1 To intCount
strCardShort(i) = rs.Fields("类别简称")
comShort.AddItem rs.Fields("图书类别")
rs.MoveNext
Next i
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Else
comShort.Visible = False
txtContent.Visible = True
comShort.Left = 1080
comShort.Top = 885
txtContent.SetFocus
SendKeys "{Home}+{End}"
End If
End Sub
Private Sub Data1_Reposition()
Data1.Caption = "图书记录:" & Data1.Recordset.AbsolutePosition + 1
End Sub
Private Sub Form_Activate()
txtContent.SetFocus
End Sub
Private Sub Form_Load()
OFFCAT.Play "wave"
comSort.AddItem "图书编号"
comSort.AddItem "条形码"
comSort.AddItem "图书名称"
comSort.AddItem "图书种类"
End Sub
Private Sub Form_Resize()
SSTab1.Left = (Me.Width - SSTab1.Width) / 2
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -