Page 1 of 1

How to set Report Variable from Visual Studio code?

Posted: Fri Feb 12, 2016 3:39 pm
by jp2code
I've created a report file "D:\Sales\Report1.mrt" with multiple variables.
screenshot showing variables over on the RIGHT
screenshot showing variables over on the RIGHT
getgreenshot_org.jpg (373.7 KiB) Viewed 2344 times
How do I now go about setting one of these variables?

Code: Select all

public void ShowReport()
{
    using (var report = new StiReport())
    {
        report.Load(_reportPath);
        report.p_boolPrintAmounts = false; // this is wrong.
        report.Compile();
        report.Show();
    }
}
For example, how would I set the parameter `p_boolPrintAmounts` to false?

I have many variables that need to be set before compiling the report:

Code: Select all

private String _reportPath;

public Boolean DisplayAmountsTendered { get; set; }
public Boolean DisplayNegativeInvoicesOnly { get; set; }
public Boolean DisplayMargins { get; set; }
public Boolean DisplayMarkups { get; set; }
public Boolean DisplayProfits { get; set; }
public Boolean DisplayTaxCodesAndAmounts { get; set; }
public Boolean DisplayWebOrdersOnly { get; set; }
public Boolean DisplayZeroTaxInvoiceOnly { get; set; }
public Boolean FilterIsInclusive { get; set; }
public Boolean UseMarketCost { get; set; }
public Boolean UseMarkupCost { get; set; }
public DateTime FilterInvoiceDateBegin { get; set; }
public DateTime FilterInvoiceDateEnd { get; set; }
public ReportSortSequence ReportSort { get; set; }
public DisplayWhichCost WhichCost { get; set; }
public DisplayWhichFormat WhichFormat { get; set; }
public DisplayWhichInvoice WhichInvoice { get; set; }
public DisplayWhichSales WhichSales { get; set; }
public String FilterInvoiceNumberBegin { get; set; }
public String FilterInvoiceNumberEnd { get; set; }
public String OnlyDisplayTaxCode { get; set; }

Re: How to set Report Variable from Visual Studio code?

Posted: Tue Feb 16, 2016 5:56 am
by HighAley
Hello.

There are two different ways to change variable value.

One is to do it before compilation and other one to change value after compilation:

Code: Select all

report.Dictionary.Variables["Variable1"].Value = yourCancatenatedString; 
report.Compile(); 
report["Variable2"] = yourCancatenatedString;
Thank you.

Re: How to set Report Variable from Visual Studio code?

Posted: Tue Feb 16, 2016 11:56 am
by jp2code
Interesting. I did not realize the 2nd version (report["Variable2"] = yourCancatenatedString;) could only be done after a compile.

Thank you!

Re: How to set Report Variable from Visual Studio code?

Posted: Tue Feb 16, 2016 12:26 pm
by HighAley
Hello.

We are always glad to help you.
Let us know if you need our help.

Thank you.