2014-01-10 58 views
0

需要一些幫助。使用QBFC在QuickBooks中添加組項目

我只是想使用QBFC12在其上添加一個帶有物品清單的組合物品,但是我遇到了麻煩。我已經嘗試使用庫存裝配創建同樣的方法,並且工作正常。但是這個讓我感覺很糟糕。處理請求時,會返回錯誤,告知請求中缺少字段。希望任何人都可以幫助我解決這個問題。

感謝

這裏是我下面的代碼:

Dim msgSetRequest As IMsgSetRequest 

Dim QBSM As New QBSessionManager 

Try 

    With QBSM 

     .OpenConnection("", "QB Test") 

     .BeginSession("", ENOpenMode.omDontCare) 

    End With 

Catch ex As Exception 

    Throw New Exception(ex.Message) 

    Return False 

End Try 

msgSetRequest = QBSM.CreateMsgSetRequest("US", 8, 0) 
msgSetRequest.Attributes.OnError = ENRqOnError.roeStop 

msgSetRequest.ClearRequests() 

Dim gAdd As IItemGroupAdd = msgSetRequest.AppendItemGroupAddRq 
gAdd.IsActive.SetValue(True) 

gAdd.Name.SetValue("Group Name") 

gAdd.ItemDesc.SetValue("Group Description") 



For Each gListItem As clsInventoryGroupItem In gItem.InventoryGroupItemList 

     Dim gItemAdd As IItemGroupLine = msgSetRequest.AppendItemGroupAddRq.ItemGroupLineList.Append 

     gItemAdd.ItemRef.FullName.SetValue(gListItem.ItemRef) 

     gItemAdd.Quantity.SetValue(gListItem.Quantity) 

Next 



Dim response As IMsgSetResponse = QBSM.DoRequests(msgSetRequest) 

If response.ResponseList.GetAt(0).StatusCode = 0 Then 

    MessageBox.Show("Success") 

else 

    MessageBox.Show("An Error occurred while inserting Group") 

endif 

回答

0

我認爲這個問題是你如何將你的組線,但還沒有測試它。您應該從您的IItemGroupAdd對象gAdd中調用它,而不是使用msgSetRequest中的ItemGroupLineList.Append。這是我想到的,但沒有測試它。


Dim msgSetRequest As IMsgSetRequest 

Dim QBSM As New QBSessionManager 

Try 

    With QBSM 

     .OpenConnection("", "QB Test") 

     .BeginSession("", ENOpenMode.omDontCare) 

    End With 

Catch ex As Exception 

    Throw New Exception(ex.Message) 

    Return False 

End Try 

msgSetRequest = QBSM.CreateMsgSetRequest("US", 8, 0) 
msgSetRequest.Attributes.OnError = ENRqOnError.roeStop 

msgSetRequest.ClearRequests() 

Dim gAdd As IItemGroupAdd = msgSetRequest.AppendItemGroupAddRq 
gAdd.IsActive.SetValue(True) 

gAdd.Name.SetValue("Group Name") 

gAdd.ItemDesc.SetValue("Group Description") 



For Each gListItem As clsInventoryGroupItem In gItem.InventoryGroupItemList 

     Dim gItemAdd As IItemGroupLine = gAdd.ItemGroupLineList.Append 

     gItemAdd.ItemRef.FullName.SetValue(gListItem.ItemRef) 

     gItemAdd.Quantity.SetValue(gListItem.Quantity) 

Next 



Dim response As IMsgSetResponse = QBSM.DoRequests(msgSetRequest) 

If response.ResponseList.GetAt(0).StatusCode = 0 Then 

    MessageBox.Show("Success") 

else 

    MessageBox.Show("An Error occurred while inserting Group") 

endif 
相關問題