📄 frmdel_score.frm
字号:
VERSION 5.00
Begin VB.Form Frmdel_score
Caption = "成绩管理-删改"
ClientHeight = 4770
ClientLeft = 60
ClientTop = 420
ClientWidth = 8280
LinkTopic = "Form1"
ScaleHeight = 4770
ScaleWidth = 8280
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton cmd_cancel
Caption = "返回"
Height = 375
Left = 4920
TabIndex = 15
Top = 4200
Width = 1095
End
Begin VB.CommandButton cmd_del
Caption = "删除"
Height = 375
Left = 3240
TabIndex = 14
Top = 4200
Width = 1095
End
Begin VB.CommandButton cmd_modify
Caption = "修改"
Height = 375
Left = 1560
TabIndex = 13
Top = 4200
Width = 1095
End
Begin VB.Frame Frame2
Caption = "课程基本信息"
Height = 1935
Left = 480
TabIndex = 1
Top = 2040
Width = 7335
Begin VB.TextBox score
Height = 375
Left = 5160
TabIndex = 12
Top = 720
Width = 735
End
Begin VB.TextBox course_name
Height = 375
Left = 1920
TabIndex = 10
Top = 1320
Width = 1575
End
Begin VB.TextBox stu_name
Height = 375
Left = 1920
TabIndex = 9
Top = 480
Width = 1575
End
Begin VB.Label Label5
Caption = "课程成绩:"
Height = 255
Left = 3960
TabIndex = 11
Top = 840
Width = 1095
End
Begin VB.Label Label4
Caption = "课程名称:"
Height = 255
Left = 720
TabIndex = 8
Top = 1320
Width = 975
End
Begin VB.Label Label3
Caption = "学生姓名:"
Height = 255
Left = 720
TabIndex = 7
Top = 600
Width = 975
End
End
Begin VB.Frame Frame1
Caption = "查询"
Height = 1335
Left = 480
TabIndex = 0
Top = 240
Width = 7215
Begin VB.CommandButton cmd_query
Caption = "查询"
Height = 375
Left = 5040
TabIndex = 6
Top = 480
Width = 1215
End
Begin VB.ComboBox course_no
Height = 300
Left = 2040
TabIndex = 5
Top = 840
Width = 1695
End
Begin VB.ComboBox stu_no
Height = 300
Left = 2040
TabIndex = 4
Top = 240
Width = 1695
End
Begin VB.Label Label2
Caption = "课程编号:"
Height = 255
Left = 840
TabIndex = 3
Top = 840
Width = 1095
End
Begin VB.Label Label1
Caption = "学生学号:"
Height = 255
Left = 840
TabIndex = 2
Top = 360
Width = 975
End
End
End
Attribute VB_Name = "Frmdel_score"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub initcourse_no()
Dim rstcourse As ADODB.Recordset
sqlStr = "select Course_no from courses "
Set rstcourse = executesql(sqlStr, msgText)
course_no.Clear
If Not rstcourse.EOF Then
Do While Not rstcourse.EOF
course_no.AddItem Trim(rstcourse.Fields(0))
rstcourse.MoveNext
Loop
course_no.ListIndex = 0
Else
MsgBox "请添加课程编号", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rstcourse.Close
End Sub
Sub initstu_no()
Dim rststudent As ADODB.Recordset
sqlStr = "select stu_no from students "
Set rststudent = executesql(sqlStr, msgText)
stu_no.Clear
If Not rststudent.EOF Then
Do While Not rststudent.EOF
stu_no.AddItem Trim(rststudent.Fields(0))
rststudent.MoveNext
Loop
stu_no.ListIndex = 0
Else
MsgBox "请添加学生编号", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
rststudent.Close
End Sub
Private Sub cmd_cancel_Click()
Unload Me
End Sub
Private Sub cmd_del_Click()
Dim conn As ADODB.Connection
sqlStr = "delete from score where stu_no='" & stu_no.Text & "'and course_no='" & course_no.Text & "'"
On Error GoTo exitsub
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute sqlStr
MsgBox "修改数据成功!"
exitsub:
conn.Close
initform
End Sub
Private Sub cmd_modify_Click()
Dim conn As ADODB.Connection
sqlStr = "update score set [score]='" & score.Text & "' where stu_no='" & stu_no.Text & "' and course_no='" & course_no.Text & "'"
On Error GoTo exitsub
Set conn = New ADODB.Connection
conn.Open connStr
conn.Execute sqlStr
MsgBox "修改数据成功!"
exitsub:
conn.Close
initform
End Sub
Private Sub cmd_query_Click()
Dim rs As ADODB.Recordset
sqlStr = "select Score from score where Course_no ='" & course_no.Text & "' and stu_no='" & stu_no.Text & "'"
Set rs = executesql(sqlStr, msgText)
If Not rs.EOF Then
score.Text = rs.Fields(0)
rs.Close
Else
MsgBox "你查找的信息不存在!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
End Sub
Private Sub Form_Load()
initcourse_no
initstu_no
initform
End Sub
Sub initform()
course_no.Text = ""
course_name.Text = ""
stu_no.Text = ""
stu_name.Text = ""
score.Text = ""
End Sub
Private Sub stu_no_click()
Dim rststudent As ADODB.Recordset
sqlStr = "select name from students where stu_no='" & stu_no.Text & "'"
Set rststudent = executesql(sqlStr, msgText)
If Not rststudent.EOF Then
stu_name.Text = rststudent.Fields(0)
rststudent.Close
End If
End Sub
Private Sub course_no_click()
Dim rstcourse As ADODB.Recordset
sqlStr = "select Course_name from courses where Course_no='" & course_no.Text & "'"
Set rstcourse = executesql(sqlStr, msgText)
If Not rstcourse.EOF Then
course_name.Text = rstcourse.Fields(0)
rstcourse.Close
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -