BeforePrint event in ReportTool
Introduction
BCE.AutoCount.Report.ReportTool is commonly use for DesignReport, PreviewReport and PrintReport when developing a custom report type event in Plug-In. There are times, when programmer needs to control how the report is send to the printer.
With ReportTool, you may access to the printing property before printing to the printer.
Register Script
BCE.AutoCount.Scripting.ScriptManager.GetOrCreate(dbSetting).RegisterByType("ReportTool", typeof(ReportToolScript));
Application Script Events
/// <summary>
/// Implements script for Application.
/// </summary>
public class ReportToolScript
{
/// <summary>
/// Occurs before a report is printed
/// </summary>
/// <param name="e">The event argument</param>
public void BeforePrint(BCE.AutoCount.Report.ReportTool.BeforePrintEventArgs e)
{
}
/// <summary>
/// Occurs after a report is printed
/// </summary>
/// <param name="e">The event argument</param>
public void AfterPrint(BCE.AutoCount.Report.ReportTool.AfterPrintEventArgs e)
{
}
}
Examples
Print 2 copies of a specific report type
public void BeforePrint(BCE.AutoCount.Report.ReportTool.BeforePrintEventArgs e)
{
if (e.ReportType == "Your Report Type")
{
e.PrinterSettings.Copies = 2;
}
}
Specify a Printer when printing the report that is named as "My Receipt Voucher (format 1)"
public void BeforePrint(BCE.AutoCount.Report.ReportTool.BeforePrintEventArgs e)
{
if (e.ReportName == "My Receipt Voucher (format 1)")
{
e.PrinterSettings.PrinterName = "Panasonic KX-1121";
}
}
Control if user can print Invoice Document with a custom added access rights control
public void BeforePrint(BCE.AutoCount.Report.ReportTool.BeforePrintEventArgs e)
{
BCE.AutoCount.Authentication.AccessRight rights = BCE.AutoCount.Authentication.AccessRight.Create(e.DBSetting,
BCE.AutoCount.Authentication.UserAuthentication.GetOrCreate(e.DBSetting).LoginUserID);
if (e.ReportType == "Invoice Document")
{
e.AllowPrint = rights.IsAccessible("MYPLUGIN_OWN_PRINTINVOICECONTROL");
}
}
Go to top
|
Resources For AutoCount Software Developers
|