The below in a form plugin is what you want, then do your check and if you need to show amessage to the user on error throw a JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException with your error message in the constructor, Jiwa will show the message and stop any further processing.
Also make sure you add the sales order form to the forms section of the plugin.
- Code: Select all
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{
public override object InitializeLifetimeService()
{
// returning null here will prevent the lease manager
// from deleting the Object.
return null;
}
public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
}
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)
{
//System.Diagnostics.Debugger.Launch();
//System.Diagnostics.Debugger.Break();
var salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.BaseSalesOrderEntryForm)JiwaForm;
salesOrderForm.SalesOrder.SalesOrderLineAdding += SalesOrderLines_Adding;
}
}
public void SalesOrderLines_Adding(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine Item)
{
}
}