K/3 Wise 插件开发和配置

栏目:k3wise知识作者:金蝶来源:金蝶云社区发布:2024-09-16浏览:1

K/3 Wise 插件开发和配置

开发环境:K/3 Wise 13.0、K/3 Bos开发平台、Visual Basic 6.0目录一、二次开发插件编程
二、代码演示
三、配置插件
四、测试插件
五、插件事件附录
一、二次开发插件编程  打开Visual Basic 6.0,新建工程ActiveX DLL:  

  命名为FirstPlugin.class:  

  引用类库如下:  

  已安装K/3 Wise,在VB 6.0菜单栏上会多出一个金蝶开发插件:  

  打开金蝶开发向导,创建工业单据客户端插件(工业单据俗称“老单”):  

  点击“确定”,选择类“FirstPlugin”:  

  点击“下一步”,这里我们自定义一个菜单项“插件工具”:  

  点击“下一步”,选择事件“UserMenuClick”:  

  完成向导。二、代码演示  代码编写如下:
'配置路径:供应链-外购入库单'函数功能:插件工具--根据“长、宽、厚”自动计算批号'定义插件对象接口. 必须具有的声明, 以此来获得事件Private WithEvents m_BillTransfer As K3BillTransfer.BillDim F55 As Long, F55Text As String 'Dim F56 As Long, F56Text As String 'Dim F57 As Long, F57Text As String 'Dim FDate As Long, FDateText As String '日期Dim FBatchNo As String '批号Dim FItemID As Long, FNumber As String '物料编码Dim FBatchManager As Boolean '是否采用业务批号管理Dim str As StringPublic Sub Show(ByVal oBillTransfer As Object) '接口实现 '注意: 此方法必须存在, 请勿修改 Set m_BillTransfer = oBillTransfer End SubPrivate Sub Class_Terminate() '释放接口对象 '注意: 此方法必须存在, 请勿修改 Set m_BillTransfer = NothingEnd SubPrivate Sub m_BillTransfer_BillInitialize() '*************** 开始设置菜单 *************** m_BillTransfer.AddUserMenuItem "自动批号", "插件工具" '*************** 结束设置菜单 *************** 'TODO: 请在此处添加代码响应事件 BillInitialize F55 = GetCtlIndexByFld("FEntrySelfA0155", True) F56 = GetCtlIndexByFld("FEntrySelfA0156", True) F57 = GetCtlIndexByFld("FEntrySelfA0157", True) FBatchNo = GetCtlIndexByFld("FBatchNo", True) FDate = GetCtlIndexByFld("FDate", False) FItemID = GetCtlIndexByFld("FItemID", True)
End SubPrivate Sub m_BillTransfer_UserMenuClick(ByVal Index As Long, ByVal Caption As String) 'TODO: 请在此处添加代码响应事件 UserMenuClick Select Case Caption Case "自动批号" '此处添加处理 批号生成 菜单对象的 Click 事件 With m_BillTransfer For i = 1 To 1000 If .GetGridText(i, FItemID) = "" Then Exit For End If '从物料表检测 是否采用业务批次管理 Dim strSQL As String '用于执行SQL Dim rs As ADODB.Recordset FNumber = "" FNumber = .GetGridText(i, FItemID) strSQL = "" strSQL = "SELECT FBatchManager FROM t_ICItem WHERE FNumber='" & FNumber & "'" Set rs = SQLHelper.ExecuteSQL(strSQL, "") If rs.EOF = False Then FBatchManager = rs.Fields("FBatchManager") End If Set rs = Nothing F55Text = .GetGridText(i, F55) F56Text = .GetGridText(i, F56) F57Text = .GetGridText(i, F57) If F55Text = "" Then F55Text = "0" If F56Text = "" Then F56Text = "0" If F57Text = "" Then F57Text = "0" FDateText = Replace(.GetHeadText(FDate), "-", "") If (FBatchManager = True) Then .SetGridText i, FBatchNo, F55Text & "-" & F56Text & "-" & F57Text & "-" & FDateText End If Next End With Case Else End SelectEnd Sub'*****************************************'获取分录行数'*****************************************Public Function GetEntryMax() As LongDim k As LongDim iFItemID As LongDim oEntryCtl As VariantDim maxrow As Long '最大行'For k = LBound(m_BillTransfer.EntryCtl) To UBound(m_BillTransfer.EntryCtl) If UCase(m_BillTransfer.EntryCtl(k).FieldName) = UCase("FItemID") Then '物料代码所在列 iFItemID = k Exit For End IfNext koEntryCtl = m_BillTransfer.EntryCtlmaxrow = UBound(oEntryCtl(iFItemID).DInterID) '获取表体最大行GetEntryMax = maxrowEnd Function'**********************************'返回单据字段顺序(isEntry True是表体)'**********************************Public Function GetCtlIndexByFld(ByVal fldName As String, Optional ByVal isEntry As Boolean = False) As LongDim ctlIdx As LongDim i As IntegerDim isFind As BooleanDim vValue As VariantfldName = UCase(fldName)isFind = FalseWith m_BillTransferIf isEntry Then For i = LBound(.EntryCtl) To UBound(.EntryCtl) If UCase(.EntryCtl(i).FieldName) = fldName Then ctlIdx = .EntryCtl(i).FCtlOrder isFind = True Exit For End If Next iElse For i = LBound(.HeadCtl) To UBound(.HeadCtl) If UCase(.HeadCtl(i).FieldName) = fldName Then ctlIdx = .HeadCtl(i).FCtlIndex isFind = True Exit For End If Next iEnd IfEnd WithIf isFind = True ThenGetCtlIndexByFld = ctlIdxElseGetCtlIndexByFld = 0End IfEnd Function

