vb调用K3接口
现在我们有一个项目,他们公司用的K3的财务软件,现在我们有些业务想实时的调用K3的财务凭证,所以我们尝试用vb来调用k3凭证接口,来达到新增凭证,默认是凭证的审核状态,由于我都VB之前都不是很了解,请各位大侠只能我一下
Private Sub Command1_Click()
Dim voucher As New KFO.Dictionary
Dim GlData As New EBCGLView.GlData
Dim GLView As New EBCGLView.GLView
Dim dtvect As KFO.Vector
Dim Dt As KFO.Dictionary
Dim obj As ADODB.Recordset
Dim ReturnCollection As Object
'vchdate = DateSerial(GlData.SystemProfile.GLGetCurrentYear, GlData.SystemProfile.GLGetCurrentPeriod, 1)
vchdate = DateSerial(2009, 12, 1)
voucher("FDate") = vchdate
voucher("FGroup") = "记"
voucher("FNumber") = Val(111)
Dim voucherentry As New KFO.Vector
Dim tempentry As New KFO.Dictionary
'Set tempentry = New KFO.Dictionary
tempentry("FExplanation") = "凭证录入检测-分录1"
tempentry("FAccountID") = 1014
tempentry("FCurrencyID") = 1
tempentry("FDC") = 1
tempentry("FAmountFor") = 100
tempentry("FAmount") = 100
tempentry("Fdebit") = 100
tempentry("Fcredit") = -100
Set dtvect = New KFO.Vector
Set obj = GlData.GetAccountItem(1014)
For i = 0 To obj.RecordCount - 1
Set ReturnCollection = GLView.ItemLookup(obj("FItemClassID"))
Set Dt = New KFO.Dictionary
Dt("FItemClassID") = ReturnCollection.ReturnObject.ItemClassID
Dt("FItemID") = ReturnCollection.ReturnObject.ItemID
dtvect.Add Dt
obj.MoveNext
Next i
Set tempentry("_Details") = dtvect
voucherentry.Add tempentry
Set tempentry = New KFO.Dictionary
tempentry("FExplanation") = "凭证录入检测-分录2"
tempentry("FAccountID") = 1045
tempentry("FCurrencyID") = 1
tempentry("FDC") = 0
tempentry("FAmountFor") = 100
tempentry("FAmount") = 100
Set dtvect = New KFO.Vector
Set obj = GlData.GetAccountItem(1045)
For i = 0 To obj.RecordCount - 1
'Set ReturnCollection = GLView.ItemLookup(obj("FItemClassID"))
Set Dt = New KFO.Dictionary
'Dt("FItemClassID") = ReturnCollection.ReturnObject.ItemClassID
'Dt("FItemID") = ReturnCollection.ReturnObject.ItemID
dtvect.Add Dt
obj.MoveNext
Next i
Set tempentry("_Details") = dtvect
voucherentry.Add tempentry
Set voucher("_Entries") = voucherentry
Dim cre As Object, voucherid As Long
Set cre = CreateObject("EBSGLVoucher.VoucherUpdate")
voucherid = cre.Create(k3login.PropsString, voucher)
Set cre = Nothing
End Sub
报错的是这句Set obj = GlData.GetAccountItem(1014) ,报的错是没有发现数据源名称且没有制定默认驱动程序,大哥们,急啊!
[解决办法]
也可以直接向财务数据库写入凭证记录
[解决办法]
没有连上数据库吧,直接连数据库,写入新凭证不行吗
[解决办法]
Dim GlData As New EBCGLView.GlData
从这里切入,分析这个EBCGLView.GlData对象连接数据库的状态