Sample VB.net Quickbooks SDK
5.0 code for invoicing
I make no promises with this
code but I do ask for a link back to this site from your blog
or site or wherever you can help. Cmon, I just saved you hours!!
Dim requestMsgSet As QBFC5Lib.IMsgSetRequest
Dim sessionmgr As QBSessionManager
Try
‘this code provided by scaleprogrammers.com tested on vb.net
2005
sessionmgr = New QBSessionManager
sessionmgr.OpenConnection("", "Scale Programmers")
sessionmgr.BeginSession(qbookspath & "\" & qbooksfile,
ENOpenMode.omDontCare)
requestMsgSet = sessionmgr.CreateMsgSetRequest("US", "5", "0")
requestMsgSet.Attributes.OnError
= QBFC5Lib.ENRqOnError.roeStop
Dim invoiceAdd As QBFC5Lib.IInvoiceAdd
invoiceAdd = requestMsgSet.AppendInvoiceAddRq
Dim orInvoiceLineAdd
As IInvoiceLineAdd
invoiceAdd.CustomerRef.ListID.SetValue(“listid”) ‘get
this value previously in a qbquery
invoiceAdd.IsToBePrinted.SetValue(True)
invoiceAdd.TxnDate.SetValue(CDate(Now).ToShortDateString)
invoiceAdd.ShipAddress.Addr1.SetValue(“address1”)
invoiceAdd.ShipAddress.Addr2.SetValue(“address2”)
invoiceAdd.ShipAddress.City.SetValue(“city”)
invoiceAdd.ShipAddress.State.SetValue(“state”)
invoiceAdd.ShipAddress.PostalCode.SetValue(“zip”)
invoiceAdd.PONumber.SetValue("po")
invoiceAdd.RefNumber.SetValue(“orderid”)
Dim dt As Date
dt = thedate
Dim newdt As String = dt.Year & "-" & dt.Month & "-" & dt.Day
invoiceAdd.ShipDate.SetValue(newdt)
orInvoiceLineAdd = invoiceAdd.ORInvoiceLineAddList.Append.InvoiceLineAdd
orInvoiceLineAdd.ItemRef.FullName.SetValue(item)
orInvoiceLineAdd.Quantity.SetValue(weight)
sessionmgr.DoRequests(requestMsgSet)
requestMsgSet = Nothing
requestMsgSet = sessionmgr.CreateMsgSetRequest("US", "5", "0")
requestMsgSet.Attributes.OnError
= QBFC5Lib.ENRqOnError.roeStop
invoiceAdd = requestMsgSet.AppendInvoiceAddRq
sessionmgr.EndSession()
sessionmgr.CloseConnection()
sessionmgr = Nothing
Catch ex As Exception
MsgBox(ex.Source & ":" & ex.Message)
sessionmgr.EndSession()
sessionmgr.CloseConnection()
sessionmgr = Nothing
Finally
sessionmgr.EndSession()
sessionmgr.CloseConnection()
sessionmgr = Nothing
End Try