Page 1 of 1

System Settings

PostPosted: Fri Nov 06, 2015 4:12 pm
by neil.interactit
Hi guys,

A nice easy one (well, for you) ahead of the weekend.

I am able to add some system wide settings that I need via SQL INSERT statements ...
settings.PNG


I can use direct SQL queries to examine the settings, but it appears that there is business logic available for this ... I just can't nail the correct usage ...
Code: Select all
        Dim setting = New Setting()
        setting.ReadData("IDKey = 'LiveServerName'")

This doesn't work, and probably isn't even close! Could you set me straight?

Cheers,
Neil.

Re: System Settings  Topic is solved

PostPosted: Fri Nov 06, 2015 4:53 pm
by Scott.Pearce
Love me a nice tech question right before the weekend ;-)

There is a cached collection of settings hanging off the JiwaApplication.Manager.Instance.Database object. This is read in at logon time.

BUT

For reading and writing system settings you should make calls to:

Code: Select all
ReadSysData(ByVal Section As String, ByVal IDKey As String, Optional ByVal DefaultValue As Object = "") As Object


and

Code: Select all
SaveSysData(ByVal Section As String, ByVal IDKey As String, ByVal Contents As Object, Optional ByVal Description As String = "", Optional ByVal DisplayOrder As Decimal = -255, Optional ByVal WriteHandle As Integer = -1)


These functions live at JiwaFinancials.Jiwa.JiwaApplication.Instance.Database also. The functions load and save settings to the database, but also refresh the in-memory cache.

Re: System Settings

PostPosted: Fri Nov 06, 2015 4:55 pm
by Scott.Pearce
Further, the ReadSysData() function will go for the cache first, then the database. So I advise using that rather than walking through the JiwaApplication.Manager.Instance.Database.SystemSettings collection. Just as efficient.

Re: System Settings

PostPosted: Tue Nov 10, 2015 9:53 am
by neil.interactit
Sweet! Looks easy.

What assembly (and namespace) is ReadSysData in? My compiler isn't resolving it. As an aside ... the search option on https://help.jiwa.com.au/Jiwa7/7.00.115 ... Index.html seems to have disappeared ... which would just allow me to go look for myself instead of asking here.

Cheers,
Neil.

Re: System Settings

PostPosted: Tue Nov 10, 2015 10:33 am
by Scott.Pearce
Reference JiwaApplication.dll and JiwaODBC.dll and you will find it at JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Database.ReadSysData

Re: System Settings

PostPosted: Tue Nov 10, 2015 10:47 am
by neil.interactit
Easy, thanks.

References were there ... gotta luv it when ReSharper lets you down finding the right namespace!

Re: System Settings

PostPosted: Tue Jan 05, 2016 5:24 pm
by DannyC
Hi,
Hoping I can jump onto this thread to ask a similar question.

In purchase orders, depending who the creditor is, I want to change the money decimal places to 4 (from 2). Using some clues from the above, so far I have
Code: Select all
   Sub PurchaseOrder_CreateEnd(sender As Object, e As System.EventArgs)
      Dim purchaseOrder As JiwaPurchaseOrders.PurchaseOrder = DirectCast(sender, JiwaPurchaseOrders.PurchaseOrder)
      If purchaseOrder.Creditor.AccountNo = "5647" Then
         JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Database.ReadSysData("System","MoneyDecimalPlaces",4)
      End If
   End Sub

but it doesn't do anything.

I've also tried SaveSysData which does update the database (which I don't want) but it still doesn't change the PO money decimals.
Do I need to somehow refresh the PO with the new system value or is there a better way to do it?

Cheers

Re: System Settings

PostPosted: Tue Jan 05, 2016 8:17 pm
by Mike.Sheen
DannyC wrote:
In purchase orders, depending who the creditor is, I want to change the money decimal places to 4 (from 2). Using some clues from the above, so far I have
Code: Select all
   Sub PurchaseOrder_CreateEnd(sender As Object, e As System.EventArgs)
      Dim purchaseOrder As JiwaPurchaseOrders.PurchaseOrder = DirectCast(sender, JiwaPurchaseOrders.PurchaseOrder)
      If purchaseOrder.Creditor.AccountNo = "5647" Then
         JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Database.ReadSysData("System","MoneyDecimalPlaces",4)
      End If
   End Sub

but it doesn't do anything.

I've also tried SaveSysData which does update the database (which I don't want) but it still doesn't change the PO money decimals.
Do I need to somehow refresh the PO with the new system value or is there a better way to do it?

Cheers


The purchase order class, as most of our classes which deal with monetary values, has a property of the SystemSettings class to control this, in your case the purchaseOrder.SystemSettings class is instantiated and populated when the business logic is created, so you just need something like this:

Code: Select all
purchaseOrder.SystemSettings.MoneyDecimalPlaces = 4


Once you set it, however, it stays that way for the life of the business logic. You should hook into the readend and creatend events and set it selectively - use the ReadSysData method to set it to the value stored in the system setting, or just set the value conditionally as above.

Hope that helps.

Mike

Re: System Settings

PostPosted: Wed Jan 06, 2016 11:37 am
by DannyC
Thx Mike.
All sweet now.

Appreciate the fast response!

Cheers