📄 frmstugrade.frm
字号:
BackStyle = 0 'Transparent
Caption = "成绩表"
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 5280
TabIndex = 40
Top = 120
Width = 945
End
Begin VB.Label Label7
BackStyle = 0 'Transparent
Caption = "注意 : 请添加或修改本学期所开设的课程的成绩"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000080&
Height = 255
Left = 2640
TabIndex = 39
Top = 2160
Width = 4095
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "政治"
Height = 255
Index = 4
Left = 2640
TabIndex = 16
Top = 5520
Width = 495
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "体育"
Height = 255
Index = 3
Left = 6120
TabIndex = 15
Top = 4080
Width = 495
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "品德"
Height = 255
Index = 3
Left = 6120
TabIndex = 14
Top = 4560
Width = 495
End
Begin VB.Label Label4
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "计算机"
Height = 255
Index = 3
Left = 6000
TabIndex = 13
Top = 5040
Width = 615
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "英语"
Height = 255
Index = 2
Left = 2640
TabIndex = 12
Top = 3600
Width = 495
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "化学"
Height = 255
Index = 2
Left = 2640
TabIndex = 11
Top = 4560
Width = 495
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "生物"
Height = 255
Index = 2
Left = 2640
TabIndex = 10
Top = 5040
Width = 495
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "历史"
Height = 255
Index = 1
Left = 6120
TabIndex = 9
Top = 2640
Width = 495
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "地理"
Height = 255
Index = 1
Left = 6120
TabIndex = 8
Top = 3120
Width = 495
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "美术"
Height = 255
Index = 1
Left = 6120
TabIndex = 7
Top = 3600
Width = 495
End
Begin VB.Label Label6
BackStyle = 0 'Transparent
Caption = "语文"
Height = 255
Index = 0
Left = 2640
TabIndex = 5
Top = 2640
Width = 495
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "数学"
Height = 255
Index = 0
Left = 2640
TabIndex = 4
Top = 3120
Width = 495
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "物理"
Height = 255
Index = 0
Left = 2640
TabIndex = 3
Top = 4080
Width = 495
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "学期(主键)"
Height = 255
Left = 3360
TabIndex = 2
Top = 600
Width = 855
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "次数(主键)"
Height = 255
Left = 3360
TabIndex = 1
Top = 1200
Width = 855
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "学号(主键) "
Height = 255
Left = 3360
TabIndex = 0
Top = 1800
Width = 855
End
End
Attribute VB_Name = "frmStuGrade"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim strSql As String
Dim RS As ADODB.Recordset
Private Sub cboTerm_Click()
strSql = "select 课程名字 from 课程设置表 where 学期=" & Trim(Me.cboTerm.Text)
writeMS strSql, Me.MSFlexGrid1
End Sub
Private Sub cmdAdd_Click()
'添加
On Error Resume Next
If cboTerm.Text <> "" And cboTimes.Text <> "" And Trim(Me.cboStudent.Text) <> "" Then
Dim i As Integer
strSql = "select * from 成绩表 where "
strSql = strSql & "成绩表.学号='" & Trim(Me.cboStudent.Text) & "'" & "and "
strSql = strSql & "成绩表.学期=" & Val(Trim(cboTerm.Text))
strSql = strSql & "and 成绩表.次数=" & Val(Trim(cboTimes.Text))
Set RS = dbSelect(strSql)
If RS.BOF Then
strSql = "insert into 成绩表 values('"
strSql = strSql & Trim(Me.cboStudent.Text) & "'"
For i = 0 To 12
strSql = strSql & ",'" & Val(Trim(txtGrade(i).Text)) & "'"
Next i
strSql = strSql & "," & Val(Trim(cboTimes.Text)) & "," & Val(Trim(cboTerm.Text))
strSql = strSql & ")"
dbOperate strSql
Else
MsgBox "库中已有", vbOKOnlyvbok + vbExclamation, "提示"
End If
Else
MsgBox "主键不能为空", vbOKOnlyvbok + vbExclamation, "提示"
End If
End Sub
Private Sub cmdAll_Click()
'全部显示
On Error Resume Next
Me.mgridGrade.Clear
If cboTerm.Text <> "" And cboTimes.Text <> "" Then
strSql = "select distinct 课程名字 from 课程设置表 where 学期=" & Val(Trim(cboTerm.Text))
Set RS = dbSelect(strSql)
strSql = "select distinct 成绩表.学号,学生基本情况表.姓名,"
While Not RS.EOF
strSql = strSql & " 成绩表." & RS.Fields(0).Value & ","
RS.MoveNext
Wend
strSql = Left(strSql, Len(strSql) - 1)
strSql = strSql & " from 学生基本情况表,成绩表 where 成绩表.学号=学生基本情况表.学号 and "
strSql = strSql & "成绩表.学期=" & Val(Trim(cboTerm.Text))
strSql = strSql & "and 成绩表.次数=" & Val(Trim(cboTimes.Text))
writeMS strSql, Me.mgridGrade
Set RS = Nothing
Else
MsgBox "主键不能为空", vbOKOnlyvbok + vbExclamation, "提示"
End If
End Sub
Private Sub cmdDel_Click()
On Error Resume Next
'删除
If Trim(Me.cboStudent.Text) <> "" And Trim(cboTerm.Text) <> "" And Trim(cboTimes.Text) <> "" Then
strSql = "delete * from 成绩表 where 成绩表.学号='" & Trim(Me.cboStudent.Text) & "'and"
strSql = strSql & " 成绩表.学期=" & Val(Trim(cboTerm.Text)) & " and"
strSql = strSql & " 成绩表.次数=" & Val(Trim(cboTimes.Text))
dbOperate strSql
Else
MsgBox "主键不能为空", vbOKOnlyvbok + vbExclamation, "提示"
End If
End Sub
Private Sub cmdExit_Click()
'关闭
Unload Me
End Sub
Private Sub cmdFind_Click()
'查找
On Error Resume Next
If Trim(Me.cboStudent.Text) <> "" And Trim(cboTerm.Text) <> "" And Trim(cboTimes.Text) <> "" Then
Me.mgridGrade.Clear
Dim i As Integer
strSql = "select * from 成绩表 where "
strSql = strSql & "成绩表.学号='" & Trim(Me.cboStudent.Text) & "'" & "and "
strSql = strSql & "成绩表.学期=" & Val(Trim(cboTerm.Text))
strSql = strSql & "and 成绩表.次数=" & Val(Trim(cboTimes.Text))
Set RS = dbSelect(strSql)
Call clearAll
For i = 1 To RS.Fields.Count - 3
txtGrade(i - 1).Text = RS.Fields(i).Value
Next i
Set RS = Nothing
strSql = "select distinct 课程名字 from 课程设置表 where 学期=" & Val(Trim(cboTerm.Text))
Set RS = dbSelect(strSql)
strSql = "select distinct 成绩表.学号,学生基本情况表.姓名,"
While Not RS.EOF
strSql = strSql & " 成绩表." & RS.Fields(0).Value & ","
RS.MoveNext
Wend
strSql = Left(strSql, Len(strSql) - 1)
strSql = strSql & " from 学生基本情况表,成绩表 where"
strSql = strSql & " 成绩表.学号='" & Trim(Me.cboStudent.Text) & "' and"
strSql = strSql & " 成绩表.学号=学生基本情况表.学号 and "
strSql = strSql & " 成绩表.学期=" & Val(Trim(cboTerm.Text)) & " and"
strSql = strSql & " 成绩表.次数=" & Val(Trim(cboTimes.Text))
writeMS strSql, Me.mgridGrade
Else
MsgBox "主键不能为空", vbOKOnlyvbok + vbExclamation, "提示"
End If
End Sub
Private Sub cmdModiy_Click()
'先删除后添加
Call cmdDel_Click
Call cmdAdd_Click
End Sub
Private Sub cmdPrint_Click()
'打印
On Error Resume Next
writeMSFlexGrid Me.mgridGrade, "成绩表"
End Sub
Private Sub Form_Load()
'数据入库
On Error Resume Next
strSql = "select distinct 学期 from 课程设置表"
Set RS = dbSelect(strSql)
While Not RS.EOF
Me.cboTerm.AddItem RS.Fields(0)
RS.MoveNext
Wend
strSql = "select distinct 次数 from 成绩表"
Set RS = dbSelect(strSql)
While Not RS.EOF
Me.cboTimes.AddItem RS.Fields(0)
RS.MoveNext
Wend
strSql = "select 学号 from 学生基本情况表"
Set RS = dbSelect(strSql)
While Not RS.EOF
Me.cboStudent.AddItem RS.Fields(0)
RS.MoveNext
Wend
Me.cboTimes.Text = 1
Me.cboStudent.ListIndex = 0
Me.cboTerm.ListIndex = 0
Set RS = Nothing
Me.WindowsXPC1.InitSubClassing
End Sub
Sub clearAll()
Dim i As Integer
For i = 0 To 12
txtGrade(i).Text = ""
Next i
End Sub
Private Sub txtGrade_KeyPress(Index As Integer, KeyAscii As Integer)
If Not IsNumeric(Trim(txtGrade(Index).Text)) And Trim(txtGrade(Index).Text) <> "" Then
MsgBox "请输入数字!", vbOKCancelvbok + vbExclamation, "提示"
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -