To add to this, if you're like me and don't like bundling all your logic for the handlers as delegate functions within the Setup method, create a new method with the Plugin as a parameter, and invoke that from the delegate in Setup:
- Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;
salesOrderForm.SalesOrder.CreateEnd += delegate(object sender, System.EventArgs e)
{
SalesOrder_CreateEnd(sender, e, Plugin);
};
}
public void SalesOrder_CreateEnd(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)sender;
salesOrder.Manager.DisplayMessage(salesOrder.Client.Form, String.Format("This is Invoice No. '{0}' invoked from plugin '{1}'", salesOrder.InvoiceNo, Plugin.Name), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1);
}
This way you can still separate the logic into methods outside the Setup method, making it tidier and avoiding everything in one monolithic lump of code.