📄 frmbookquery.frm
字号:
Begin VB.CheckBox chkRigDate
BackColor = &H00FFC0FF&
Caption = "登记日期"
Height = 375
Left = 4200
TabIndex = 12
Top = 1560
Width = 1095
End
Begin VB.TextBox txtBookID
BackColor = &H00FFFFFF&
Height = 375
Left = 960
TabIndex = 5
Top = 360
Width = 3015
End
Begin VB.TextBox txtBookName
Height = 375
Left = 5040
TabIndex = 4
Top = 360
Width = 3375
End
Begin VB.ComboBox cboType
Height = 300
Left = 960
TabIndex = 3
Top = 960
Width = 3015
End
Begin VB.TextBox txtBookPrice
Height = 375
Left = 960
TabIndex = 2
Top = 1560
Width = 3015
End
Begin VB.TextBox txtBookConcern
Height = 375
Left = 5040
TabIndex = 1
Top = 960
Width = 3375
End
Begin MSComCtl2.DTPicker dtpRigDate
Height = 375
Left = 5400
TabIndex = 11
Top = 1560
Width = 2415
_ExtentX = 4260
_ExtentY = 661
_Version = 393216
Enabled = 0 'False
CalendarTrailingForeColor= -2147483625
Format = 21168129
CurrentDate = 37828
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "清空"
Height = 255
Left = 9600
TabIndex = 16
Top = 1680
Width = 375
End
Begin VB.Image ImageClear
Height = 495
Left = 8880
Picture = "FrmBookQuery.frx":1694C
Top = 1560
Width = 1335
End
Begin VB.Image ImageClose
Height = 300
Left = 9120
Picture = "FrmBookQuery.frx":17968
Top = 960
Width = 810
End
Begin VB.Image ImageFind
Height = 285
Left = 9240
Picture = "FrmBookQuery.frx":1867A
Top = 360
Width = 585
End
Begin VB.Label Label27
BackStyle = 0 'Transparent
Caption = "书籍编号:"
Height = 255
Left = 120
TabIndex = 10
Top = 480
Width = 975
End
Begin VB.Label Label25
BackStyle = 0 'Transparent
Caption = "书籍名称:"
Height = 255
Left = 4200
TabIndex = 9
Top = 480
Width = 855
End
Begin VB.Label Label24
BackStyle = 0 'Transparent
Caption = "书籍类别:"
Height = 255
Left = 120
TabIndex = 8
Top = 1080
Width = 855
End
Begin VB.Label Label26
BackStyle = 0 'Transparent
Caption = "书籍价格:"
Height = 255
Left = 120
TabIndex = 7
Top = 1680
Width = 855
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "出版社:"
Height = 255
Left = 4320
TabIndex = 6
Top = 1080
Width = 735
End
End
End
Attribute VB_Name = "FrmBookQuery"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub chkRigDate_Click()
If chkRigDate.Value = 1 Then
dtpRigDate.Enabled = True
Else
dtpRigDate.Enabled = False
End If
End Sub
Private Sub Form_Load()
'在窗口打开的同时进行书籍类别组合框的初始化
dtpRigDate.Value = Date
Set g_rs = g_db.OpenRecordset("bookType", dbOpenTable)
cboType.Clear
If g_rs.RecordCount > 0 Then
g_rs.MoveFirst
Do While Not g_rs.EOF
cboType.AddItem g_rs!类别代码 + "-" + g_rs!书籍类别
g_rs.MoveNext
Loop
End If
Set g_rs = Nothing
End Sub
Private Sub ImageClear_Click()
txtBookID.Text = ""
txtBookName.Text = ""
cboType.Text = ""
txtBookConcern.Text = ""
txtBookPrice.Text = ""
End Sub
Private Sub ImageClose_Click()
Unload Me
End Sub
Private Sub ImageFind_Click()
'按照设置的条件进行查询
Dim strSQL As String
Dim strCon(6) As String '保存设置的查询条件
Dim intCount As Integer '判断用户填写的条件的数目
Dim i As Integer
intCount = 0
'获得查询条件,根据是否选择“执行模糊查询”复选框分别进行查询条件的设置
'获得书籍编号查询条件
If txtBookID.Text <> "" Then
If chkMoHu.Value = 1 Then
strCon(1) = "书籍编号 like '%" & txtBookID.Text & "%'"
Else
strCon(1) = "书籍编号='" & txtBookID.Text & "'"
End If
Else
strCon(1) = ""
End If
'获得书籍名称查询条件
If txtBookName.Text <> "" Then
If chkMoHu.Value = 1 Then
strCon(2) = "书籍名称 like '%" & txtBookName.Text & "%'"
Else
strCon(2) = "书籍名称='" & txtBookName.Text & "'"
End If
Else
strCon(2) = ""
End If
'获得类别代码查询条件
If cboType.Text <> "" Then
If chkMoHu.Value = 1 Then
strCon(3) = "类别代码 like '%" & Mid(cboType.Text, 1, 1) & "%'"
Else
strCon(3) = "类别代码='" & Mid(cboType.Text, 1, 1) & "'"
End If
Else
strCon(3) = ""
End If
'获得出版社查询条件
If txtBookConcern.Text <> "" Then
If chkMoHu.Value = 1 Then
strCon(4) = "出版社 like '%" & txtBookConcern.Text & "%'"
Else
strCon(4) = "出版社='" & txtBookConcern.Text & "'"
End If
Else
strCon(4) = ""
End If
'获得书籍价格查询条件
If txtBookPrice.Text <> "" Then
If chkMoHu.Value = 1 Then
strCon(5) = "书籍价格 like %" & CInt(txtBookPrice.Text) & "%"
Else
strCon(5) = "书籍价格=" & CInt(txtBookPrice.Text) & ""
End If
Else
strCon(5) = ""
End If
'获得登记日期查询条件
If chkRigDate.Value = 1 Then
If chkMoHu.Value = 1 Then
strCon(6) = "登记日期 like #" & dtpRigDate.Value & "#"
Else
strCon(6) = "登记日期=#" & dtpRigDate.Value & "#"
End If
Else
strCon(6) = ""
End If
'根据查询条件进行查询SQL语句的设置
If strCon(1) = "" And strCon(2) = "" And strCon(3) = "" And strCon(4) = "" And strCon(5) = "" And strCon(6) = "" Then
strSQL = "select * from bookInfo"
Else '具有查询条件
strSQL = "select * from bookInfo where "
For i = 1 To 6
If strCon(i) <> "" Then
intCount = intCount + 1
If intCount = 1 Then '第一个查询条件不需要“and”连接符
strSQL = strSQL + strCon(i)
Else '以后的查询条件都需要“and”连接符
strSQL = strSQL + " and " + strCon(i)
End If
End If
Next
End If
'设置Adodc控件
Adodc1.connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\图书馆查询管理系统.mdb;Persist Security Info=False"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -