I had to do a similar thing for a hierarchical plugin on inventory categories, you can actually get the plugin from our mutual customer basically in the set up before handlers you get in front of Jiwa like this and use a delegate
- Code: Select all
public void SetupBeforeHandlers(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
if(JiwaForm is JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm)
{
JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm jform = (JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm)JiwaForm;
jform.Category2Lookup.ButtonClicked += delegate(object sender, System.EventArgs eventArgs) { Category2Lookup_ButtonClicked(sender, eventArgs, jform); };
jform.Category3Lookup.ButtonClicked += delegate(object sender, System.EventArgs eventArgs) { Category3Lookup_ButtonClicked(sender, eventArgs, jform); };
}
}
then you can have a handler like this
- Code: Select all
private void Category3Lookup_ButtonClicked(object sender, EventArgs e, JiwaFinancials.Jiwa.JiwaInventoryUI.InventoryMaintenanceForm iform)
{
if(!iform.Inventory.WebEnabled)
{
return;
}
if(iform.Inventory.Category2.RecID != "")
{
//System.Windows.Forms.MessageBox.Show("Got here");
string str;
Form ownerForm;
clsSearch search = iform.Manager.Search;
search.Clear();
search.FilterNo = 4003;
search.UsePinBoard = false;
search.Caption = "Category 3";
// search.SQLWhereCondition = " WHERE Category3ID in (select from vAttk_Cat2ToCat1 where category1 = '" + iform.Inventory.Category2.RecID + "') ";
clsSearch.SearchModes searchMode = clsSearch.SearchModes.jswInventoryCatagory3;
search.SetDefaultSearch(ref searchMode);
search.Options[1].SQLStr += " WHERE Category3ID in (select Category3ID from vAttk_Cat3ToCat2 where category2 = '" + iform.Inventory.Category2.RecID + "') ";
clsSearch _clsSearch = search;
ownerForm = iform;
if (_clsSearch.Show(ownerForm) != DialogResult.OK)
{
str = "";
}
else
{
if(search.Results.Count == 0)
{
str = "";
}
else
{
JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field field = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)_clsSearch.get_Fields(1);
str = field.FieldValue.ToString();
}
}
//System.Windows.Forms.MessageBox.Show(str);
if(str != null && str != "")
{
iform.Inventory.Category3.ReadRecord( str);
}
throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
}
}
The code you are looking to take over from in Jiwa is the grdAlternateChildren_ButtonClicked according to the disassembler is below
- Code: Select all
private void grdAlternateChildren_ButtonClicked(object sender, EditorNotifyEventArgs e)
{
string str = Conversions.ToString(this.grdAlternateChildren.ActiveSheet.Columns[e.Column].Tag);
int row = e.Row;
string str1 = Conversions.ToString(this.grdAlternateChildren["Key", row]);
if (str1.Trim().Length == 0)
{
if (Operators.CompareString(Strings.UCase(str), Strings.UCase("Lookup"), false) == 0)
{
AlternateChild alternateChild = this.Manager.CollectionItemFactory.CreateCollectionItem<AlternateChild>();
alternateChild.LinkedInventory.Search(this, string.Concat("IN_Main.InventoryID <> ", this.Manager.Database.FormatChar(this.Inventory.InventoryID)));
if (alternateChild.LinkedInventory.InventoryID != null)
{
this.Inventory.AlternateChildren.Add(alternateChild);
return;
}
}
}
else if (Operators.CompareString(Strings.UCase(str), Strings.UCase("Bin"), false) == 0)
{
this.Inventory.AlternateChildren.Remove(this.Inventory.AlternateChildren[str1]);
}
}
So basically in the before handler latch onto the grdAlternateChildren button clicked event with your own delegated handler that takes the form and go from there and replace the this references in the code with a reference to your form added through the delegate.
Make sure you add a client cancel exception to avoid Jiwa's event firing after yours.
You can write your own search with an sql like I did for the categories.