📄 frmclassedit.frm
字号:
VERSION 5.00
Begin VB.Form FrmClassedit
BorderStyle = 3 'Fixed Dialog
Caption = "Form1"
ClientHeight = 3675
ClientLeft = 45
ClientTop = 330
ClientWidth = 6735
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3675
ScaleWidth = 6735
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Cmd_Cancel
Caption = "取 消"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3480
TabIndex = 7
Top = 3240
Width = 1335
End
Begin VB.CommandButton Cmd_OK
Caption = "确 定"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1320
TabIndex = 6
Top = 3240
Width = 1335
End
Begin VB.TextBox TxtDes
Height = 1935
Left = 120
MaxLength = 98
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 5
Top = 1200
Width = 6495
End
Begin VB.TextBox TxtName
Height = 375
Left = 1200
MaxLength = 15
TabIndex = 3
Top = 480
Width = 5175
End
Begin VB.Label Label4
Caption = "描述:"
Height = 255
Left = 240
TabIndex = 4
Top = 960
Width = 975
End
Begin VB.Label Label3
Caption = "课程名:"
Height = 375
Left = 240
TabIndex = 2
Top = 600
Width = 855
End
Begin VB.Label UpperName
Caption = "UpperClassName"
Height = 375
Left = 1320
TabIndex = 1
Top = 120
Width = 4095
End
Begin VB.Label Label1
Caption = "上级课程:"
Height = 255
Left = 240
TabIndex = 0
Top = 120
Width = 975
End
End
Attribute VB_Name = "FrmClassedit"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Modify As Integer
'为1时,表修改课程;为2时,表添加课程,3 时表修改章节;为4时,表添加章节
Private Sub Cmd_Cancel_Click()
Unload Me
End Sub
Private Sub Cmd_Ok_Click()
If Trim(TxtName) = "" Then
MsgBox "课程名或章节名不能为空!", vbOKOnly + 48, "警告"
Exit Sub
End If
With MyClass
.Classname = MakeStr(TxtName)
.Describe = MakeStr(TxtDes)
'根据变量Modify决定是插入新数据,还是修改已有的数据
Select Case Modify
Case 2: '插入课程
'调用In_DB()函数判断用户输入的名称是否已经存在
If .In_DB(.Classname) = True Then
MsgBox "课程 " & Trim(TxtName) + " 已经存在!", _
vbOKOnly + 48, "警告"
Exit Sub
End If
'CurClass中保存在课程管理窗体中选中的课程信息
.UpperId = 0
Bh = .Insert
MsgBox "课程 " & .Classname & " 添加成功!", _
vbOKOnly + 64, "信息"
FrmclassMan.Adodc1.Refresh
Case 1: '修改课程
If SelClass.Classname <> Trim(TxtName) Then
If .In_DB(Trim(TxtName)) = True Then
MsgBox "课程 " & Trim(TxtName) + " 已经存在!", _
vbOKOnly + 48, "警告"
Exit Sub
End If
End If
'当修改记录时,不能改变上下级之间的关系
.UpperId = SelClass.UpperId
.Update (SelClass.ClassId)
MsgBox "课程 " & SelClass.Classname & " 修改成功!", _
vbOKOnly + 64, "信息"
If SelClass.Classname <> Trim(TxtName) Then
FrmclassMan.Adodc1.Refresh
FrmclassMan.TxtClassName = Trim(TxtName)
FrmclassMan.TxtClassDes = Trim(TxtDes)
End If
'设置CurClass变量
'CurClass.ClassName = Trim(TxtName)
Case 3: '修改章节
If SelClass.Classname <> Trim(TxtName) Then
If .In_DB(Trim(TxtName)) = True Then
MsgBox "章节 " & Trim(TxtName) + " 已经存在!", _
vbOKOnly + 48, "警告"
Exit Sub
End If
End If
'当修改记录时,不能改变上下级之间的关系
.UpperId = SelClass.UpperId
.Update (SelClass.ClassId)
MsgBox "章节 " & SelClass.Classname & " 修改成功!", _
vbOKOnly + 64, "信息"
If SelClass.Classname <> Trim(TxtName) Then
FrmclassMan.Adodc1.Refresh
FrmclassMan.TxtClassName = Trim(TxtName)
FrmclassMan.TxtClassDes = Trim(TxtDes)
End If
'设置CurClass变量
'CurClass.ClassName = Trim(TxtName)
Case 4: '表添加章节
If .In_DB(.Classname) = True Then
MsgBox "章节 " & Trim(TxtName) + " 已经存在!", _
vbOKOnly + 48, "警告"
Exit Sub
End If
.UpperId = SelClass.UpperId
Bh = .Insert
MsgBox "课程 " & UpperName.Caption & " 的章节" _
& Chr(10) & Chr(13) _
& .Classname & " 添加成功!", vbOKOnly + 64, "信息"
FrmclassMan.Adodc1.Refresh
Case 5: '为没有章节的课程添加最少一个章节
If .In_DB(.Classname) = True Then
MsgBox "章节 " & Trim(TxtName) + " 已经存在!", _
vbOKOnly + 48, "警告"
Exit Sub
End If
.UpperId = SelClass.ClassId
Bh = .Insert
MsgBox "课程 " & UpperName.Caption & " 的章节" _
& Chr(10) & Chr(13) _
& .Classname & " 添加成功!", vbOKOnly + 64, "信息"
FrmclassMan.Adodc1.Refresh
Case 6: '表一般用户在进行课程的第一次添加章节
If .In_DB(.Classname) = True Then
MsgBox "章节 " & Trim(TxtName) + " 已经存在!", _
vbOKOnly + 48, "警告"
Exit Sub
End If
.UpperId = CurClass.ClassId
Bh = .Insert
MsgBox "课程 " & UpperName.Caption & " 的章节" _
& Chr(10) & Chr(13) _
& .Classname & " 添加成功!", vbOKOnly + 64, "信息"
FrmclassMan.Adodc1.Refresh
End Select
End With
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -