📄 frmbooksort.frm
字号:
VERSION 5.00
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form frmBookSort
BorderStyle = 3 'Fixed Dialog
Caption = "图书分类编目"
ClientHeight = 4680
ClientLeft = 1125
ClientTop = 1740
ClientWidth = 6630
HelpContextID = 2
Icon = "frmBookSort.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4680
ScaleWidth = 6630
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
WhatsThisButton = -1 'True
WhatsThisHelp = -1 'True
Begin VB.Frame Frame1
Height = 4095
Left = 120
TabIndex = 7
Top = 0
Width = 6375
Begin VB.TextBox txtDescribe
Height = 300
Left = 2040
MaxLength = 10
TabIndex = 2
Top = 1200
Width = 2535
End
Begin VB.TextBox txtRemark
Height = 1965
Left = 2040
MaxLength = 255
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 3
Top = 1920
Width = 4095
End
Begin VB.CommandButton cmdDel
Caption = "删除(&D)"
Height = 360
Left = 4800
TabIndex = 5
Top = 795
Width = 1275
End
Begin VB.CommandButton cmdAdd
Caption = "添加(&A)"
Height = 360
Left = 4800
TabIndex = 4
Top = 360
Width = 1275
End
Begin VB.TextBox txtSort
Height = 300
IMEMode = 3 'DISABLE
Left = 2040
MaxLength = 2
TabIndex = 1
Top = 480
Width = 855
End
Begin MSDataListLib.DataList dblSort
Height = 3420
Left = 240
TabIndex = 0
Top = 480
Width = 1575
_ExtentX = 2778
_ExtentY = 6033
_Version = 393216
ListField = ""
BoundColumn = ""
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "主题词:"
Height = 180
Index = 1
Left = 2040
TabIndex = 11
Top = 960
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "备注:"
Height = 180
Index = 3
Left = 2040
TabIndex = 10
Top = 1680
Width = 450
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "分类号:"
Height = 180
Index = 0
Left = 2040
TabIndex = 9
Top = 240
Width = 630
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "图书分类列表:"
Height = 180
Index = 2
Left = 240
TabIndex = 8
Top = 240
Width = 1170
End
End
Begin VB.CommandButton cmdExit
Cancel = -1 'True
Caption = "关闭"
Height = 360
Left = 4800
TabIndex = 6
Tag = "确定"
Top = 4200
Width = 1260
End
End
Attribute VB_Name = "frmBookSort"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim WithEvents rs As ADODB.Recordset
Attribute rs.VB_VarHelpID = -1
Private Sub cmdAdd_Click()
'追加新记录
rs.AddNew
rs("类别代码") = ""
rs("命名描述") = ""
rs("说明") = ""
txtSort.SetFocus
End Sub
Private Sub cmdDel_Click()
'删除记录
Dim intBook As Integer
Dim rsBook As ADODB.Recordset
Set rsBook = mCdt.rsBookSortStat(rs("类别代码"))
intBook = rsBook(0)
rsBook.Close
If intBook > 0 Then
MsgBox "该图书类别下已有图书,不能被删除!", vbInformation
Exit Sub
End If
If Not (rs.EOF Or rs.BOF) Then
rs.Delete
rs.MoveNext
End If
End Sub
Private Sub cmdExit_Click()
On Error Resume Next
rs.Update
Unload Me
End Sub
Private Sub dblSort_Click()
Dim strSortID As String
strSortID = dblSort.Text
rs.MoveFirst
rs.Find "类别代码='" & strSortID & "'"
End Sub
Private Sub Form_Load()
Set rs = mCdt.rsBookSortRegister
Set dblSort.RowSource = rs
dblSort.ListField = "类别代码"
Set txtSort.DataSource = rs
txtSort.DataField = "类别代码"
Set txtDescribe.DataSource = rs
txtDescribe.DataField = "命名描述"
Set txtRemark.DataSource = rs
txtRemark.DataField = "说明"
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
rs.Close
Set rs = Nothing
End Sub
Private Sub rs_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
rsRefresh
End Sub
Private Sub txtSort_GotFocus()
txtSort.SelStart = 0
txtSort.SelLength = Len(txtSort)
End Sub
Private Sub txtSort_LostFocus()
'检验数据
On Error Resume Next
If Trim(txtSort) = "" Then
MsgBox "类别代码不能为空字串!", vbExclamation
txtSort.SetFocus
Exit Sub
End If
rs.Update
Select Case Err
Case 0
rsRefresh
Case -2147467259
MsgBox Error
MsgBox "类别代码发生重复冲突!", vbExclamation
txtSort.SetFocus
Case Else
txtSort.SetFocus
End Select
End Sub
Private Sub rsRefresh()
If rs.AbsolutePosition < 1 Then
txtSort.Enabled = False
txtRemark.Enabled = False
cmdDel.Enabled = False
Else
txtSort.Enabled = True
txtRemark.Enabled = True
cmdDel.Enabled = True
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
If rs.BOF Or rs.EOF Then
Exit Sub
End If
If (rs.EditMode = adEditAdd Or rs.EditMode = adEditInProgress) Then
Cancel = 1
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -