#region 报表打印相关
bool FReportRunning;
/// <summary>
/// 报表相关操作
/// </summary>
/// <param name="filename">PrintReport文件夹下的文件名</param>
/// <param name="dt">加载的数据源</param>
/// <param name="flag">0 设计,1 预览,2 打印</param>
/// <param name="error">错误框控件</param>
public void PreviewReport(string filename, System.Data.DataTable dt, int flag, TextBox error)
{
if (FReportRunning)
return;
FReportRunning = true;
try
{
Report report = new Report();
if (dt != null)
{
report.RegisterData(dt, dt.TableName);
report.GetDataSource(dt.TableName).Enabled = true;
}
#if DEBUG
report.Load(@"..\..\PrintReport\" + filename);
#else
report.Load(Application.StartupPath + @"\PrintReport\"+ filename);
#endif
switch (flag)
{
case 0:
report.Design();
break;
case 1:
report.Show();
break;
case 2:
report.Print();
break;
}
}
catch (Exception ex)
{
error.Text = ex.Message;
}
finally
{
FReportRunning = false;
}
}
#endregion