📄 frmdepartmentlistcard.frm
字号:
VERSION 5.00
Object = "{F42BDC2B-FC9B-11D1-9ABD-444553540000}#3.2#0"; "ATLEDIT.OCX"
Begin VB.Form frmDepartmentListCard
BorderStyle = 1 'Fixed Single
Caption = "新增部门"
ClientHeight = 2400
ClientLeft = 1680
ClientTop = 1950
ClientWidth = 5970
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MDIChild = -1 'True
ScaleHeight = 2400
ScaleWidth = 5970
Begin AtlEdit.TEdit txtDepartment
Height = 315
Index = 0
Left = 1530
TabIndex = 1
Top = 510
Width = 2475
_ExtentX = 4366
_ExtentY = 556
maxchar = 16
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Text = ""
End
Begin VB.CommandButton cmdOk
Cancel = -1 'True
Height = 350
Index = 1
Left = 4530
Style = 1 'Graphical
TabIndex = 6
Tag = "1002"
Top = 540
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CommandButton cmdOk
Default = -1 'True
Height = 350
Index = 0
Left = 4530
Style = 1 'Graphical
TabIndex = 5
Tag = "1001"
Top = 150
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CommandButton cmdOk
Height = 350
Index = 2
Left = 4530
Style = 1 'Graphical
TabIndex = 7
Tag = "1009"
Top = 950
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CommandButton cmdOk
Height = 350
Index = 3
Left = 4530
Style = 1 'Graphical
TabIndex = 8
Tag = "1013"
Top = 1350
UseMaskColor = -1 'True
Width = 1215
End
Begin VB.CheckBox chkStop
Caption = "停用"
Height = 225
Left = 4560
TabIndex = 4
Top = 1800
Width = 1215
End
Begin AtlEdit.TEdit txtDepartment
Height = 315
Index = 1
Left = 1530
TabIndex = 3
Top = 1200
Width = 2475
_ExtentX = 4366
_ExtentY = 556
maxchar = 30
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Text = ""
End
Begin VB.Label lblNote
Caption = "部门编号(&C)"
Height = 195
Index = 0
Left = 360
TabIndex = 0
Top = 540
Width = 1035
End
Begin VB.Label lblNote
Caption = "部门名称(&N)"
Height = 195
Index = 1
Left = 360
TabIndex = 2
Top = 1230
Width = 1035
End
End
Attribute VB_Name = "frmDepartmentListCard"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'功能: 完成部门的增、删、改。
'卡片接口: EditCard 参数: lngID 记录的ID号
'作用: LNGID为零是增加记录、其它为编辑记录
' DelCard 参数: lngID 记录的ID号
'作用: 删除ID号为LNGID的记录
'作者: 苏涛
Option Explicit
Option Compare Text
Private mblnIsInit As Boolean
Private mblnIsChanged As Boolean
Private mblnIsDetail As Boolean
Private mblnIsNew As Boolean
Private mblnIsInActive As Boolean
Private mblnPIsInActive As Boolean 'NEW--上级停用,EDIT--目的停用
Private mblnPIsDetail As Boolean 'NEW--上级明细,EDIT--目的明细
Private mintLevel As Integer
Private mintOldLevel As Integer
Private mlngPCodeID As Long 'NEW--上级ID,EDIT--目的ID
Private mlngDepartmentID As Long '当前部门ID
Private mstrNotes As String
Private mstrLastCode As String
Private mstrCode As String
Private mstrName As String
Private mstrLastName As String
Private mstrFullName As String
Private mstrOldFullName As String
Private mstrStartDate As String
Private WithEvents mclsMainControl As MainControl '主控对象
Attribute mclsMainControl.VB_VarHelpID = -1
Public Property Get getID() As Variant
getID = mlngDepartmentID
End Property
Public Function AddCard(Optional strName As String = "", Optional intModal As Integer = 0) As Long
If IsContinue Then Exit Function
mlngDepartmentID = 0
mblnIsChanged = True
mblnIsNew = True
InitCard strName
Caption = "新增部门"
cmdOk(2).Default = True
Show intModal
AddCard = mlngDepartmentID
Refresh
ZOrder 0
Unload MsgForm
End Function
Public Sub EditCard(ByVal lngID As Long, Optional intModal As Integer = 0, _
Optional strDepartment As String)
Dim strMess As String
If IsContinue Then Exit Sub
If Not CheckIDUsed("Department", "lngDepartmentID", lngID) Then
If Trim(strDepartment) <> "" Then
strMess = "“" & strDepartment & "”"
Else
strMess = "该"
End If
ShowMsg 0, strMess & "部门不存在,不能进行修改!", _
vbExclamation + MB_TASKMODAL, "修改部门"
Unload Me
Else
mlngDepartmentID = lngID
mblnIsNew = False
mblnIsChanged = False
InitCard
Caption = "修改部门"
cmdOk(0).Default = True
cmdOk(2).Visible = False
cmdOk(3).Move cmdOk(2).Left, cmdOk(2).top
Show intModal
Refresh
ZOrder 0
End If
Unload MsgForm
End Sub
Private Sub chkStop_Click()
' Dim strDep As String
'
' strDep = txtDepartment(0).Text & " " & txtDepartment(1).Text
' If chkStop.Value = Checked And Not mblnIsNew Then
' If CodeIsUsed(mlngDepartmentID) Then
' ShowMsg hwnd, strDep & "部门已有业务发生,不能停用!", vbExclamation, Caption
' chkStop.Value = Unchecked
' End If
' End If
If Not mblnIsInit Then mblnIsChanged = True
End Sub
Private Sub cmdOK_Click(Index As Integer)
Dim strNextCode As String
If Index = 0 Then
If Not SaveCard Then Exit Sub
ElseIf Index = 2 Then
If SaveCard Then
strNextCode = GetNextCode(txtDepartment(0).Text)
' mlngDepartmentID = 0
InitCard
txtDepartment(0).Text = strNextCode
txtDepartment(0).SetFocus
txtDepartment(0).SelStart = 0
txtDepartment(0).SelLength = Len(txtDepartment(0).Text)
End If
Exit Sub
ElseIf Index = 3 Then
mstrNotes = frmNotePad.EditCard(Me.Caption, txtDepartment(0).Text, _
txtDepartment(1).Text, mstrNotes) '调记事
Exit Sub
End If
Unload Me
End Sub
Public Function DelCard(ByVal lngID As Long) As Boolean
Dim recDep As rdoResultset, Strsql As String
Dim strDep As String, strCode As String
If lngID = mlngDepartmentID And frmEmployeeList.IsShowCard(0) Then
ShowMsg 0, "不能删除正在修改的部门!", vbExclamation + MB_TASKMODAL, "删除部门"
Show
Exit Function
End If
On Error GoTo ErrHandle
gclsBase.BaseWorkSpace.BeginTrans
DelCard = False
If lngID = 0 Then Exit Function
Strsql = "SELECT * FROM Department WHERE lngDepartmentID=" & lngID
Set recDep = gclsBase.BaseDB.OpenResultset(Strsql, rdOpenForwardOnly)
If Not recDep.EOF = True Then
strCode = recDep!strDepartmentCode
strDep = "“" & Trim(recDep!strDepartmentCode) & " " _
& Trim(recDep!strDepartmentName) & "”"
If recDep!blnIsDetail = 0 Then
ShowMsg 0, strDep & "有下级部门,不能删除!", vbExclamation + MB_TASKMODAL, "删除部门"
GoTo ErrHandle
End If
Else
DelCard = True
GoTo ErrHandle
End If
If frmDepartmentCard.CodeIsUsed(lngID) Then
ShowMsg 0, strDep & "部门已有业务发生,不能删除!", vbExclamation + MB_TASKMODAL, "删除部门"
GoTo ErrHandle
End If
If ShowMsg(0, "你确实要删除" & strDep & "部门吗?", vbQuestion + vbYesNo + MB_TASKMODAL, _
"删除部门") = vbNo Then GoTo ErrHandle
Strsql = "DELETE FROM Department WHERE lngDepartmentID=" & lngID
If Not gclsBase.ExecSQL(Strsql) Then GoTo ErrHandle
If Not ChangeHigherCardDetail("Department", "strDepartmentCode", strCode) Then GoTo ErrHandle
gclsBase.BaseWorkSpace.CommitTrans
DelCard = True
' gclsSys.SendMessage CStr(Me.hwnd), Message.msgDepartment
Exit Function
ErrHandle:
gclsBase.BaseWorkSpace.RollbackTrans
End Function
Private Sub Form_Activate()
gclsSys.CurrFormName = Me.hwnd
End Sub
Private Sub Form_Load()
Me.Hide
Me.Left = -30000
MsgForm.PleaseWait
SetHelpID hwnd, 30009
frmEmployeeList.IsShowCard(0) = True
mblnIsChanged = False
Set mclsMainControl = gclsSys.MainControls.Add(Me)
End Sub
Private Sub Form_Paint()
FrameBox Me.hwnd, 180, 180, 4335, 2000
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Dim intMsgReturn As Integer, strMess As String
If UnloadMode <> vbFormControlMenu Then Exit Sub
If Trim(txtDepartment(0).Text & txtDepartment(1).Text) = "" Then Exit Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -