📄 frmsystemoperator.frm
字号:
VERSION 5.00
Object = "{4932CEF1-2CAA-11D2-A165-0060081C43D9}#2.0#0"; "Actbar2.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form frmSystemOperator
Caption = "操作员维护"
ClientHeight = 8940
ClientLeft = 60
ClientTop = 450
ClientWidth = 15180
Icon = "frmSystemOperator.frx":0000
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 8940
ScaleWidth = 15180
Begin ActiveBar2LibraryCtl.ActiveBar2 ActiveBar21
Height = 8940
Left = 0
TabIndex = 0
Top = 0
Width = 15180
_LayoutVersion = 1
_ExtentX = 26776
_ExtentY = 15769
_DataPath = ""
Bands = "frmSystemOperator.frx":0CFA
Begin VB.Frame Frame1
BeginProperty Font
Name = "宋体"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 8415
Left = 60
TabIndex = 1
Top = 420
Width = 15015
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MSHF1
Height = 8055
Left = 120
TabIndex = 2
Top = 240
Width = 14775
_ExtentX = 26061
_ExtentY = 14208
_Version = 393216
AllowUserResizing= 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_NumberOfBands = 1
_Band(0).Cols = 2
End
End
End
End
Attribute VB_Name = "frmSystemOperator"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim lngRow As Integer
Private Sub ActiveBar21_ToolClick(ByVal Tool As ActiveBar2LibraryCtl.Tool)
Select Case Tool.Name
Case "cmdAdd":
NewOperatorInf
Case "cmdEdit":
EditOperatorInf
Case "cmdDel":
DelOperatorInf
Case "cmdCancel":
Unload Me
End Select
End Sub
Private Sub Form_Load()
'设置窗口大小
FormInit Me, True
SetObjectWH Frame1
SetObjectWH MSHF1
ReadOperatorInf
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
'begin 滚轮
HookWheel Me.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnHookWheel Me.hwnd
End Sub
Private Sub MSHF1_GotFocus()
Set CtlWheel = MSHF1
End Sub
Private Sub MSHF1_LostFocus()
Set CtlWheel = Nothing
End Sub
'end 滚轮
'读入操作信息
Public Sub ReadOperatorInf()
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
Dim rs As ADODB.Recordset
SystemExecuteStart Me
'On Error GoTo errlabel
Set rs = New ADODB.Recordset
With rs
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
Set .ActiveConnection = cn
End With
Dim strSql As String
strSql = "select * from toperatorinfo order by company,dept asc"
rs.Open strSql
With frmSystemOperator.MSHF1
.Redraw = False
.Rows = 2
.Cols = 14
.Clear
'初始化
.WordWrap = False
.TextMatrix(0, 0) = "序号"
.ColWidth(0) = 800
.TextMatrix(0, 1) = "操作员编号"
.ColWidth(1) = 1200
.TextMatrix(0, 2) = "操作员姓名"
.ColWidth(2) = 1200
.TextMatrix(0, 3) = "所属公司"
.ColWidth(3) = 1500
.TextMatrix(0, 4) = "部门"
.ColWidth(4) = 1500
.TextMatrix(0, 5) = "是经营人员"
.ColWidth(5) = 1000
.TextMatrix(0, 6) = "职务"
.ColWidth(6) = 1200
.TextMatrix(0, 7) = "入职时间"
.ColWidth(7) = 1000
.TextMatrix(0, 8) = "是否离职"
.ColWidth(8) = 800
.TextMatrix(0, 9) = "离职时间"
.ColWidth(9) = 1000
.TextMatrix(0, 10) = "禁止登录"
.ColWidth(10) = 1000
.TextMatrix(0, 11) = "创建人"
.ColWidth(11) = 1200
.TextMatrix(0, 12) = "创建时间"
.ColWidth(12) = 1800
.TextMatrix(0, 13) = "ID"
.ColWidth(13) = 0
'.....................................................
.Rows = rs.RecordCount + 2
'On Error Resume Next
Dim i As Integer
For lngRow = 2 To rs.RecordCount + 1
.TextMatrix(lngRow, 0) = lngRow - 1
.TextMatrix(lngRow, 1) = NullValue(rs.Fields!OperatorNo)
.TextMatrix(lngRow, 2) = NullValue(rs.Fields!Operator)
.TextMatrix(lngRow, 3) = NullValue(rs.Fields!Company)
.TextMatrix(lngRow, 4) = NullValue(rs.Fields!Dept)
.TextMatrix(lngRow, 5) = IIf(NullValue(rs.Fields!IsOperation) = 0, "否", "是")
.TextMatrix(lngRow, 6) = NullValue(rs.Fields!Duty)
.TextMatrix(lngRow, 7) = NullValue(rs.Fields!JoinDate)
'.TextMatrix(lngRow, 7) = IIf(rs.Fields!Role = 0, "否", "是")
If NullValue(rs.Fields!IsEnd) = True Then
'离职
.TextMatrix(lngRow, 8) = "是"
.TextMatrix(lngRow, 9) = NullValue(rs.Fields!EndDate)
Else
.TextMatrix(lngRow, 8) = "否"
End If
.TextMatrix(lngRow, 10) = IIf(rs.Fields!Role = 0, "否", "是")
.TextMatrix(lngRow, 11) = NullValue(rs.Fields!CreateOperator)
.TextMatrix(lngRow, 12) = NullValue(rs.Fields!CreateDate)
.TextMatrix(lngRow, 13) = NullValue(rs.Fields!ID)
.row = lngRow
For i = 1 To .Cols - 1
.col = i
If rs.Fields!IsEnd Then '离职
.CellForeColor = vbBlue '&HC0&
ElseIf rs.Fields!Role Then '禁登陆
.CellForeColor = vbRed '&HC0&
Else
.CellForeColor = &H80000008
End If
Next
rs.MoveNext
Next
lngRow = 0
.TextMatrix(1, 0) = "总计"
.TextMatrix(1, 1) = .Rows - 2
SetItemBackColor MSHF1
.Redraw = True
End With
rs.Close
Set rs = Nothing
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
remClear:
Set rs = Nothing
SystemExecuteEnd Me
Exit Sub
errLabel:
On Error Resume Next
frmSystemOperator.MSHF1.Redraw = True
GoTo remClear
End Sub
'增加操作员
Private Sub NewOperatorInf()
frmSystemOperatorInf.newItem = True
frmSystemOperatorInf.InitInfo ""
frmSystemOperatorInf.Show vbModal
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
End Sub
'编辑操作员
Private Sub EditOperatorInf()
frmSystemOperatorInf.newItem = False
frmSystemOperatorInf.InitInfo MSHF1.TextMatrix(lngRow, 1)
frmSystemOperatorInf.Show vbModal
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
End Sub
'删除操作员
Private Sub DelOperatorInf()
Dim strSql As String
If lngRow > MSHF1.Rows - 1 Then Exit Sub
If lngRow <= 1 Then
MsgBox "请选中一条要删除的记录!", vbExclamation, "提示"
Exit Sub
End If
On Error GoTo errHandle
If MsgBox("确定要刪除?", vbQuestion + vbYesNo, "询问") = vbNo Then
Exit Sub
Else
strSql = "delete from tOperatorInfo where OperatorNo=" & objDatabase.FormatSQL(MSHF1.TextMatrix(lngRow, 1))
objDatabase.ExecCmd strSql
MsgBox "刪除成功!", vbInformation, "提示"
End If
ReadOperatorInf
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = False
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = False
Exit Sub
errHandle:
objDatabase.DatabaseError
End Sub
Private Sub MSHF1_Click()
lngRow = Val(MSHF1.row)
If lngRow = 1 Then
MSHF1.Sort = 1
Else
MSHF1.row = lngRow
MSHF1.col = 0
MSHF1.ColSel = MSHF1.Cols - 1
ActiveBar21.Bands("toolbar").Tools.item("cmdDel").Enabled = True
ActiveBar21.Bands("toolbar").Tools.item("cmdEdit").Enabled = True
End If
End Sub
Private Sub MSHF1_DblClick()
EditOperatorInf
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -