110,568
社区成员
发帖
与我相关
我的任务
分享
//调用报表预览
public void ActionRptPrev(int _rptbarid, FastReport.Preview.PreviewControl previewCtl)
{
if (textBox8.Text.Trim() == string.Empty)
{
MessageBox.Show("报表数据源不能为空", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
CusReportContext db = new CusReportContext();
List<bgdatasrc> rBarlist = db.bgdatasrc.Where(x => x.rptbarid == _rptbarid).ToList(); //本级项目主表
int _dsrctype = rBarlist.Select(c => c.dsrctype).FirstOrDefault(); //数据源类型
string _rptfile = "Report/" + rBarlist.Select(d => d.rptfile).FirstOrDefault(); //报表文件名
db.Dispose();
if (!System.IO.File.Exists(_rptfile))
{
MessageBox.Show(_rptfile + "报表模板文件不存在,需创建该文件模板", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
pReport = new FastReport.Report();
pReport.Load(_rptfile);
pReport.Preview = previewCtl;
DataSet ds = FrmDesign.BindingData(_rptbarid);
pReport.RegisterData(ds.Tables[0], "自定义报表");
pReport.Prepare();
pReport.ShowPrepared();
}