📄 addcj.frm
字号:
VERSION 5.00
Begin VB.Form addCj
BorderStyle = 3 'Fixed Dialog
Caption = "添加成绩"
ClientHeight = 3840
ClientLeft = 5565
ClientTop = 3555
ClientWidth = 4680
Icon = "addCj.frx":0000
LinkTopic = "Form3"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3840
ScaleWidth = 4680
ShowInTaskbar = 0 'False
Begin VB.TextBox Text2
Appearance = 0 'Flat
BackColor = &H80000018&
Height = 320
Left = 720
TabIndex = 12
Top = 6240
Visible = 0 'False
Width = 2020
End
Begin VB.TextBox Text1
Appearance = 0 'Flat
BackColor = &H80000018&
Height = 320
Left = 720
TabIndex = 11
Top = 5880
Visible = 0 'False
Width = 2020
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 375
Left = 3000
TabIndex = 9
Top = 3360
Width = 1095
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 375
Left = 600
TabIndex = 8
Top = 3360
Width = 1095
End
Begin VB.Frame Frame1
Height = 3015
Left = 0
TabIndex = 0
Top = 120
Width = 4815
Begin VB.Frame Frame5
Caption = "分数:"
Height = 615
Left = 120
TabIndex = 6
Top = 2280
Width = 2775
Begin VB.TextBox Text3
Appearance = 0 'Flat
BackColor = &H80000018&
Height = 320
Left = 600
TabIndex = 7
Top = 180
Width = 2020
End
End
Begin VB.Frame Frame3
Caption = "课程名称:"
Height = 615
Left = 120
TabIndex = 4
Top = 1560
Width = 2775
Begin VB.ComboBox Combo1
BackColor = &H80000018&
Height = 300
Index = 1
ItemData = "addCj.frx":08CA
Left = 600
List = "addCj.frx":08CC
Style = 2 'Dropdown List
TabIndex = 5
Top = 180
Width = 2055
End
End
Begin VB.Frame Frame2
Caption = "学号:"
Height = 615
Left = 120
TabIndex = 3
Top = 120
Width = 2775
Begin VB.ComboBox Combo1
BackColor = &H80000018&
Height = 300
Index = 0
ItemData = "addCj.frx":08CE
Left = 600
List = "addCj.frx":08D0
Style = 2 'Dropdown List
TabIndex = 10
Top = 180
Width = 2055
End
End
Begin VB.Frame Frame4
Caption = "学期:"
Height = 615
Left = 120
TabIndex = 1
Top = 840
Width = 2775
Begin VB.ComboBox Combo1
BackColor = &H80000018&
Height = 300
Index = 3
ItemData = "addCj.frx":08D2
Left = 600
List = "addCj.frx":08EE
TabIndex = 2
Text = "大一上学期"
Top = 180
Width = 2055
End
End
Begin VB.Image Image1
Height = 2655
Left = 3240
Picture = "addCj.frx":0952
Stretch = -1 'True
Top = 240
Width = 1335
End
End
End
Attribute VB_Name = "addCj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Combo1_Click(Index As Integer)
Select Case Index
Case 1
txtSQL = "select * from zpcourse where 课程名称='" & Trim(Combo1(1).Text) & "'"
Set mrc = ExecuteSQL(txtSQL)
If mrc.EOF = True Then
Exit Sub
End If
mrc.MoveFirst
Do Until mrc.EOF
Text1.Text = mrc.Fields(2)
Text2.Text = mrc.Fields(4)
mrc.MoveNext
Loop
Set mrc = Nothing
Case 3
txtSQL = "select 课程名称 from zpcourse where 学期='" & Trim(Combo1(3).Text) & "'"
Set mrc1 = ExecuteSQL(txtSQL)
If mrc1.EOF = True Then
Exit Sub
End If
Combo1(1).Clear
mrc1.MoveFirst
Do Until mrc1.EOF
Combo1(1).AddItem mrc1.Fields(0)
mrc1.MoveNext
Loop
Set mrc1 = Nothing
End Select
End Sub
Private Sub Command1_Click()
If Combo1(0).Text = "" Then
sss = MsgBox("学号不能为空!", vbExclamation + vbOKOnly, "警告")
Combo1(0).SetFocus
Exit Sub
End If
If Combo1(3).Text = "" Then
sss = MsgBox("学期不能为空!", vbExclamation + vbOKOnly, "警告")
Combo1(3).SetFocus
Exit Sub
End If
If Combo1(1).Text = "" Then
sss = MsgBox("课程名不能为空!", vbExclamation + vbOKOnly, "警告")
Combo1(1).SetFocus
Exit Sub
End If
If Not Testtxt(Text3.Text) Then
MsgBox "还没有输入分数呢!!", vbOKOnly + vbExclamation, "警告"
Text3.SetFocus
Exit Sub
End If
If Not IsNumeric(Text3.Text) Then
MsgBox "分数必须输入数字!", vbOKOnly + vbExclamation, "警告"
Text3.Text = ""
Text3.SetFocus
Exit Sub
End If
Dim mrc As ADODB.Recordset
txtSQL = "select 学号 from cj where 学号='" & Trim(Combo1(0).Text) & "' and 学期='" & Trim(Combo1(3).Text) & "' and 课程名称='" & Trim(Combo1(1).Text) & "'"
Set mrc = ExecuteSQL(txtSQL)
If mrc.EOF = False Then
sss = MsgBox("已存在该学号的成绩记录!", vbExclamation + vbOKOnly, "警告")
Combo1(0).SetFocus
Exit Sub
End If
txtSQL = "select * from cj"
Set mrc = ExecuteSQL(txtSQL)
mrc.AddNew
mrc.Fields(1) = Combo1(0).Text
mrc.Fields(2) = Trim(Combo1(3).Text)
mrc.Fields(3) = Trim(Combo1(1).Text)
mrc.Fields(4) = Val(Trim(Text3.Text))
mrc.Fields(5) = Val(Trim(Text3.Text)) * Val(Trim(Text1.Text)) * Val(Trim(Text2.Text))
mrc.Update
Text3.Text = ""
Combo1(0).SetFocus
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
End Sub
Private Sub Form_Load()
Dim mrc As ADODB.Recordset
txtSQL = "select 学号 from stud"
Set mrc = ExecuteSQL(txtSQL)
If mrc.EOF = True Then
Exit Sub
End If
mrc.MoveFirst
Do Until mrc.EOF
Combo1(0).AddItem mrc.Fields(0)
mrc.MoveNext
Loop
Set mrc = Nothing
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmMain.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -