如何运行报告并同时在后台加载其数据
本文关键字:后台 加载 数据 何运行 运行 报告 | 更新日期: 2023-09-27 18:09:44
我创建了一个报告(Active report)并运行它。但是,直到加载了整个报表之后,才会出现报表窗口或报表。
我想报告应该立即打开,只要我点击"显示报告"按钮,报告中的数据应该在后台加载
private void ViwerGLactivityReport_Load(object sender, EventArgs e)
{
try
{
ar = new ActiveReport();
ar = LoadReport(wSession, ar, CurrentUserContext, StartDate, EndDate, accountstart, accountEnd, PostInvoiceDate, JournalIDInvoiceNo);
ViwerGLactivityReport.Document = ar.Document;
ar.Run();
}
catch (Exception ex)
{
CusException cex = new CusException(ex);
cex.Show(MessageBoxIcon.Error);
}
}
public ActiveReport LoadReport(NHSessionManager.SessionForWindows wSession, ActiveReport ar, M3.Globals.UserContext CurrentUserContext, DateTime StartDate, DateTime EndDate, double accountstart, double accountEnd, string PostInvoiceDate, string JournalIDInvoiceNo)
{
ar = new ActiveReport();
try
{
Company = CurrentUserContext.CurrentCompany;
Assembly asm = Assembly.GetAssembly(this.GetType());
ar.DataInitialize += new EventHandler(ar_DataInitialize);
ar.FetchData += new ActiveReport.FetchEventHandler(ar_FetchData);
System.IO.Stream stre = asm.GetManifestResourceStream(asm.GetName().Name + ".GL.arActivity.rpx");
using (XmlTextReader xr = new XmlTextReader(stre))
{
ar.LoadLayout(xr);
}
foreach (var itemAccRange in lstLedAccOrderBy)
{
List<M3.UDT.ReportDataGLActivityTransactions> lstReportData = new List<ReportDataGLActivityTransactions>();
lstReportData = obj.GLActivityReport(Company, Property, itemAccRange.Account, StartDate, EndDate);
var Acc = lstLedAcc.Where(x => x.Account == itemAccRange.Account).FirstOrDefault();
foreach (var item in lstReportData)
{
item.AccountNumber = itemAccRange.Account;
string AccName = string.Empty;
if (Acc != null)
{
AccName = Acc.FName;
}
item.AccountName = AccName;
if (Property != null)
{
item.CompanyName = Property.FName;
}
else
{
item.CompanyName = Company.FName;
}
((DataDynamics.ActiveReports.Label)ar.Sections["PageFooter"].Controls["lblDateTime"]).Value = DateTime.Now.ToShortDateString() + " at " + DateTime.Now.ToLongTimeString();
item.PostInvoiceDate = PostInvoiceDate;
item.JournalIDInvoiceNo = JournalIDInvoiceNo;
item.StartAcc = accountstart;
item.EndAcc = accountEnd;
item.TotalForAccountNumber = itemAccRange.Account;
item.PostDate = item.fPostDate.ToShortDateString();
if (item.DebitAmount == Convert.ToDecimal("0.00"))
{
item.DebitAmtDisplay = "";
}
else
{
item.DebitAmtDisplay = Convert.ToString(item.DebitAmount);
}
if (item.CreditAmount == Convert.ToDecimal("0.00"))
{
item.CreditAmtDisplay = "";
}
else
{
item.CreditAmtDisplay = Convert.ToString(item.CreditAmount);
}
item.period = string.Format(" {0} {1} {2} {3}", CultureManager.GetReportMessageString("IdPeriod"), item.fPostDate.Month, CultureManager.GetReportMessageString("IdOf"), item.fPostDate.Year);
item.Totalperiod = string.Format(" {0} {1} {2} {3}", CultureManager.GetReportMessageString("IdTotalPerid"), item.fPostDate.Month, CultureManager.GetReportMessageString("IdOf"), item.fPostDate.Year);
if (ShowAccountsHeader == "show")
{
item.ShowAccountsHeader = CultureManager.GetReportMessageString("IdShowAcc"); //"Show Accounts with no activity";
}
else if (ShowAccountsHeader == "hide")
{
item.ShowAccountsHeader = CultureManager.GetReportMessageString("IdHideAcc");//"Hide Accounts with no activity";
}
else if (ShowAccountsHeader == "zero")
{
item.ShowAccountsHeader = CultureManager.GetReportMessageString("IdShowAccBalZero"); //"Show Accounts with no activity if Begining Balance is not zero";
}
else
{
}
lstReportDataPrint.Add(item); //added by jitendra
lstReportDataPrint.GroupBy(elem => elem.fJEID).Select(group => group.First());
}
}
ar.DataSource = lstReportDataPrint;
ar.Run();
}
这是可能的吗?
这是使用分段报告的一个限制(在活动报告6及以下版本中,它们被称为活动报告)。Section Reports使用"带状列表"方法(如果您愿意的话),并且在查询完成之前不允许显示报告。
在活动报告7及以上版本中,我们引入了页面报告的概念,它允许这种行为。Page Report可以做到这一点是因为它的设计方式(Page by Page方法),所以在第1页完成后,它会显示它和
1/#总页数
总页数的#从1开始递增。