AyaNova service management & work order software
AyaNova Support Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        


Scripts to display custom field as currency,... Expand / Collapse
Author
Message
Posted 11/10/2006 8:08:54 AM
AyaNova Sales & Support

AyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & Support

Group: Administrators
Last Login: 2 days ago @ 7:58:18 AM
Posts: 1,851, Visits: 4,300
Here is a custom sample report template that provides some different types of scripting. This custom report template is based on a collaboration between myself and an Electrician company that uses AyaNova.

One script is based on the AyaNova v3 Manual tutorial "Converting a custom field to display as a currency value" starting page 696

Sample Parts Custom To Currency and Blanks

This report template includes scripts to display a custom currency field as currency in a report template, and also includes scripts to not display fields that have a price of $0.00 (a suggestion for possible use - so that the user can manually pencil in the amounts to enter at a later time on the printed copy). Parts display grouped by Category, with a new category starting a new page.

This report template, once imported, would be availalbe from the Parts grid in the INventory navigation pane.

This report assumes that you have enabled the following custom fields for the Part entry screen

  • Custom0 as a text field
  • Custom1 as a text field
  • Custom3 as a currency field

Because Custom3 is a custom field - it by default always displays in a report as a string (as text) even though in the Custom field editor you have selected currency. This is because as it is possible for you to easily change the currency format to a different format, the data in the custom field has to be saved in the database as a string.

When you want to display a custom field in a report, it will therefore by default always display as a string.

Selecting a FormatString for a custom field will not apply the format, because the string property won't accept it.

You have to enter a script to change the data from a string to a decimal, and than have that decimal display formated for currency.

To do this we open the Properties tab for the field (in this case xrLabel12), expand Scripts and open the OnBeforePrint script to edit

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{

//this gets the value of the custom field, and displays it in field xrLabel12 in currency format
decimal d;
decimal.TryParse(DetailReport.GetCurrentColumnValue("LT_Part_Label_Custom3").ToString(),out d);
xrLabel12.Text= d.ToString("c");

//this states that if the Custom3 is empty (whichis ""), to set the field xrLabel12 to not be visible
xrLabel12.Visible=(""!=(DetailReport.GetCurrentColumnValue("LT_Part_Label_Custom3").ToString()));

}

Note the second part of the script - which sets that if the datafield for Custom3 is empty "", the Visible property of the field xrLabel12 = false - which means xrLabel12 won't be visible.

Now open the Properties tab for the xrLabel13 field (Cost), expand the Scripts, and open the OnBeforePrint script

Because Cost is saved within the database as a number, this script actually specifically states if not equal to 0

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{

//this states that if the Cost is 0, to set the field xrLabel13 to not be visible
xrLabel13.Visible=(0!=decimal.Parse(DetailReport.GetCurrentColumnValue("LT_Part_Label_Cost").ToString()));

}

Same also with the OnBeforePrint script for xrLabel14 (Retail)


This report template is grouped by the Part Category. To do this, select the GroupHEader1 band, and select Properties.
Now select the GroupFields property, and open the Collection
You will see that there is one GroupField set up - which is the LT_O_PartCategory in a descending SortORder

And as this report template also wants a new grouping to start on a new page, the PageBreak property is set to BeforeBand, so that a new group starts on a new page.


Again, with all sample report templates, I encourage you to customize further, editing to your needs - or use to refer to when customizing and creating your own.

AyaNova Sales & Technical Support
http://www.ayanova.com
Post #2260
Posted 12/8/2006 6:40:48 PM
AyaNova Sales & Support

AyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & SupportAyaNova Sales & Support

Group: Administrators
Last Login: 2 days ago @ 7:58:18 AM
Posts: 1,851, Visits: 4,300
The above download sample report template Sample Custom To Currency and Blanks on this date has been replaced so that it will be compliant with the new version of the printing design and engine component that we will be releasing with the next maintenance update of AyaNova guess-timated to be released late Dec / early Janurary.

If you had previously downloaded the sample report template above, do remove it (via Administration -> Report Templates) and download this new replacement via  Sample Custom To Currency and Blanks 

AyaNova Sales & Technical Support
http://www.ayanova.com
Post #2419
« Prev Topic | Next Topic »

Reading This Topic Expand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: AyaNova Sales & Support

Permissions Expand / Collapse

All times are GMT -8:00, Time now is 7:56am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.078. 13 queries. Compression Disabled.