Loading
Uniconta
Search
Generic filters
Free trial signup
  • Visit a Country Site
    • Dansk
    • Deutsch
    • Eesti
    • Íslenska
    • Lietuvis
    • Nederlands
    • Norsk
    • English
  • Search
  • Uniconta
    • What is Uniconta ?
    • Modules
    • Ledger
    • Customer
    • Sales Order
    • Vendor
    • Purchase
    • Inventory
    • Logistics
    • Project
    • Light Manufacturing
    • CRM
    • Fixed assets
    • Dashboard
    • Company
    • Adaptability
  • Download
    • Uniconta for Windows
    • Uniconta for Mac
    • Download for Developers
    • Free trial signup
  • Resellers
    • Find a reseller
    • Become a reseller
    • Partner Portal Login
    • Partner Portal sign up
  • Developers
    • Become an integration partner
    • Documentation
    • Samples
    • Downloads
  • Accountants
    • Become a Univisor
  • News Overview
    • Blog
    • News
    • Uniconta Update
    • Customer cases
  • About us
    • About us
      • Management
      • Contact
      • IT Security ISAE 3402
      • System status
    • Terms & Conditions
      • License Agreement
      • Data Processing Agreement (DPA)
      • Privacy policy
      • Cookie policy
      • Sub-processors

Developers Unipedia

  • API
    • API
    • User defined fields
    • User defined tables
    • Saving a Session
    • Posting an Invoice
    • Post Invoice and get PDF
    • Localization
    • Attach physical voucher to entities
    • Server-Login User
    • How to find C# Property from Uniconta Label
    • Minimize network traffic and optimize speed
  • Plugins
    • Plugins
    • Debug Uniconta Plugins
    • Refreshing UI with plugins
    • How to use Uniconta Plugin
    • Develop a user plugin
    • Event Handling
    • Global Script
    • How to capture menu events
    • How to open a form in Uniconta from Plugin
    • Open new content in a IContentPluginBase plugin
    • Adding plugin in a menu
    • How to add user parameter in plugin menu
    • How to create plugin with Devexpress Library
    • Synchronize Entity Support in form page
    • Develop a PageEventBase Plugin
    • Logging Exceptions on local machine
    • Create Custom Uniconta Pages From Github Code
  • OData
    • CRUD operations in OData
    • ODATA REST API – Testing with Postman

Develop a PageEventBase Plugin

640 778 April 11th, 2018 January 7th, 2021
Print Friendly, PDF & Email

PageEventBase plugin is a part of Uniconta Windows API. It can be found under Uniconta.WindowsAPI.PageEventBase.cs. For performing some work on inserting, updating, deleting, validating, on property change of a record on gridbase page, create a new plugin by extending PageEventBase.cs class and overriding virtual methods described in below code snippet.

//Summary
// The abstract class PageEventsBase to be inherited for creating PageEventBase Plugin dll
//Summary
public abstract class PageEventsBase
{
    public CrudAPI api;
    public UnicontaBaseEntity master;
    public object page;

    //summary
    // PageEventsBase constructor
    //summary
    public PageEventsBase()
    {
    }

    //summary
    // Variable _LastError
    //summary
    protected string _LastError;

    //summary
    // The GetLastError method to get last error
    //summary
    public string GetLastError { get { var s = _LastError; _LastError = null; return s; } }


    //summary
    // The Initialize method to set local variables
    //summary
    //Params object page :- to pass the page object
    //Params CrudAPI api :- to pass the api
    //Params UnicontaBaseEntity master :- to pass the master
    public void Initialize(object page, CrudAPI api, UnicontaBaseEntity master)
    {
        this.page = page;
        this.api = api;
        this.master = master;
    }

    //summary
    // Virtual method Init to initialize values
    //summary
    //Params object page :- to pass the page object
    //Params CrudAPI api :- to pass the api
    //Params UnicontaBaseEntity master :- to pass the master
    public virtual void Init(object page, CrudAPI api, UnicontaBaseEntity master)
    {
        this.page = page;
        this.api = api;
        this.master = master;
    }

    //summary
    // Virtual method Validate, when record is validated
    //summary
    //Params UnicontaBaseEntity record :- to pass the record
    public virtual ErrorCodes Validate(UnicontaBaseEntity record) { return 0; }

    //summary
    // Virtual method OnInsert, when record is inserted
    //summary
    //Params UnicontaBaseEntity record :- to pass the insterted record
    public virtual ErrorCodes OnInsert(UnicontaBaseEntity record) { return 0; }

