Пример #1
0
        /// <summary>
        /// Visualiza um relatório.
        /// <br>
        /// O relatório sempre será escrito no disco.
        /// </br>
        /// O designer é montando manualmente.
        /// </summary>
        /// <param name="report"></param>
        public static void PrintReportOverwrite(ReportImage report)
        {
            try
            {
                using (var ctx = new ReportContext())
                {
                    var    current = ctx.ReportImageDao.Find(report.IdReport);
                    string path    = Path.Combine(Application.StartupPath, "Reports", current.ReportName + ".repx");

                    FileManagerIts.WriteBytesToFile(path, current.ReportImageData);

                    //carregue a estrutura do relatório
                    XtraReport xreport = XtraReport.FromFile(path, true);

                    //objeto para gerar a tela de parametros
                    ReportPrintTool reportPrintTool = new ReportPrintTool(xreport);

                    //chama a tela de parametros
                    xreport.CreateDocument();

                    //gera o relatorio
                    PrintPreviewFormEx preview = new PrintPreviewFormEx();
                    preview.PrintingSystem = xreport.PrintingSystem;
                    //exibe o relatorio
                    preview.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                XMessageIts.Erro("Falha gerar relatório\n\n" + ex.Message, "Atenção!!!");
                LoggerUtilIts.GenerateLogs(ex);
            }
        }
        void PreviewForm_Shown(object sender, EventArgs e)
        {
            PrintPreviewFormEx  form = (PrintPreviewFormEx)sender;
            PrintPreviewBarItem item = (PrintPreviewBarItem)form.PrintBarManager.GetBarItemByCommand(PrintingSystemCommand.ExportFile);

            PopupMenu     control = (PopupMenu)((DevExpress.XtraBars.BarButtonItem)(item)).DropDownControl;
            BarButtonItem barItem = new BarButtonItem();

            barItem.ItemClick += barItem_ItemClick;
            barItem.Caption    = "Custom Item";
            control.AddItem(barItem);
        }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Create a PrintingSystem instance.
            PrintingSystemBase ps = new PrintingSystemBase();

            // Load the document from a stream.
            ps.LoadDocument(stream);

            // Create an instance of the preview dialog.
            PrintPreviewFormEx preview = new PrintPreviewFormEx();

            // Load the report document into it.
            preview.PrintingSystem = ps;

            // Show the preview dialog.
            preview.ShowDialog();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedValue == null)
            {
                MessageBox.Show("Please select a report.");
                return;
            }

            string reportName = comboBox1.SelectedValue.ToString();

            byte[] reportDocument = null;

            if (!reportName.Contains("Parametrized"))
            {
                reportDocument = client.GetReportDocument(reportName);
            }
            else
            {
                reportDocument = client.GetParametrizedReportDocument("HostApp.ParametrizedReport",
                                                                      new ReportParameterInfo[] {
                    new ReportParameterInfo()
                    {
                        Name = "parameter1", Value = DateTime.Now
                    }
                });
            }

            MemoryStream       memoryStream = new MemoryStream(reportDocument);
            PrintPreviewFormEx preview      = new PrintPreviewFormEx()
            {
                PrintingSystem = new PrintingSystem()
            };

            preview.PrintingSystem.LoadDocument(memoryStream);
            preview.ShowDialog();
        }
Пример #5
0
        void PreviewForm_Load(object sender, EventArgs e)
        {
            PrintPreviewFormEx frm = (PrintPreviewFormEx)sender;

            frm.PrintingSystem.ExecCommand(PrintingSystemCommand.Scale, new object[] { 0.7f });
        }
Пример #6
0
        private void btnOpenReport_ItemClick(object sender, ItemClickEventArgs e)
        {
            //DevExpress.XtraPrinting.Preview.Prev
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Filter = "Reports|*.prnx";
            ofd.Multiselect = false;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                PrintingSystem print = new PrintingSystem();
                print.LoadDocument(ofd.FileName);
                // Create an instance of the preview dialog.
                PrintPreviewFormEx preview = new PrintPreviewFormEx();

                // Load the report document into it.
                preview.PrintingSystem = print;

                // Show the preview dialog.
                preview.ShowDialog();

            }
        }
Пример #7
0
        /// <summary>
        /// Visualizar ou salvar o relatório selecionado do spool
        /// </summary>
        /// <param name="idSpool">Id do spool</param>
        /// <param name="typeGeracaoSpool">Informar o tipo: Visualizar, ExpPdf ou ExpExcel</param>
        public void GerarRelatorioFromSpool(Int32 idSpool, TypeGeracaoSpool typeGeracaoSpool)
        {
            using (var ctx = new ReportContext())
            {
                try
                {
                    var sv = new SaveFileDialog();
                    //relatorio selecionado
                    var relat = ctx.ReportSpoolDao.Find(idSpool);
                    //caminho temporario
                    var path = Application.StartupPath + "\\temp.prnx";
                    //escreve os bytes do relatorio selecionado no arquivo
                    var reportImageUnzip = ZipUtil.UnzipFromBytes(relat.ReportSpoolImage);
                    FileManagerIts.WriteBytesToFile(path, reportImageUnzip);
                    // Create a PrintingSystem instance.
                    PrintingSystem ps = new PrintingSystem();

                    // Load the document from a file.
                    ps.LoadDocument(path);

                    // Create an instance of the preview dialog.
                    PrintPreviewRibbonFormEx preview = new PrintPreviewRibbonFormEx();

                    PrintPreviewFormEx prev = new PrintPreviewFormEx();
                    prev.PrintingSystem = ps;
                    // Load the report document into it.
                    //preview.PrintingSystem = ps;
                    if (typeGeracaoSpool == TypeGeracaoSpool.PreVisualizar)
                    {
                        // Show the preview dialog.
                        //preview.ShowDialog(); //ribbon

                        //não ribbon
                        prev.Show();
                    }
                    else if (typeGeracaoSpool == TypeGeracaoSpool.ExportarParaPdf)
                    {
                        sv.Filter = "Arquivo PDF | *.pdf";
                        sv.ShowDialog();
                        if (sv.FileName != "")
                        {
                            ps.ExportToPdf(sv.FileName);
                        }
                    }
                    else if (typeGeracaoSpool == TypeGeracaoSpool.ExportarParaExcel)
                    {
                        sv.Filter = "Arquivo XLSX | *.xlsx";
                        sv.ShowDialog();
                        if (sv.FileName != "")
                        {
                            ps.ExportToXlsx(sv.FileName);
                        }
                    }
                    //Remova o relatorio temporario
                    FileManagerIts.DeleteFile(path);
                }
                catch
                (Exception
                 ex)
                {
                    LoggerUtilIts.ShowExceptionLogs(ex);
                }
            }
        }