===============================

目录:

1、添加工具栏按钮

2、查询被添加工具栏按钮的业务单据的FMenuID和FID

3、添加工具栏按钮和业务单据的映射关系

4、工具栏按钮点击激发事件MainFunction

5、工具栏按钮点击激发事件DLL注册

6、测试结果

7、附转载源码

===============================

本例以销售订单为例,已实际测试可行!

1、添加工具栏按钮

insert into t_MenuToolBar
( FToolID,FName,FCaption,FCaption_CHT,FCaption_EN,
FImageName,FToolTip,FToolTip_CHT,FToolTip_EN,FControlType,
FVisible,FEnable,FChecked,FShortCut,FCBList,
FCBList_CHT,FCBList_EN,FCBStyle,FCBWidth,FIndex,
FToolCaption,FToolCaption_CHT,FToolCaption_EN)
values
(99999,'NewMenuTest','测试按钮1','测试按钮','测试按钮',
'','测试按钮','测试按钮','测试按钮',0,
1,1,0,0,'',
'','',0,0,0,
'测试按钮','测试按钮','测试按钮')

2、查询被添加工具栏按钮的业务单据的FMenuID和FID

--查询被添加工具栏按钮的业务单据的FmenuID和FID,分别是100,32
select FID,FmenuID,* from iclisttemplate where Fname LIKE '%销售订单%'

3、添加工具栏按钮和业务单据的映射关系

--t_BandToolMapping.FID 对应 iclisttemplate.FMenuID,
--t_BandToolMapping.FToolID 对应 t_MenuToolBar.FToolID
--t_BandToolMapping.FComName 是按钮激发组件DLL中命名空间.类名
insert into t_BandToolMapping
(FID,FBandID,FToolID,FSubBandID,FIndex,
FComName,FBeginGroup)
values
(100,48,99999,0,999,
'|BOS_BillEvent_PlugIns.Class3',0)

4、工具栏按钮点击激发事件MainFunction

MainFunction(ByVal sKey As string,oList AsObject,Byref bCancel as Boolean)
sKey :     菜单的Key值,也就是菜单名
oList :     K3List控件
bCancel:是否取消后继操作标志

九、K3 WISE 开发插件《工业单据老单序时薄插件工具栏按钮开发实例》-LMLPHP

代码如下:

Public Function MainFunction(ByVal sKey As String, oList As Object, ByRef bCancel As Boolean)

'Set InBatch = New InBatch  显示窗体
MsgBox ""
Dim vectBill As KFO.Vector --经实际测试K3Connection.AppConnection取不到变量。请使用SQLHelper去连接数据库,代码和使用方法在第一篇插件新手指导里
Set OBJ = CreateObject("K3Connection.AppConnection") '老单据里的连接字串
'菜单响应
Select Case sKey
Case "NewMenuTest" '和你在数据库里插入的FNAME一样
'通过Set vectBill = oList.GetSelected 可以获取当前选中序时薄数据 '返回记录集方式
'Set rs = obj.Execute("select * from t_icitem") '执行存储过程方式
' obj.Execute3 ("exec KY_PlanQty") End Select
End Function

5、工具栏按钮点击激发事件DLL注册

新建批处理文件:注册.bat

文本内容:regsvr32 "BOS_BillEvent_PlugIns.dll"

双击注册.bat,进行DLL注册

6、测试结果

九、K3 WISE 开发插件《工业单据老单序时薄插件工具栏按钮开发实例》-LMLPHP

7、附转载源码

Public Function MainFunction(ByVal sKey As String, oList As Object, ByRef bCancel As Boolean)
Dim vectBill As KFO.Vector
Dim lmul As Long
Dim rs As ADODB.Recordset
Dim InBatch As Form
Dim J
Dim I
Dim Dict As KFO.Dictionary
Dim DictCheck As KFO.Dictionary
Dim fiterid As Integer
Dim fbillno As String
Dim sqlUpdate As String
Dim sqlSelect As String
Dim strList As String 'Set InBatch = New InBatch 显示窗体
Set OBJ = CreateObject("K3Connection.AppConnection") '老单据里的连接字串 Select Case sKey1
Case "PlanUpdate"
'Set vectBill = New KFO.Vector
: Set vectBill = oList.GetSelData("FInterID")
If vectBill.UBound > Then
frmUpdate.Show
If frmUpdate.dtUpdate = "白班" Then
For I = vectBill.LBound To vectBill.UBound '辅助资料内码 40025=白班
Set DictCheck = vectBill(I)
sqlUpdate = "Update ICMO set FHeadSelfJ0176 =40025 where finterid = " & DictCheck.GetValue("FInterID"))
OBJ.Execute3 (sqlUpdate))
Next I
SendKeys ("{F5}")
MsgBox "生产任务单班别更新成功", vbOKOnly, "金蝶提示"
End If
If frmUpdate.dtUpdate = "夜班" Then
For I = vectBill.LBound To vectBill.UBound '辅助资料内码 40026=夜班
Set DictCheck = vectBill(I)
sqlUpdate = "Update ICMO set FHeadSelfJ0176 =40026 where finterid = " & DictCheck.GetValue("FInterID")
OBJ.Execute3 (sqlUpdate) `
Next I
SendKeys ("{F5}")
MsgBox "生产任务单班别更新成功", vbOKOnly, "金蝶提示"
End If
End If
Case "PlanUpdate2"
Set vectBill = oList.GetSelData("FInterID")
If vectBill.UBound > Then
strList = ""
For I = vectBill.LBound To vectBill.UBound '辅助资料内码 40025=白班
Set DictCheck = vectBill(I)
strList = strList & DictCheck.GetValue("FInterID") & ","
Next I
strList = Left(strList, Len(Trim(strList)) - )
sqlSelect = "select t2.FNumber,t2.FName,sum(t1.FQty) from ICMO t1 inner join t_icitem t2 on t1.FItemID=t2.FItemID where t1.FInterID in (" & strList & ") group by t2.FNumber,t2.FName"
Set rs = OBJ.Execute(sqlSelect)
End Function
--在采购订单序时簿上添加工具栏按钮
INSERT INTO t_BandToolMapping
(FID,FBandID,FToolID,FSubBandID,FIndex,FComName,FBeginGroup)
VALUES
(81,47,1001,0,1001,'&mnuFileUserAdd1',1)
INSERT INTO t_MenuToolBar
(FToolID,FName,FCaption,FCaption_CHT,FCaption_EN,FImageName,FToolTip,FToolTip_CHT,FToolTip_EN,FControlType,
FVisible,FEnable,FChecked,FShortCut,FShortChar,FCBList,FCBList_CHT,FCBList_EN,FCBStyle,FCBWidth,
FIndex,FToolCaption,FToolCaption_CHT,FToolCaption_EN )
VALUES
(1001,'UserAdd1','自定义1','自定义1','自定义1',17,'由用户自定义的按钮','由用户自定义的按钮','由用户自定义的按钮',0,
1,1,0,0,'','','','',0,0,0,'自定义1','自定义1','自定义1')
05-08 08:42