有两种情况可以外挂U8,根据不同的需求选择以下的方法。
1 : 直接在用友U8的Form上面添加按钮,用于解决用友不能实现的功能,如 打Label,Barcode 等,或者单独都报表进行控制也可。
首先,需要找到ForM的标号,
进入到生产订单 手动输入的Form ,然后按住crtl +Alt + shift 3 键后随便点击按钮,然后开启WordPad,点击粘贴,可以看到如下资料:单据Key=MO21,就是Key的号码
单据Key=MO21
按钮标题:打印,按钮Key:tlbPrint;
按钮标题:预览,按钮Key:tlbPreview;
按钮标题:输出,按钮Key:tlbExport;
按钮标题:,按钮Key:tlbSeparator1;
按钮标题:增加,按钮Key:tlbAdd;
按钮标题:修改,按钮Key:tlbModify;
按钮标题:删除,按钮Key:tlbDelete;
按钮标题:草稿,按钮Key:tlbDraft;
按钮标题:模版,按钮Key:tlbTemplate;
按钮标题:保存,按钮Key:tlbSave;
按钮标题:放弃,按钮Key:tlbUndo;
按钮标题:,按钮Key:tlbSeparator5;
按钮标题:增行,按钮Key:tlbAddLine;
按钮标题:删行,按钮Key:tlbDelLine;
按钮标题:插行,按钮Key:tlbInsertLine '插行;
按钮标题:,按钮Key:tlbSeparator2;
按钮标题:子件,按钮Key:tlbComponent;
按钮标题:提交,按钮Key:Submit;
按钮标题:撤销,按钮Key:UnSubmit;
按钮标题:审核,按钮Key:RLS;
按钮标题:弃审,按钮Key:UNR;
按钮标题:xx-xSN,按钮Key:SN;
按钮标题:关联单据,按钮Key:tlbLinkList;
按钮标题:,按钮Key:tlbSeparator3;
按钮标题:定位,按钮Key:tlbLocal;
按钮标题:首张,按钮Key:tlbFirst;
按钮标题:上张,按钮Key:tlbPrevious;
按钮标题:下张,按钮Key:tlbNext;
按钮标题:末张,按钮Key:tlbLast;
按钮标题:,按钮Key:tlbSeparator4;
按钮标题:刷新,按钮Key:tlbRefresh;
按钮标题:附件,按钮Key:tlbAttached;
按钮标题:帮助,按钮Key:tlbHelp;
2 :
然后将预计的内容插入到SQL server 中,如下的语法。
--发货单
if exists(select 1 from AA_customerButton where cButtonKey='btnDACPrint' and cCustomerObjectName='EFDACPrj.Print')
delete from AA_customerButton where cButtonKey='btnDACPrint' and cCustomerObjectName='EFDACPrj.Print'
INSERT INTO [AA_CustomerButton]([cButtonID], [cButtonKey], [cButtonType], [cProjectNO], [cFormKey], [cVoucherKey], [cKeyBefore], [iOrder], [cGroup], [cCustomerObjectName], [cCaption], [cLocaleID], [cImage], [cToolTip], [cHotKey], [bInneralCommand], [cVariant], [cVisibleAsKey], [cEnableAsKey])
VALUES(newid(), 'btnDACPrint','default', 'U8CustDef',
'MO21', 'MO21','print', '0', 'IEDIT','EFDACPrj.Print','标签打印',
'zh-cn','Convert','客制化标签打印','',1,'标签打印','print','print')
if exists(select 1 from AA_customerButton where cButtonKey='btnDACPrint_PO' and cCustomerObjectName='HMPRJ.HMPO')
delete from AA_customerButton where cButtonKey='btnDACPrint_PO' and cCustomerObjectName='HMPRJ.HMPO'
INSERT INTO [AA_CustomerButton]([cButtonID], [cButtonKey], [cButtonType], [cProjectNO], [cFormKey], [cVoucherKey], [cKeyBefore], [iOrder], [cGroup], [cCustomerObjectName], [cCaption], [cLocaleID], [cImage], [cToolTip], [cHotKey], [bInneralCommand], [cVariant], [cVisibleAsKey], [cEnableAsKey])
VALUES(newid(), 'btnDACPrint_PO','default', 'U8CustDef',
'MO21', 'MO21','Confirm', '0', 'IEDIT','HMPRJ.HMPO','客制化按钮测试',
最好复制刷新的按钮,
然后进入VB ,新建一个DLL的VB工程,然后编写 RUNCOMMAND 函数,
如下的代码:
Option Explicit
'Dim UFGFFS As UFGeneralFilter.FilterSrv
'Dim clsUC As clsUserControlor
Public Function RunCommand(ByVal objLogin As Object, ByVal objForm As Object, ByVal objVoucher As Object, _
ByVal sKey As String, ByVal VarentValue As Variant, ByVal other As String)
' Dim oVoucher As Object 'UAPVoucherControl85.ctlVoucher
'U8Login.clsLogin
'U8Login.UfDbName
Dim t As U8Login.clsLogin
' MsgBox (objLogin.cAcc_Id)
MsgBox (objVoucher.headerText("cpoid"))
MsgBox (objLogin.UfDbName)
MsgBox (objVoucher.bodyText(1, "cinvcode"))
Dim tfrm As Form1
Set tfrm = New Form1
tfrm.Show vbModal
End Function
'³õʼ»¯
Public Function Init(ByVal objLogin As Object, ByVal objForm As Object, ByVal objVoucher As Object, msbar As Object)
'MsgBox "Init"
End Function
Public Function BeforeRunSysCommand(ByVal objLogin As Object, ByVal objForm As Object, ByVal objVoucher As Object, _
ByVal sKey As String, ByVal VarentValue As Variant, ByRef Cancel As Boolean, ByVal other As String)
MsgBox "Save is Canceled"
Cancel = True
End Function
然后在新建一个Form ,名字叫Form1.
添加按钮,然后加入如下事件:
Private Sub Command1_Click()
MsgBox ("test11111111111")
End Sub
编译生成,然后重新开启U8,进入生产订单,可以看到左上方添加了 客制化按钮测试 的按钮,点击会提示,test111 等内容,
3: RUNCOMMAND函数,包括几个参数,
Public Function RunCommand(ByVal objLogin As Object, ByVal objForm As Object, ByVal objVoucher As Object, ByVal sKey As String, ByVal VarentValue As Variant, ByVal other As String)
Dim t As U8Login.clsLogin
' MsgBox (objLogin.cAcc_Id)
MsgBox (objVoucher.headerText("cpoid"))
MsgBox (objLogin.UfDbName)
MSgBOx(bojVoucher.bodytext(1,"cinvcode"))
可以通过objlogin 取的登录的用户信息,和服务器的连接方式等,
可以通过objVoucher.headerText 取到当前界面上的Form资料作为外挂的参数等,
取子表的资料是 (bojVoucher.bodytext(1,"cinvcode"))
然后可以自行控制VB的报表或者功能。
培训导师说只要用VB6才可以,我认为也许VS2005 的VB和C#都能用,因为用友有提供接口资料。
比如打开用友U8的U8API资源管理器,明显可以看到用C#和VB两种接口。
C# 的调用方式下次研究。
转载请注明出处。
Long Wu You .
2010-12-28