Integration With Autocount Accounting Ver 1.9

Introduction
The following article as well as other posts linked to this post is applicable only to AutoCount Accounting version 1.8.8 and above. The information covered in these articles will be of interest to any third-party application developer that directly call the assembly files of AutoCount Accounting version 1.8.8 for their application (non-plugin type) especially due to the fact that there is major differences between version 1.8.8 and earlier versions

 

 

Initialization
In version 1.8.8, several classes has been restructured and renamed. One such class is the BCE.AutoCount.MainEntry.MainEntry. Now known as BCE.AutoCount.MainEntry.Startup, this class implements the Startup and Shutdown procedure of AutoCount Accounting. As such any program developed to access AutoCount Accounting must call the startup methods in this class first before attempting to access to AutoCount Accounting

 

 

DBSetting
Before explaining the startup method themselves, an explanation on an important object must be done first. The object meant here is the DBSetting object. A DBSetting object is important as it is the object used by the AutoCount Accounting program to handle the connection between the database layer and application layer of its implementation. As such, most if not all classes in the AutoCount Accounting assemblies require that this object be pass into them during initialization. Below are the constructors for the DBSetting object:
DBSetting Constructors

public DBSetting(DBServerType serverType, string connectionString);

public DBSetting(DBServerType serverType, string serverName, string dbName);

public DBSetting(DBServerType serverType, string serverName, string dbName, bool usePool);

public DBSetting(DBServerType serverType, string serverName, string userId, string password, string dbName);

public DBSetting(DBServerType serverType, string serverName, string userId, string password, string dbName, bool usePool);

An example on how to create a DBSetting object is shown below:
Code Snippet
DBSetting dbSetting = new DBSetting(DBServerType.SQL2000, @”(local)\A2006″“sa”“saPassword”“AED_MOBILE”);
Certain startup methods requires a DBSetting object as a parameter while there is one startup method that will return a DBSetting object when called. This particular method will be discussed later in this post

 

 

SubProjectStartup
This is one of the startup method available for use to begin the startup procedure for any AutoCount related project. You should call this method once only and be aware that this method will not prompt any user log-in UI. As such, if you wish to allow user to enter their login information, you will have to develop a Windows form that will allow the user to enter their login information
SubProjectStartup Methods

public void SubProjectStartup(DBSetting dbSetting);

public void SubProjectStartup(DBSetting dbSetting, StartupLicenseControlType slcType);

For your information, the StartupLicenseControlType parameter contains 3 choices which are:
  1. Default: The default license control information stored in the database
  2. License Code
  3. Dongle
After calling the method above, you will need to call the Login method in the UserAuthentication class to facilitate the AutoCount user login. The following code snippet will show how to do so:
SubProjectStartup Example

public class MainEntry

{

    static void Main()

    {

        // Here you must provide a dbSetting which points to your AutoCount Accounting database.

        DBSetting dbSetting = new DBSetting(DBServerType.SQL2000, @”(local)\A2006″“sa”“saPassword”“AED_MOBILE”);

 

         // Call the startup method SubProjectStartup to begin initialization

        BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(dbSetting);

 

        /*

         * Put the UI and logic component to handle the user input for the user id and password here

         */

 

        // use the provided login details to login, if the login failed exit the program

        // modify this portion of the example to add warning message rather than just exiting.

        if (!BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).Login(“userID”“password”))

            return;

    }

}

 

 

SubProjectStartupWithLogin
This method of startup is formerly called CustomProjectStartup in its previous incarnation. Similar to its cousin, the SubProjectStartup method, you should call this method once only in your application. The difference between this method and its cousin is instead of having to create a DBSetting object before calling the method, this method will generate the DBSetting object for you instead
Another difference is that this method will prompt the user to enter their login details via the standard AutoCount Accounting login window, which allows the user to choose which account book he wishes to login into
Code Snippet
public DBSetting SubProjectStartupWithLogin(string dmfPath, string loginTitle);

The dmfPath parameter denotes the Database Management File path. If you are using a custom Database Management File, please enter the path into the parameter. Leaving an empty string will denote that the default file path is to be used. The loginTitle parameter denotes the string you wish to show on top of the login window screen

Code Snippet

public class MainEntry

{

    static void Main()

    {

        // create the DBSetting object to use later on

        DBSetting dbSetting = BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartupWithLogin(“”“Testing Integration”);

    }

}

 

 

Consuming AutoCount
Accounting Assemblies
The following section is written in different posts to help ensure an easier time to read as they may contain a lot of code sample as well as explanation. This section will serve as a place to hold the links to each posts for ease of navigation
  1. Access AR Tutorial
  2. Access GL Tutorial
  3. Access Purchase Tutorial
  4. Access Sales Tutorial
  5. Access Stock Tutorial

 

 

Shutdown
The Shutdown method is a method that will cleanly end a users session within a program that was using the AutoCount Accounting assembly. Hence please call the Shutdown method once in your code when you wish to end such sessions. Call this method especially when you have used the two Startup methods discussed previously. Below is an example on how to call the method:
Code Snippet

public class MainEntry

{

    static void Main()

    {

        // Here you must provide a dbSetting which points to your AutoCount Accounting database.

        DBSetting dbSetting = newDBSetting(DBServerType.SQL2000, @”(local)\A2006″“sa”“saPassword”“AED_MOBILE”);

 

         // Call the startup method SubProjectStartup to begin initialization

        BCE.AutoCount.MainEntry.Startup.Default.SubProjectStartup(dbSetting);

 

        try

        {

            /*

             * Put the UI and logic component to handle the user input for the user id and password here

             */

 

            // use the provided login details to login, if the login failed exit the program

            // modify this portion of the example to add warning message rather than just exiting.

            if (!BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(dbSetting).Login(“userID”“password”))

                return;

 

             /*

             * Execute the logic you wish to work on here

             */

        }

        finally

        {

            BCE.AutoCount.MainEntry.Startup.Default.Shutdown();

        }

    }

}