4,819
社区成员
发帖
与我相关
我的任务
分享/// <summary>
/// 资产领用报表
/// </summary>
/// <param name="applyId">领用单Id</param>
public void ViewReport(string applyId)
{
try
{
report = null;
datatable = null;
dataviewAsset = null;
// Create report object
report = new TfrxReportClass();
report.SetGlobalVariable("Language", "Chinese");
#region 查询领用单报表数据
ApplyBLL applyBll = new ApplyBLL();
DataSet ds = null;
DataTable dtB2 = null;
DataTable dtR2 = null;
DataTable dtAsset = null;
if (!string.IsNullOrEmpty(applyId))
{
ds = applyBll.GetApplyReport(applyId);
dtB2 = ds.Tables["apply"];
dtR2 = ds.Tables["applyRel"];
dtAsset = ds.Tables["asset"];
}
#endregion
datatable = new FrxDataTable(dtB2);
datatable.Dispose();
datatable.AcceptChanges();
// These events used for Master/Detail implementation
datatable.FrxEventOnFirst += new FrxOnFirst(datatable_FrxEventHandler);
datatable.FrxEventOnNext += new FrxOnNext(datatable_FrxEventHandler);
datatable.FrxEventOnPrior += new FrxOnPrior(datatable_FrxEventHandler);
// Create the FR compatible DataView object
dataviewAsset = new FrxDataView(dtAsset, "DataViewAsset");
// We need following to make ongoing the report windows modal
report.MainWindowHandle = (int)this.Handle;
// Load demmonstration report from file
string reportPath = Smt.Utils.Common.SysRootPath() + "report\\资产领用报表.fr3";
report.LoadReportFromFile(reportPath);
report.ClearDatasets();
// Asiign datasets to report one more time
// beacuse theLoadReport... family functions breaks links between report and dataset
datatable.AssignToReport(true, report);
dataviewAsset.AssignToReport(true, report);
// Assigns DataTable to MasterBand
datatable.AssignToDataBand("MasterData1", report);
// Assigns DataView to DetailBand
dataviewAsset.AssignToDataBand("DetailData1", report);
report.ShowReport();//fastreport自带的预览窗体界面
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}