New search for sales order AlternateInventorySearch  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

New search for sales order AlternateInventorySearch

Postby DannyC » Fri Apr 16, 2021 5:48 pm

I've got a client who has added notes in the inventory alternate-children.
When their entered item is out of stock & the alternative inventory search displays they want to include the notes in the returned rows.

I can't work out how to read the passed-in inventoryid from my searchObject.

(VB!)
Code: Select all
Dim searchObject As JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch = DirectCast(sender, JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.clsSearch)


I know the filter is 38 but from there I need some guidance.
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: New search for sales order AlternateInventorySearch  Topic is solved

Postby SBarnes » Fri Apr 16, 2021 8:37 pm

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests