PO Shipping Address Spare Fields  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

PO Shipping Address Spare Fields

Postby pricerc » Wed Nov 20, 2019 12:17 pm

So after reading https://forums.jiwa.com.au/viewtopic.php?f=26&t=375&hilit=shipping+address I put some similar code in my form.

Except then it doesn't populate.

So I take a look at ILSpy, and see this:
Code: Select all
public void DisplayShippingAddress()
{
   JiwaGrid shippingAddressJiwaGrid = ShippingAddressJiwaGrid;
   checked
   {
      int num = ShippingAddressJiwaGrid.ActiveSheet.RowCount - 1;
      for (int i = 0; i <= num; i++)
      {
string text = Conversions.ToString(shippingAddressJiwaGrid.get_GridText("Field", i));
         switch (<PrivateImplementationDetails>.ComputeStringHash(text))
         {
....
         case 2959222051u:
            if (Operators.CompareString(text, "Spare1", TextCompare: false) == 0)
            {
               shippingAddressJiwaGrid.set_GridText("Value", i, (object)_PurchaseOrder.ShippingAddress.Spare1);
            }
            break;
...
      }
      shippingAddressJiwaGrid = null;
   }
}



this suggests to me that if the text in the "Field" column isn't "Spare1", then it's not going to get the Spare1 value out of the ShippingAddress.

Any other suggestions?
Last edited by pricerc on Wed Nov 20, 2019 12:36 pm, edited 1 time in total.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: PO Shipping Address Spare Fields  Topic is solved

Postby pricerc » Wed Nov 20, 2019 12:33 pm

To answer my own question....


this works, but it is a bit clunky:

Code: Select all
       Private Sub PurchaseOrderForm_ReadEnd(sender As Object, e As EventArgs)
            Dim purchaseOrder = TryCast(sender, PurchaseOrder)
            If purchaseOrder Is Nothing Then Return

            Dim purchaseOrderForm As MainForm = TryCast(purchaseOrder.Client, MainForm)
            If purchaseOrderForm Is Nothing Then Return

'...
            purchaseOrderForm.ShippingAddressJiwaGrid.GridText("Value", 9) = purchaseOrder.ShippingAddress.Spare1
        End Sub

/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: PO Shipping Address Spare Fields

Postby Scott.Pearce » Wed Nov 20, 2019 12:36 pm

You are correct.

To work around this you could add handlers for these events:

PurchaseOrder.Read
PurchaseOrder.Created
PurchaseOrder.PropertyChanged (e.PropertyName == "ShippingAddress")
PurchaseOrder.Deserialized
PurchaseOrder.CopyEnd

The handlers should then call a function you write called DisplaySpareShippingAddressFields, and could look something like this:

Code: Select all
public void DisplaySpareShippingAddressFields(JiwaFinancials.Jiwa.JIwaApplication.Controls.JiwaGrid ShippingAddressGrid, JiwaFinancials.Jiwa.JiwaPurchaseOrder.PurchaseOrders PurchaseOrder)
{
    ShippingAddressGrid.GridText("Value", 9) = PurchaseOrder.ShippingAddress.Spare1;
}
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221


Return to Technical and or Programming

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron