Change Back Colour Sales order Form  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Change Back Colour Sales order Form

Postby Sunny » Thu May 28, 2015 12:14 pm

There is a requirement that the Sales Order Form colour should turn red if a Credit is being raised.
The following code gives a "Object reference not set to an instance of an object. Module:SalesOrder_Created"
Could you help please?
Thanks !
Code: Select all
Public Class FormPlugin
    Inherits System.MarshalByRefObject
    Implements JiwaApplication.IJiwaFormPlugin   
   Private salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm
   
    Public Overrides Function InitializeLifetimeService() As Object
        ' returning null here will prevent the lease manager
        ' from deleting the Object.
        Return Nothing
    End Function

    Public Sub SetupBeforeHandlers(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.SetupBeforeHandlers
    End Sub

    Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = DirectCast(JiwaForm, JiwaSalesUI.SalesOrder.SalesOrderEntryForm)
      
      AddHandler salesOrderForm.SalesOrder.Created, AddressOf SalesOrder_Created
    End Sub
   Public Sub SalesOrder_Created(sender As Object, e As System.EventArgs, ByVal NewSalesOrderType As JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes, ByRef SourceQuoteObject As JiwaSales.SalesQuote.SalesQuote)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)   
      If salesOrder.CreditNote Then
         msgbox ("Cr Note")
         salesOrderForm.BackColor= System.Drawing.Color.Red               
      Else
         msgbox ("NOT Cr Note")
      End If   
   End Sub
'   
End Class
Sunny
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon May 11, 2015 1:38 pm
Topics Solved: 2

Re: Change Back Colour Sales order Form

Postby Scott.Pearce » Thu May 28, 2015 12:17 pm

The error would be being caused by the line:

Code: Select all
salesOrderForm.BackColor= System.Drawing.Color.Red   


In the SalesOrder_Created function, where is the variable salesOrderForm coming from?
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

Re: Change Back Colour Sales order Form

Postby Sunny » Thu May 28, 2015 12:34 pm

You are right Scott. That's the "crucial" :), statement I'm struggling with.
As can be seen in the code, I have declared "Private salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm"
I have also tried declaring within the
SalesOrder_Created function as below with the same error:
Code: Select all
   Public Sub SalesOrder_Created(sender As Object, e As System.EventArgs, ByVal NewSalesOrderType As JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes, ByRef SourceQuoteObject As JiwaSales.SalesQuote.SalesQuote)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm
      If salesOrder.CreditNote Then
         msgbox ("Cr Note")
         salesOrderForm.BackColor= System.Drawing.Color.Red               
      Else
         msgbox ("NOT Cr Note")
      End If   
   End Sub
Sunny
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon May 11, 2015 1:38 pm
Topics Solved: 2

Re: Change Back Colour Sales order Form

Postby Scott.Pearce » Thu May 28, 2015 12:37 pm

Declaring it isn't going to do anything. You need to set it.

Code: Select all
 Public Sub SalesOrder_Created(sender As Object, e As System.EventArgs, ByVal NewSalesOrderType As JiwaSales.SalesOrder.SalesOrder.NewSalesOrderTypes, ByRef SourceQuoteObject As JiwaSales.SalesQuote.SalesQuote)
      Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = DirectCast(sender, JiwaSales.SalesOrder.SalesOrder)
      Dim salesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm = salesOrder.Client
      If salesOrder.CreditNote Then
         msgbox ("Cr Note")
         salesOrderForm.BackColor= System.Drawing.Color.Red               
      Else
         msgbox ("NOT Cr Note")
      End If   
   End Sub


We slip the form object into a property of the business logic (.client). Comes in handy at times like this.
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

Re: Change Back Colour Sales order Form

Postby Sunny » Thu May 28, 2015 4:19 pm

Thanks for that Scott- that worked, though not exactly as I wanted it to. The
Code: Select all
salesOrderForm.BackColor= System.Drawing.Color.Red

does not seem to anything. The form is not visible because of the controls on it?
When I put in .ForeColor, it makes all the labels, red, though not the form itself (at least we got somewhere!)
The code
Code: Select all
salesOrderForm.Panel2.BackColor= System.Drawing.Color.Red
salesOrderForm.Panel2.ForeColor= System.Drawing.Color.Red

does not seem to do anything either.
Any pointers will be appreciated.
Sunny
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon May 11, 2015 1:38 pm
Topics Solved: 2

Re: Change Back Colour Sales order Form  Topic is solved

Postby Scott.Pearce » Thu May 28, 2015 5:57 pm

It's because of the "Application Styling" that gets applied to everything. Every-time a form is loaded in Jiwa, an "Application Style" is applied - this affects the appearance of most of the controls used throughout Jiwa. I guess you could think of it as a style-sheet (css).

Anyway, I suspect that your settings are having no effect because the application style would override them. On each control you want to manipulate, have a look for a property called "UseAppStyling". Set this property to false, then apply your settings. Also note that *most* of the controls in Jiwa are Infragistics controls. These controls have an .Appearance property through which you can set colours, etc.

I've created a post at http://forums.jiwa.com.au/viewtopic.php?f=27&t=340 that should help.
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

Re: Change Back Colour Sales order Form

Postby Sunny » Fri May 29, 2015 10:58 am

Thanks for that Scott! :) Appreciate your time.
Sunny
Occasional Contributor
Occasional Contributor
 
Posts: 23
Joined: Mon May 11, 2015 1:38 pm
Topics Solved: 2

Re: Change Back Colour Sales order Form

Postby DannyC » Tue Oct 03, 2017 5:39 pm

Does the code in
viewtopic.php?f=27&t=340
still apply to version 7.1?

I ask because I have something similar working in version 7.0.175 (and prior) which sets the inventory colour based on the status
it uses the code
Code: Select all
inventoryForm.TableLayoutPanel1.BackColor = System.Drawing.Color.Red

but TableLayoutPanel1 doesn't exist in 7.1.
User avatar
DannyC
Senpai
Senpai
 
Posts: 636
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 30

Re: Change Back Colour Sales order Form

Postby Mike.Sheen » Sun Oct 08, 2017 2:30 pm

DannyC wrote:Does the code in
viewtopic.php?f=27&t=340
still apply to version 7.1?

I ask because I have something similar working in version 7.0.175 (and prior) which sets the inventory colour based on the status
it uses the code
Code: Select all
inventoryForm.TableLayoutPanel1.BackColor = System.Drawing.Color.Red

but TableLayoutPanel1 doesn't exist in 7.1.


Hi Danny,

Yes, it does work - have tested it in 7.1 and the only issue is when importing that plugin it references a JiwaSendMail assembly which no longer exists (emailing is now handled by plugins, so that assembly was retired a year or two ago) - after importing the plugin, just delete the bad reference from the Assembly references tab, save and away you go. Credit notes will display the header section in red.

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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 10 guests

cron