by Mike.Sheen » Mon Jan 30, 2017 11:10 am
Hi Danny,
You just need to add a handler to each Cost Centre's stage collection - do this on when the job is read, and when a cost centre is added:
- Code: Select all
Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
JobCostForm = JiwaForm
AddHandler JobCostForm.Job.Read, AddressOf JobReadEnd
AddHandler JobCostForm.Job.CostCentres.Added, AddressOf CostCentreAdded
End Sub
Private Sub JobReadEnd()
For Each costCentre As JiwaJobCosting.CostCentre In JobCostForm.Job.CostCentres
AddHandler costCentre.Stages.Added, AddressOf StageAdded
Next
End Sub
Private Sub CostCentreAdded(CostCentre As JiwaJobCosting.CostCentre)
' Add a handler for the stage added event
AddHandler CostCentre.Stages.Added, AddressOf StageAdded
End Sub
Private Sub StageAdded(Stage As JiwaJobCosting.Stage)
JiwaApplication.Manager.DisplayMessage(JobCostForm, String.Format("Stage '{0}' was added to Cost Centre '{1}'", Stage.Stage.Name, Stage.Stages.CostCentre.CostCentre.Name), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1)
End Sub
Attached is a sample plugin demonstrating this (in VB.NET which I assumed you would have preferred).
- Attachments
-
- Plugin Job Costing Stage Added.xml
- Sample Plugin
- (33.56 KiB) Downloaded 113 times
Mike Sheen
Chief Software Engineer
Jiwa Financials
If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution