VIII. K3 WISE development plug-in development example of toolbar button of old single document list plug-in of industrial documents

Posted by dekeb55 on Thu, 17 Oct 2019 17:54:42 +0200

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

Catalog:

1. Add toolbar button

2. Query the FMenuID and FID of the business document with the added toolbar button.

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

4. Click the toolbar button to trigger the event main function

5. Click the toolbar button to trigger event DLL registration

6. Test results

7. Source code attached

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

This example takes the sales order as an example, which has been tested to be feasible!

1. Add toolbar button

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','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 with the added toolbar button

--Query the business document of the added toolbar button. FmenuID and FID,100, 32
select FID,FmenuID,* from iclisttemplate where Fname LIKE '%Sales order%'

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

--t_BandToolMapping.FID Corresponding iclisttemplate.FMenuID,
--t_BandToolMapping.FToolID Corresponding t_MenuToolBar.FToolID
--t_BandToolMapping.FComName Is the button firing component DLL Middle namespace.Class name
insert into t_BandToolMapping 
(FID,FBandID,FToolID,FSubBandID,FIndex,
FComName,FBeginGroup) 
values 
(100,48,99999,0,999,
'|BOS_BillEvent_PlugIns.Class3',0)

 

4. Click the toolbar button to trigger the event main function

Main function (ByVal skey as string, oList asobject, byref bCancel as Boolean) skey: the Key value of the menu, that is, the menu name oList: K3List control bCancel: cancel 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

--Tested in practice K3Connection.AppConnection Variable not available. Please use SQLHelper To connect to the database, code and usage are listed in the first tutorial for new plugins.
Set OBJ = CreateObject("K3Connection.AppConnection")   'Connection strings in old documents
'Menu response
Select Case sKey
Case "NewMenuTest" 'And what you inserted into the database FNAME equally
    'adopt Set vectBill = oList.GetSelected You can get the currently selected documents list data
    
    'Return to recordset mode
    'Set rs = obj.Execute("select * from t_icitem")
    
    'How to execute stored procedures
    ' obj.Execute3 ("exec KY_PlanQty")




End Select
End Function

 

5. Click the toolbar button to trigger event DLL registration

New batch file: register.bat

Text content: Regsvr32 "BOS? Billevent? Plugins. DLL"

Double click register.bat to register DLL

 

6. Test results

 

7. Source code attached

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 strings in old documents
       
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  'Internal code of auxiliary data 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 "The shift of Mo is updated successfully.", vbOKOnly, "Kingdee prompt"
           End If
           If frmUpdate.dtUpdate = "Night shift" Then
                For I = vectBill.LBound To vectBill.UBound  'Auxiliary data internal 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 "The shift of Mo is 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  'Internal code of auxiliary data 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 (" & strList & ") group by t2.FNumber,t2.FName"
             Set rs = OBJ.Execute(sqlSelect)
 End Function

 

--Add toolbar button to Po doc list
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','Custom 1','Custom 1','Custom 1',17,'User defined buttons','User defined buttons','User defined buttons',0,
 1,1,0,0,'','','','',0,0,0,'Custom 1','Custom 1','Custom 1')

Topics: PHP Database