Venice
C# example
 
The following topics are available:
the actual example
Remark: This example doesn't contain any business logic, it is just meant to show the possibilities and syntax of the SDK.
adding references
 
Example
 
using System;
using ClSdk;

namespace SdkExample
{
    class Program
    {
        static void Main(string[] args)
        {
            Venice oVenice = null;
            Dossier oDossier = null;
            Year oYear = null;
            Custm oCustm = null;
            Sales oSales = null;
            Balan oBalan = null;

            try
            {
                eAccessMode eAM;
                object      oPer0, oPer1, oPer2, oPer3, oPer4, oRem;
                double      dValue;
                int         iSysNum;
                string      sValue, sStreet, sPostal, sCity;

                // 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 10.00_
                if (eAM == eAccessMode.amSecure)
                    oVenice.LogonSecure ("10.00_", "MyApplication", eLanguage.lngNld, true, "ClSdkUser", "ClSdkPassword");
                else
                    oVenice.Logon ("10.00_", "MyApplication", eLanguage.lngNld, true, "SDK", "ClSdkUser", "Software engineer");
                
                // Get some Venice properties
                Console.WriteLine ("Venice user: " + oVenice.vUserName + "\nWindows 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 + "\nLast financial year: " + oDossier.vLastYear);

                // 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"))
                {
                    // 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))
                        Console.WriteLine ("Update failed!");
                }
                else
                    Console.WriteLine ("No customer found in Brugge.");

                // 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)
                {
                    // Seek the selected record
                    if (oCustm.SeekBySysNum (eSeekMode.smEqual, iSysNum))
                    {
                        // 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)
                        {
                            dValue = oCustm.GetExpired (0, out oPer0, out oPer1, out oPer2, out oPer3, out oPer4, out oRem);

                            // If there are open documents in period 2 or higher, show the documents
                            if ((double)oPer2 + (double)oPer3 + (double)oPer4 != 0.0)
                            {
                                iSysNum = oCustm.BrowseDocuments ((int)oCustm.pNumber);

                                // iSysNum != 0 means a document was selected
                                if (iSysNum != 0)
                                {
                                    // Create Sales Object - CanChange = false
                                    oSales = oYear.CreateSales (false);

                                    // Seek the selected document
                                    if (oSales.SeekBySysNum (eSeekMode.smEqual, iSysNum))
                                        oSales.View ();        // and show it
                                }
                            }
                        }
                    }
                }
                
                // 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);

                // Get the last Customer in the file - the parameter is redundant
                if (oCustm.SeekBySysNum (eSeekMode.smLast, 0))
                {
                    // Remember system number of last Customer
                    iSysNum = (int)oCustm.pSysNum;

                    // Import some new Customers
                    oCustm.ImportDialog ();

                    // Enumerate the newly imported Customers
                    if (oCustm.SeekBySysNum (eSeekMode.smGreater, iSysNum))
                    {
                        sValue = "";
                        // Until not EOF
                        while (oCustm.GetDBStatus () == 0)
                        {
                            sValue += oCustm.pName.ToString () + "\n";

                            // Seek the next customer (with a greater system number)
                            oCustm.GetNext ();
                        }
                        Console.WriteLine (sValue);
                    }
                }

                // Done, delete the customer
                // oCustm.Delete (eDeleteMode.dmFullReport);                
            }
            catch (Exception ex)
            {
                Console.WriteLine ("Error while executing application.\nReason:" + ex.Message + "\nSource: " + ex.Source);
            }

            finally
            {
                // Explicitly release COM objects
                if (oBalan != null)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oBalan);
                if (oSales != null)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oSales);
                if (oYear != null)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oYear);
                if (oCustm != null)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oCustm);
                if (oDossier != null)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oDossier);
                if (oVenice != null)
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oVenice);
            }
        }
    }
}
 
HOW TO: Add a reference to your project (using Microsoft Visual Studio 2022 ©)
Right click your project and select 'Add' ► 'COM Reference...'.
Tick the entry 'Exact Venice Software Development Kit'.
Exit this dialog by clicking the 'OK' button.
A COM interop reference to ClSdk is now added to your project.