C# syntax to instantiate sales order history  Topic is solved

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

C# syntax to instantiate sales order history

Postby DannyC » Mon Aug 27, 2018 3:50 pm

I need to get the first character of the delivery address.
It doesn't seem to be available from the salesorder object, so I figure I need to read the full history object, then get the postcode from that.

My code here is erroring when trying to assign the salesHist object
Code: Select all
    public void Setup(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm, JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
    {
      JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm salesOrderForm = (JiwaFinancials.Jiwa.JiwaSalesUI.SalesOrder.SalesOrderEntryForm)JiwaForm;
      salesOrderForm.SalesOrder.SalesOrderLineAdding += GetThePostcode;
    }
   
   public void GetThePostcode(object sender, System.EventArgs e, JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderLine item)
   {
      JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder salesOrder = (JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder) sender;
      JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderHistory salesHist = salesOrder.SalesOrderHistorys(salesOrder.CurrentHistoryNo);
      string StateCode = salesHist.PostCode.Substring(0,1);
   }

error is "non invocable member JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder.SalesOrderHistorys cannot be used like a method. "

What am I doing wrong?
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: C# syntax to instantiate sales order history  Topic is solved

Postby Scott.Pearce » Mon Aug 27, 2018 3:52 pm

c# uses [] instead of () when indexing into something. So change your line:

Code: Select all
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderHistory salesHist = salesOrder.SalesOrderHistorys(salesOrder.CurrentHistoryNo);


to:

Code: Select all
JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrderHistory salesHist = salesOrder.SalesOrderHistorys[salesOrder.CurrentHistoryNo];
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: C# syntax to instantiate sales order history

Postby DannyC » Mon Aug 27, 2018 3:58 pm

Oh man, ya kidding right? Something so simple yet cryptically silent when googling!
This C# is doing my head in...
User avatar
DannyC
Senpai
Senpai
 
Posts: 718
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 31

Re: C# syntax to instantiate sales order history

Postby Scott.Pearce » Mon Aug 27, 2018 4:00 pm

You'll get used to it in no time mate. c# is a lot stricter but it results in better code.
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: C# syntax to instantiate sales order history

Postby SBarnes » Tue Aug 28, 2018 7:28 am

Amen to that give me a strict type safe language any day as it means 80% of issues are found by the compiler rather than debugging which always takes longer.

Opening the Jiwa DLLs with Telerik Just Decompile and reading the code as C# is probably one of the quickest ways to become familiar with it.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests