Example #1
0
 public void ViewReport(SectionReport ar)
 {
     reportType       = ar.GetType().ToString();
     rprt             = ar;
     viewer1.Document = rprt.Document;
     rprt.Run();
 }
Example #2
0
 public void ViewDrawingLogWithExcel(SectionReport ar)
 {
     reportType       = ar.GetType().ToString();
     rprt             = ar;
     viewer1.Document = rprt.Document;
     rprt.Run();
 }
Example #3
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;
            }
        }
Example #4
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 #5
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 #6
0
 //Getting the Designer to Export the Report on Menu Item "Export" click
 private void OnExport(object sender, EventArgs e)
 {
     if (ConfirmSaveChanges())
     {
         fileName = SaveFile("pdf files|*.pdf", ".pdf");
         SectionReport rpt = new SectionReport();
         XmlTextReader xtr = new XmlTextReader(reportName);
         rpt.LoadLayout(xtr);
         rpt.Run();
         Export.Pdf.Section.PdfExport PdfExport1 = new Export.Pdf.Section.PdfExport();
         PdfExport1.Export(rpt.Document, fileName);
         System.Diagnostics.Process.Start(fileName);
     }
 }
Example #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionReport rpt = new SectionReport();

            var reportsPath = Path.Combine(Server.MapPath("~"), "Reports") + @"\";

            rpt.ResourceLocator = new DefaultResourceLocator(new Uri(reportsPath));
            System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Path.Combine(reportsPath, "Invoice.rpx"));
            rpt.LoadLayout(xtr);
            xtr.Close();
            try
            {
                rpt.Run(false);
            }
            catch (ReportException eRunReport)
            {
                // Failure running report, just report the error to the user.
                Response.Clear();
                Response.Write(GetLocalResourceObject("Error"));
                Response.Write(eRunReport.ToString());
                return;
            }

            // Tell the browser this is a PDF document so it will use an appropriate viewer.
            // If the report has been exported in a different format, the content-type will
            // need to be changed as noted in the following table:
            //	ExportType  ContentType
            //	PDF	   "application/pdf"  (needs to be in lowercase)
            //	RTF	   "application/rtf"
            //	TIFF	  "image/tiff"	   (will open in separate viewer instead of browser)
            //	HTML	  "message/rfc822"   (only applies to compressed HTML pages that includes images)
            //	Excel	 "application/vnd.ms-excel"
            //	Excel	 "application/excel" (either of these types should work)
            //	Text	  "text/plain"
            Response.ContentType = "application/pdf";

            Response.AddHeader("content-disposition", "inline; filename=MyPDF.PDF");

            // Create the PDF export object.
            PdfExport pdf = new PdfExport();

            // Create a new memory stream that will hold the pdf output.
            System.IO.MemoryStream memStream = new System.IO.MemoryStream();
            // Export the report to PDF.
            pdf.Export(rpt.Document, memStream);
            // Write the PDF stream to the output stream.
            Response.BinaryWrite(memStream.ToArray());
            // Send all buffered content to the client.
            Response.End();
        }
Example #8
0
        void RunSectionReport()
        {
            MemoryStream memoryStream = new MemoryStream();

            memoryStream.Position = 0;
            using (XmlWriter writer = XmlWriter.Create(memoryStream))
            {
                ((SectionReport)_report).SaveLayout(writer);
            }
            memoryStream.Position = 0;
            using (XmlReader reader = XmlReader.Create(memoryStream))
            {
                _sectionReport.LoadLayout(reader);
            }
            _sectionReport.Run();
        }
Example #9
0
        private void CustomPrint()
        {
            report = new ReporteBar();
            var preview = AppConstant.GeneralInfo.Preview.Bar;

            report.DataSource = dsReport;
            report.DataMember = tableNameReport;
            report.Document.Printer.PrinterName = printerName;
            var pSize = new PaperSize("CUSTOM", paperWidth, paperHeight);

            report.Document.Printer.PaperKind = PaperKind.Custom;
            report.Document.Printer.PaperSize = pSize;
            viewer1.Document = report.Document;
            report.Run();
            report.Document.Print(false, false, false);
            Close();
        }
