📄 form2.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form2
BackColor = &H00FFFF00&
Caption = "学生选课查询"
ClientHeight = 3675
ClientLeft = 60
ClientTop = 390
ClientWidth = 6105
ForeColor = &H80000008&
LinkTopic = "Form2"
ScaleHeight = 3675
ScaleWidth = 6105
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command7
Caption = "后退"
Height = 375
Left = 4440
TabIndex = 21
Top = 2160
Width = 1335
End
Begin VB.CommandButton Command6
Caption = "前移"
Height = 375
Left = 4440
TabIndex = 20
Top = 1440
Width = 1335
End
Begin VB.TextBox Text7
Height = 375
Left = 3000
TabIndex = 19
Top = 2280
Width = 1095
End
Begin MSAdodcLib.Adodc Adodc1
Height = 330
Left = 2280
Top = 2760
Width = 1935
_ExtentX = 3413
_ExtentY = 582
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=a;Data Source=a10"
OLEDBString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=a;Data Source=a10"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "kecheng"
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.CommandButton Command3
Caption = "查询"
Height = 375
Left = 4440
TabIndex = 17
Top = 600
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "返回"
Height = 375
Left = 4440
TabIndex = 16
Top = 2760
Width = 1335
End
Begin VB.TextBox Text10
Height = 375
Left = 3000
TabIndex = 15
Top = 1680
Width = 1095
End
Begin VB.TextBox Text8
Height = 375
Left = 3000
TabIndex = 14
Top = 1080
Width = 1095
End
Begin VB.TextBox Text6
Height = 375
Left = 3000
TabIndex = 13
Top = 480
Width = 1095
End
Begin VB.TextBox Text5
Height = 375
Left = 960
TabIndex = 12
Top = 2760
Width = 735
End
Begin VB.TextBox Text4
Height = 375
Left = 960
TabIndex = 11
Top = 2160
Width = 735
End
Begin VB.TextBox Text3
Height = 375
Left = 960
TabIndex = 10
Top = 1560
Width = 735
End
Begin VB.TextBox Text2
Height = 375
Left = 960
TabIndex = 9
Top = 960
Width = 735
End
Begin VB.TextBox Text1
Height = 375
Left = 960
TabIndex = 8
Top = 360
Width = 735
End
Begin VB.Label Label7
BackColor = &H00FFFF00&
Caption = "查询课程号"
ForeColor = &H000000FF&
Height = 255
Left = 1920
TabIndex = 18
Top = 2400
Width = 975
End
Begin VB.Label Label10
BackColor = &H00FFFF00&
Caption = "余额"
ForeColor = &H000000FF&
Height = 255
Left = 1920
TabIndex = 7
Top = 1800
Width = 735
End
Begin VB.Label Label8
BackColor = &H00FFFF00&
Caption = "名额"
ForeColor = &H000000FF&
Height = 255
Left = 1920
TabIndex = 6
Top = 1200
Width = 495
End
Begin VB.Label Label6
BackColor = &H00FFFF00&
Caption = "任课老师"
ForeColor = &H000000FF&
Height = 255
Left = 1920
TabIndex = 5
Top = 600
Width = 735
End
Begin VB.Label Label5
BackColor = &H00FFFF00&
Caption = "地点"
ForeColor = &H000000FF&
Height = 375
Left = 240
TabIndex = 4
Top = 2880
Width = 495
End
Begin VB.Label Label4
BackColor = &H00FFFF00&
Caption = "学分"
ForeColor = &H000000FF&
Height = 375
Left = 240
TabIndex = 3
Top = 2280
Width = 495
End
Begin VB.Label Label3
BackColor = &H00FFFF00&
Caption = "学时"
ForeColor = &H000000FF&
Height = 375
Left = 240
TabIndex = 2
Top = 1680
Width = 375
End
Begin VB.Label Label2
BackColor = &H00FFFF00&
Caption = "课程名"
ForeColor = &H000000FF&
Height = 375
Left = 240
TabIndex = 1
Top = 1080
Width = 615
End
Begin VB.Label Label1
BackColor = &H00FFFF00&
Caption = "课程号"
ForeColor = &H000000FF&
Height = 255
Left = 240
TabIndex = 0
Top = 480
Width = 615
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim conn As New ADODB.Connection
Dim add As New ADODB.Command
Dim rst As New ADODB.Recordset
Private Sub Command1_Click()
Form2.Hide
Form1.Show
End Sub
Private Sub Command3_Click()
Dim one As String
Set rst.ActiveConnection = conn
If (Text7.Text = "") Then
one = "select*from kecheng"
Else
one = "select*from kecheng where 课程号=" & CInt(Text7.Text)
End If
rst.Open one
If rst.EOF Then
MsgBox "nothing"
GoTo end1
End If
Text1.Text = rst.Fields("课程号")
Text2.Text = rst.Fields("课程名")
Text3.Text = rst.Fields("学时")
Text4.Text = rst.Fields("学分")
Text5.Text = rst.Fields("地点")
Text6.Text = rst.Fields("任课老师")
Text8.Text = rst.Fields("名额")
Text10.Text = rst.Fields("余额")
end1:
rst.Close
End Sub
Private Sub Command4_Click()
Dim one As String
Set rst.ActiveConnection = conn
one = "select * from kecheng "
rst.Open one
If Text1.Text <> "" And Text2.Text <> "" And Text3.Text <> "" And Text4.Text <> "" And Text5.Text <> "" And Text6.Text <> "" And Text8.Text <> "" And Text10.Text <> "" Then
rst.AddNew
rst.Fields("课程号") = CInt(Text1.Text)
rst.Fields("课程名") = Text2.Text
rst.Fields("学时") = Text3.Text
rst.Fields("学分") = Text4.Text
rst.Fields("地点") = Text5.Text
rst.Fields("任课老师") = Text6.Text
rst.Fields("名额") = Text8.Text
rst.Fields("余额") = Text10.Text
rst.Update
MsgBox "ok"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text8.Text = ""
Text10.Text = ""
Else
MsgBox "nothing"
End If
rst.Close
End Sub
Private Sub Command5_Click()
Dim one As String
Set rst.ActiveConnection = conn
If (Text7.Text = "") Then
MsgBox "在查询处填入你要删掉的记录的课程号"
GoTo end2
Else
one = "select*from kecheng where 课程号=" & CInt(Text7.Text)
End If
rst.Open one
If rst.EOF Then
MsgBox "nothing"
GoTo end1
End If
Text1.Text = rst.Fields("课程号")
Text2.Text = rst.Fields("课程名")
Text3.Text = rst.Fields("学时")
Text4.Text = rst.Fields("学分")
Text5.Text = rst.Fields("地点")
Text6.Text = rst.Fields("任课老师")
Text8.Text = rst.Fields("名额")
Text10.Text = rst.Fields("余额")
rst.Delete
rst.Update
end1:
rst.Close
end2:
End Sub
Private Sub Command6_Click()
Dim one As String
Set rst.ActiveConnection = conn
one = "select*from kecheng"
rst.Open one
If Not rst.BOF Then
rst.Find ("课程号=" & CInt(Text1.Text))
rst.MovePrevious
If (rst.BOF) Then rst.MoveFirst
Text1.Text = rst.Fields("课程号")
Text2.Text = rst.Fields("课程名")
Text3.Text = rst.Fields("学时")
Text4.Text = rst.Fields("学分")
Text5.Text = rst.Fields("地点")
Text6.Text = rst.Fields("任课老师")
Text8.Text = rst.Fields("名额")
Text10.Text = rst.Fields("余额")
End If
rst.Close
End Sub
Private Sub Command7_Click()
Dim one As String
Set rst.ActiveConnection = conn
one = "select*from kecheng"
rst.Open one
If Not rst.BOF Then
rst.Find ("课程号=" & CInt(Text1.Text))
rst.MoveNext
If (rst.BOF) Then rst.MoveLast
Text1.Text = rst.Fields("课程号")
Text2.Text = rst.Fields("课程名")
Text3.Text = rst.Fields("学时")
Text4.Text = rst.Fields("学分")
Text5.Text = rst.Fields("地点")
Text6.Text = rst.Fields("任课老师")
Text8.Text = rst.Fields("名额")
Text10.Text = rst.Fields("余额")
End If
rst.Close
End Sub
Private Sub Form_Load()
Set conn = New ADODB.Connection
Set rst = New ADODB.Recordset
Set add = New ADODB.Command
rst.LockType = adLockOptimistic
rst.CursorType = adOpenKeyset
conn.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=a"
conn.Open
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -