📄 form4.frm
字号:
VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomct2.ocx"
Begin VB.Form Form4
BackColor = &H00FFC0C0&
Caption = "Form4"
ClientHeight = 3930
ClientLeft = 5310
ClientTop = 3420
ClientWidth = 4965
LinkTopic = "Form4"
ScaleHeight = 3930
ScaleWidth = 4965
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Caption = "学生成绩登记:"
Height = 3615
Left = 120
TabIndex = 0
Top = 120
Width = 4575
Begin VB.CommandButton Command4
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3240
TabIndex = 12
Top = 2280
Width = 975
End
Begin VB.CommandButton Command3
Caption = "返回"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3240
TabIndex = 11
Top = 2280
Width = 975
End
Begin VB.CommandButton Command2
Caption = "修改"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3240
TabIndex = 10
Top = 1320
Width = 975
End
Begin MSComCtl2.DTPicker DTPicker1
Height = 495
Left = 1320
TabIndex = 9
Top = 1680
Width = 1455
_ExtentX = 2566
_ExtentY = 873
_Version = 393216
Format = 23855105
CurrentDate = 38710
End
Begin VB.CommandButton Command1
BackColor = &H00FFC0C0&
Caption = "登记"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 3240
TabIndex = 7
Top = 360
Width = 975
End
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 = 495
Index = 2
Left = 1320
TabIndex = 4
Text = "Text1"
Top = 2520
Width = 1455
End
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 = 495
Index = 1
Left = 1320
TabIndex = 3
Text = "Text1"
Top = 960
Width = 1455
End
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 = 495
Index = 0
Left = 1320
TabIndex = 2
Text = "Text1"
Top = 240
Width = 1455
End
Begin VB.Label Label1
Caption = "成绩:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 3
Left = 120
TabIndex = 8
Top = 2520
Width = 855
End
Begin VB.Label Label1
Caption = "考试时间:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 2
Left = 120
TabIndex = 6
Top = 1800
Width = 1095
End
Begin VB.Label Label1
Caption = "课程编号:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 120
TabIndex = 5
Top = 960
Width = 1095
End
Begin VB.Label Label1
Caption = "学号:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 120
TabIndex = 1
Top = 360
Width = 735
End
End
End
Attribute VB_Name = "Form4"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim DBConn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim SqlText As String
Dim s1 As String
Dim s2 As String
Dim s3 As String
Dim s4 As String
Set DBConn = CreateObject("ADODB.Connection")
DBConn.ConnectionString = "DBQ=" + App.Path + "\db1;Driver={Microsoft Access Driver (*.mdb)}"
stu_Id = Text1(0).Text
cou_Id = Text1(1).Text
T_time = Trim(Format(DTPicker1.Value, "yyyy-mm-dd"))
Grade = Text1(2).Text
s1 = "select stu_Id from 学生信息 where stu_Id='" & stu_Id & "'"
's2 = "select stu_Id from 成绩表 where stu_Id='" & stu_Id & "'"
's3 = "select cou_Id from 成绩表 where cou_Id='" & cou_Id & "'"
s4 = "select * from 成绩表"
If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Text1(2).Text) = "" Then
MsgBox "录入信息不完整,请重新输入!", vbOKOnly, "提示!"
Else
Set rs = TransactSQL(s1)
If rs.EOF = True Then
MsgBox "该学生信息不存在!请检查学号输入是否正确,或登记该学生信息!", vbOKOnly, "提示!"
rs.Close
Else
'Set rs = TransactSQL(s2)
'If rs.EOF = False Then
' GradeFlag = True
' rs.Close
' Else
' Set rs = TransactSQL(s3)
' If rs.EOF = False And GradeFlag = True Then
' MsgBox "该学生的这门课程成绩已存在,请核对!", vbOKOnly
' rs.Close
' Else
Set rs = TransactSQL(s4)
rs.AddNew
rs.Fields(0) = Trim(Text1(0).Text)
rs.Fields(1) = Trim(Text1(1).Text)
rs.Fields(2) = Trim(Format(DTPicker1.Value, "yyyy-mm-dd"))
rs.Fields(3) = Trim(Text1(2).Text)
rs.Update
MsgBox "操作成功!!!"
rs.Close
End If
End If
'End If
'End If
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
GradeFlag = False
End Sub
Private Sub Command2_Click()
Dim rs As New ADODB.Recordset
Dim sql As String
sql = "update 成绩表 set cou_Id='" & Text1(1).Text & "'"
sql = sql & ",T_time='" & Format(DTPicker1.Value, "yyyy-mm-dd") & "',Grade='" & Text1(2).Text & "' where stu_Id='" & Text1(0).Text & "'"
If Trim(Text1(0).Text) = "" Or Trim(Text1(1).Text) = "" Or Trim(Text1(2).Text) = "" Then
MsgBox "成绩信息输入不完整!", vbOKOnly, "提示!"
Else
TransactSQL (sql)
MsgBox "成绩信息修改成功!", vbOKOnly, "提示!"
Unload Me
'Form1.Show
Unload Form5
Form5.Show
Form5.command2.Enabled = False
End If
End Sub
Private Sub Command3_Click()
Form1.Show
Unload Form4
End Sub
Private Sub Command4_Click()
Unload Me
Unload Form5
Form5.Show
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim rs As New ADODB.Recordset
'Dim sqlType As String
'sqlType = "select typename from booktype order by typename"
'Set rs = TransactSQL(sqlType)
'While Not rs.EOF
' Combo1.AddItem rs(0)
' rs.MoveNext
'Wend
'rs.Close
'操作选择
If modifyGrFlag2 = True Then
'Dim rs As New ADODB.Recordset
Dim sql As String
sql = "select * from 成绩表 where stu_Id ='" & modifyGrFlag1 & "'"
Set rs = TransactSQL(sql)
Text1(0).Text = rs.Fields(0)
Text1(0).Locked = True ' 使不可改动
Text1(1).Text = rs.Fields(1)
DTPicker1.Value = rs.Fields(2)
Text1(2).Text = rs.Fields(3)
modifyGrFlag2 = modifyGrFlag2 Xor True
Command1.Enabled = False
Else
Text1(0).Text = ""
Text1(1).Text = ""
Text1(2).Text = ""
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -