Modifying sales order line item lookup  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Modifying sales order line item lookup

Postby sh_jackland » Mon Oct 24, 2022 7:10 pm

I am trying to make a plugin which modifies how the sales order Part No lookup works. More specifically, I want to change what happens when a Part No doesn't exist.

My idea on how to do this is to find where this lookup code is running and override it.

From what I can see, the lookup is run by an event in grdLines.PartNo which triggers when focus is lost.
The problem I'm having is that grdLines.PartNo is a JiwaTextCellType and I can't see any events which do this.

This is the approach I'm currently taking
Code: Select all
public class FormPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaFormPlugin
{
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
        if (JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
        {
            var salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;


            salesOrderForm.SalesOrder.ReadEnd += delegate (object sender, EventArgs args)
            {
                SalesOrder_ReadEnd(salesOrderForm);
            };
        }
    }

    private void SalesOrder_ReadEnd(JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesOrderForm)
    {
        for (int row = 0; row < salesOrderForm.grdLines.ActiveSheet.RowCount; row++)
        {
            var cellPartNo = (JiwaFinancials.Jiwa.JiwaApplication.JiwaManageGrid.JiwaTextCellType)salesOrderForm.grdLines.ActiveSheet.Cells[row, 1].CellType;

            //insert code changing lookup
        }

    }
}
sh_jackland
I'm new here
I'm new here
 
Posts: 7
Joined: Thu Oct 06, 2022 12:18 pm
Topics Solved: 1

Re: Modifying sales order line item lookup  Topic is solved

Postby SBarnes » Tue Oct 25, 2022 6:36 am

If I am following what you are trying to do the following code in a form plugin will do what you want make sure you add JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm under the forms tab, the ClientCancelledException will stop Jiwa executing its own code as if the user had stopped things

Code: Select all
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      if(JiwaForm is JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
      {
         JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm sform = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;
         sform.FormDoPartNoSearchBefore += FormDoPartNoSearchBefore;
      }
    }
   
   
   private void FormDoPartNoSearchBefore(object sender , ref string SearchText, ref string FilterSQL, ref bool AllowMultiSelect)
   {
      System.Windows.Forms.MessageBox.Show("Now I have taken over");
      throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
   }



If you want to capture any entry into the part no column you need to attach to grdLines on the form's charge event the signature of which is below, this needs to go in the SetupBeforeHandlers which gets you in ahead of Jiwa's code, you would also need the same exception as above to stop Jiwa.

Code: Select all
grdLines_Change(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.ChangeEventArgs)


and then try

Code: Select all
Dim column As FarPoint.Win.Spread.Column = grdLines.ActiveSheet.Columns(e.Column)
                    Dim ColID As String = column.Tag


to see if CoLID equals "PartNo"
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Modifying sales order line item lookup

Postby sh_jackland » Tue Oct 25, 2022 3:17 pm

Yes that first code snippet is exactly what I was looking for. Thank you.
sh_jackland
I'm new here
I'm new here
 
Posts: 7
Joined: Thu Oct 06, 2022 12:18 pm
Topics Solved: 1


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 24 guests

cron