System Settings  Topic is solved

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

System Settings

Postby neil.interactit » Fri Nov 06, 2015 4:12 pm

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.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: System Settings  Topic is solved

Postby Scott.Pearce » Fri Nov 06, 2015 4:53 pm

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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: System Settings

Postby Scott.Pearce » Fri Nov 06, 2015 4:55 pm

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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: System Settings

Postby neil.interactit » Tue Nov 10, 2015 9:53 am

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.
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: System Settings

Postby Scott.Pearce » Tue Nov 10, 2015 10:33 am

Reference JiwaApplication.dll and JiwaODBC.dll and you will find it at JiwaFinancials.Jiwa.JiwaApplication.Manager.Instance.Database.ReadSysData
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: System Settings

Postby neil.interactit » Tue Nov 10, 2015 10:47 am

Easy, thanks.

References were there ... gotta luv it when ReSharper lets you down finding the right namespace!
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: System Settings

Postby DannyC » Tue Jan 05, 2016 5:24 pm

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
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: System Settings

Postby Mike.Sheen » Tue Jan 05, 2016 8:17 pm

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
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: System Settings

Postby DannyC » Wed Jan 06, 2016 11:37 am

Thx Mike.
All sweet now.

Appreciate the fast response!

Cheers
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests