Method inside method !

Stimulsoft Reports.WEB discussion
Post Reply
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Method inside method !

Post by m.issa »

Hello

is it possible to use method inside method in stimulsoft?

In my TextBox component in the group footer, i will take the sum of numbers and convert it to Hours:Minutes:seconds, the sum method is built in stimulsoft and i created method to convert this double numbers into Hours:Minutes:Seconds, but how i can use both method in the same step inside the expression of the TextBox component?

Note: as i said i use this TextBox component in the GroupFooterBand

i tried in the expression of the TextBox component as the following but it did not work:
{IntToTime({Sum(ViewEmpSummary.SsmBeginEarly)})}

As i said i created method for IntToTime in the code page inside my report as the following:

Code: Select all

   public string IntToTime (double seconds )
		{
			string fullTime;
			
			TimeSpan ts = TimeSpan.FromSeconds(seconds);
			fullTime = ts.Hours.ToString() + ":" + ts.Minutes.ToString() + ":" + ts.Seconds;
			
			return fullTime;  
		}

please find the report in the attachment.

Thank you
Attachments
LateAndEarlyCome.mrt
(46.04 KiB) Downloaded 228 times
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Method inside method !

Post by Alex K. »

Hello,

Please try to use the following expression:

Code: Select all

{IntToTime(Sum(ViewEmpSummary.SsmBeginEarly))}
Thank you.
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: Method inside method !

Post by m.issa »

Hello

i changed my method as the following:

Code: Select all

public string IntToTime(decimal seconds )
		{
			string fullTime;
			double doubleSum = Convert.ToDouble(seconds);
			
			TimeSpan ts = TimeSpan.FromSeconds(doubleSum);
			fullTime = ts.Hours.ToString() + ":" + ts.Minutes.ToString() + ":" + ts.Seconds;
			
			return fullTime;  
		}
then i rewrite the following code inside the TextBox Component :

Code: Select all

{IntToTime(Sum(ViewEmpSummary.SsmBeginEarly))}
but when i run the report the following error generated:

The error of compilation is found in the 'Report' report:
'Stimulsoft.Report.StiReport.Convert(Stimulsoft.Report.Units.StiUnit, Stimulsoft.Report.Units.StiUnit)' is a 'method', which is not valid in the given context
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Method inside method !

Post by Alex K. »

Hello,

Please try to use the following code in your method:

Code: Select all

double doubleSum = System.Convert.ToDouble(seconds);
or

Code: Select all

double doubleSum = (double)seconds;
Thank you.
m.issa
Posts: 27
Joined: Tue Sep 04, 2012 8:08 am

Re: Method inside method !

Post by m.issa »

Hello

this is work for me:
double doubleSum = System.Convert.ToDouble(seconds);

Thanks a lot
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Method inside method !

Post by Alex K. »

Hello,

We are always glad to help you!
Let us know if you need any additional help.

Thank you.
Post Reply