📄 bjtj.frm
字号:
VERSION 5.00
Begin VB.Form 班级添加
Caption = "班级管理-班级添加"
ClientHeight = 3300
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form7"
ScaleHeight = 3300
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 3255
Left = 0
TabIndex = 0
Top = 0
Width = 4695
Begin VB.TextBox Text2
Height = 315
Left = 1470
TabIndex = 11
Top = 2280
Width = 2685
End
Begin VB.ComboBox Combo2
Height = 300
Left = 1440
Style = 2 'Dropdown List
TabIndex = 9
Top = 1200
Width = 1995
End
Begin VB.CommandButton Command2
Caption = "取消"
Height = 315
Left = 2820
TabIndex = 7
Top = 2820
Width = 915
End
Begin VB.CommandButton Command1
Caption = "确定"
Height = 315
Left = 1080
TabIndex = 6
Top = 2820
Width = 915
End
Begin VB.TextBox Text1
Height = 315
Left = 1440
TabIndex = 5
Top = 1740
Width = 1995
End
Begin VB.ComboBox Combo1
Height = 300
Left = 1440
Style = 2 'Dropdown List
TabIndex = 4
Top = 690
Width = 1995
End
Begin VB.Label Label5
Caption = "班级代码"
Height = 285
Left = 360
TabIndex = 10
Top = 1800
Width = 795
End
Begin VB.Label Label4
Caption = "专业"
Height = 255
Left = 360
TabIndex = 8
Top = 1200
Width = 465
End
Begin VB.Label Label3
Caption = "班级名称"
Height = 315
Left = 360
TabIndex = 3
Top = 2370
Width = 795
End
Begin VB.Label Label2
Caption = "院系"
Height = 315
Left = 360
TabIndex = 2
Top = 750
Width = 615
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "班 级 添 加"
BeginProperty Font
Name = "黑体"
Size = 15
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 360
TabIndex = 1
Top = 240
Width = 3975
End
End
End
Attribute VB_Name = "班级添加"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim mrc As ADODB.Recordset
Private Sub Command1_Click()
txtsql = "select * from 院系 where 院系名称='" & Trim(Combo1.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
MsgBox " 请先添加院系记录!", vbExclamation + vbOKOnly, "警告"
Unload Me
Exit Sub
Else
combo1text = mrc.Fields(0)
mrc.Close
End If
txtsql = "select * from 专业 where 专业名称='" & Trim(Combo2.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
MsgBox " 请先添加专业记录!", vbExclamation + vbOKOnly, "警告"
Unload Me
Exit Sub
Else
combo2text = mrc.Fields(0)
mrc.Close
End If
If Text1.Text = "" Then
MsgBox " 请输入班级代码!", vbExclamation + vbOKOnly, "警告"
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
MsgBox " 请输入班级名称!", vbExclamation + vbOKOnly, "警告"
Text2.SetFocus
Exit Sub
End If
txtsql = "select * from 班级 where 班级代码='" & Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
MsgBox " 存在该班级代码!", vbExclamation + vbOKOnly, "警告"
Text1.SetFocus
'mrc.Close
Exit Sub
End If
txtsql = "select * from 班级 where 班级名称='" & Trim(Text2.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
MsgBox " 存在该班级名称!", vbExclamation + vbOKOnly, "警告"
Text2.SetFocus
'mrc.Close
Exit Sub
End If
mrc.AddNew
mrc.Fields(0) = Text1.Text
mrc.Fields(1) = Text2.Text
mrc.Fields(2) = combo1text
mrc.Fields(3) = combo2text
mrc.Update
mrc.Close
MsgBox " 添加班级成功!", vbExclamation + vbOKOnly, "提示"
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
'院系组合框内容添加
txtsql = "select * from 院系"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
MsgBox " 没有院系记录,请先添加院系记录!", vbExclamation + vbOKOnly, "警告"
Exit Sub
End If
Do While Not mrc.EOF
Combo1.AddItem mrc.Fields(1)
mrc.MoveNext
Loop
'专业组合框内容添加
txtsql = "select * from 专业"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
MsgBox " 没有专业记录,请先添加专业记录!", vbExclamation + vbOKOnly, "警告"
Exit Sub
End If
Do While Not mrc.EOF
Combo2.AddItem mrc.Fields(1)
mrc.MoveNext
Loop
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -