Example #1
0
        /// <summary>
        /// btnCustomersLeveled_Click - Creates a OrdersLeveled report and sets
        /// the data source for it.
        /// </summary>
        private void btnCustomersLeveled_Click(object sender, EventArgs e)
        {
            try
            {
                //OrdersLeveled rpt = new OrdersLeveled();
                var rpt = new SectionReport();
                rpt.LoadLayout(XmlReader.Create(Properties.Resources.OrdersLeveled));

                Data.XMLDataSource ds = rpt.DataSource as Data.XMLDataSource;
                if (ds == null)
                {
                    // Display the message when an error occurs.
                    MessageBox.Show(Properties.Resources.DataSourceError, this.Text);
                    return;
                }

                // Set the XML file name.
                ds.FileURL = Properties.Resources.ConnectionString;

                // Display the report.
                ViewerForm frm = new ViewerForm();
                frm.Show();
                frm.LoadReport(rpt);
            }
            catch (ReportException ex)
            {
                MessageBox.Show(ex.ToString(), Text);
            }
        }
Example #2
0
        void LoadReport(ReportType reportType)
        {
            // Instantiate a new Invoice report
            var report = new SectionReport();

            report.LoadLayout(XmlReader.Create(Properties.Resources.Invoice));

            report.MaxPages = 10;

            // Set the connection string to the sample database.
            ((OleDBDataSource)report.DataSource).ConnectionString = Properties.Resources.ConnectionString;
            switch (reportType)
            {
            case ReportType.CrossSectionControls:
                cscViewer.LoadDocument(report);
                break;

            case ReportType.RepeatToFill:
                ((Detail)report.Sections["Detail"]).RepeatToFill = true;
                repeatToFillViewer.LoadDocument(report);
                break;

            case ReportType.PrintAtBottom:
                ((GroupFooter)report.Sections["customerGroupFooter"]).PrintAtBottom = true;
                printAtBottomViewer.LoadDocument(report);
                break;
            }
        }
Example #3
0
 public void PdfExport(SectionReport report, string path)
 {
     using (var exporter = new PdfExport())
     {
         exporter.Export(report.Document, path);
     }
 }
Example #4
0
        public frmVOnePreviewForm(SectionReport report)
        {
            InitializeComponent();

            var isCloudEdition = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsCloudEdition"]);

            Icon = (isCloudEdition) ? Properties.Resources.cloud_icon : Properties.Resources.app_icon;

            Report = report;

            if (Report != null &&
                Report.Document != null &&
                Report.Document.Printer != null)
            {
                Report.Document.Printer.EndPrint += (sender, e) => OutputHandler?.Invoke(this);
            }
            ShowSaveFileDialogHandler = ShowSaveFileDialogInner;

            Load                += frmVOnePreviewForm_Load;
            rptViewer.Click     += rptViewer_Click;
            rptViewer.MouseDown += rptViewer_MouseDown;
            rptViewer.PrintingSettings
                = GrapeCity.Viewer.Common.PrintingSettings.ShowPrintDialog
                  | GrapeCity.Viewer.Common.PrintingSettings.ShowPrintProgressDialog
                  | GrapeCity.Viewer.Common.PrintingSettings.UsePrintingThread
                  | GrapeCity.Viewer.Common.PrintingSettings.UseStandardDialog;
        }
Example #5
0
        public ReportViewer(SectionReport report)
        {
            InitializeComponent();

            this.viewModel.Report = report;
            DataContext           = viewModel;
        }
Example #6
0
        private void RunReport_DSRelations()
        {
            // ***** Sub report using the data set that contains the relationship *****

            DataSet myJoinedDS = new DataSet();
            var     rpt        = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptDSRelationParent));

            string cnnString = Properties.Resources.ConnectionString;

            OleDbConnection cnn = new OleDbConnection(cnnString);

            cnn.Open();
            OleDbDataAdapter catAd  = new OleDbDataAdapter("Select * from categories order by categoryname", cnn);
            OleDbDataAdapter prodAd = new OleDbDataAdapter("Select * from products order by productname", cnn);
            OleDbDataAdapter ODAd   = new OleDbDataAdapter("Select * from [order details]", cnn);

            //Add three DataTables in the DataSet (myJoinedDS)
            catAd.Fill(myJoinedDS, "Categories");
            prodAd.Fill(myJoinedDS, "Products");
            ODAd.Fill(myJoinedDS, "OrderDetails");
            cnn.Close();

            //Sets the parent-child relationship between DataTable.
            myJoinedDS.Relations.Add("CategoriesProducts", myJoinedDS.Tables["Categories"].Columns["CategoryID"], myJoinedDS.Tables["Products"].Columns["CategoryID"]);
            myJoinedDS.Relations.Add("ProductsOrderDetails", myJoinedDS.Tables["Products"].Columns["ProductID"], myJoinedDS.Tables["OrderDetails"].Columns["ProductID"]);
            rpt.DataSource = (myJoinedDS);
            rpt.DataMember = "Categories";
            arvMain.LoadDocument(rpt);
        }
Example #7
0
        private void buttonRunReport_Click(object sender, EventArgs e)
        {
            SectionReport report = null;

            // Select the report in the Viewer.
            if (radioButtonProductListReport.Checked)
            {
                report = new ProductsReport();
            }
            else if (radioButtonCategoriesReport.Checked)
            {
                report = new CategoryReport();
            }
            // Apply stylesheet on the report.
            string outputFolder = new FileInfo(GetType().Assembly.Location).DirectoryName + "\\";
            string styleSheet   = "";

            if (radioButtonClassicStyle.Checked)
            {
                styleSheet = outputFolder + "Classic.reportstyle";
            }
            else if (radioButtonColoredStyle.Checked)
            {
                styleSheet = outputFolder + "Colored.reportstyle";
            }
            else if (_externalStyleSheet != "")
            {
                styleSheet = _externalStyleSheet;
            }
            if (styleSheet != "")
            {
                report.LoadStyles(styleSheet);
            }
            reportViewer.LoadDocument(report);
        }
Example #8
0
        private void RunReport_UnboundDataSet()
        {
            // ***** To view the DataSet with multiple tables using sub-reports *****

            // To generate dataset using "Customers" and "Orders" tables.
            OleDbConnection nwindConn = new OleDbConnection(Properties.Resources.ConnectionString);

            OleDbCommand selectCMD = new OleDbCommand("SELECT * FROM Customers", nwindConn);

            selectCMD.CommandTimeout = 30;
            OleDbCommand selectCMD2 = new OleDbCommand("SELECT * FROM Orders", nwindConn);

            selectCMD2.CommandTimeout = 30;

            OleDbDataAdapter custDA = new OleDbDataAdapter();

            custDA.SelectCommand = selectCMD;
            OleDbDataAdapter ordersDA = new OleDbDataAdapter();

            ordersDA.SelectCommand = selectCMD2;

            DataSet DS = new DataSet();

            custDA.Fill(DS, "Customers");
            ordersDA.Fill(DS, "Orders");
            nwindConn.Close();

            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptUnboundDSMain));
            rpt.DataSource = DS;
            rpt.DataMember = "Customers";
            arvMain.LoadDocument(rpt);
        }
Example #9
0
        /// <summary>
        /// ShowReport - takes the supplied SectionReport object and loads it into
        /// the PreviewForm for viewing.
        /// </summary>
        /// <param name="rpt">SectionReport object to run and display.</param>
        private void ShowReport(SectionReport rpt)
        {
            // Change the mouse cursor to the wait cursor.
            Cursor tmp = Cursor;

            Cursor = Cursors.WaitCursor;
            try
            {
                // Make the sure the connection string points to the correct file location.
                OleDBDataSource ds = (OleDBDataSource)rpt.DataSource;
                ds.ConnectionString = _connectString;
                // Create a new instance of the preview form.
                PreviewForm viewerForm = new PreviewForm(rpt.Document, this);
                viewerForm.Show();
                rpt.Run();
            }
            catch (ReportException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                Cursor = tmp;
            }
        }
        protected override object OnCreateReportHandler(string reportPath)
        {
            SectionReport rptOrders;

            switch (reportPath)
            {
            case "Reports/BillingInvoice.rdlx":
            case "Reports/Orders.rdlx":
                PageReport rptPageRDL = new PageReport();
                rptPageRDL.Load(new FileInfo(Server.MapPath(reportPath)));
                rptPageRDL.Report.DataSources[0].ConnectionProperties.ConnectString = "data source=" + Server.MapPath("~/App_Data/NWind.mdb") + ";provider=Microsoft.Jet.OLEDB.4.0;";
                return(rptPageRDL);

            case "Reports/Invoice.rpx":

                rptOrders = new SectionReport();
                XmlTextReader xtr = new XmlTextReader(Server.MapPath(reportPath));
                rptOrders.LoadLayout(xtr);
                (rptOrders.DataSource as OleDBDataSource).ConnectionString = "data source=" + Server.MapPath("~/App_Data/NWind.mdb") + ";provider=Microsoft.Jet.OLEDB.4.0;";
                return(rptOrders);

            default:
                return(base.OnCreateReportHandler(reportPath));
            }
        }
