|
Create Item Sale |
Top Previous Next |
|
[Visual Basic] The following example demonstrates how to create and save a new Item Sale document. (This example uses the ItemSaleWebService.)
' ---------------------------------------- ' Step 1: Create an instance of the web service. ' ---------------------------------------- Dim itemSaleWs As New WebServices.ItemSaleWebService("http://localhost/objacctwebservices/")
' ---------------------------------------- ' Step 2: Set the LoginKey. (Use Login.GetLoginKey to ' login to a specific company and generate a LoginKey.) ' For this example, the LoginKey is being stored in a ' public variable called PublicLoginKey. ' ---------------------------------------- StdLib.PopulateObjAcctSoapHeader(itemSaleWs, PublicLoginKey)
' ---------------------------------------- ' Step 3: Create and populate a DataSet with the new document. ' For this example, we're creating a new Item Sale document, so ' we will use the ObjAcct.WebServices.DataSets.ItemSaleDataSet. ' ---------------------------------------- Dim itemSaleDs As DataSet = New WebServices.DataSets.ItemSaleDataSet()
' ------------------- ' Document Header. ' ------------------- Dim headerDr As DataRow = itemSaleDs.Tables("Header").NewRow
headerDr("RowID") = "" headerDr("AccountRowID") = "20.0" headerDr("ClassRowID") = "6.0" headerDr("DocAmount") = 290 headerDr("DocDate") = Today.ToShortDateString headerDr("DocID") = "IS5000" headerDr("EnteredDate") = Today.ToShortDateString headerDr("JobRowID") = "39.0"
' Add the row to the Header table. itemSaleDs.Tables("Header").Rows.Add(headerDr)
' ------------------- ' Transaction - Invoice. ' ------------------- Dim transDr As DataRow
transDr = itemSaleDs.Tables("Transaction").NewRow
transDr("RowID") = "" transDr("AccountRowID") = "14.0" transDr("ClassRowID") = "17.0" transDr("Description") = "Accounting Software" transDr("DisplayOrder") = 1 transDr("ItemRowID") = "4.0" transDr("JobRowID") = "39.0" transDr("Quantity") = 1 transDr("TransactionAmount") = 500 transDr("TransactionType") = "S" ' Sale (Invoice) transDr("UnitRate") = 500 transDr("UnitRowID") = "2.0"
' Add the row to the Transaction table. itemSaleDs.Tables("Transaction").Rows.Add(transDr)
' ------------------- ' Transaction - Credit Memo. ' ------------------- transDr = itemSaleDs.Tables("Transaction").NewRow
transDr("RowID") = "" transDr("AccountRowID") = "14.0" transDr("ClassRowID") = "3.0" transDr("Description") = "Marketing Binders" transDr("DisplayOrder") = 2 transDr("ItemRowID") = "33.0" transDr("JobRowID") = "39.0" transDr("Quantity") = 10 transDr("TransactionAmount") = 210 transDr("TransactionType") = "R" ' Return (Credit Memo) transDr("UnitRate") = 21 transDr("UnitRowID") = "2.0"
' Add the row to the Transaction table. itemSaleDs.Tables("Transaction").Rows.Add(transDr)
' ---------------------------------------- ' Step 4: Save the document. ' ---------------------------------------- Dim returnDs As DataSet = itemSaleWs.SaveDocument(itemSaleDs)
' Check for errors. If StdLib.GetErrorNumber(returnDs) < 0 Then MsgBox(StdLib.GetErrorAsString(returnDs)) End If |