?? 課程查詢.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form search_subject
BorderStyle = 1 'Fixed Single
Caption = "課程查詢"
ClientHeight = 4755
ClientLeft = 4080
ClientTop = 3240
ClientWidth = 7065
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4755
ScaleWidth = 7065
Begin MSAdodcLib.Adodc Adodc1
Height = 735
Left = 2760
Top = 2040
Visible = 0 'False
Width = 1575
_ExtentX = 2778
_ExtentY = 1296
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=MSDASQL.1;Persist Security Info=False;Data Source=stu_manage"
OLEDBString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=stu_manage"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = "sa"
Password = "manager"
RecordSource = ""
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.ListBox List1
Height = 3300
Left = 240
TabIndex = 5
Top = 840
Width = 6495
End
Begin VB.CommandButton Command2
Caption = "查詢"
Height = 375
Left = 5760
TabIndex = 4
Top = 240
Width = 855
End
Begin VB.CommandButton Command1
Caption = "查詢"
Height = 375
Left = 2520
TabIndex = 2
Top = 240
Width = 855
End
Begin VB.TextBox Text1
Height = 375
Left = 4560
TabIndex = 3
Top = 240
Width = 975
End
Begin VB.ComboBox Combo1
BeginProperty Font
Name = "宋體"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 330
Left = 1080
Style = 2 'Dropdown List
TabIndex = 1
Top = 240
Width = 1215
End
Begin VB.Label showinfo
Height = 375
Left = 240
TabIndex = 7
Top = 4320
Width = 6495
End
Begin VB.Line Line1
X1 = 3600
X2 = 3600
Y1 = 120
Y2 = 720
End
Begin VB.Label Label2
Caption = "授課教師"
Height = 255
Left = 3720
TabIndex = 6
Top = 360
Width = 735
End
Begin VB.Label Label1
Caption = "課程類別"
Height = 255
Left = 240
TabIndex = 0
Top = 360
Width = 735
End
End
Attribute VB_Name = "search_subject"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public rs As New ADODB.Recordset
Public adoconn As New ADODB.Connection 'Connection 對象代表了打開與數據源的連接。
'按課程類別查詢
Private Sub Command1_Click()
List1.clear
showinfo.Caption = ""
Dim type_name As String
type_name = Combo1.Text
If Len(type_name) = 0 Then
MsgBox "請選擇課程類別!"
Combo1.SetFocus
Exit Sub
End If
adoconn.Open
rs.Open "select subject.id as id1,subject.name as name1,teacher,addr from type,subject where subject.type=type.id and type.name='" & type_name & "'", adoconn
If rs.RecordCount = 0 Then
MsgBox "沒有任何屬于該類別的科目!"
rs.Close
adoconn.Close
Combo1.SetFocus
Exit Sub
End If
List1.AddItem "課程編號 課程名稱 授課教師 上課地點 "
Dim i As Integer
rs.MoveFirst
For i = 0 To rs.RecordCount - 1
List1.AddItem rs.Fields("id1") & Space(15) & rs.Fields("name1") & Space(12) & rs.Fields("teacher") & Space(12) & rs.Fields("addr")
rs.MoveNext
Next i
rs.Close
adoconn.Close
End Sub
'按教師姓名查詢
Private Sub Command2_Click()
List1.clear
Dim teacher_name As String
teacher_name = Text1.Text
If Len(teacher_name) = 0 Then
MsgBox "請輸入授課教師姓名!"
Text1.SetFocus
Exit Sub
End If
adoconn.Open
rs.Open "select subject.id as id1,subject.name as name1,type.name as name2,addr from subject,type where subject.type=type.id and teacher='" & teacher_name & "'", adoconn
If rs.RecordCount = 0 Then
MsgBox "沒有該教師授的課!"
Text1.Text = ""
Text1.SetFocus
rs.Close
adoconn.Close
Exit Sub
End If
List1.AddItem "課程編號 課程名稱 課程類別 上課地點 "
rs.MoveFirst
Dim i As Integer
For i = 0 To rs.RecordCount - 1
List1.AddItem rs.Fields("id1") & Space(15) & rs.Fields("name1") & Space(12) & rs.Fields("name2") & Space(12) & rs.Fields("addr")
rs.MoveNext
Next i
rs.Close
adoconn.Close
End Sub
Private Sub Form_Load()
'加載課程類別列表
adoconn.ConnectionString = Adodc1.ConnectionString 'Adodc1為窗體中的ADO控件,并已成功連接數據庫
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
adoconn.Open
rs.Open "select * from type", adoconn
rs.MoveFirst
Dim i As Integer
For i = 0 To rs.RecordCount - 1
Combo1.AddItem rs.Fields("name")
rs.MoveNext
Next i
rs.Close
adoconn.Close
End Sub
Private Sub List1_Click()
showinfo.Caption = List1.Text
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -