📄 findcd.frm
字号:
Width = 1575
End
Begin VB.OptionButton Option3
Caption = "按影碟类别查询"
Height = 255
Left = 240
TabIndex = 7
Top = 720
Width = 1575
End
Begin VB.OptionButton Option2
Caption = "按影碟名称查询"
Height = 255
Left = 2880
TabIndex = 6
Top = 240
Width = 1575
End
Begin VB.OptionButton Option1
Caption = "按影碟编号查询"
Height = 255
Left = 240
TabIndex = 5
Top = 240
Width = 1575
End
End
End
Attribute VB_Name = "FindCD"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub Command1_Click()
Dim SQL As String
If Option1.Value = False And Option2.Value = False And Option3.Value = False And Option4.Value = False Then
MsgBox "请先选择查询类型!", vbInformation + vbOKOnly, "警告"
Option1.Value = True
Text1.SetFocus
Exit Sub
Else
If Text1.Text <> "" Then
If Check1.Value = 0 Then
If Option1.Value = True Then
SQL = "select * from cdinfo where 影碟编号='" & Text1.Text & "'"
End If
If Option2.Value = True Then
SQL = "select * from cdinfo where 影碟名称='" & Text1.Text & "'"
End If
If Option3.Value = True Then
SQL = "select * from cdinfo where 影碟类别='" & Text1.Text & "'"
End If
If Option4.Value = True Then
SQL = "select * from cdinfo where 入店时间=#" & Text1.Text & "#"
End If
ElseIf Check1.Value = 1 Then
If Option1.Value = True Then
SQL = "select * from cdinfo where 影碟编号 like '%" & Text1.Text & "%'"
End If
If Option2.Value = True Then
SQL = "select * from cdinfo where 影碟名称 like '%" & Text1.Text & "%'"
End If
If Option3.Value = True Then
SQL = "select * from cdinfo where 影碟类别 like '%" & Text1.Text & "%'"
End If
If Option4.Value = True Then
SQL = "select * from cdinfo where 入店时间 like '%" & Text1.Text & "%'"
End If
End If
Else
MsgBox "请输入查询关键词!", vbInformation + vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
End If
Adodc1.RecordSource = SQL
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Set DataGrid1.DataSource = Adodc1
LabelCS
Else
MsgBox "对不起,你所查询的影碟不存在!", vbInformation + vbOKOnly, "信息"
Text1.Text = ""
Text1.SetFocus
End If
End Sub
Private Sub Command2_Click()
Option1.Value = False
Option2.Value = False
Option3.Value = False
Option4.Value = False
Option5.Value = False
Text1.Text = ""
Text1.SetFocus
Check1.Value = 0
End Sub
Private Sub Command3_Click()
If MDIForm1.MdSet.Visible = False Then
MsgBox "对不起,你不是管理员,无法进行修改!", vbInformation + vbOKOnly, "警告"
Exit Sub
End If
If DataGrid1.Row >= 0 Then
EditCD.Show vbModal
Else
MsgBox "没有影碟信息可供修改或没有指定需要修改的影碟信息!", vbInformation + vbOKOnly, "警告"
Option1.Value = True
Text1.SetFocus
End If
End Sub
Private Sub Command4_Click()
Dim SQL As String
Dim vbName As String
If MDIForm1.MdSet.Visible = False Then
MsgBox "对不起,你不是管理员,无法删除信息!", vbInformation + vbOKOnly, "警告"
Exit Sub
End If
If DataGrid1.Row < 0 Then
MsgBox "对不起,没有影碟信息可供删除!", vbInformation + vbOKOnly, "提示"
Exit Sub
End If
DataGrid1.Col = 1
vbName = DataGrid1.Text
If MsgBox("你确定要删除影碟名称为“" & vbName & "”的信息吗?", vbInformation + vbYesNo, "删除信息") = vbYes Then
DataGrid1.Col = 0
SQL = "select 是否借出 from cdinfo where 影碟编号=""" & DataGrid1.Text & """"
OpenDBFile
OpenRS (SQL)
If gRst("是否借出") = -1 Then
If MsgBox("名称为“" & vbName & "”的影碟尚未还回,是否删除?", vbInformation + vbYesNo, "是否删除") = vbNo Then
CloseRS
Exit Sub
End If
End If
CloseRS
With Adodc1.Recordset
.Delete
End With
MsgBox "影碟名称为“" & vbName & "”的信息已经删除!", vbInformation + vbOKOnly, "提示"
End If
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=" _
& App.Path & "\cdlent.mdb;Mode=ReadWrite;Persist Security Info=True;Jet OLEDB:Database Password=vcdglxt"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
End Sub
Private Sub Option1_Click()
Label1.Caption = Option1.Caption
Text1.SetFocus
End Sub
Private Sub Option2_Click()
Label1.Caption = Option2.Caption
Text1.SetFocus
End Sub
Private Sub Option3_Click()
Label1.Caption = Option3.Caption
Text1.SetFocus
End Sub
Private Sub Option4_Click()
Label1.Caption = Option4.Caption
Text1.SetFocus
End Sub
Private Sub Option5_Click()
Dim SQL As String
SQL = "select * from cdinfo"
Adodc1.RecordSource = SQL
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Set DataGrid1.DataSource = Adodc1
LabelCS
Else
MsgBox "对不起,目前数据库是空的!请先录入CD!", vbInformation + vbOKOnly, "信息"
End If
End Sub
Public Sub LabelCS()
LabelSum.Caption = Adodc1.Recordset.RecordCount & "部"
End Sub
Private Sub text1_keypress(keyascii As Integer)
If keyascii = "13" And Text1.Text <> "" Then
Dim SQL As String
If Option1.Value = False And Option2.Value = False And Option3.Value = False And Option4.Value = False Then
MsgBox "请先选择查询类型!", vbInformation + vbOKOnly, "警告"
Option1.Value = True
Text1.SetFocus
Exit Sub
Else
If Check1.Value = 0 Then
If Option1.Value = True Then
SQL = "select * from cdinfo where 影碟编号='" & Text1.Text & "'"
End If
If Option2.Value = True Then
SQL = "select * from cdinfo where 影碟名称='" & Text1.Text & "'"
End If
If Option3.Value = True Then
SQL = "select * from cdinfo where 影碟类别='" & Text1.Text & "'"
End If
If Option4.Value = True Then
SQL = "select * from cdinfo where 入店时间=#" & Text1.Text & "#"
End If
ElseIf Check1.Value = 1 Then
If Option1.Value = True Then
SQL = "select * from cdinfo where 影碟编号 like '%" & Text1.Text & "%'"
End If
If Option2.Value = True Then
SQL = "select * from cdinfo where 影碟名称 like '%" & Text1.Text & "%'"
End If
If Option3.Value = True Then
SQL = "select * from cdinfo where 影碟类别 like '%" & Text1.Text & "%'"
End If
If Option4.Value = True Then
SQL = "select * from cdinfo where 入店时间 like '%" & Text1.Text & "%'"
End If
End If
End If
Adodc1.RecordSource = SQL
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Set DataGrid1.DataSource = Adodc1
LabelCS
Else
MsgBox "对不起,你所查询的影碟不存在!", vbInformation + vbOKOnly, "信息"
Text1.Text = ""
Text1.SetFocus
End If
ElseIf keyascii = "13" And Text1.Text = "" Then
MsgBox "请输入需要查找的关键字!", vbInformation + vbOKOnly, "信息"
Text1.SetFocus
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -