📄 frmbm.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmBM
Caption = "部门管理"
ClientHeight = 3615
ClientLeft = 1110
ClientTop = 345
ClientWidth = 5745
KeyPreview = -1 'True
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 3615
ScaleWidth = 5745
WindowState = 2 'Maximized
Begin VB.Frame Frame3
Caption = "操作"
Height = 1455
Left = 5640
TabIndex = 7
Top = 2880
Width = 4455
Begin VB.CommandButton Command4
Caption = "取消"
Height = 375
Left = 1920
TabIndex = 11
Top = 840
Width = 1335
End
Begin VB.CommandButton Command3
Caption = "保存"
Height = 375
Left = 240
TabIndex = 10
Top = 840
Width = 1335
End
Begin VB.CommandButton Command2
Caption = "删除部门"
Height = 375
Left = 1920
TabIndex = 9
Top = 360
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "增加部门"
Height = 375
Left = 240
TabIndex = 8
Top = 360
Width = 1335
End
End
Begin VB.Frame Frame2
Caption = "当前部门"
Height = 1455
Left = 5640
TabIndex = 3
Top = 840
Width = 4455
Begin VB.TextBox Text2
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 1320
TabIndex = 4
Top = 840
Width = 2775
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 360
Left = 1320
TabIndex = 1
Top = 360
Width = 2775
End
Begin VB.Label Label2
Caption = "部门:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 600
TabIndex = 6
Top = 840
Width = 975
End
Begin VB.Label Label1
Caption = "部门代号:"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 5
Top = 360
Width = 1215
End
End
Begin VB.Frame Frame1
Caption = "部门列表"
Height = 3495
Left = 240
TabIndex = 0
Top = 840
Width = 5295
Begin MSDataGridLib.DataGrid grdDataGrid
Bindings = "frmBM.frx":0000
Height = 3015
Left = 120
TabIndex = 2
Top = 360
Width = 5025
_ExtentX = 8864
_ExtentY = 5318
_Version = 393216
AllowUpdate = -1 'True
HeadLines = 1
RowHeight = 15
AllowAddNew = -1 'True
AllowDelete = -1 'True
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
Begin MSAdodcLib.Adodc datPrimaryRS
Height = 330
Left = 5640
Top = 2400
Visible = 0 'False
Width = 4440
_ExtentX = 7832
_ExtentY = 582
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 = ""
OLEDBString = ""
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
End
Attribute VB_Name = "frmBM"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
Command3.Enabled = True
Command4.Enabled = True
Command1.Enabled = False
Command2.Enabled = False
Text1.SetFocus
datPrimaryRS.Recordset.AddNew
End Sub
Private Sub Command2_Click()
If MsgBox("确定删除当前资料吗?", vbInformation + vbYesNo, "删除资料?") = vbYes Then
datPrimaryRS.Recordset.Delete
End If
End Sub
Private Sub Command3_Click()
If Text1.Text = "" Then
MsgBox "请输入部门编号!"
Text1.SetFocus
End If
If Text2.Text = "" Then
MsgBox "请输入部门名称!"
Text2.SetFocus
End If
If MsgBox("确定保存当前资料吗?", vbInformation + vbYesNo, "保存资料?") = vbYes Then
datPrimaryRS.Recordset(0) = Text1.Text
datPrimaryRS.Recordset(1) = Text2.Text
datPrimaryRS.Recordset.UpdateBatch
Command3.Enabled = False
Command4.Enabled = False
Command1.Enabled = True
Command2.Enabled = True
End If
End Sub
Private Sub Command4_Click()
datPrimaryRS.Recordset.CancelBatch adAffectAllChapters
Command3.Enabled = False
Command4.Enabled = False
Command1.Enabled = True
Command2.Enabled = True
End Sub
Private Sub Form_Load()
datPrimaryRS.ConnectionString = constr
datPrimaryRS.RecordSource = "select 部门编号,部门名称 from 部门列表 Order by 部门编号"
datPrimaryRS.Refresh
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = False
Command4.Enabled = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
Screen.MousePointer = vbDefault
End Sub
Private Sub datPrimaryRS_Error(ByVal ErrorNumber As Long, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, fCancelDisplay As Boolean)
'错误处理程序代码置于此处
'想要忽略错误,注释掉下一行
'想要捕获它们,在此添加代码以处理它们
MsgBox "Data error event hit err:" & Description
End Sub
Private Sub datPrimaryRS_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
'验证代码置于此处
'下列动作发生时该事件被调用
Dim bCancel As Boolean
Select Case adReason
Case adRsnAddNew
Case adRsnClose
Case adRsnDelete
Case adRsnFirstChange
Case adRsnMove
Case adRsnRequery
Case adRsnResynch
Case adRsnUndoAddNew
Case adRsnUndoDelete
Case adRsnUndoUpdate
Case adRsnUpdate
End Select
If bCancel Then adStatus = adStatusCancel
End Sub
Private Sub grdDataGrid_Click()
Text1.Text = grdDataGrid.Columns(0)
Text2.Text = grdDataGrid.Columns(1)
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -