Esempio n. 1
0
        private static string GetPageHeader(ReportBuilder reportBuilder)
        {
            string strHeader = "";

            if (reportBuilder.Page == null || reportBuilder.Page.ReportHeader == null)
            {
                return("");
            }
            ReportSections reportHeader = reportBuilder.Page.ReportHeader;

            strHeader = @"<PageHeader> 
                        <Height>" + reportHeader.Size.Height.ToString() + @"in</Height> 
                        <PrintOnFirstPage>" + reportHeader.PrintOnFirstPage.ToString().ToLower() + @"</PrintOnFirstPage> 
                        <PrintOnLastPage>" + reportHeader.PrintOnLastPage.ToString().ToLower() + @"</PrintOnLastPage> 
                        <ReportItems>";
            ReportTextBoxControl[] headerTxt = reportBuilder.Page.ReportHeader.ReportControlItems.TextBoxControls;
            if (headerTxt != null)
            {
                for (int i = 0; i < headerTxt.Count(); i++)
                {
                    strHeader += GetHeaderTextBox(headerTxt[i].Name, null, headerTxt[i].ValueOrExpression);
                }
            }
            strHeader += @" 
                        <Image Name=""Image1""> 
                            <Source>Embedded</Source> 
                            <Value>Logo</Value> 
                            <Sizing>FitProportional</Sizing> 
                            <Top>0.05807in</Top> 
                            <Left>1cm</Left> 
                            <Height>0.4375in</Height> 
                            <Width>1.36459in</Width> 
                            <ZIndex>1</ZIndex> 
                            <Style /> 
                        </Image> 

                        </ReportItems> 

                        <Style /> 
                    </PageHeader>";
            return(strHeader);
        }
Esempio n. 2
0
        public void DataBind(DataSet ds)
        {
            int count = 0;

            foreach (DataTable dt in ds.Tables)
            {
                count++;
                var       report_name = "Report" + count;
                DataTable dt1         = new DataTable(report_name.ToString());
                dt1           = ds.Tables[count - 1];
                dt1.TableName = report_name.ToString();
            }


            ReportViewerMaster.Reset();
            for (int i = 0; i < ds.Tables.Count; i++)
            {
                ReportViewerMaster.LocalReport.DataSources.Add(new ReportDataSource(ds.Tables[i].TableName, ds.Tables[i]));
            }
            ReportViewerMaster.LocalReport.EnableHyperlinks = true;

            ReportBuilder reportBuilder = new ReportBuilder();

            reportBuilder.DataSource = ds;

            reportBuilder.Page = new ReportPage();
            ReportSections reportFooter      = new ReportSections();
            ReportItems    reportFooterItems = new ReportItems();

            ReportTextBoxControl[] footerTxt = new ReportTextBoxControl[3];
            //string footer = string.Format("Copyright {0}         Report Generated On {1}          Page {2}", DateTime.Now.Year, DateTime.Now, ReportGlobalParameters.CurrentPageNumber);
            string footer = string.Format("Copyright  {0}         Report Generated On  {1}          Page  {2}  of {3} ", DateTime.Now.Year, DateTime.Now, ReportGlobalParameters.CurrentPageNumber, ReportGlobalParameters.TotalPages);

            footerTxt[0] = new ReportTextBoxControl()
            {
                Name = "txtCopyright", ValueOrExpression = new string[] { footer }
            };

            reportFooterItems.TextBoxControls = footerTxt;
            reportFooter.ReportControlItems   = reportFooterItems;
            reportBuilder.Page.ReportFooter   = reportFooter;

            ReportSections reportHeader = new ReportSections();

            reportHeader.Size = new ReportScale();
            // reportHeader.Size.Height = 0.56849;
            reportHeader.Size.Height = 0.7;

            ReportItems reportHeaderItems = new ReportItems();

            ReportTextBoxControl[] headerTxt = new ReportTextBoxControl[1];
            headerTxt[0] = new ReportTextBoxControl()
            {
                Name = "txtReportTitle", ValueOrExpression = new string[] { ReportTitle }
            };

            reportHeaderItems.TextBoxControls = headerTxt;
            reportHeader.ReportControlItems   = reportHeaderItems;
            reportBuilder.Page.ReportHeader   = reportHeader;

            ReportViewerMaster.LocalReport.LoadReportDefinition(ReportEngine.GenerateReport(reportBuilder));
            ReportViewerMaster.LocalReport.DisplayName      = ReportName;
            ReportViewerMaster.LocalReport.EnableHyperlinks = true;
        }