📄 frmaddcourse.frm
字号:
VERSION 5.00
Begin VB.Form frmAddcourse
BackColor = &H80000005&
Caption = "添加课程"
ClientHeight = 4485
ClientLeft = 60
ClientTop = 345
ClientWidth = 6735
Icon = "frmAddcourse.frx":0000
MDIChild = -1 'True
ScaleHeight = 4485
ScaleWidth = 6735
Begin VB.Frame Frame1
BackColor = &H80000005&
Caption = "添加课程"
Height = 3735
Left = 240
TabIndex = 0
Top = 360
Width = 6255
Begin VB.CommandButton cmdSave
BackColor = &H80000005&
Caption = "保存/修改(&S)"
Height = 375
Left = 1080
Style = 1 'Graphical
TabIndex = 12
Top = 3120
Width = 1335
End
Begin VB.CommandButton cmdCancel
BackColor = &H80000005&
Caption = "取消(&C)"
Height = 375
Left = 3000
Style = 1 'Graphical
TabIndex = 11
Top = 3120
Width = 1335
End
Begin VB.TextBox TxtCno
Height = 270
Left = 2160
TabIndex = 5
Text = "TxtCno"
Top = 480
Width = 1695
End
Begin VB.TextBox TxtCname
Height = 270
Left = 2160
TabIndex = 4
Text = "TxtCname"
Top = 960
Width = 2295
End
Begin VB.TextBox TxtTname
Height = 270
Left = 2160
TabIndex = 3
Text = "TxtTname"
Top = 1440
Width = 2295
End
Begin VB.TextBox TxtCcredit
Height = 270
Left = 2160
TabIndex = 2
Text = "TxtCcredit"
Top = 1920
Width = 1095
End
Begin VB.CommandButton cmdClear
Caption = "清除(&C)"
Height = 375
Left = 6480
TabIndex = 1
Top = 360
Width = 1335
End
Begin VB.Label lbInfo
BackColor = &H80000005&
ForeColor = &H00C0C0C0&
Height = 495
Left = 600
TabIndex = 10
Top = 2400
Width = 5415
End
Begin VB.Label Label5
BackColor = &H80000005&
Caption = "课程名称"
Height = 255
Left = 960
TabIndex = 9
Top = 960
Width = 855
End
Begin VB.Label Label3
BackColor = &H80000005&
Caption = "授课老师姓名"
Height = 255
Left = 840
TabIndex = 8
Top = 1440
Width = 1095
End
Begin VB.Label Label4
BackColor = &H80000005&
Caption = "课程学分"
Height = 255
Left = 960
TabIndex = 7
Top = 1920
Width = 855
End
Begin VB.Label Label2
BackColor = &H80000005&
Caption = "课程编号"
Height = 255
Left = 960
TabIndex = 6
Top = 480
Width = 975
End
End
End
Attribute VB_Name = "frmAddcourse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim SQL As String
Dim kcjl As New ADODB.Recordset '课程表 jc_c 中的课程记录
Private Sub Form_Activate()
TxtCno.SetFocus
lbInfo.Caption = "注意:要修改某门课程输入课程编号,同时输入相关数据即可。"
End Sub
Private Sub Form_Load()
Call Clear
End Sub
Private Sub Clear()
TxtCno.Text = ""
TxtCname.Text = ""
TxtTname.Text = ""
TxtCcredit.Text = ""
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdSave_Click()
Dim msg As String
Dim strCno As String
Dim strCname As String
Dim strTname As String
Dim strCcredit As String
strCno = Trim(TxtCno.Text)
strCname = Trim(TxtCname.Text)
strTname = Trim(TxtTname.Text)
strCcredit = Trim(TxtCcredit.Text)
'检查是否存在该课程数据
If strCno = "" Or strCname = "" Then
Call showMsg("课程编号和课程名称不能为空!", 1)
TxtCno.SetFocus
Exit Sub
End If
On Error GoTo sqlErr
SQL = "select cno from jc_c where cno='" & strCno & "'"
Set kcjl = cnn.Execute(SQL)
If kcjl.BOF And kcjl.EOF Then
SQL = "insert into jc_c(cno,cname,tname,ccredit) "
SQL = SQL & "values('" & strCno & "','" & strCname & "','" & strTname & "','" & strCcredit & "') "
cnn.Execute (SQL)
Call showMsg("添加课程 " & strCname & " 成功 !", 1)
Exit Sub
Else
SQL = "update jc_c set cname='" & strCname & "',tname='" & strTname & "',ccredit='" & strCcredit & "' where cno='" & strCno & "'"
cnn.Execute (SQL)
Call showMsg("修改课程 " & strCname & " 成功 !", 1)
Exit Sub
End If
sqlErr:
Call showMsg("无法保存,可能原因:" & vbCrLf & "-你选择信息已经存在。" & vbCrLf & "-您输入的成绩为非法字符。", 0)
End Sub
Private Sub Form_Resize()
With Me
Frame1.Left = (.ScaleWidth - Frame1.Width) / 2
Frame1.Top = (.ScaleHeight - Frame1.Height) / 2
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -