文档库 最新最全的文档下载
当前位置:文档库 › 工业单据的单据或序时薄界面增加自定义菜单按钮 (1)

工业单据的单据或序时薄界面增加自定义菜单按钮 (1)

'单据界面添加自定义按钮并在单击时弹出提示框的示例代码:
'单据初始化时添加自定义按钮
Private Sub m_BillTransfer_BillInitialize()
'Dim aryShortCuts(0) As New ActiveBar3LibraryCtl.ShortCut

'aryShortCuts(0).Value = "Control+D" '定义自定义按钮的快捷键
m_BillTransfer.AddUserMenuItem "用户自定义按钮", "自定义菜单"
'm_BillTransfer.BillForm.ABar.Bands("mnuUserDef").Tools(1).ShortCuts = aryShortCuts
'Erase aryShortCuts

End Sub

'捕获自定义按钮的单击事件
Private Sub m_BillTransfer_UserMenuClick(ByVal Index As Long, ByVal Caption As String)

If Caption = "用户自定义按钮" Then
MsgBox "单据自定义按钮单击调用成功!"
End If

End Sub

'序时簿界面添加自定义按钮并在单击按钮时弹出提示框的示例代码:
'用VB创建一个ACTIVEX DLL类型的工程,比如工程名命名为:K3OldListPlugs,对应的插件类名命名为:clsList
'然后在插件类(clsList)中输入以下代码即添加自定义按钮及对应的单击事件处理:
Public Sub IniMenu(ByVal BarList As Object, ByVal dct As KFO.Dictionary)
Dim oTool As Object
Dim oTools As Object
Dim oToolItem As Object
Dim ToolIndex As Long

Set oTool = BarList.Bands(BarList.Tools("Edit").SubBand).Tools.Add(200001, "mnuListSelfDefineBtn") '200001为按钮ID,如果出现重复,换一个ID即可
Set oTools = BarList.Bands(BarList.Tools("Edit").SubBand).Tools
ToolIndex = oTools.Count
With oTool
.Caption = "序时薄自定义按钮"
.Description = "序时薄自定义按钮"
.ToolTipText = "序时薄自定义按钮"
.Visible = True '设置为可见
oTools.Insert ToolIndex, oTool '插入到"编辑"子菜单下最后
End With
Set oTools = Nothing
'插入"序时薄自定义按钮"到工具栏
For Each oBand In BarList.Bands
If oBand.Type = ddBTNormal Then '找到工具栏
Set oTools = oBand.Tools
Exit For
End If
Next

If Not oTools Is Nothing Then '找到了工具栏
For i = 0 To oTools.Count
Set oToolItem = oTools(i)
If (UCase(https://www.wendangku.net/doc/5d6080728.html,) = UCase("BillCheck")) Then '找到要插入的哪个按钮后面,例如插入到审核按钮后面
With oTool
.Alignment = oToolItem.Alignment
.CaptionPosition = oToolItem.CaptionPosition
.Style = oToolItem.Style
.Caption = "序时薄自定义按钮"
oTools.Insert i + 1, oTool
End With
Exit For
End If
Next
End If
Set oTool = Nothing
Set oToolItem = Nothing
Set oTools = Nothing
End Sub

'------------------------序时薄按钮单击事件的处理-------------------------------
'@sToolName

点击的菜单按钮Name
'@oList 当前序时薄控件对象
'@dct 当前序时薄所选单据的数据包
'@bIsCancel 是否取消菜单按钮的单击事件
'-------------------------------------------------------------------------------
Public Sub MainFunction(ByVal sToolName As String, _
ByVal oList As Object, _
ByVal dct As KFO.Dictionary, _
ByRef bIsCancel As Boolean)
If sToolName = "mnuListSelfDefineBtn" Then '捕获序时薄自定义按钮的单击事件
MsgBox "序时薄自定义按钮单击调用成功!"
End If
End Sub

另外在插件代码编写完成及编译成DLL组件后,需要挂接到对应的老单序时薄上去
挂接时需要根据【工程名.类名】去更新后台数据库对应序时薄的模板,SQL脚本如下,请参考:

--先根据序时薄的名称,查询出对应的序时薄模板ID,例如查询出采购订单的序时模板ID为:26
--后面的SQL语句需要根据这个FID(26)作为WHERE条件
SELECT FID,* FROM ICListTemplate where FName LIKE '采购订单'
DECLARE @FComponentExt AS VARCHAR(100)
SELECT @FComponentExt=FComponentExt FROM ICListTemplate WHERE FID=26
--此例中的【工程名.类名】为:K3OldListPlugs.clsList 具体根据你的命名更改即可
IF CHARINDEX('K3OldListPlugs.clsList', @FComponentExt) = 0
BEGIN
IF LEN(@FComponentExt)>0
SET @FComponentExt=@FComponentExt+';K3OldListPlugs.clsList'
ELSE
SET @FComponentExt=';K3OldListPlugs.clsList'
UPDATE ICListTemplate SET FComponentExt=@FComponentExt WHERE FID=26
END
GO
--其他单据类型的序时薄亦可参照此方法执行

相关文档