|
Imports ClSdk
Module Example
Sub Main()
Try
Dim oVenice As Venice
Dim oDossier As Dossier
Dim oYear As Year
Dim oCustm As Custm
Dim oSales As Sales
Dim oBalan As Balan
Dim eAM As eAccessMode
Dim oPer0, oPer1, oPer2, oPer3, oPer4, oRem As Object
Dim sStreet, sPostal, sCity, sValue As String
Dim dValue As Double
Dim iSysNum As Integer
' Create the Venice object interface
oVenice = New Venice
' Is option 'Access Management' installed?
eAM = oVenice.GetAccessMode()
' Logon into Venice, allowing user interface - script written for version 13.30_
If eAM = eAccessMode.amSecure Then
oVenice.LogonSecure("13.30_", "MyApplication", eLanguage.lngNld, True, "ClSdkUser", "ClSdkPassword")
Else
oVenice.Logon("13.30_", "MyApplication", eLanguage.lngNld, True, "SDK", "ClSdkUser", "Software engineer")
End If
' Get some Venice properties
Console.WriteLine("Venice user: " + oVenice.vUserName + vbCrLf + "Windows user: " + oVenice.vWindowsUser)
' Create DossierContext, use the default filing cabinet 'Data' and the dossier 'MyCompany'
oDossier = oVenice.CreateDossierContext("", "MyCompany")
' Get some Dossier properties
Console.WriteLine("Full path name: " + oDossier.vPath + vbCrLf + "Last financial year: " + oDossier.vLastYear.ToString())
' Create YearContext - 0 = last year
oYear = oDossier.CreateYearContext(0)
' Create a customer object - CanChange = true
oCustm = oDossier.CreateCustm(True)
' Seek a customer in Brugge
If oCustm.SeekByPostal(eSeekMode.smEqual, "8000") Then
' Show customer found
oCustm.View()
' Get some Customer properties
sStreet = oCustm.pStreet.ToString()
sPostal = oCustm.pPostalCode.ToString()
sCity = oCustm.pCity.ToString()
' Change some Customer properties
oCustm.pStreet = "SDK Street"
oCustm.pPostalCode = 1234
oCustm.pCity = "SDK Town"
' And update the Customer Card
oCustm.Update(eUpdateMode.umFullReport)
' Show the result
oCustm.View()
' Restore original values with alternative way of setting a property
oCustm.SetFieldVal(eCustmFld.cusfStreet, sStreet)
oCustm.SetFieldVal(eCustmFld.cusfPostalCode, sPostal)
oCustm.SetFieldVal(eCustmFld.cusfCity, sCity)
' And update the Customer Card again
oCustm.Update(eUpdateMode.umFullReport)
' Verify if the update succeeded, using the string version of GetField
If sPostal <> oCustm.GetFieldStr(eCustmFld.cusfPostalCode) Then
Console.WriteLine("Update failed!")
End If
Else
Console.WriteLine("No customer found in Brugge.")
End If
' Now select a Customer using the browse list
iSysNum = oCustm.Browse(False)
' iSysNum <> 0 means a customer was selected in the browse
If iSysNum <> 0 Then
' Seek the selected record
If oCustm.SeekBySysNum(eSeekMode.smEqual, iSysNum) Then
' and update it in a dialog
oCustm.Update(eUpdateMode.umDialog)
' Get the balance of the current Customer
dValue = oCustm.GetBalance(0)
' If a balance was returned, get the expired amounts
If dValue <> 0.0 Then
dValue = oCustm.GetExpired(0, oPer0, oPer1, oPer2, oPer3, oPer4, oRem)
' If there are open documents in period 2 or higher, show the documents
If oPer2 + oPer3 + oPer4 <> 0.0 Then
iSysNum = oCustm.BrowseDocuments(oCustm.pNumber)
' iSysNum <> 0 means a document was selected
If iSysNum <> 0 Then
' Create Sales Object - CanChange = false
oSales = oYear.CreateSales(False)
' Seek the selected document
If oSales.SeekBySysNum(eSeekMode.smEqual, iSysNum) Then
oSales.View() ' and show it
End If
End If
End If
End If
End If
End If
' oSales is no longer needed
oSales = Nothing
' We are interested in the turnover, so create a Balance object - CanChange = false
oBalan = oYear.CreateBalan(False)
' Get the balance for all accounts starting with '70' for the complete financial year
dValue = oBalan.GetBalance("70*", 0)
' Show the result
Console.WriteLine("Total turnover: " + dValue.ToString())
' oBalan is no longer needed
oBalan = Nothing
' Get the last Customer in the file - the parameter is redundant
If oCustm.SeekBySysNum(eSeekMode.smLast, 0) Then
' Remember system number of last Customer
iSysNum = oCustm.pSysNum
' Import some new Customers
oCustm.ImportDialog()
' Enumerate the newly imported Customers
If oCustm.SeekBySysNum(eSeekMode.smGreater, iSysNum) Then
sValue = ""
' Until not EOF
While oCustm.GetDBStatus() = 0
sValue += oCustm.pName.ToString() + vbCrLf
' Seek the next customer (with a greater system number)
oCustm.GetNext()
End While
Console.WriteLine(sValue)
End If
End If
' Done, delete the customer
' oCustm.Delete (eDeleteMode.dmFullReport)
' No need to destroy the remaining objects, they are destroyed automatically
Catch ex As Exception
Console.WriteLine("Error while executing application." + vbCrLf + "Reason:" + ex.Message + vbCrLf + "Source: " + ex.Source)
End Try
End Sub
End Module
|