📄 coursemanage.frm
字号:
VERSION 5.00
Begin VB.Form courseManage
Caption = "课程信息管理"
ClientHeight = 3300
ClientLeft = 3090
ClientTop = 2610
ClientWidth = 5655
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3300
ScaleWidth = 5655
Begin VB.CommandButton cmdSea
Caption = "查询"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4080
TabIndex = 17
Top = 120
Width = 1215
End
Begin VB.TextBox txtrecno
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 16
Top = 2160
Width = 3495
End
Begin VB.CommandButton cmdExit
Caption = "关闭"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4080
TabIndex = 15
Top = 2040
Width = 1215
End
Begin VB.CommandButton cmdSave
Caption = "保存"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4080
TabIndex = 14
Top = 1560
Width = 1215
End
Begin VB.CommandButton cmdDelete
Caption = "删除"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4080
TabIndex = 13
Top = 1080
Width = 1215
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 4080
TabIndex = 12
Top = 600
Width = 1215
End
Begin VB.CommandButton cmdMove
Caption = "尾记录"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 4200
TabIndex = 11
Top = 2760
Width = 1095
End
Begin VB.CommandButton cmdMove
Caption = "下一记录"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 2
Left = 2880
TabIndex = 10
Top = 2760
Width = 1215
End
Begin VB.CommandButton cmdMove
Caption = "前一记录"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 1
Left = 1560
TabIndex = 9
Top = 2760
Width = 1215
End
Begin VB.CommandButton cmdMove
Caption = "首记录"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 240
TabIndex = 8
Top = 2760
Width = 1095
End
Begin VB.TextBox txtTime
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1800
TabIndex = 3
Text = " "
Top = 1560
Width = 1695
End
Begin VB.TextBox txtRoom
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1800
TabIndex = 2
Text = " "
Top = 1080
Width = 1695
End
Begin VB.TextBox txtTeacher
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1800
TabIndex = 1
Text = " "
Top = 600
Width = 1695
End
Begin VB.TextBox txtName
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1800
TabIndex = 0
Text = " "
Top = 120
Width = 1695
End
Begin VB.Label Label4
Caption = "上课时间"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 7
Top = 1560
Width = 975
End
Begin VB.Label Label3
Caption = "上课教室"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 6
Top = 1080
Width = 1215
End
Begin VB.Label Label2
Caption = "任课老师"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 5
Top = 600
Width = 1095
End
Begin VB.Label Label1
Caption = "课程名称"
BeginProperty Font
Name = "微软雅黑"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 360
TabIndex = 4
Top = 120
Width = 1095
End
End
Attribute VB_Name = "coursemanage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim isadding As Boolean '定义布尔变量
Dim objCourse As Recordset
Dim objCn As Connection
Private Sub cmdAdd_Click()
txtrecno = "添加新记录"
txtName = ""
txtTeacher = ""
txtRoom = ""
txtTime = ""
isadding = True
txtName.SetFocus
End Sub
Private Sub cmdDelete_Click()
If isadding Then
isadding = False
If objCourse.BOF = objCourse.EOF Then
txtrecno = "记录:无"
Else
ShowData
End If
Else
If objCourse.RecordCount > 0 Then
If MsgBox("是否删除当前记录?", vbYesNo + vbQuestion, "课程信息管理") = vbYes Then
objCourse.Delete
cmdMove(2).Value = True
Else
ShowData
End If
End If
End If
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
If isadding Then objCourse.AddNew
objCourse.Fields("课程") = Trim(txtName)
objCourse.Fields("教师") = Trim(txtTeacher)
objCourse.Fields("教室") = Trim(txtRoom)
objCourse.Fields("时间") = Trim(txtTime)
objCourse.Update
MsgBox "数据保存成功", vbInformation, "课程信息管理"
txtrecno = "记录:" & objCourse.AbsolutePosition & "/" & objCourse.RecordCount
End Sub
Private Sub cmdSea_Click()
coursemanage.Hide
frmQCourse.Show
frmQCourse.txtCourse.SetFocus
End Sub
Private Sub Form_Load()
Set objCn = New Connection
With objCn
.Provider = "SQLOLEDB"
.ConnectionString = "User ID=db4;PWD=lsc;Data Source=(local);" & _
"Initial Catalog=成绩管理"
.Open
End With
Set objCourse = New Recordset
With objCourse
Set .ActiveConnection = objCn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Open " SELECT * FROM 课程信息"
End With
cmdMove(0).Value = True
End Sub
Private Sub cmdMove_Click(Index As Integer)
With objCourse
Select Case Index
Case 0
If .RecordCount > 0 And Not .BOF Then .MoveFirst
Case 1
If .RecordCount > 0 And Not .BOF Then
.MovePrevious
If .BOF Then .MoveFirst
End If
Case 2
If .RecordCount > 0 And Not .EOF Then
.MoveNext
If .EOF Then .MoveLast
End If
Case 3
If .RecordCount > 0 And Not .EOF Then .MoveLast
End Select
If .RecordCount < 1 Then
txtrecno = "记录:无"
txtName = ""
txtTeacher = ""
txtRoom = ""
txtTime = ""
Else
ShowData
End If
End With
If isadding Then isadding = False
End Sub
Private Sub ShowData()
With objCourse
txtName = .Fields("课程")
txtTeacher = .Fields("教师")
txtRoom = .Fields("教室")
txtTime = .Fields("时间")
txtrecno = "当前记录:第" & .AbsolutePosition & "条/共" & .RecordCount & "条"
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
objCn.Close
Set objCn = Nothing
Set objCourse = Nothing
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -