📄 tjkc.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form tjkc
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Dialog
Caption = "课程录入"
ClientHeight = 3120
ClientLeft = 2880
ClientTop = 2010
ClientWidth = 4380
Icon = "tjkc.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4380
ShowInTaskbar = 0 'False
Begin VB.CommandButton Command3
Caption = "关闭"
Height = 375
Left = 2880
TabIndex = 8
Top = 2280
Width = 975
End
Begin VB.CommandButton Command2
Caption = "删除(&D)"
Height = 375
Left = 1560
TabIndex = 7
Top = 2280
Width = 975
End
Begin VB.TextBox Text3
BackColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 6
Top = 1680
Width = 2535
End
Begin VB.TextBox Text2
BackColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 4
Top = 960
Width = 2535
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 2
Top = 240
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "添加(&A)"
Height = 375
Left = 240
TabIndex = 0
Top = 2280
Width = 975
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 2640
Top = 600
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cj.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cj.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "课程表"
Caption = ""
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label Label3
BackColor = &H00C0C0C0&
Caption = "授课老师:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 5
Top = 1800
Width = 1095
End
Begin VB.Label Label2
BackColor = &H00C0C0C0&
Caption = "课程名称:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 3
Top = 1080
Width = 1215
End
Begin VB.Label Label1
BackColor = &H00C0C0C0&
Caption = "课程号:"
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 1
Top = 360
Width = 1095
End
End
Attribute VB_Name = "tjkc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim SD As Boolean
Private Function checkclass() As Boolean '检测添加的课程是否重复
On Error GoTo errh
Set rs = cn.Execute("SELECT 课程号 FROM 课程表 WHERE 课程号='" & Trim(Text1.Text) & "'")
' Adodc2.RecordSource = "select * from 课程 where 课程号='" & Trim(Text1.Text) & "' and 课程名称='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
checkclass = True
Exit Function
End If
checkclass = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Sub Command1_Click()
On Error GoTo errh
If Text1.Text <> "" Then
If Text2.Text <> "" Then
If Text3.Text <> "" Then
If checkclass Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("课程号").Value = Text1.Text
Adodc1.Recordset.Fields("课程名称").Value = Text2.Text
Adodc1.Recordset.Fields("授课老师").Value = Text3.Text
Adodc1.Recordset.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
MsgBox "添加成功!"
'Adodc1.Refresh
Else
MsgBox "课程重复,请另外输入一门课程!"
Text1.SetFocus
End If
Else
MsgBox "该项不能为空,请输入授课老师姓名!"
End If
Else
MsgBox "该项不能为空,请输入课程名称!"
End If
Else
MsgBox "该项不能为空,请输入课程号!"
End If
'MsgBox("你的操作将关系到所有选这门课的学生,所有这门课的纪录将被删除,你确信吗?", vbOKCancel, "警告") = vbOK Then
'Adodc1.Recordset.Delete adAffectAllChapters
'
'Adodc1.Recordset.UpdateBatch adAffectAllChapters
'DataGrid1.ReBind
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub Command15_Click()
Unload Me
End Sub
Private Sub Command2_Click()
On Error GoTo errh
If MsgBox("你的操作将会删除当前的纪录,你确信吗?", vbOKCancel, "警告") = vbOK Then
If Text1.Text <> "" Then
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM 课程表 WHERE 课程号='" & Trim(Text1.Text) & "' ", cn, adOpenDynamic, adLockOptimistic, adCmdText
If rs.EOF Then
rs.Close
MsgBox "没有该课程,无法删除!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Exit Sub
End If
rs.Delete
rs.Update
rs.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
MsgBox "删除成功!"
Else
MsgBox "该项不能为空,请输入课程号!"
End If
End If
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo errh
MakeCenter tjkc
Exit Sub
errh:
MsgBox Err.Description
End Sub
'Private Sub Form_Unload(Cancel As Integer)
'On Error Resume Next
' Adodc1.Recordset.Close
'End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -