Difference between revisions of "How AutoCount Application Script Works"

From AutoCount Resource Center
Jump to navigation Jump to search
(Created page with "{{NavigateDeveloper|collapsed}} AutoCount Application Script provides flexibility and expandability for programmers to enhance application's (AutoCount Accounting) calculati...")
 
Line 20: Line 20:
 
*Which then '''statement (scripting)''' in '''OnNewDocument''' event method can be executed;<br />In this example, a message ''"Hello AutoCount Application Script"'' is prompted, when OnNewDocument is fired.<br /><br />
 
*Which then '''statement (scripting)''' in '''OnNewDocument''' event method can be executed;<br />In this example, a message ''"Hello AutoCount Application Script"'' is prompted, when OnNewDocument is fired.<br /><br />
 
*In order for the application to fire OnNewDocument method, it requires:-
 
*In order for the application to fire OnNewDocument method, it requires:-
#The class that encapsulate OnNewDocument must be registered with correct '''script name''';<syntaxhighlight lang="csharp">BCE.AutoCount.Scripting.ScriptManager.GetOrCreate(dbSetting).RegisterByType("IV", typeof(InvoiceScript));</syntaxhighlight>
+
#The class that encapsulate OnNewDocument must be registered with correct '''script name''';<syntaxhighlight lang="csharp">BCE.AutoCount.Scripting.ScriptManager.GetOrCreate(dbSetting).RegisterByType("IV", typeof(InvoiceScript));</syntaxhighlight>The class '''InvoiceScript''' is registered with a script name of "IV", which the script name must be recognized in AutoCount Accounting.<br /><br />
#Name of the method must be identical to the name that has been defined in application (AutoCount Accounting);
+
#'''Name of the method''' such as OnNewDocument, must be identical to the name that has been defined in AutoCount Accounting.<br /><br />
#The '''signature''' of the method must be same as the Event Arguments that is created.<br \>The signature of OnNewDocument's Event Argument is '''BCE.AutoCount.Invoicing.Sales.Invoice.InvoiceEventArgs'''.<br />The Event Arguments holds necessary objects and properties that are passed from application.
+
#'''Argument''' of the method must be same as the Argument that is defined in the Event Method.<br \>The event method of OnNewDocument's Event Argument is '''BCE.AutoCount.Invoicing.Sales.Invoice.InvoiceEventArgs'''.<br />The Event Arguments holds necessary objects and properties that are passed from application.
  
 
  The above 3 requirements can be found in [[DeveloperDownload#Application Script Template|'''Application Script Template''']] that has been compiled in Microsoft Visual Studio Project.
 
  The above 3 requirements can be found in [[DeveloperDownload#Application Script Template|'''Application Script Template''']] that has been compiled in Microsoft Visual Studio Project.
 
  
 
[[Category:Developers]]
 
[[Category:Developers]]
 
[[Category:Tutorials]]
 
[[Category:Tutorials]]
 
[[Category:AppScript]]
 
[[Category:AppScript]]

Revision as of 03:34, 2 October 2017

Go to menu

IconAC81.png Go to top
ProgrammerGo.jpg Resources For AutoCount Software Developers


AutoCount Application Script provides flexibility and expandability for programmers to enhance application's (AutoCount Accounting) calculation, accessible, layout and etc. at runtime.
How Application Script works?
When a specific action is called in the application, it fires events call. Method that is matching the method's name and signature of the event will be fired.


Example of OnNewDocument event method

Take OnNewDocument for example.

public void OnNewDocument(BCE.AutoCount.Invoicing.Sales.Invoice.InvoiceEventArgs e)
{
    BCE.Application.AppMessage.ShowMessage("Hello AutoCount Application Script");
}
  • OnNewDocument event method is fired when the application opens a new document.

  • Which then statement (scripting) in OnNewDocument event method can be executed;
    In this example, a message "Hello AutoCount Application Script" is prompted, when OnNewDocument is fired.

  • In order for the application to fire OnNewDocument method, it requires:-
  1. The class that encapsulate OnNewDocument must be registered with correct script name;
    BCE.AutoCount.Scripting.ScriptManager.GetOrCreate(dbSetting).RegisterByType("IV", typeof(InvoiceScript));
    
    The class InvoiceScript is registered with a script name of "IV", which the script name must be recognized in AutoCount Accounting.

  2. Name of the method such as OnNewDocument, must be identical to the name that has been defined in AutoCount Accounting.

  3. Argument of the method must be same as the Argument that is defined in the Event Method.
    The event method of OnNewDocument's Event Argument is BCE.AutoCount.Invoicing.Sales.Invoice.InvoiceEventArgs.
    The Event Arguments holds necessary objects and properties that are passed from application.
The above 3 requirements can be found in Application Script Template that has been compiled in Microsoft Visual Studio Project.