Esempio n. 1
0
        public void SubreportProcessing(SubreportProcessingEventArgs e)
        {
            if (OnSubreport != null)
            {
                OnSubreport(e);
                return;
            }
            string           fnm = ReportHelper.ReportNameFromPath(e.ReportPath);
            ReportViewerData rvd = SubReports[fnm];

            foreach (var link in rvd.SubreportLinks.Values)
            {
                DataTable dt = rvd.Sources[link.SourceName] as DataTable;
                DataView  dv;
                if (dt == null)
                {
                    dv = rvd.Sources[link.SourceName] as DataView;
                    if (dv == null)
                    {
                        throw new Exception("Not supported DataSource");
                    }
                    dt = dv.Table;
                }
                string filter = link.GetFilterString(e);
                dv = new DataView(dt, filter, null, DataViewRowState.CurrentRows);

                e.DataSources.Add(
                    new ReportDataSource(link.SourceName, dv.ToTable()));
            }
        }
Esempio n. 2
0
 public virtual void ShowReport(ReportViewerData rd)
 {
     try
     {
         Form_ReportViewer f = new Form_ReportViewer(rd);
         f.Show(this);
     }
     catch (Exception e)
     {
         MyException me = new MyException("Neizdevās atvērt atskaiti", e);
         Form_Error.ShowException(MyMainForm, me);
     }
 }
Esempio n. 3
0
 public static bool RenderToPdf(ReportViewerData rd, string filename)
 {
     try
     {
         var bytes = RenderToPdf(rd);
         if (File.Exists(filename))
         {
             File.Delete(filename);
         }
         using (FileStream stream = new FileStream(filename, FileMode.Create))
         {
             stream.Write(bytes, 0, bytes.Length);
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Esempio n. 4
0
        public Form_ReportViewer(ReportViewerData reportViewerData)
        {
            InitializeComponent();
            CheckMyFontAndColors();
            reportViewer1.Messages = ReportHelper.ReportViewerMessages;

            this.reportViewerData = reportViewerData;

            foreach (var source in reportViewerData.Sources)
            {
                reportViewer1.LocalReport.DataSources.Add(
                    new ReportDataSource(source.Key, source.Value));
            }

            //reportViewer1.LocalReport.ReportEmbeddedResource = "KlonsF.Reports.Report1.rdlc";
            reportViewer1.LocalReport.ReportPath = MyData.GetBasePath() + "\\Reports\\" + reportViewerData.FileName + ".rdlc";
            if (reportViewerData.ReportParameters != null)
            {
                reportViewer1.LocalReport.SetParameters(reportViewerData.ReportParameters);
            }
            reportViewer1.LocalReport.SubreportProcessing += reportViewer1_SubreportProcessing;
        }
Esempio n. 5
0
        public static byte[] RenderToPdf(ReportViewerData rd)
        {
            var rv = new ReportViewer();

            foreach (var source in rd.Sources)
            {
                rv.LocalReport.DataSources.Add(new ReportDataSource(source.Key, source.Value));
            }
            //reportViewer1.LocalReport.ReportEmbeddedResource = "KlonsF.Reports.Report1.rdlc";
            rv.LocalReport.ReportPath = MyData.GetBasePath() + "\\Reports\\" + rd.FileName + ".rdlc";
            if (rd.ReportParameters != null)
            {
                rv.LocalReport.SetParameters(rd.ReportParameters);
            }

            rv.LocalReport.SubreportProcessing += (sender, e) =>
            {
                rd.SubreportProcessing(e);
            };
            var ret = rv.LocalReport.Render(format: "PDF", deviceInfo: "");

            rv.Clear();
            return(ret);
        }