Example #11
0
        protected override object OnCreateReportHandler(string reportPath)
        {
            var data = reportPath.Split(';');

            if (data.Length != 2)
            {
                return(base.OnCreateReportHandler(reportPath));
            }
            switch (data[0])
            {
            case "Section":
                var sectionReport = new SectionReport();
                sectionReport.LoadLayout(XmlReader.Create(Server.MapPath("~/Reports/OrderReport.rpx")));
                sectionReport.DataSource = Repository.GetOrders(data[1]);
                var xvalues = new List <string>();
                var yvalues = new List <double>();
                foreach (Order order in Repository.GetOrders(data[1]))
                {
                    xvalues.Add(order.ShippedDate);
                    yvalues.Add((double)order.Freight);
                }
                ((SectionReportModel.ChartControl)sectionReport.Sections["reportFooter1"].Controls[0]).Series[0].Points.DataBindXY(xvalues.ToArray(), yvalues.ToArray());
                return(sectionReport);

            case "Page":
                var pageReport = new PageReport(new FileInfo(Server.MapPath("~/Reports/OrderDetailsReport.rdlx")));
                pageReport.Document.LocateDataSource += delegate(object sender, LocateDataSourceEventArgs args)
                {
                    args.Data = Repository.GetDetails(data[1]);
                };
                return(pageReport);
            }
            return(base.OnCreateReportHandler(reportPath));
        }
Example #12
0
 public void ViewReport(SectionReport ar)
 {
     reportType       = ar.GetType().ToString();
     rprt             = ar;
     viewer1.Document = rprt.Document;
     rprt.Run();
 }
Example #13
0
 public void ViewDrawingLogWithExcel(SectionReport ar)
 {
     reportType       = ar.GetType().ToString();
     rprt             = ar;
     viewer1.Document = rprt.Document;
     rprt.Run();
 }
Example #14
0
        /// <summary>
        /// Handles the hyperlink sent from the viewer object.
        /// </summary>
        private void arvMain_HyperLink(object sender, GrapeCity.ActiveReports.Viewer.Win.HyperLinkEventArgs e)
        {
            e.Handled = true;
            string hyperlink = e.HyperLink.Split(':')[1];
            string report    = e.HyperLink.Split(':')[0];

            if (report == "DrillThrough1")
            {
                // Click on customer ID to open the drill through for that customer.
                var rpt2 = new SectionReport();
                rpt2.LoadLayout(XmlReader.Create(Properties.Resources.DrillThrough1));
                ViewerMain frm2 = new ViewerMain(false);
                rpt2.Parameters["customerID"].Value = hyperlink;
                frm2.arvMain.LoadDocument(rpt2);
                frm2.ShowDialog(this);
            }
            else if (report == "DrillThrough2")
            {
                // Click order number to open the order details
                var rpt3 = new SectionReport();
                rpt3.LoadLayout(XmlReader.Create(Properties.Resources.DrillThrough2));
                ViewerMain frm3 = new ViewerMain(false);
                rpt3.Parameters["orderID"].Value = hyperlink;
                frm3.arvMain.LoadDocument(rpt3);
                frm3.ShowDialog(this);
            }
        }
Example #15
0
        public static void Print <T>(SectionReport report, IList <T> data) where T : new()
        {
            report.DataSource = data;

            var viewer = new ReportViewer(report);

            viewer.ShowDialog();
        }
Example #16
0
        private void RunReport_Bookmark()
        {
            // ***** Bookmark in sub-report *****
            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptBookmarkMain));
            arvMain.LoadDocument(rpt);
        }
Example #17
0
 public void ViewReport(SectionReport ar)
 {
     rprt       = ar;
     reportType = ar.GetType().ToString(); ////******************Added and Commented for M-File button*****11/18
     //viewer1.Document = rprt.Document;
     //rprt.Run();
     //Cursor.Current = Cursors.Default;
 }
