📄 frm_addmark.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{57EA6131-FAB3-49C3-BF10-85A4777A5A7C}#1.0#0"; "XPButton.ocx"
Begin VB.Form frm_addmark
BorderStyle = 0 'None
Caption = "成绩录入"
ClientHeight = 5730
ClientLeft = 0
ClientTop = 0
ClientWidth = 8280
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
MinButton = 0 'False
ScaleHeight = 5730
ScaleWidth = 8280
ShowInTaskbar = 0 'False
Begin XP_Button.XPButton command1
Height = 435
Left = 3240
TabIndex = 4
Top = 4860
Width = 1095
_ExtentX = 1931
_ExtentY = 767
caption = "录入"
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Height = 345
Left = 2040
MaxLength = 4
TabIndex = 3
Text = "Text1"
Top = 3960
Visible = 0 'False
Width = 915
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 3975
Left = 2880
TabIndex = 2
Top = 660
Width = 4935
_ExtentX = 8705
_ExtentY = 7011
_Version = 393216
Rows = 31
Cols = 5
FixedCols = 0
ScrollBars = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComctlLib.TreeView tvwClass
Height = 4665
Left = 480
TabIndex = 1
Top = 660
Width = 2175
_ExtentX = 3836
_ExtentY = 8229
_Version = 393217
Indentation = 661
LabelEdit = 1
LineStyle = 1
Style = 7
FullRowSelect = -1 'True
SingleSel = -1 'True
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9.75
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XP_Button.XPButton command2
Height = 435
Left = 4800
TabIndex = 5
Top = 4860
Width = 1095
_ExtentX = 1931
_ExtentY = 767
caption = "取消"
End
Begin XP_Button.XPButton command3
Height = 435
Left = 6300
TabIndex = 6
Top = 4860
Width = 1095
_ExtentX = 1931
_ExtentY = 767
caption = "退出"
End
Begin VB.Image imgleftwindow
Height = 4905
Left = 0
Picture = "frm_addmark.frx":0000
Stretch = -1 'True
Top = 420
Width = 465
End
Begin VB.Image imgrightwindow
Height = 4860
Left = 7815
Picture = "frm_addmark.frx":35B2
Stretch = -1 'True
Top = 420
Width = 450
End
Begin VB.Image imgclose
Height = 240
Left = 7830
Picture = "frm_addmark.frx":78CC
Top = 60
Width = 240
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "成绩录入"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H8000000E&
Height = 315
Left = 405
TabIndex = 0
Top = 105
Width = 1785
End
Begin VB.Image imglefttitle
Height = 450
Left = 0
Picture = "frm_addmark.frx":7C0E
Top = 0
Width = 450
End
Begin VB.Image imgleftbottom
Height = 450
Left = 0
Picture = "frm_addmark.frx":8718
Top = 5280
Width = 450
End
Begin VB.Image imgrightbottom
Height = 450
Left = 7820
Picture = "frm_addmark.frx":9222
Top = 5280
Width = 450
End
Begin VB.Image imgbottom
Height = 450
Left = 450
Picture = "frm_addmark.frx":9D2C
Stretch = -1 'True
Top = 5280
Width = 7410
End
Begin VB.Image imgrighttitle
Height = 525
Left = 7890
Picture = "frm_addmark.frx":1066E
Top = 0
Width = 375
End
Begin VB.Image imgtop
Height = 450
Left = 450
Picture = "frm_addmark.frx":11114
Stretch = -1 'True
Top = -15
Width = 7455
End
End
Attribute VB_Name = "frm_addmark"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim myGrade As Cls_Grade
Dim mycourse As Cls_Course
Dim myUser As Cls_user
Dim strtvwClassCourseID As String '保存TreeView中选中的课程编号
Dim strtvwClassClassID As String '保存TreeView中选中的班级编号
Dim intTotalRecord As Integer
Private Sub command1_Click()
Dim i As Integer
Dim j As Integer
Set myGrade = New Cls_Grade
If command1.Caption = "录入" Then
MSFlexGrid1.Enabled = True
'按选中的班级编号查询,将学员编号显示在表格中
myGrade.PrcGradeStudentIDByClassID strtvwClassClassID
If myGrade.GetGrade.EOF = False Then
i = 1
Do Until myGrade.GetGrade.EOF
If i > 30 Then
MsgBox "每班最多为30人!", vbApplicationModal + vbOKOnly + vbExclamation, "错误"
Set myGrade = Nothing
command2_Click
Exit Sub
End If
MSFlexGrid1.Col = 0
MSFlexGrid1.Row = i
MSFlexGrid1.Text = Trim(myGrade.GetGrade.Fields(0))
MSFlexGrid1.Col = 1
MSFlexGrid1.Text = strtvwClassCourseID
i = i + 1
myGrade.GetGrade.MoveNext
Loop
Else
Set myGrade = Nothing
command2_Click
Exit Sub
End If
intTotalRecord = i - 1
tvwClass.Enabled = False
command1.Caption = "提交"
command2.DragMode = 0
command3.DragMode = 1
MSFlexGrid1.Row = 1
MSFlexGrid1.Col = 2
MoveText 1, 2
Else
frm_ProgressBar.Show 1
myGrade.OpenGradeInfo
For i = 1 To intTotalRecord
myGrade.GetGradeRs.AddNew
MSFlexGrid1.Row = i
For j = 0 To 4
MSFlexGrid1.Col = j
myGrade.GetGradeRs.Fields(j + 1) = Trim(MSFlexGrid1.Text)
Next
myGrade.GetGradeRs.Update
myGrade.GetGradeRs.Requery
Next
command2_Click
End If
Set myGrade = Nothing
End Sub
Private Sub command2_Click()
MSFlexGrid1.Clear
LoadMSFlexGrid1
Text1.Visible = False
MSFlexGrid1.Enabled = False
tvwClass.Enabled = True
command1.Caption = "录入"
command1.DragMode = 1
command2.DragMode = 1
command3.DragMode = 0
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
Move (frm_main.Width - Me.Width) / 2, (frm_main.Height - Me.Height) / 2 - 800
LoadtvwClass
LoadMSFlexGrid1
command1.DragMode = 1
command2.DragMode = 1
MSFlexGrid1.Enabled = False
End Sub
Private Sub imgclose_Click()
Unload Me
End Sub
Private Sub imglefttitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DrawForms Me
End Sub
Private Sub imgtop_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DrawForms Me
End Sub
Private Sub imgrighttitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DrawForms Me
End Sub
Private Sub MSFlexGrid1_Click()
If (MSFlexGrid1.Row > intTotalRecord) Or (MSFlexGrid1.Col < 2) Then
Beep
Text1.Visible = False
Else
MoveText MSFlexGrid1.Row, MSFlexGrid1.Col
End If
End Sub
Private Sub MSFlexGrid1_Scroll()
Text1.Visible = False
End Sub
Private Sub Text1_Change()
MSFlexGrid1.Text = Text1.Text
End Sub
Private Sub Text1_GotFocus()
Text1.SelLength = Len(Text1.Text)
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'If (KeyAscii >= 58 And KeyAscii <= 64) Or (KeyAscii >= 33 And KeyAscii <= 47) Or (KeyAscii >= 91 And KeyAscii <= 96) Or (KeyAscii >= 123 And KeyAscii <= 126) Then KeyAscii = 0
If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 46 And KeyAscii <> 8 And KeyAscii <> 13 Then KeyAscii = 0
If KeyAscii = 13 Then
If MSFlexGrid1.Col = 4 Then
If MSFlexGrid1.Row < intTotalRecord Then
MSFlexGrid1.Row = MSFlexGrid1.Row + 1
MSFlexGrid1.Col = 2
End If
Else
MSFlexGrid1.Col = MSFlexGrid1.Col + 1
End If
KeyAscii = 0
MoveText MSFlexGrid1.Row, MSFlexGrid1.Col
End If
End Sub
Private Sub tvwClass_NodeClick(ByVal Node As MSComctlLib.Node)
Set mycourse = New Cls_Course
mycourse.QueryCourseById Node.Text
If mycourse.GetQryCourseByIdRs.EOF = False Then
'保存选中的课程编号,班级编号
strtvwClassCourseID = Trim(Node.Text)
strtvwClassClassID = Trim(Node.Parent.Text)
command1.DragMode = 0
Else
command1.DragMode = 1
End If
Set mycourse = Nothing
End Sub
Private Sub LoadtvwClass()
Dim strClassID As String '保存班级编号
Set myUser = New Cls_user
Set myGrade = New Cls_Grade
'按UserID查询班级编号
myUser.OpenConnectByUserID UserID
If myUser.GetUserMessageRs.EOF = False Then
Do Until myUser.GetUserMessageRs.EOF
'保存班级编号
strClassID = Trim(myUser.GetUserMessageRs.Fields(2))
'添加班级编号
tvwClass.Nodes.Add , tvwFirst, strClassID, strClassID
'按班级查询本班的课程
myGrade.PrcGradeSemIDByClassID strClassID
If myGrade.GetGrade.EOF = False Then
Do Until myGrade.GetGrade.EOF
'添加课程编号作为班级编号的字节点
tvwClass.Nodes.Add strClassID, tvwChild, strClassID & Trim(myGrade.GetGrade.Fields(0)), Trim(myGrade.GetGrade.Fields(0))
myGrade.GetGrade.MoveNext
Loop
End If
myUser.GetUserMessageRs.MoveNext
Loop
End If
Set myUser = Nothing
Set myGrade = Nothing
End Sub
Private Sub LoadMSFlexGrid1()
MSFlexGrid1.FormatString = "^学员编号|^课程编号|^机试成绩|^平时成绩|^笔试成绩"
End Sub
Private Sub MoveText(ByVal r As Integer, ByVal c As Integer)
Text1.Width = MSFlexGrid1.CellWidth
Text1.Height = MSFlexGrid1.CellHeight - 100
Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.ColPos(c) + 52
Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.RowPos(r) + 50
Text1.Text = MSFlexGrid1.Text
Text1.Visible = True
Text1.SetFocus
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -