|
Create Check |
Top Previous Next |
|
[Visual Basic] The following example demonstrates how to create and save a new Check document. (This example uses the CheckWebService.)
' ---------------------------------------- ' Step 1: Create an instance of the web service. ' ---------------------------------------- Dim checkWs As New WebServices.CheckWebService("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(checkWs, PublicLoginKey)
' ---------------------------------------- ' Step 3: Create and populate a DataSet with the new document. ' For this example, we're creating a new Check document, so we ' will use the ObjAcct.WebServices.DataSets.CheckDataSet. ' ---------------------------------------- Dim checkDs As DataSet = New WebServices.DataSets.CheckDataSet()
' ------------------- ' Document Header. ' ------------------- Dim headerDr As DataRow = checkDs.Tables("Header").NewRow
headerDr("RowID") = "" headerDr("AccountRowID") = COMPANYSETUP("APPaymentAccountRowID") headerDr("ClassRowID") = "7.0" headerDr("Description") = "Customizations and Reporting" headerDr("DocAmount") = 4745 headerDr("DocDate") = Today.ToShortDateString headerDr("DocID") = "CK5000" headerDr("EnteredDate") = Today.ToShortDateString headerDr("EntityRowID") = "5.0" headerDr("EntityType") = "Vendor" headerDr("RemitToAddressRowID") = "12.0" headerDr("ToBePrinted") = COMPANYSETUP("ChecksMarkedToPrintByDefault")
' Add the row to the Header table. checkDs.Tables("Header").Rows.Add(headerDr)
' ------------------- ' Transaction. ' ------------------- Dim transDr As DataRow
transDr = checkDs.Tables("Transaction").NewRow
transDr("RowID") = "" transDr("AccountRowID") = "18.0" transDr("ClassRowID") = "7.0" transDr("Description") = "Application Development" transDr("DisplayOrder") = 1 transDr("GroupType") = "E" transDr("InvoiceDate") = Today.ToShortDateString transDr("InvoiceNbr") = "PL3442" transDr("TransactionAmount") = 1750
' Add the row to the Transaction table. checkDs.Tables("Transaction").Rows.Add(transDr)
transDr = checkDs.Tables("Transaction").NewRow
transDr("RowID") = "" transDr("AccountRowID") = "3.0" transDr("ClassRowID") = "17.0" transDr("Description") = "Software" transDr("DisplayOrder") = 2 transDr("GroupType") = "E" transDr("InvoiceDate") = Today.ToShortDateString transDr("InvoiceNbr") = "PL3442" transDr("TransactionAmount") = 2995
' Add the row to the Transaction table. checkDs.Tables("Transaction").Rows.Add(transDr)
' ---------------------------------------- ' Step 4: Save the document. ' ---------------------------------------- Dim returnDs As DataSet = checkWs.SaveDocument(checkDs)
' Check for errors. If StdLib.GetErrorNumber(returnDs) < 0 Then MsgBox(StdLib.GetErrorAsString(returnDs)) End If |