8. K3 WISE development plug-in “Industrial document old order time thin plug-in toolbar button development example”

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

Table of contents:

1. Add toolbar button

2. Query the FMenuID and FID of the business document to which the toolbar button is added

3. Add the mapping relationship between toolbar buttons and business documents

4. Clicking the toolbar button triggers the event MainFunction

5. Toolbar button click trigger event DLL registration

6. Test results

7. Attached is the reproduced source code

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

This example uses a sales order as an example, and it has been actually tested and works!

1. Add toolbar button

insert into t_MenuToolBar
 (FToolID,FName,FCaption,FCaption_CHT,FCaption_EN,
 FImageName,FToolTip,FToolTip_CHT,FToolTip_EN,FControlType,
 FVisible,FEnable,FCchecked,FShortCut,FCBList,
 FCBList_CHT,FCBList_EN,FCBStyle,FCBWidth,FIndex,
 FToolCaption,FToolCaption_CHT,FToolCaption_EN)
values
(99999,'NewMenuTest','Test Button 1','Test Button','Test Button',
'39','Test button','Test button','Test button',0,
1,1,0,0,'',
'','',0,0,0,
'Test Button','Test Button','Test Button')

2. Query the FMenuID and FID of the business document to which the toolbar button is added

--Query the FmenuID and FID of the business document to which the toolbar button is added, which are 100 and 32 respectively.
select FID,FmenuID,* from iclisttemplate where Fname LIKE '%Sales Order%'

3. Add the mapping relationship between toolbar buttons and business documents

--t_BandToolMapping.FID corresponds to iclisttemplate.FMenuID,
--t_BandToolMapping.FToolID corresponds to t_MenuToolBar.FToolID
--t_BandToolMapping.FComName is the namespace and class name in the DLL of the button activation component.
insert into t_BandToolMapping
(FID,FBandID,FToolID,FSubBandID,FIndex,
FComName,FBeginGroup)
values
(100,48,99999,0,999,
'|BOS_BillEvent_PlugIns.Class3',0)

4. Clicking the toolbar button triggers the event MainFunction

MainFunction(ByVal sKey As string,oList AsObject,Byref bCancel as Boolean) sKey: The Key value of the menu, which is the menu name oList: K3List control bCancel: Whether to cancel the subsequent operation flag

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

'Set InBatch = New InBatch display form
MsgBox "111"
Dim vectBill As KFO.Vector

--After actual testing, K3Connection.AppConnection cannot get the variables. Please use SQLHelper to connect to the database. The code and usage are in the first plug-in novice guide.
Set OBJ = CreateObject("K3Connection.AppConnection") 'Connection string in the old document
'Menu response
Select Case sKey
Case "NewMenuTest" 'is the same as the FNAME you inserted in the database
    'You can get the currently selected vectBill data by Set vectBill = oList.GetSelected
    
    'Return to recordset mode
    'Set rs = obj.Execute("select * from t_icitem")
    
    'Execute stored procedure mode
    ' obj.Execute3 ("exec KY_PlanQty")




End Select
End Function

5. Toolbar button click trigger event DLL registration

Create a new batch file: registration.bat

Text content: regsvr32 “BOS_BillEvent_PlugIns.dll”

Double-click registration.bat to register DLL

6. Test results

< /strong>

7. Attached is the reproduced source code

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 display form
 Set OBJ = CreateObject("K3Connection.AppConnection") 'Connection string in the old document
       
Select Case sKey1
    Case "PlanUpdate"
        'Set vectBill = New KFO.Vector
: Set vectBill = oList.GetSelData("FInterID")
        If vectBill.UBound > 0 Then
            frmUpdate.Show 1
            If frmUpdate.dtUpdate = "Day shift" Then
                 For I = vectBill.LBound To vectBill.UBound 'auxiliary information code 40025=day shift
                         Set DictCheck = vectBill(I)
                         sqlUpdate = "Update ICMO set FHeadSelfJ0176 =40025 where finterid = " & DictCheck.GetValue("FInterID"))
                          OBJ.Execute3 (sqlUpdate))
                Next I
               SendKeys ("{F5}")
               MsgBox "Production order shift updated successfully", vbOKOnly, "Kingdee prompt"
           End If
           If frmUpdate.dtUpdate = "night shift" Then
                For I = vectBill.LBound To vectBill.UBound 'auxiliary information code 40026=night shift
                        Set DictCheck = vectBill(I)
                        sqlUpdate = "Update ICMO set FHeadSelfJ0176 =40026 where finterid = " & DictCheck.GetValue("FInterID")
                        OBJ.Execute3 (sqlUpdate) `
                Next I
                SendKeys ("{F5}")
                MsgBox "Production order shift updated successfully", vbOKOnly, "Kingdee prompt"
           End If
       End If
 Case "PlanUpdate2"
        Set vectBill = oList.GetSelData("FInterID")
        If vectBill.UBound > 0 Then
             strList = ""
             For I = vectBill.LBound To vectBill.UBound 'auxiliary information code 40025=day shift
                   Set DictCheck = vectBill(I)
                   strList = strList & DictCheck.GetValue("FInterID") & ","
             Next I
             strList = Left(strList, Len(Trim(strList)) - 1)
             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 (" & amp; strList & amp; \ ") group by t2.FNumber,t2.FName"
             Set rs = OBJ.Execute(sqlSelect)
 End Function
--Add a toolbar button to the purchase order timeline
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,FCchecked,FShortCut,FShortChar,FCBList,FCBList_CHT,FCBList_EN,FCBStyle,FCBWidth,
 FIndex,FToolCaption,FToolCaption_CHT,FToolCaption_EN )
VALUES
(1001,'UserAdd1','Custom 1','Custom 1','Custom 1',17,'Button customized by user','Defined by user Customized button','Button customized by user',0,
 1,1,0,0,'','','','',0,0,0,'Custom 1','Custom 1', 'Custom 1')
syntaxbug.com © 2021 All Rights Reserved.