?? findcd.frm
字號:
Width = 1575
End
Begin VB.OptionButton Option3
Caption = "按vcd類別查詢"
Height = 255
Left = 240
TabIndex = 7
Top = 720
Width = 1575
End
Begin VB.OptionButton Option2
Caption = "按vcd名稱查詢"
Height = 255
Left = 2880
TabIndex = 6
Top = 240
Width = 1575
End
Begin VB.OptionButton Option1
Caption = "按vcd編號查詢"
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 + -