Example #18
0
        private void exportButton_Click(object sender, EventArgs e)
        {
            var reportName = (string)reportsNames.SelectedItem;
            var exportType = (string)exportTypes.SelectedItem;
            IDocumentExportEx documentExportEx = null;

            var report = new SectionReport();

            System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(@"..\..\..\..\Reports\" + reportName);
            report.LoadLayout(xtr);
            report.Run();

            var exporTypeLower = exportType.ToLower();

            switch (exporTypeLower)
            {
            case _pdf:
                documentExportEx = new GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport();
                break;

            case _xlsx:
                documentExportEx = new GrapeCity.ActiveReports.Export.Excel.Section.XlsExport()
                {
                    FileFormat = GrapeCity.ActiveReports.Export.Excel.Section.FileFormat.Xlsx
                };
                break;

            case _rtf:
                documentExportEx = new GrapeCity.ActiveReports.Export.Word.Section.RtfExport();
                break;

            case _mht:
                documentExportEx = new GrapeCity.ActiveReports.Export.Html.Section.HtmlExport();
                break;

            case _csv:
                documentExportEx = new GrapeCity.ActiveReports.Export.Xml.Section.TextExport();
                break;
            }

            var fileName       = Path.GetFileNameWithoutExtension(reportName);
            var saveFileDialog = new SaveFileDialog()
            {
                FileName = fileName + GetSaveDialogExtension(exporTypeLower),
                Filter   = GetSaveDialogFilter(exporTypeLower)
            };


            if (saveFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            exportButton.Enabled = false;
            using (var stream = new FileStream(Path.Combine(saveFileDialog.FileName), FileMode.Create))
                documentExportEx.Export(report.Document, stream);
            exportButton.Enabled = true;
        }
Example #19
0
        private void Button_Click(object sender, EventArgs e)
        {
            var rpt        = new SectionReport();
            var reportPath = "..\\..\\" + (string)comboBox1.SelectedItem;

            rpt.LoadLayout(XmlReader.Create(reportPath));
            rpt.PrintWidth = 6.5F;
            arvMain.LoadDocument(rpt);
        }
Example #20
0
        private void RunReport_Hierarchical()
        {
            // *****Hierarchical structure of sub-reports *****

            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptHierarchicalMain));
            arvMain.LoadDocument(rpt);
        }
        private void ActiveReportsWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            _sectionReport = new SectionReport {
                DataSource = DataTable
            };

            _sectionReport.Document.Printer.PrinterName = "";
            _sectionReport.PageSettings.Margins.Left    = 0.1f;
            _sectionReport.PageSettings.Margins.Right   = 0.1f;
            _sectionReport.PrintWidth = 15F;

            _sectionReport.Sections.Add(SectionType.ReportHeader, "ReportHeader");
            _sectionReport.Sections.Add(SectionType.Detail, "Detail");
            _sectionReport.Sections.Add(SectionType.ReportFooter, "ReportFooter");

            var section1 = _sectionReport.Sections[1];

            section1.CanGrow   = true;
            section1.CanShrink = true;

            float locationX = 0;

            foreach (DataColumn dataSetColumn in DataTable.Columns)
            {
                var labelHeader = new Label
                {
                    Text            = dataSetColumn.ColumnName,
                    Alignment       = GrapeCity.ActiveReports.Drawing.TextAlignment.Left,
                    Location        = new PointF(locationX, 0.0F),
                    ShrinkToFit     = false,
                    MinCondenseRate = 100,
                    BackColor       = Color.Gainsboro,
                    Width           = 2
                };
                _sectionReport.Sections[0].Controls.Add(labelHeader);

                var ctl = new TextBox
                {
                    Name        = dataSetColumn.ColumnName,
                    Text        = dataSetColumn.ColumnName,
                    DataField   = dataSetColumn.ColumnName,
                    Location    = new PointF(locationX, 0.05F),
                    ShrinkToFit = false,
                    WrapMode    = WrapMode.NoWrap,
                    CanShrink   = false,
                };


                ctl.Border.BottomStyle = BorderLineStyle.Dash;

                _sectionReport.Sections[1].Controls.Add(ctl);

                locationX += ctl.Width;
            }

            ReportViewer.LoadDocument(_sectionReport);
        }
Example #22
0
 /// <summary>
 /// ViewerForm_Load - Handles initial form setup.
 /// </summary>
 private void ViewerForm_Load(object sender, EventArgs e)
 {
     if (_loadMainReport)
     {
         var rpt = new SectionReport();
         rpt.LoadLayout(XmlReader.Create(Properties.Resources.DrillThroughMain));
         arvMain.LoadDocument(rpt);
     }
 }
