📄 frmmodicourse.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmModiCourse
BorderStyle = 1 'Fixed Single
Caption = "修改课程"
ClientHeight = 2265
ClientLeft = 2460
ClientTop = 2430
ClientWidth = 5175
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2265
ScaleWidth = 5175
Begin MSAdodcLib.Adodc adoEdit
Align = 2 'Align Bottom
Height = 375
Left = 0
Top = 1890
Width = 5175
_ExtentX = 9128
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
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=Stud97.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Stud97.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "SELECT * FROM 课程信息 ORDER BY 课号"
Caption = "Adodc1"
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.Frame Frame1
Caption = "修改课程"
Height = 1215
Left = 600
TabIndex = 5
Top = 120
Width = 3975
Begin VB.TextBox txtCourseNo
DataField = "课号"
DataSource = "adoEdit"
Height = 264
Left = 1320
TabIndex = 7
Top = 360
Width = 2055
End
Begin VB.TextBox txtCourseName
DataField = "课程"
DataSource = "adoEdit"
Height = 264
Left = 1320
TabIndex = 6
Top = 720
Width = 2055
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "课程编号"
Height = 180
Left = 480
TabIndex = 9
Top = 405
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "课程名称"
Height = 180
Left = 480
TabIndex = 8
Top = 765
Width = 720
End
End
Begin VB.CommandButton cmdEdit
Caption = "修改记录"
Height = 312
Left = 60
TabIndex = 4
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdUpdate
Caption = "更新数据"
Height = 312
Left = 1080
TabIndex = 3
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdCancel
Caption = "取消修改"
Height = 312
Left = 2100
TabIndex = 2
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdDelect
Caption = "删除记录"
Height = 312
Left = 3120
TabIndex = 1
Top = 1610
Width = 972
End
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 312
Left = 4140
TabIndex = 0
Top = 1610
Width = 972
End
End
Attribute VB_Name = "frmModiCourse"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'修改课程窗体frmModiCourse
Option Explicit
Private Sub adoEdit_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, _
ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, _
ByVal pRecordset As ADODB.Recordset)
'显示当前记录位置/总记录数
adoEdit.Caption = "Record: " & _
CStr(adoEdit.Recordset.AbsolutePosition) & _
"/" & adoEdit.Recordset.RecordCount
End Sub
Private Sub cmdCancel_Click() '取消
With adoEdit.Recordset
.CancelUpdate '取消更新
.MoveNext
.MovePrevious
End With
Call MyLock(True)
End Sub
Private Sub cmdDelect_Click() '删除
Dim Response As Integer
Response = MsgBox("删除当前记录吗?", vbQuestion + vbYesNo, "询问")
If Response = vbYes Then
With adoEdit.Recordset
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
End If
End Sub
Private Sub cmdEdit_Click() '修改
Call MyLock(False)
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdUpdate_Click() '更新
On Error Resume Next
'各文本框若为空白,提示重新输入
If Trim$(txtCourseNo.Text) = "" Then
MsgBox "请输入课程编号!", vbExclamation
txtCourseNo.SetFocus
Exit Sub
End If
If Trim$(txtCourseName.Text) = "" Then
MsgBox "请输入课程名称!", vbExclamation
txtCourseName.SetFocus
Exit Sub
End If
adoEdit.Recordset.Update '更新数据库
If Err = -2147467259 Then '该错误号为主键重复错误
MsgBox "课程编号重复,请重新输入!", vbExclamation
With txtCourseNo '焦点返回课号框
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
Exit Sub
End If
MsgBox "课程信息已成功修改!", vbInformation
Call MyLock(True) '锁定
End Sub
Private Sub Form_Initialize()
ChDrive App.Path
ChDir App.Path
End Sub
Private Sub Form_Load()
Call MyLock(True)
End Sub
Private Sub Form_Unload(Cancel As Integer) '窗体卸载时
frmMain.Show
End Sub
Private Sub MyLock(ByVal bLock As Boolean) '自定义过程:锁定/解锁用于输入的控件
txtCourseNo.Locked = bLock 'True
txtCourseName.Locked = bLock 'True
cmdEdit.Enabled = bLock 'True
cmdCancel.Enabled = Not bLock 'False
cmdUpdate.Enabled = Not bLock 'False
adoEdit.Enabled = bLock 'True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -