Page 1 of 1

PO Shipping Address Spare Fields

PostPosted: Wed Nov 20, 2019 12:17 pm
by pricerc
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?

Re: PO Shipping Address Spare Fields  Topic is solved

PostPosted: Wed Nov 20, 2019 12:33 pm
by pricerc
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


Re: PO Shipping Address Spare Fields

PostPosted: Wed Nov 20, 2019 12:36 pm
by Scott.Pearce
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;
}