基礎檔案後臺CO應用例項_存貨檔案自動同步功能
阿新 • • 發佈:2020-09-23
存貨檔案自動同步功能
toolbar按鈕二開外掛預置:直接在原存貨檔案卡片的“儲存”按鈕進行實現同步功能。
--meta庫 delete from AA_CustomerButton where cButtonKey ='InvCOtoSync' insert into AA_CustomerButton (cButtonKey,cButtonType,cProjectNO,cFormKey,cVoucherKey,cKeyBefore,iOrder,cGroup,cCustomerObjectName,cCaption,cLocaleID,cImage,cToolTip,cHotKey,bInneralCommand,cVariant,cVisibleAsKey,cEnableAsKey,cSubID,DependenceSubIdList,iheightRow ,iSetGroupRow ) values('InvCOtoSync','system','U870','Inventory_Edit','Inventory_Edit','SaveRs',0,'bj','U8ArchiveSyn_inv.clsToolbarCommon','存貨同步','ZH-CN','SaveRs','呼叫基礎檔案後臺CO同步更新存貨檔案','','1','呼叫基礎檔案後臺CO同步更新存貨檔案','SaveRs','SaveRs','','',1,2)
二開外掛程式碼實現:
Public g_oLogin As Object 'UFLoginSQL.Login '設定Login物件 Public SrvDB As Object ' U8SrvTrans.IClsCommon '設定公共資料庫事務處理物件 Private Function Init(ologin As Object) As Boolean On Error Resume Next Set g_oLogin = ologin If g_oLogin Is Nothing Then ShowMsg g_oPub.GetResString("U8.AA.ARCHIVE.COMMON.nologin") '"沒有傳入Login物件!" Exit Function End If Set SrvDB = CreateObject("U8SrvTrans.IClsCommon") If SrvDB Is Nothing Then ShowMsg g_oPub.GetResString("U8.AA.ARCHIVE.COMMON.loadsrvdbfail") '"建立CO物件失敗!" Exit Function End If SrvDB.Init Replace(ologin.UfDbName, "ufdata_001_2019", "ufdata_002_2019") '001 是源賬套,002是目標賬套 SrvDB.SetLogin ologin If SrvDB.Status = False Then ShowMsg g_oPub.GetResString("U8.AA.ARCHIVE.COMMON.dbconnectfail") '"資料連線失敗!" Exit Function End If Init = True End Function Public Function AfterRunSysCommand(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) Dim sErrTmp As String Dim succeed As Boolean 'objForm.m_SaveXML 串可以再次加工 If objForm.OperationType = 1 Then '新增儲存 succeed = SrvDB.Add(objForm.m_SaveXML, "Inventory", sErrTmp) Else '修改儲存 succeed = SrvDB.Modify(objForm.m_SaveXML, "Inventory", sErrTmp) End If End Function
注:如上是直接通過預置存貨檔案的系統按鈕“儲存”的外掛機制實現了從一個賬套呼叫基礎檔案CO自動同步到另外一個賬套的過程,如果是其他應用場景則需要自行建立U8Login物件、XML串;