Example #23
0
        /// <summary>
        /// btnArray_Click - Illustrates using a Array as a data source
        /// </summary>
        private void btnArray_Click(object sender, System.EventArgs e)
        {
            //Create the report
            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.UnboundDAInvoice));
            //Run and view the report
            arvMain.LoadDocument(rpt);
        }
Example #24
0
        private void RunReport_Simple()
        {
            // ***** Simple sub-report *****

            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptSimpleMain));
            arvMain.LoadDocument(rpt);
        }
Example #25
0
        // Define a structure for LINQtoObject.
        private void ViewerForm_Load(object sender, EventArgs e)
        {
            // To generate a report.
            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create("..\\..\\rptLINQtoObject.rpx"));
            // To run the report.
            arvMain.LoadDocument(rpt);
        }
Example #26
0
        private void RunReport_Nested()
        {
            // ***** Nested sub-reports *****

            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptNestedParent));
            arvMain.LoadDocument(rpt);
        }
Example #27
0
        private void RunReport_Parameter()
        {
            // ***** Use a parameter in the subreport *****

            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptParamMain));
            arvMain.LoadDocument(rpt);
        }
Example #28
0
        private void RunReport_MasterSubreport()
        {
            // ***** Master-detail report contains a subreport *****

            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.rptMasterMain));

            arvMain.LoadDocument(rpt);
        }
Example #29
0
        private void ReportForm_Load(object sender, EventArgs e)
        {
            rpt = new SectionReport();

            //Adding Page Header/Footer sections
            rpt.Sections.InsertPageHF();
            rpt.Sections[0].BackColor = Color.LightGray;

            //Adding Detail section
            rpt.Sections.Insert(1, new Detail());
            rpt.Sections[1].BackColor = Color.PeachPuff;
            rpt.Sections[1].Height    = 0.5f;

            //Adding label to display first column's name
            GrapeCity.ActiveReports.SectionReportModel.Label lblCategoryID = new GrapeCity.ActiveReports.SectionReportModel.Label();
            lblCategoryID.Location  = new PointF(0, 0.05F);
            lblCategoryID.Text      = "Tên món ăn";
            lblCategoryID.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Center;
            lblCategoryID.Font      = new Font("Arial", 10, FontStyle.Bold);
            rpt.Sections[0].Controls.Add(lblCategoryID);

            //Adding label to display second column's name
            GrapeCity.ActiveReports.SectionReportModel.Label lblCategoryName = new GrapeCity.ActiveReports.SectionReportModel.Label();
            lblCategoryName.Location = new PointF(1.459f, 0.05f);
            lblCategoryName.Size     = new SizeF(1.094f, 0.2f);
            lblCategoryName.Text     = "Giá";
            lblCategoryName.Font     = new Font("Arial", 10, FontStyle.Bold);
            rpt.Sections[0].Controls.Add(lblCategoryName);


            // Adding Textbox to display first column's records
            GrapeCity.ActiveReports.SectionReportModel.TextBox txtCategoryID = new GrapeCity.ActiveReports.SectionReportModel.TextBox();
            txtCategoryID.Location  = new PointF(0, 0);
            txtCategoryID.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Center;
            rpt.Sections[1].Controls.Add(txtCategoryID);

            //Adding Textbox to display second column's records
            GrapeCity.ActiveReports.SectionReportModel.TextBox txtCategoryName = new GrapeCity.ActiveReports.SectionReportModel.TextBox();
            txtCategoryName.Location = new PointF(1.459f, 0);
            rpt.Sections[1].Controls.Add(txtCategoryName);

            // Setting report's data source
            rpt.DataSource = DataProvider.Instance.ExecuteQuery("select * from dbo.menu where created ='" + _dateReport + "' ");

            // Assigning DataField properties of controls in the detail section
            txtCategoryID.DataField   = "name";
            txtCategoryName.DataField = "price";

            rpt.Run();
            this.viewer1.Document = rpt.Document;
        }
Example #30
0
        /// <summary>
        /// btnGenerateReport_Click - Opens a new viewer form to display the
        /// report bound to the DataLayer object
        /// </summary>
        private void btnGenerateReport_Click(object sender, System.EventArgs e)
        {
            // Create new report object
            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create("IlistReportSample.rpx"));
            rpt.DataSource = _productCollection;

            // Pass the document to show in the viewer form
            ViewerForm frmViewer = new ViewerForm();

            frmViewer.Show();
            frmViewer.LoadDocument(rpt);
        }
Example #31
0
        public ViewerForm(SectionReport report)
        {
            InitializeComponent();

            _report = report;
        }