' target='_blank'>



三、配置插件  在Visual Basic 6.0生成DLL:  

  启动K/3 Wise BOS开发平台,打开外购入库单,并进行插件配置:  

  点击“插件配置管理”,配置客户端插件:  

  点击“浏览”,找到插件并勾选:  

  点击“确定”,并保存外购入库单。四、测试插件  启动K/3 Wise,打开“供应链-仓存管理-外购入库单-新增”:  

  
  至此,插件开发和配置完成!五、插件配置后未生效 1.在插件配置管理提示“没有找到文件,或文件没有正确注册” 解决方法:插件dll名称命名要和工程名称一致。 比如工程名称“aaaa”,其中有一个类“bbb”,dll命名为“aaa”, 配置插件后,显示完整名称“aaa.bbb”,提示aaaa“没有找到文件,或文件没有正确注册”。 修改dll名称“aaa”为“aaaa”,重新配置插件,即可修复问题。六、插件事件附录  附上K/3 Wise 工业单据开发事件说明:
[tr][td] 序号[td]事 件  [td] 函 数[td] 描 述
[tr][td] 1[td] BillTerminate[td] Public Event BillTerminate()[td]单据卸载完成时激发该事件
[tr][td] 2[td] UserMenuClick[td] Public Event UserMenuClick(ByVal Index As Long, ByVal Caption As String)[td]当点击用户自定义的菜单时激发这个事件。参数:Index:表示第几个菜单、由添加菜单的先后顺序决定,Caption:菜单项的标题
[tr][td] 3[td] LeveCell[td] Public Event LeveCell(ByVal Col As Long, ByVal Row As Long, ByVal NewCol As Long, ByVal NewRow As Long, Cancel As Boolean)[td]当离开分录的一个单元格的时候激发这个事件参数:Col 分录的要离开列Row分录的要离开行NewCol 新的列NewRow新的行Cancel是否取消
[tr][td] 4[td] HeadChange[td] Public Event HeadChange(ByVal CtlIndex As Long, ByVal Value As Variant, ByVal bNewBill As Boolean, Cancel As Boolean)[td]当表头的一个项目改变时激发这个事件参数:ctlIndex 表头字段索引Value 当前值bNewBill是否是新增单据Cancel是否取消
[tr][td] 5[td] GridChange[td] Public Event GridChange(ByVal Col As Long, ByVal Row As Long, ByVal Value As Variant, ByVal bNewBill As Boolean, Cancel As Boolean)[td]当表体的一个项目改变时激发这个事件参数:Col 分录的当前列Row分录的当前行Value 当前值bNewBill是否是新增单据Cancel是否取消
[tr][td] 6[td] BeforGridLookUp[td] Public Event BeforGridLookUp(ByVal Row As Long, ByVal Col As Long, ByVal nLookUpClsID As Long, Cancel As Boolean)[td]在分录执行查找功能之前激发这个事件参数:Col 分录的当前列Row分录的当前行nLookUpClsID 当前查询的资料类型,Cancel是否取消
[tr][td] 7[td] EndGridLookUp[td] Public Event EndGridLookUp(ByVal Row As Long, ByVal Col As Long, ByVal nLookUpClsID As Long)[td]在分录完成查找功能之后激发这个事件参数:Col 分录的当前列Row分录的当前行nLookUpClsID 当前查询的资料类型
[tr][td] 8[td] BeforHeadLookUp[td] Public Event BeforHeadLookUp(ByVal CtlIndex As Long, ByVal nLookUpClsID As Long, Cancel As Boolean)[td]在表头的一个项目执行查找功能之前激发这个事件参数:ctlIndex表头字段索引nLookUpClsID 当前查询的资料类型Cancel是否取消
[tr][td] 9[td] EndHeadLookUp[td] Public Event EndHeadLookUp(ByVal CtlIndex As Long, ByVal nLookUpClsID As Long)[td]在表头的一个项目完成查找功能之后激发这个事件,参数:ctlIndex表头字段索引nLookUpClsID 当前查询的资料类型
[tr][td] 10[td] BeforeSave[td] Public Event BeforeSave(ByVal bNew As Boolean, ByRef ReturnCode As Long)[td]在单据执行保存功能的时候激发这个事件参数:bNew 表示是否是新增单据ReturnCode 返回参数 -1: 失败,结束单据保存;0:成功,继续单据保存1:成功返回,结束单据保存
[tr][td] 11[td] EndSave[td] Public Event EndSave(ByVal BillNo As String)[td]在单据执行完成保存功能的时候激发这个事件参数:BillNo表示单据的编号
[tr][td] 12[td] LoadBillEnd[td] Public Event LoadBillEnd(ByVal ShowType As Long)[td]在单据装载完成的时候激发这个事件参数:ShowType 单据显示状态 0.新增 1.修改 2.查看 3.审核
[tr][td] 13[td] NewBillEnd[td] Public Event NewBillEnd()[td] 在单据新增完成的时候激发这个事件
[tr][td] 14[td] SetMenuBarCtlPropEnd[td]Public Event SetMenuBarCtlPropEnd(ByVal ShowType As Long, ByVal BillChecked As Boolean)
[td]在单据设置菜单、工具条各属性完成的时候激发这个事件参数:ShowType 单据显示状态 0.新增 1.修改 2.查看 3.审核BillChecked 单据是否已被审核
[tr][td] 15[td] BeforeFillBillData[td] Public Event BeforeFillBillData(ByVal BillTransType As Long, ByVal BillInterID As Long)[td]在装载某张单据之前激发这个事件参数:BillTransType 单据事务类型BillInterID单据内码
[tr][td] 16[td] EndBillFormActive[td] Public Event EndBillFormActive()[td]在显示单据之后激发这个事件
[tr][td] 17[td] GridFormat[td] Public Event GridFormat(ByVal Dest As Long, ByVal Col As Long, ByVal Row As Long)[td]在设置单据体格式后激发这个事件参数:DestCol 要设置格式的目标列Row 要设置格式的目标行
[tr][td] 18[td] RefreshControl[td]Public Event RefreshControl() [td] Public Event RefreshControl()
[tr][td] 19[td] BeforeEntrySplit[td]Public Event BeforeEntrySplit(ByVal pCurRow As Long, ByVal pSplitCount As Long, ByVal pSplitMethod As Long, ByRef pCancel As Boolean)[td]在单据的拆分操作之前激发此事件参数:pCurRow 要拆分的当前分录行pSplitCount 拆分的数目pSplitMethod 拆分分录位置 0 插入式, 1追加式pCancel 是否取消拆分 true:取消拆分 false:拆分
[tr][td] 20[td]AfterEntrySplit[td]Public Event AfterEntrySplit(ByVal pCurRow As Long, ByVal pSplitCount As Long, ByVal pSplitMethod As Long)[td]在单据的拆分操作之后激发此事件参数:pCurRow 被拆分的分录行pSplitCount 被拆分成的数目pSplitMethod 拆分分录位置 0: 插入式, 1:追加式
[tr][td] 21[td]BeforeSelBills[td] [td]
[tr][td] 22[td]RetEvents[td] [td]
[tr][td] 23[td]HookInvoke[td] [td]
[tr][td] 24[td]BeforeSaveSplit[td] [td]
[tr][td] 25[td]AfterSaveSplit[td] [td]
[tr][td] 26[td]BillEntryGetFocus[td] [td]
[tr][td] 27[td]vHeadChange[td] [td]
[tr][td] 28[td]vGridChange[td] [td]
[tr][td] 29[td]GetBillHeadCtl[td] [td]
[tr][td] 30[td]SetBillHeadCtl[td] [td]
[tr][td] 31[td]GetBillEntryCtl[td] [td]
[tr][td] 32[td]SetBillEntryCtl[td] [td]
[tr][td] 33[td]SetBillCtlLookupSrcInfo[td] [td]
[tr][td] 34[td]RefreshGLData[td] [td]
[tr][td] 35[td]GetSaveVect[td] [td]
[tr][td] 36[td]OnBeforeDelRow[td]Public Event OnBeforeDelRow(ByVal lRow As Long, ByRef bCancel As Boolean)[td]在单据删除指定行之前激发此事件参数:lRow 指定要删除的行bCancel 是否取消删除 true:取消删除 false:删除
[tr][td] 37[td]OnAfterDelRow[td]Public Event OnAfterDelRow(ByVal lRow As Long, ByRef bCancel As Boolean)[td]在单据删除指定行后激发此事件参数:lRow 被删除的行bCancel 备用参数,目前没用到
[tr][td] 38[td]BeforeChangeMaterial[td] [td]


请问基础资料 物料  能二开写插件吗


【emoji】


{:5_152:}
那么爱你,为什么?{:6_153:}
学习学习。
{:5_152:}
:/'(图片坏了,看不到图
{:5_152:}
{:5_152:}
{:5_152:}

K/3 Wise 插件开发和配置

开发环境:K/3 Wise 13.0、K/3 Bos开发平台、Visual Basic 6.0目录一、二次开发插件编程二、代码演示三、配置插件四、测试插件五、插...
点击下载文档
标签: # K/3 WISE-BOS
分享:
确认删除?
回到顶部
客服QQ
  • 客服QQ点击这里给我发消息