Example #10
0
        public void ProcessRequest(HttpContext context)
        {
            if (!context.Request.Url.AbsolutePath.EndsWith(HandlerExtension))
            {
                if (!context.Request.Url.AbsolutePath.EndsWith(HandlerCacheExtension))
                {
                    return;
                }

                // return image
                var keyName   = Path.GetFileName(context.Request.FilePath);
                var cacheItem = context.Cache[keyName];
                context.Response.BinaryWrite((byte[])cacheItem);
                return;
            }

            var rpxFile     = context.Server.MapPath(context.Request.Url.LocalPath);
            var htmlHandler = new HtmlOutputHandler(context.Cache, Path.GetFileNameWithoutExtension(rpxFile));

            context.Response.ContentType = "text/html";
            try
            {
                using (var report = new SectionReport())
                    using (var reader = XmlReader.Create(rpxFile))
                    {
                        report.ResourceLocator = new DefaultResourceLocator(new Uri(Path.GetDirectoryName(rpxFile) + @"\"));
                        report.LoadLayout(reader);
                        report.Run(false);
                        using (var html = new HtmlExport {
                            IncludeHtmlHeader = true
                        })
                            html.Export(report.Document, htmlHandler, "");
                        report.Document.Dispose();
                    }
            }
            catch (ReportException eRunReport)
            {
                // Failure running report, just report the error to the user.
                context.Response.Write(Properties.Resource.Error);
                context.Response.Write(eRunReport.ToString());
                return;
            }

            context.Response.BinaryWrite(htmlHandler.MainPageData);
        }
Example #11
0
        /// <summary>
        /// PrintMultiplePagesPerSheetForm_Load: Run the sample report and load it into the viewer control (first 20 pages - report normally runs to 100 pages).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PrintMultiplePagesPerSheetForm_Load(object sender, EventArgs e)
        {
            //Define and run the Invoice report
            var rpt = new SectionReport();

            rpt.LoadLayout(XmlReader.Create(Properties.Resources.Invoice));
            ((Data.OleDBDataSource)rpt.DataSource).ConnectionString = Properties.Resources.ConnectionString;
            rpt.Run(false);

            //Remove all but the first 20 pages from the generated report.
            while (rpt.Document.Pages.Count > 20)
            {
                rpt.Document.Pages.RemoveAt(rpt.Document.Pages.Count - 1);
            }

            arViewer.Document  = rpt.Document;
            apiViewer.Document = rpt.Document;

            // Find the maximum page size.
            PagesCollection pages = arViewer.Document.Pages;
            Page            page;

            _pageCount = pages.Count;
            for (int pageIndex = 0; pageIndex < _pageCount; pageIndex++)
            {
                page = pages[pageIndex];
                if (_maxPageSize.Width < page.Size.Width)
                {
                    _maxPageSize.Width = page.Size.Width;
                }

                if (_maxPageSize.Height < page.Size.Height)
                {
                    _maxPageSize.Height = page.Size.Height;
                }
            }

            // Convert to document units.
            _maxPageSize.Width  *= 100;
            _maxPageSize.Height *= 100;

            cmbPageCount.SelectedIndex = cmbPageCountAPI.SelectedIndex = 0;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            SectionReport rpt = new SectionReport();

            System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(Server.MapPath("~") + @"\RpxReports\NwindLabels.rpx");
            rpt.LoadLayout(xtr);
            xtr.Close();
            try
            {
                rpt.Run(false);
            }
            catch (ReportException eRunReport)
            {
                // Show error message to the user when there is a failure in generating the report.
                Response.Clear();
                Response.Write("<h1>Error running report:</h1>");
                Response.Write(eRunReport.ToString());
                return;
            }
            // Used when the page output is already getting created.
            Response.Buffer = true;
            // Clear the output contents from the buffer stream.
            Response.ClearContent();
            // Clear any headers from the buffer stream (such as the content type for an HTML page).
            Response.ClearHeaders();
            // Notify the browser that cache should not be created.
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            // Specify the appropriate viewer for the browser.
            Response.ContentType = "text/html";
            // Create an instance of the HTMLExport class.
            HtmlExport html = new HtmlExport {
                IncludeHtmlHeader = true
            };

            // Export the report to HTML in this session's webcache.
            RpxHandler.HtmlOutputHandler output = new RpxHandler.HtmlOutputHandler(Cache, "Custom HTML");
            html.Export(rpt.Document, output, string.Empty);
            Response.BinaryWrite(output.MainPageData);
            // Send all buffered content to the client
            Response.End();
        }
Example #13
0
        private void NormalPrint()
        {
            var preview = false;

            try
            {
                switch (reporteName)
                {
                case AppConstant.Reportes.Cocina:
                    report  = new ReporteCocina();
                    preview = AppConstant.GeneralInfo.Preview.Cocina;
                    break;

                case AppConstant.Reportes.Bar:
                    report  = new ReporteBar();
                    preview = AppConstant.GeneralInfo.Preview.Bar;
                    break;

                case AppConstant.Reportes.Cuenta:
                    report  = new ReporteRecibos();
                    preview = AppConstant.GeneralInfo.Preview.Recibos;
                    break;

                case AppConstant.Reportes.Boleta:
                    report  = new ReporteBoleta();
                    preview = AppConstant.GeneralInfo.Preview.Boleta;
                    break;

                case AppConstant.Reportes.Recibos:
                    report  = new ReporteRecibos();
                    preview = AppConstant.GeneralInfo.Preview.Recibos;
                    break;

                case AppConstant.Reportes.Turno:
                    report  = new ReporteTurno();
                    preview = AppConstant.GeneralInfo.Preview.Reportes;
                    break;

                case AppConstant.Reportes.ReporteVentas:
                    report  = new ReporteVentas();
                    preview = AppConstant.GeneralInfo.Preview.Reportes;
                    break;

                case AppConstant.Reportes.ReporteCierre:
                    report  = new ReporteCierre();
                    preview = AppConstant.GeneralInfo.Preview.Reportes;
                    break;
                }
                report.DataSource = dsReport;
                report.DataMember = tableNameReport;
                if (report.Document.Printer.PrinterName == "EPSON TM-T88III Receipt")
                {
                    report.Document.Printer.PrinterName = string.Empty;
                    var pSize = new PaperSize("EPSON", 80, 297);
                    report.Document.Printer.PaperKind = PaperKind.Custom;
                    report.Document.Printer.PaperSize = pSize;
                }
                else if (report.Document.Printer.PrinterName == "CITIZEN CT-S310" || printerName == "CITIZEN CT-S310")
                {
                    report.Document.Printer.PrinterName = "CITIZEN CT-S310";
                    //var pSize = new PaperSize("CITIZEN", 80, 297);
                    //rpt.Document.Printer.PaperKind = PaperKind.A4;
                    //rpt.Document.Printer.PaperSize = pSize;
                }
                else
                {
                    if (PrinterValid(printerName))
                    {
                        report.Document.Printer.PrinterName = printerName;
                    }
                    else
                    {
                        report.Document.Printer.PrinterName = string.Empty;
                    }
                }
                viewer1.Document = report.Document;
                report.Run();
                if (report.Document.Printer.PrinterName != string.Empty)
                {
                    report.Document.Print(false, false, false);
                }
                if (preview == false)
                {
                    Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(@"Error en reporte : " + ex.Message);
            }
        }