1、U8知识库文档行开插件开发实例-供应商资质管理摘要U8系列产品提供了许多的二次开发接口,用户可在U8平台充分利用二次开发技术及接口开发出符合特定业务需求的插件,以更好的满足用户的个性化需求。本文将以供应商资质管理为实例介绍如何利用U8平台提供的二次开发技术及接口实现插件式的二次开发,并应用于U8标准流程的控制。目标本文通过一个实例分步介绍了如何利用U8提供的开发技术及接口实现供应商资质管理。通过本文的学习,开发人员可掌握U8中权限管理、菜单挂接、工具条、单据开发、单据事件接口等相关技术,并能按步骤开发出类似的插件。实例简介供应商资质管理介绍:建立供应商资质档案,菜单挂接:供应链资质管理供应商资
2、质业务处理供应商资质认证 供应链采购管理供应商管理供应商资质认证列表在审核采购订单时,判断订单供应商是否有对应资质认证,只有供应商存在对应资质认证的前提下才能成功审核采购订单,否则提示该供应商无资质认证,审核失败。业务流程如下图:开发实现步骤1. 菜单挂接和权限U8的菜单都是通过脚本,将菜单的数据,包括菜单层级关系预制到ufdata库的ua_menu表,下面将以“供应商资质”为例介绍一下如何插入菜单节点:如下图:首先,需要了解一下UA_menu 表的结构:字段名数据类型含义AutoIDuid自动编号cMenu_IdString菜单编号,自动产生,不可修改cMenu_NameString菜单名称
3、,输入cMenu_EngString程序类型,可忽略cSub_IdString模块标识,程序处理IGradeInt16级次,根据当前选中菜单程序自动处理cSupMenu_IdString上级菜单编号,根据当前选中菜单程序自动处理bEndGradeBoolean是否末级,输入,cAuth_IdString功能权限编号,程序内部处理,控制权限时有效(cAuth_Id= cMenu_Id)。iOrderInt32显示顺序号,程序处理iImgIndexInt32图标索引号,暂不用ParamtersString参数,输入,只有末级菜单才允许录入参数DependsString依赖 FlagInt标志按照层
4、级关系,首先在供应链下面插入资质管理的顶级菜单节点:insert into ua_menu (cMenu_Id,cMenu_Name,cMenu_Eng,cSub_Id,IGrade,cSupMenu_Id,bEndGrade,cAuth_Id,iOrder,iImgIndex,Paramters,Depends,Flag)values(HH,资质管理,Null,HH,1,SCMG,0,Null,-9999,1,Null,HH,Null)然后再分别插入“供应商资质”节点和末级节点“供应商资质认证”insert into ua_menu (cMenu_Id,cMenu_Name,cMenu_En
5、g,cSub_Id,IGrade,cSupMenu_Id,bEndGrade,cAuth_Id,iOrder,iImgIndex,Paramters,Depends,Flag)values(EFZZGL01,供应商资质,Null,HH,2,HH,0,EFZZGL01,800,1,Null,HH,Null)insert into ua_menu (cMenu_Id,cMenu_Name,cMenu_Eng,cSub_Id,IGrade,cSupMenu_Id,bEndGrade,cAuth_Id,iOrder,iImgIndex,Paramters,Depends,Flag)values(EFZ
6、ZGL010101,供应商资质认证,Null,HH,4,EFZZGL0101,1,EFZZGL01010101,1000,1,Null,HH,Null)做完上述的菜单插入后,就要为各个菜单关联上权限,这样才可以在系统内对菜单进行权限控制,U8功能权限信息也是通过预制数据库数据实现,预制权限是对ua_auth_base表进行操作:见上图,这里需要说明一下权限与菜单的差异:权限节点,某模块的顶级节点,在U8拥有该模块产品号的前提下是不需要预制,例如上图资质管理节点,在权限表内是找不到该权限节点,但是,如果U8未包含的产品,就必须预制权限表,预制的例子如下:首先预制权限主表ua_auth_base:
7、IF NOT EXISTS (SELECT TOP 1 DATA AS DATA FROM ua_auth_base Where (cAuth_Id=EFZZGL01010101 and cSub_Id=HH) ) INSERT INTO ua_auth_base(cAuth_Id,cSub_Id,iGrade,cSupAuth_Id,bEndGrade,iOrder,cAcc_Id,cAuthType,cAllSupAuths,irepnum,cRepellent,cRepellentModule,cNotRepellent,cRepInDB,cRepModInDB,cNotRepInDB)
8、VALUES (EFZZGL01010101,HH,4,EFZZGL010101,1,2300,NULL,0,EFZZGL010101,EFZZGL0101,EFZZGL01,NULL,NULL,NULL,NULL,NULL,NULL,NULL) 然后预制权限语言信息ua_auth_lang:IF NOT EXISTS (SELECT TOP 1 DATA AS DATA FROM UA_Auth_lang Where (cAuth_ID=EFZZGL010101) ) INSERT INTO UA_Auth_lang(localeid,cAuth_ID,cAuth_Name)VALUES (
9、zh-CN,EFZZGL010101,供应商资质认证)注:预制菜单时,可以使用先删除后插入的方式进行预制,预制权限怎不允许这种方式,所以在例子语句中,都添加了判断的SQL语句2. 预制门户按钮(U8 V11.0以下版本不需要做这一步)下面先对U8门户按钮做一下简单介绍:按钮插入步骤1、插入窗体信息主表AA_Forms_base与窗体信息语言AA_Forms_lang,插入时可采用先删除后插入的模式Delete From AA_Forms_base Where cFormCode =NHH_Voucher_EFZZGL01Delete From AA_Forms_lang Where cForm
10、Code =NHH_Voucher_EFZZGL01Insert Into AA_Forms_base(cFormCode,cSubID,iFormType,cMemo,cProjectNO,bSmallbutton) Values (NHH_Voucher_EFZZGL01,NHH,0,N供应商资质,NU870,0)Insert Into AA_Forms_lang(cFormCode,localeid,cFormCaption,cFormDesc,cSubID,cProjectNO) Values (NHH_Voucher_EFZZGL01,Nzh-CN,N供应商资质,N,NHH,NU87
11、0)2、插入按钮主表AA_FormButtons_base与按钮语言AA_FormButtons_langInsert Into AA_FormButtons_base(cFormCode,cButtonKey,cGroup,cPic,cToolBarType,iToolBarStyle,iOrder,iheightRow,cHotKey,cAuthid,iVoucherCtlIndex,ctoolbarPosIndex,cResID,cTipResID,cSubID,cProjectNO,cForegroundColor,cBackgroundColor,cSetGroup,iSetGrou
12、pRow,ProcessObjectName,FunctionKey) Values (NHH_Voucher_EFZZGL01,Nprint,NHH_Voucher_P_10,NPrint,NPortalToolbar,5,10,1,NCtrl+P,N,0,NP,N,N,NHH,NU870,N,N,NHH_Voucher_P_10_10,2,N,N)Insert Into AA_FormButtons_lang(cFormCode,localeid,cButtonKey,cCaption,cToolTip,cSubID,cProjectNO) Values (NHH_Voucher_EFZZ
13、GL01,Nzh-CN,Nprint,N打印,N打印,NHH,NU870)3、如果该按钮包含下拉按钮,则还需要插入按钮菜单表AA_FormButtonMenus_base与按钮菜单语言表Insert Into AA_FormButtonMenus_base(cFormCode,cButtonKey,cMenuKey,iOrder,cParentKey,igrade,cAuthid,cResID,cSubID,cProjectNO,cForegroundColor,cBackgroundColor,iMenuType,ProcessObjectName,FunctionKey) Values (
14、NHH_Voucher_EFZZGL01,NPrint,Nprint,1,N,0,N,N,NHH,NU870,Nblack,N,0,N,N)Insert Into AA_FormButtonMenus_lang(cFormCode,localeid,cButtonKey,cMenuKey,cCaption,cToolTip,cSubID,cProjectNO) Values (NHH_Voucher_EFZZGL01,Nzh-CN,NPrint,Nprint,N打印,N,NHH,NU870)注:在U8V11.0以前的版本,按钮都是通过在代码中利用toolbar控件的additem方法添加按钮(
15、既微软原有的方式),但是此种方法并不适用于U8V11.0,下面也为大家简单介绍一下U8V11.0以前版本预制按钮的方式,请看一下例子代码:初始化微软工具栏工具栏Public Sub Init_Toolbar(tlbObj As Toolbar, iSetType As Integer) With tlbObj.Buttons .Clear With .Add(, sKey_Print, strPrint, tbrDropdown) .ToolTipText = “打印” & (Ctrl+P) Call .ButtonMenus.Add(, PrintList,”打印列表”) Call .But
16、tonMenus.Add(, PrintBarCode, “打印条码”) End With .Add , sKey_Confirm, strConfirm .Item(sKey_Confirm).ToolTipText = strConfirm .Add , sKey_Cancelconfirm, strCancelconfirm .Item(sKey_Cancelconfirm).ToolTipText = strCancelconfirmEnd将微软工具栏与U8工具栏进行绑定Public Sub ChangeOneFormTbr(frm As Form, objTbl As Toolbar
17、, objU8Tbl As Control) Set objU8Tbl.Business = g_oBusiness With objTbl .Buttons(sKey_Print).Tag = g_oBusiness.createportaltoolbartag(print, ICOMMON, PortalToolbar).Buttons(sKey_Confirm).Tag = g_oBusiness.createportaltoolbartag(Approve, ICOMMON, PortalToolbar) End With objU8Tbl.SetToolbar objTbl objU
18、8Tbl.SetDisplayStyle 0 TextOnly objTbl.Visible = False objU8Tbl.Visible = True objU8Tbl.Left = objTbl.Left objU8Tbl.Top = objTbl.Top objU8Tbl.Width = frm.Width - 6 * Screen.TwipsPerPixelX objU8Tbl.Height = objTbl.HeightEnd SubCreateportaltoolbartag方法的第一参数,传入就是该按钮所使用的图标,图标文件可以在U8SOFTicons中寻找到。3. 预制单据
19、模板信息U8单据模板信息,同样是将模板信息存储在数据库当中,主要涉及以下几个表:Vouchers_base、Vouchers_lang、VoucherTemplates_Base、VoucherTemplates_lang、VoucherItems_Base、Voucheritems_PRN_base、VoucherItems_PRN_Lang预制数据时需要按照顺序预制这几张表。insert into Vouchers_base (CardNumber,Shield,Name,CardType,ItemTblName,itemCol,BTTblName,BTQName,BWTblName,BW
20、QName,VchListQName,HaveBodyGrid,BodyModify,VoucherWidth,VoucherHeight,BodyTop,BodyLeft,BodyWidth,BodyHeight,SelfDef1,SelfDef2,SelfDef3,DEF_ID,DEF_ID_PRN,cSub_Id,Memo,iOrder,cIndustry,bAllowMulTemp,cDefWhere,vchtblPrimarykeyNames,ReceiptNoFieldName,IsPrintLimited,AllowDateTimeFormat,NotAppiesAuth,Inv
21、entoryFieldName,UpdateTime,cHeadBusObjectId,cBodyBusObjectId,cHeadFuncName,cBodyFuncName,cFieldAuthid,vchBodyPKName,BodyFKName)values(EFZZGL01,0,供应商资质,Null,Null,3,EF_ZZGL_VenLicence,EF_ZZGL_V_VenLicence_EFZZGL01,EF_ZZGL_VenLicences,EF_ZZGL_V_VenLicences_EFZZGL01,EF_ZZGL_V_VenLicenceList01,1,1,1000,1
22、000,100,10,1000,10000,Null,Null,Null,31267,31268,HH,Null,1421,Null,1,Null,id,Null,1,1,1,Null,Null,Null,Null,Null,Null,Null,Null,Null)insert into Vouchers_lang (cardnumber,localeid,ccardname,appname)values(EFZZGL01,zh-cn,供应商资质,资质管理)insert into VoucherTemplates_Base (VT_ID,VT_CardNumber,VT_TemplateMod
23、e,VT_Width,VT_Height,VT_BodyTop,VT_BodyLeft,VT_BodyWidth,VT_BodyHeight,VT_SelfDef1,VT_SelfDef2,VT_SelfDef3,VT_Memo,VT_Lock,VT_TitleTop,VT_TitleLeft,VT_PageHeader,VT_BodyFixedCols,VT_BodyMaxRows,VT_GridStyle,VT_WorkAreaColor,VT_FiexdColor,VT_TotalColor,VT_ControlStyle,VT_GridPrnRows,VT_GridPrnRowHeig
24、ht,VT_PrintTemplID,VT_AutoCalc,VT_PageSubTotal,VT_PageTotal,VT_PrintGrid,nAutoCalcWidth,nPrintSeril,nPrintGridLine,varPrintSetting,VT_PRN_DEF_LANDID,vt_saveObject,VT_ReservedInfo,VT_xamlField,VT_RowLayoutEnabled,AuditDisplayFlag)values(VT_ID,EFZZGL01,0,11339,7937,1400,120,11099,6107,3000,480,Null,Nu
25、ll,0,0,4830,Null,1,0,1,16777215,16769984,16777215,2,0,255,100001,0,1,1,1,31,496,1,Null,Null,Null,0,Null)-insert into VoucherTemplates_lang (vt_id,localeid,vt_cardnumber,vt_name,vt_titlename,vt_titlefontstate,vt_foot,vt_gridstylehead,vt_gridstylebody,vt_gridstyletotal,vt_footheaderfont,vt_header,vt_R
26、owLayoutXML)values(VT_ID,zh-cn,EFZZGL01,供应商资质显示模版,供应商资质,Tahoma,15,0,0,1,第%p页共%P页,Null)insert into VoucherItems_Base (VT_ID,CardNum,CardItemNum,CanNotSelect,ShowIt,LinkIt,LinkTbl,LinkField,TableName,FieldName,FieldType,ReferType,ReferTable,CardSection,CanModify,MaxLength,MaxShowLen,NumPoint,IsNull,Ca
27、nDelete,UserCheck,UserPrompt,FormatChar,IsMain,NeedSum,CalcField,AliasNum,isSelfDef,COX,COY,Width,Height,TabIndex,DefaultValue,IsFixedLenght,FormatData,PrintCaption,PrintUpcase,PrintInterval,DataSource,EnterType,DataRule,ValidityCheck,ReserveSegTitlePos,BuildArchives,ReferReturnField,cmemo,nBorder,E
28、numType,IsEnum,EnumTypeString,bZeroAllowable,iFlags,vValueDefault,refObject,AutoFillRule,Catalog)values(VT_ID,EFZZGL01,94,0,1,0,Null,Null,EF_ZZGL_VenLicence,iscontrol,1,4,Null,T,1,20,1300,0,1,1,Null,Null,1,1,0,0,0,3,3860,1090,3500,250,5,0,1,0,0,0,Null,0,1,0,Null,0,0,False,0,False,0,0,Null,0,0)insert
29、 into VoucherItems_Base (VT_ID,CardNum,CardItemNum,CanNotSelect,ShowIt,LinkIt,LinkTbl,LinkField,TableName,FieldName,FieldType,ReferType,ReferTable,CardSection,CanModify,MaxLength,MaxShowLen,NumPoint,IsNull,CanDelete,UserCheck,UserPrompt,FormatChar,IsMain,NeedSum,CalcField,AliasNum,isSelfDef,COX,COY,
30、Width,Height,TabIndex,DefaultValue,IsFixedLenght,FormatData,PrintCaption,PrintUpcase,PrintInterval,DataSource,EnterType,DataRule,ValidityCheck,ReserveSegTitlePos,BuildArchives,ReferReturnField,cmemo,nBorder,EnumType,IsEnum,EnumTypeString,bZeroAllowable,iFlags,vValueDefault,refObject,AutoFillRule,Cat
31、alog)values(VT_ID,EFZZGL01,94,0,1,0,Null,Null,EF_ZZGL_VenLicence,iscontrol,1,4,Null,T,1,20,1300,0,1,1,Null,Null,1,1,0,0,0,3,3860,1090,3500,250,5,0,1,0,0,0,Null,0,1,0,Null,0,0,False,0,False,0,0,Null,0,0)insert into VoucherItems_lang (guid,localeid,vt_id,fieldname,cardsection,cardnum,carditemname,card
32、formula1,cardformula2,fontstate)values(newid(),en-us,VT_ID,autoid,B,EFZZGL01,编号id,Tahoma,9,0,0,1)insert into Voucheritems_PRN_base (VT_ID,CardNum,CardItemNum,CanNotSelect,ShowIt,LinkIt,LinkTbl,LinkField,TableName,FieldName,FieldType,ReferType,ReferTable,CardSection,CanModify,MaxLength,MaxShowLen,Num
33、Point,IsNull,CanDelete,UserCheck,UserPrompt,FormatChar,IsMain,NeedSum,CalcField,AliasNum,isSelfDef,COX,COY,Width,Height,TabIndex,DefaultValue,IsFixedLenght,FormatData,PrintCaption,PrintUpcase,PrintInterval,DataSource,EnterType,DataRule,ValidityCheck,ReserveSegTitlePos,BuildArchives,nBorder,ReferRetu
34、rnField,cmemo,EnumType,IsEnum,EnumTypeString,bZeroAllowable,iFlags,vValueDefault,refObject,AutoFillRule,Catalog)values(VT_ID,EFZZGL01,70,0,0,0,Null,Null,EF_ZZGL_VenLicences,autoid,2,2,Null,B,1,4,1300,6,0,1,Null,Null,1,1,0,0,0,3,1000,28,2505,0,73,Null,0,Null,1,0,Null,0,0,Null,0,1,0,0,Null,Null,False,
35、0,True,0,0,Null,Null,0,0)insert into VoucherItems_PRN_Lang (guid,localeid,vt_id,fieldname,cardsection,cardnum,carditemname,cardformula1,cardformula2,fontstate)values(newid(),en-us,VT_ID,autoid,B,EFZZGL01,编号id,Null,Null,Tahoma,9,0,0,1)4. 代码开发预制完上述菜单、权限、按钮、单据模板信息后,下面要进行的就是代码开发。代码开发,主要就是三个方面的工作:(1) 门户登
36、录,既在门户中双击插入的菜单,登录到程序界面;(2) 完成对门户按钮预制信息,单据模板预制信息的加载(3) 功能逻辑实现在本文档,主要讲一下第一点与第二点,第三点由于程序各异,就不多加说明 门户登录:组件引用:在编写门户登录时,需要在VB工程内增加一个接口类,接口类主要对门户登录接口的一个实现,并同时从门户中获取门户的登录业务对象Business、登录组件Login以及数据库连接对象,为后续代码编写提供基础,“供应商资质”的接口类为clsProductFacade,下列是实例代码: 获取门户的业务对象Public Property Get Business() As Object Set Bu
37、siness = g_obusinessEnd PropertyPublic Property Set Business(ByRef bBus As Object) Set g_obusiness = bBus 获得business对象。End Property门户登录时运行Private Function ILoginable_Login() As Boolean If (Not g_obusiness Is Nothing) And g_bLogined = False) Then Set g_oLogin = g_obusiness.GetVBclsLogin() 获得login对象 I
38、f g_Conn.State = 1 Then g_Conn.Close g_Conn.ConnectionString = g_oLogin.UfDbName g_Conn.CursorLocation = adUseClient g_Conn.Open Call InitNumberFormat g_bLogined = True ILoginable_Login = True Else ILoginable_Login = Not g_obusiness Is Nothing End IfEnd Function门户退出Private Function ILoginable_LogOff
39、() As Boolean 程序退出前,添加自己的代码 ILoginable_LogOff = True 本行代码必须。 g_bLogined = False 本行代码必须。End Function门户登录主方法Private Function ILoginable_CallFunction(ByVal cMenuId As String, ByVal cMenuName As String, ByVal cAuthId As String, ByVal cCmdLine As String) As Object Dim vfd As Object Dim clsListInterFace A
40、s VouchListInterFace DolistVoucher = False Dim mEncrypt As Object Dim var As Variant Set gEncryptLogin = CreateObject(UFSoft.U8.Framework.Login.UI.clsLogin) Set mEncrypt = CreateObject(HY_FZ_Library.clsCommonLib) If mEncrypt.Encrypt(HH, gEncryptLogin, g_oLogin) = False Then Exit Function End If If Z
41、wTaskExec(AuthShow, 1) = False Then Exit Function End If If Not (g_obusiness Is Nothing) Then Set vfd = g_obusiness.CreateFormEnv(frmMain_key4, frmMain) Form11_key为任意字符串,建议以窗体名_key来表示,既防止重复,又清晰易懂。 Call g_obusiness.ShowForm(frmMain, DP, f frmMain_key4, False, True, vfd) Else frmMain.Show frmMain.ZOrd
42、er 0 End IfEnd Function而编写这个类又怎么跟门户挂接呢,此时在数据的UFSYSTEM库的ua_idt这个表需要预知一条数据,将菜单ID(cMenu_id)与接口类关联,例如“供应商资质”工程名叫EFZZGLMain,接口类叫clsProductFacade,则预知到ua_idt这个表的SQL语句如下:insert into ufsystem.ua_idt (id,assembly,catalogtype,type,class,entrypoint,parameter,reserved)values(EFZZGL010101,EFZZGLMain.clsProductFacade,0,0,Null,Null,Null,Null) 按钮加载:使用U8的按钮,需要同时在窗体中增加微软的toolbar控件和U8的uftoolbar控件按钮加载一般在窗体的Form_laod事件中进行: 方法说明 Settoolbarfromdata(oMSToolBar As Object, CN As Connection, oLogin As Object, sFormKey As String, sSu
©2010-2024 宁波自信网络信息技术有限公司 版权所有
客服电话:4008-655-100 投诉/维权电话:4009-655-100