    //summary
    // Virtual method OnUpdate, when record is updated
    //summary
    //Params UnicontaBaseEntity record :- to pass the updated record
    //Params UnicontaBaseEntity original :- to pass the original record
    public virtual ErrorCodes OnUpdate(UnicontaBaseEntity record, UnicontaBaseEntity original) { return 0; }

    //summary
    // Virtual method OnDelete, when record is deleted
    //summary
    //Params UnicontaBaseEntity record :- to pass the deleted record
    public virtual ErrorCodes OnDelete(UnicontaBaseEntity record) { return 0; }

    //summary
    // Virtual SelectedRowChanged, when selected row of grid is changed
    //summary
    public virtual void SelectedRowChanged(SelectedItemChangedArgs e)
    {
    }

    //summary
    // Virtual event Record_PropertyChanged, when property value is changed
    //summary
    public virtual void Record_PropertyChanged(object sender, PropertyChangedEventArgs e)
    {
    }

    //summary
    // Virtual method OnMenuClickedClicked, when local menu is clicked
    //summary
    //Params string ActionType :- to pass the local ribbon menu action type string
    [Obsolete("Use OnMenuItemClicked function instead. It will be removed in future versions")]
    public virtual bool OnMenuClickedClicked(string ActionType)
    {
        return true;
    }

    //summary
    // Virtual method OnMenuItemClicked, when local menu is clicked
    //summary
    //Params string ActionType :- to pass the local ribbon menu action type string
    //Params object sender :- to pass the local menu ribbon item
    public virtual bool OnMenuItemClicked(string ActionType, object sender)
    {
        return true;
    }

    //summary
    // Virtual method OnMenuItemClicked, when local menu is clicked
    //summary
    //Params string ActionType :- to pass the local ribbon menu action type string
    //Params object sender :- to pass the local menu ribbon item
    public virtual bool OnMenuItemClicked(string ActionType, object sender, object args)
    {
        return true;
    }

    //summary
    // Virtual method PageClosing, when page is closed
    //summary
    public virtual void PageClosing()
    {
    }

    //summary
    // Virtual method CheckMandatoryFields, when madatory fields are validated
    //summary
    //Params UnicontaBaseEntity record :- to pass the record
    public virtual string CheckMandatoryFields(UnicontaBaseEntity record)
    {
        return null;
    }

    //summary
    // Trace method, for opening trace window
    //summary
    //Params string msg :- to pass message for tracing
    public void Trace(string msg)
    {
        var traceFunction = this.page?.GetType().GetMethod("Trace");
        traceFunction?.Invoke(this.page, new object[] { msg });
    }

    //summary
    // ShowMessageBox method, for showing messagebox
    //summary
    //Params string msg :- to pass message
    //Params string caption :- to pass caption
    //Returns MessageBoxResult;
    public MessageBoxResult ShowMessageBox(string msg, string caption)
    {
        return MessageBox.Show(msg, caption, MessageBoxButton.OK);
    }
}

Handling menu events

Menu events can be handled on the basis of ActionType

For example: To restrict adding or deleting row on certain conditions, user can handle onMenuItemClicked  event like this:

public override bool OnMenuItemClicked(string ActionType, object sender, object arguments)
{
	if (ActionType == "PreAddRow" || ActionType == "PreDeleteRow")
	return false;
	return true;
}

Installing a PageEventsBase plugin

  1. Similarly to other plugins, put the .dll file into the C:\Uniconta\PluginPath folder.
  2. Go to Tools-> Menus-> User Plugin, then add UserPlugin, specify the name of the plugin, select control name on which plugin will work, select PageEventBasePlugin by clicking on ‘+’ button if it is a partner plugin, otherwise just type in the name of the .dll file. Specify the class name inheriting PageEventBase class. Lastly, remember to tick the Control script check box.

Categories: Developers Unipedia, Plugins

Get in touch with us

Uniconta

  • Uniconta
  • Modules
  • Downloads
  • Free trial signup
  • Subscription Terms
  • System Status

PARTNER

  • Become a Reseller
  • Become App Partner
  • For Developers
  • For Accountants (Univisor)
  • Uniconta Partner Portal

INFO

  • News
  • Updates
  • Customer cases
  • Video
  • IT Security
  • About us
  • Management

Support

  • Unipedia
  • API information
  • Contacts
  • Visit a Country Site
    • Dansk
    • Deutsch
    • Eesti
    • Íslenska
    • Lietuvis
    • Nederlands
    • Norsk
    • English
Uniconta
© Copyright 2019 | All rights reserved | info@uniconta.com | Terms & Conditions
Facebook Twitter LinkedIn Youtube