📄 eddegree.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Begin VB.Form eddegree
Caption = "编辑学生成绩记录"
ClientHeight = 4980
ClientLeft = 60
ClientTop = 345
ClientWidth = 8295
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4980
ScaleWidth = 8295
StartUpPosition = 2 '屏幕中心
Begin VB.Frame Frame1
Caption = "录入或修改分数"
BeginProperty Font
Name = "隶书"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 1395
Left = 6150
TabIndex = 6
Top = 1260
Width = 2055
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 570
TabIndex = 8
Top = 330
Width = 885
End
Begin VB.CommandButton Comm1
Caption = "确定"
Enabled = 0 'False
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 660
TabIndex = 7
Top = 870
Width = 765
End
End
Begin VB.ListBox List2
Height = 4380
Left = 4770
TabIndex = 5
Top = 390
Width = 1275
End
Begin VB.ListBox List1
Height = 4380
Left = 2820
TabIndex = 4
Top = 390
Width = 1845
End
Begin VB.CommandButton retCom
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 645
Left = 6660
TabIndex = 3
Top = 3870
Width = 1035
End
Begin MSComctlLib.ImageList ImageList1
Left = 7320
Top = 540
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 37
ImageHeight = 23
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "eddegree.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "eddegree.frx":0A64
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.TreeView TreeView1
Height = 4755
Left = 60
TabIndex = 0
Top = 60
Width = 2535
_ExtentX = 4471
_ExtentY = 8387
_Version = 393217
PathSeparator = ""
Style = 7
Appearance = 1
End
Begin VB.Label Label4
AutoSize = -1 'True
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 210
Left = 6120
TabIndex = 10
Top = 630
Width = 135
End
Begin VB.Label Label3
Caption = "注意:输入分数后,只有单击""确定""命令按钮后才有效!"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 585
Left = 6240
TabIndex = 9
Top = 2850
Width = 1995
WordWrap = -1 'True
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "课程列表"
BeginProperty Font
Name = "隶书"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 3210
TabIndex = 2
Top = 90
Width = 1035
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "学生列表"
BeginProperty Font
Name = "隶书"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 240
Left = 4890
TabIndex = 1
Top = 90
Width = 1035
End
End
Attribute VB_Name = "eddegree"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs1 As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim rst As ADODB.Recordset
Dim rst1 As ADODB.Recordset
Dim sqltxt As String
Dim pname As String '保存当前用户选择的专业
Dim cname As String '保存当前用户选择的班号
Private Sub Form_Load()
TreeView1.ImageList = ImageList1
TreeView1.LineStyle = 1
TreeView1.Style = 7
Dim n As Integer
n = 1
sqltxt = "select * from prof"
Set rs1 = exesql(sqltxt)
If rs1.RecordCount > 0 Then
rs1.MoveFirst
Do While Not rs1.EOF
TreeView1.Nodes.Add , , "K" & Trim(Str(n)), Trim(rs1.Fields("专业")), 1
sqltxt = "select 班号 from classn where 专业='" + Trim(rs1.Fields("专业")) + "' order by 班号"
Set rs2 = exesql(sqltxt)
If rs2.RecordCount > 0 Then
rs2.MoveFirst
Do While Not rs2.EOF()
TreeView1.Nodes.Add "K" & Trim(Str(n)), 4, , Trim(rs2.Fields("班号")), 2
rs2.MoveNext
Loop
End If
rs2.Close
n = n + 1
rs1.MoveNext
Loop
End If
rs1.Close
End Sub
Private Sub Comm1_Click()
If Trim(Text1.Text) <> "" Then
sqltxt = "select * from degree where 班号='" + cname + _
"' and 姓名='" + Trim(List2.Text) + "' and 课程='" + Trim(List1.Text) + "'"
Set rst = exesql(sqltxt)
If rst.RecordCount > 0 Then
rst.Fields("分数") = Text1.Text
Else
sqltxt = "select * from student where 班号='" + cname + "' and 姓名='" + Trim(List2.Text) + "'"
Set rst1 = exesql(sqltxt)
rst.AddNew
rst.Fields("学号") = rst1.Fields("学号")
rst.Fields("姓名") = rst1.Fields("姓名")
rst.Fields("班号") = rst1.Fields("班号")
rst.Fields("课程") = Trim(List1.Text)
rst.Fields("分数") = Text1.Text
rst1.Close
End If
rst.Update
rst.Close
Else
MsgBox "分数为空,不能进行添加操作", vbOKOnly, "信息提示"
End If
End Sub
Private Sub List1_Click()
If List1.ListIndex >= 0 And List2.ListIndex >= 0 Then
Comm1.Enabled = True
Text1.Text = ""
sqltxt = "select * from degree where 班号='" + cname + _
"' and 姓名='" + Trim(List2.Text) + "' and 课程='" + Trim(List1.Text) + "'"
Set rst = exesql(sqltxt)
If rst.RecordCount > 0 Then
Text1.Text = rst.Fields("分数")
End If
rst.Close
End If
End Sub
Private Sub List2_Click()
If List1.ListIndex >= 0 And List2.ListIndex >= 0 Then
Comm1.Enabled = True
Text1.Text = ""
sqltxt = "select * from degree where 班号='" + cname + _
"' and 姓名='" + Trim(List2.Text) + "' and 课程='" + Trim(List1.Text) + "'"
Set rst = exesql(sqltxt)
If rst.RecordCount > 0 Then
Text1.Text = rst.Fields("分数")
End If
rst.Close
End If
End Sub
Private Sub TreeView1_Collapse(ByVal Node As MSComctlLib.Node)
List1.Clear
List2.Clear
Text1.Text = ""
Label4.Caption = ""
Comm1.Enabled = False
End Sub
Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
Comm1.Enabled = False
If Node.Image = 2 Then '若单击的是班号项
List1.Clear
List2.Clear
cname = Trim(Node.Text)
pname = Trim(Node.Parent.Text)
Label4.Caption = "<-" + cname + "班"
sqltxt = "select * from course where 专业='" + pname + "'"
Set rst = exesql(sqltxt)
If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF
List1.AddItem rst.Fields("课程")
rst.MoveNext
Loop
End If
rst.Close
sqltxt = "select * from student where 专业='" + pname + "' and 班号='" + cname + "' order by 学号"
Set rst = exesql(sqltxt)
If rst.RecordCount > 0 Then
rst.MoveFirst
Do While Not rst.EOF
List2.AddItem rst.Fields("姓名")
rst.MoveNext
Loop
End If
rst.Close
End If
End Sub
Private Sub retCom_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -