Hi,
I'd like to have a Text in the report to be filled out by the name of an "enum" if I know the ID (pseudo code: CURRENCY[VOUCHER.CURRENCY_ID].ABBREVIATION, where CURRENCY_ID is the primary key of CURRENCY).
How is this best done?
Thanks,
Peter
How to do lookup?
-
- Posts: 18
- Joined: Tue Jun 26, 2007 8:04 am
- Location: Hungary
-
- Posts: 18
- Joined: Tue Jun 26, 2007 8:04 am
- Location: Hungary
How to do lookup?
What I figured out is this: {CURRENCY.DataTable.Rows.Find(VOUCHER.CURRENCY_ID)["ABBREVIATION"]}
Is there anything better?
Is there anything better?
How to do lookup?
So we have two DataSources in report. Here they are:Peter wrote:I'd like to have a Text in the report to be filled out by the name of an "enum" if I know the ID (pseudo code: CURRENCY[VOUCHER.CURRENCY_ID].ABBREVIATION, where CURRENCY_ID is the primary key of CURRENCY).
CURRENCY with CURRENCY_ID filed as a primary key
and
VOUCHER with CURRENCY_ID field as a primary key
The simplest way to connect these two tables is to create a relation between them.
Parent: CURRENCY (as I understand it is a dictionary for currencies)
Child: VOUCHER (here you need to show the ABBREVIATION for each Currency)
When the DataSource is connected with a DataBand (in our case it is VOUCHER DataSource) then the scrolling is done from record to record automatically. But you also can find a record you need manually via
DataSource.Next() or
DataSource.Prior() methods.
The relation for VOUCHER will point to record you need from the Detail (Currency.ABBREVIATION) datasource automatically.
In report you refer such fields via relation directly:
{CURRENCY.VOUCHER_Relation_Name.ABBREVIATION}
Thank you.
-
- Posts: 18
- Joined: Tue Jun 26, 2007 8:04 am
- Location: Hungary
How to do lookup?
Edward,
Thanks for the reply. I ended up using the following function:
This way the code is quite clean and self-explanatory. One may define additional overloaded versions, if their key is not string (e.g. decimal, etc.), or use .ToString() accordingly.
Cheers,
Peter
Thanks for the reply. I ended up using the following function:
Code: Select all
public System.String Lookup(string key, Stimulsoft.Report.Dictionary.StiDataTableSource ds, string valueCol)
{
try
{
return ds.DataTable.Rows.Find(key)[valueCol].ToString();
}
catch
{
return "";
}
}
Cheers,
Peter
How to do lookup?
It is really smart solution for your task.
Thank you.
Thank you.