Exemplo n.º 1
0
        private void PrintPDF(int distinctLeft, int distinctRight, int distinctTop, int distinctButtom, bool setPageSize)
        {
            //检查主体是否有数据
            if (rptViewer.ServerReport.GetTotalPages() < 1)
            {
                return;
            }

            //直接 打印

            ReportPrintDocument rp = new ReportPrintDocument(this.rptViewer.ServerReport, distinctLeft, distinctRight, distinctTop, distinctButtom);

            //rp.distinctButtom = distinctButtom;
            //rp.distinctLeft = distinctLeft;
            //rp.distinctRight = distinctRight;
            //rp.distinctTop = distinctTop;
            // MessageBox.Show(distinctTop.ToString() + "," + distinctButtom.ToString() + "," + left.ToString() + "," + right.ToString() + "234");
            if (setPageSize)
            {
                rp.Print();
                return;
            }
            else
            {
                // Allow the user to choose the page range he or she would
                // like to print.
                PrintDialog printDialog = new PrintDialog();
                printDialog.AllowSomePages = true;


                // Show the help button.
                printDialog.ShowHelp = true;


                // Set the Document property to the PrintDocument for
                // which the PrintPage Event has been handled. To display the
                // dialog, either this property or the PrinterSettings property
                // must be set
                printDialog.Document = rp;


                DialogResult result = printDialog.ShowDialog();


                // If the result is OK then print the document.
                if (result == DialogResult.OK)
                {
                    rp.Print();//开始打印
                }
            }
        }
Exemplo n.º 2
0
        private void PrintReport(string printerName, bool isLandscape, int noOfCopies, bool isAllPages, bool isCurrentpage, bool isPageRange, int fromPage, int toPage)
        {
            try
            {
                CurrentPage = rpViewer.CurrentPage;

                ReportPrintDocument rptPrintDoc = new ReportPrintDocument(rpViewer.LocalReport, isLandscape);
                rptPrintDoc.PrinterSettings.PrinterName = printerName;
                rptPrintDoc.NoofCopies = noOfCopies;
                if (isAllPages == true)
                {
                }
                else if (isCurrentpage == true)
                {
                    rptPrintDoc.PageRange = true;
                    rptPrintDoc.FromPage  = CurrentPage;
                    rptPrintDoc.ToPage    = CurrentPage;
                }
                else
                {
                    rptPrintDoc.PageRange = true;
                    rptPrintDoc.FromPage  = fromPage;
                    rptPrintDoc.ToPage    = toPage;
                }
                rptPrintDoc.Print();
            }
            catch (Exception ex)
            {
                Response.Output.WriteLine(ex.Message);
            }
        }
Exemplo n.º 3
0
        private void imprime_recibo_pago(int id_pago_registrado, string wimp_letra)
        {
            //MANDAR IMPRIMIR
            sp_Recibo_de_PagoTableAdapter recibo_pago_tableAdapter = new sp_Recibo_de_PagoTableAdapter();

            Sporting_Gym_Dataset.sp_Recibo_de_PagoDataTable recibo_pago_dataTable = new Sporting_Gym_Dataset.sp_Recibo_de_PagoDataTable();
            recibo_pago_tableAdapter.Fill(recibo_pago_dataTable, id_pago_registrado, wimp_letra);

            ReportDataSource recibo_pago_datasource = new ReportDataSource("Recibo_de_Pago_DataSet", (DataTable)recibo_pago_dataTable);

            reporte_reportViewer.LocalReport.DataSources.Clear();

            reporte_reportViewer.LocalReport.DataSources.Add(recibo_pago_datasource);
            reporte_reportViewer.LocalReport.Refresh();
            reporte_reportViewer.RefreshReport();

            ReportPrintDocument print = new ReportPrintDocument(reporte_reportViewer.LocalReport);

            print.Print();

            reporte_gym_reportViewer.LocalReport.DataSources.Clear();

            reporte_gym_reportViewer.LocalReport.DataSources.Add(recibo_pago_datasource);
            reporte_gym_reportViewer.LocalReport.Refresh();
            reporte_gym_reportViewer.RefreshReport();

            ReportPrintDocument print2 = new ReportPrintDocument(reporte_gym_reportViewer.LocalReport);

            print2.Print();

            //FIN IMPRESION DE RECIBO DE PAGO
        }
Exemplo n.º 4
0
    //protected void Page_Init(object Sender, EventArgs e)
    //{
    //    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    //    Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
    //    Response.Cache.SetNoStore();
    //}
    protected void Button1_Click(object sender, EventArgs e)
    {
        LocalReport lr = new LocalReport();

        lr.ReportPath = "Report.rdlc";
        rpd           = new ReportPrintDocument(lr);
        rpd.Print();
    }
Exemplo n.º 5
0
        public void Easy_Print(String printName, PaperKind paperKind, Boolean isHorizon, Boolean isShowPrintDlg)
        {
            PrinterSettings printerSettings = new PrinterSettings();
            PageSettings    pageSetting;

            if (printName != null && printName.Equals("") == false)
            {
                printerSettings.PrinterName = printName;
                pageSetting = new PageSettings(printerSettings);
            }
            else
            {
                pageSetting = new PageSettings();
            }

            PaperSize paperSize = new PaperSize();

            paperSize.PaperName = paperKind.ToString();
            paperSize.RawKind   = (int)paperKind;

            pageSetting.PaperSize = paperSize;
            pageSetting.Landscape = isHorizon;

            if (isShowPrintDlg)
            {
                /*
                 * SetPageSettings(pageSetting);
                 * if (printName != null && printName.Equals("") == false) PrintDialog(PrinterSettings);
                 * else
                 */
                _rv.PrintDialog();
            }
            else
            {
                try
                {
                    _reportPrintDoc = new ReportPrintDocument(_rv.LocalReport);
                    _reportPrintDoc.DefaultPageSettings = pageSetting;
                    _reportPrintDoc.Print();
                }
                catch
                {
                    try
                    {
                        _rv.PrintDialog();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("프린트시 에러발생.." + e.ToString());
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void Imprime(TRegistro_CadContaGer LayoutCh,
                             bool St_imprimir,
                             bool St_visualizar,
                             bool St_enviaremail,
                             List <string> Destinatarios,
                             string Titulo,
                             string Mensagem)
        {
            InlineReportSlot InlineNF = new InlineReportSlot();

            if (!string.IsNullOrEmpty(LayoutCh.LayoutCheque))
            {
                InlineNF.DocumentStream = LayoutCh.LayoutCheque;
            }
            else
            {
                InlineNF.DocumentStream = Utils.ResourcesUtils.ModeloCheque;
            }
            this.reportManager.Reports.Add(InlineNF);
            this.reportManager.Reports[0].LoadReport();
            this.reportManager.Reports[0].Prepare();
            this.reportManager.Reports[0].GetReportParameter += new PerpetuumSoft.Reporting.Components.GetReportParameterEventHandler(this.Parametros);
            if (St_imprimir)
            {
                using (System.Windows.Forms.PrintDialog pd = new PrintDialog())
                {
                    pd.UseEXDialog = true;
                    if (pd.ShowDialog() == DialogResult.OK)
                    {
                        using (ReportPrintDocument rpd = new ReportPrintDocument())
                        {
                            rpd.PrinterSettings = pd.PrinterSettings;
                            rpd.Source          = InlineNF;
                            rpd.Print();
                        }
                    }
                }
            }
            else if (St_visualizar)
            {
                using (PerpetuumSoft.Reporting.View.PreviewForm view = new PerpetuumSoft.Reporting.View.PreviewForm(this.reportManager.Reports[0]))
                {
                    view.WindowState = FormWindowState.Maximized;
                    view.ShowDialog();
                }
            }

            if (St_enviaremail)
            {
                using (PerpetuumSoft.Reporting.Export.Pdf.PdfExportFilter pdf = new PerpetuumSoft.Reporting.Export.Pdf.PdfExportFilter())
                {
                    string path_anexo = System.IO.Path.GetTempPath();
                    if (!path_anexo.EndsWith("\\"))
                    {
                        path_anexo += System.IO.Path.DirectorySeparatorChar.ToString();
                    }
                    path_anexo += "CHEQUE" + DateTime.Now.Date.Year.ToString() + DateTime.Now.Date.Month.ToString() + DateTime.Now.Date.Day.ToString() + DateTime.Now.Date.Hour.ToString() + DateTime.Now.Date.Minute.ToString() + DateTime.Now.Date.Second.ToString() + ".pdf";
                    if (pdf.ShowDialog() == DialogResult.OK)
                    {
                        pdf.Export(InlineNF.Document, path_anexo, false);
                        if (new Email(Destinatarios,
                                      Titulo,
                                      Mensagem,
                                      new List <string>()
                        {
                            path_anexo
                        }).EnviarEmail())
                        {
                            MessageBox.Show("Email enviado com sucesso.");
                        }
                        if (System.IO.File.Exists(path_anexo))
                        {
                            try
                            {
                                System.IO.File.Delete(path_anexo);
                            }
                            catch { }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        public bool Gera_Relatorio(string Documento,
                                   bool St_imprimir,
                                   bool St_visualizar,
                                   bool St_enviaremail,
                                   bool St_exportPdf,
                                   string Path_exportPdf,
                                   List <string> Destinatarios,
                                   List <string> Anexos,
                                   string Titulo,
                                   string Mensagem,
                                   bool St_enviarcomoanexo)
        {
            bool retorno = false;

            try
            {
                //VERIFICA SE JÁ TEM O ITEM LANÇADO
                if (string.IsNullOrEmpty(Cad_Report.DS_Report))
                {
                    Cad_Report.Modulo    = Modulo;
                    Cad_Report.NM_Classe = NM_Classe;
                    Cad_Report.DS_Report = NM_Classe;
                    Cad_Report.Ident     = Ident;
                }

                //Se nao existir relatorio no banco, baixar da net
                if (!BuscaRelatorio())
                {
                    if (AtualizarRDC.VerificarVersaoRDC(Cad_Report, false))
                    {
                        BuscaRelatorio();
                    }
                }

                XmlDocument docXMLRelatorio = new XmlDocument();
                if (Cad_Report.Code_Report != null)
                {
                    docXMLRelatorio.LoadXml(System.Text.ASCIIEncoding.UTF8.GetString(Compact_Data.Descompactar(Cad_Report.Code_Report, string.Empty)));
                }

                //CRIA O ARQUIVO PARA O RELATORIO
                InlineReportSlot ArquivoRelatorio = new InlineReportSlot();
                //ADICIONAR O NOME E OS PARAMETROS
                ArquivoRelatorio.GetReportParameter += new GetReportParameterEventHandler(Parametros);
                Nome_Relatorio = Nome_Relatorio.Replace(' ', '_');
                ArquivoRelatorio.ReportName = Nome_Relatorio;
                reportManager.DataSources.Add("DTS", DTS_Relatorio);

                if (Cad_Report.Code_Report != null)
                {
                    //ADICIONA O STREAM DO RELATORIO (XML)
                    ArquivoRelatorio.DocumentStream = docXMLRelatorio.InnerXml;
                    reportManager.Reports.Add(ArquivoRelatorio);

                    if (!Altera_Relatorio)
                    {
                        reportManager.Reports[0].LoadReport();
                        reportManager.Reports[0].Prepare();
                        reportManager.Reports[0].RenderDocument();

                        using (PerpetuumSoft.Reporting.View.PreviewForm view = new PerpetuumSoft.Reporting.View.PreviewForm(reportManager.Reports[0]))
                        {
                            if (St_imprimir)
                            {
                                object obj = new CamadaDados.Diversos.TCD_CadTerminal().BuscarEscalar(
                                    new TpBusca[]
                                {
                                    new TpBusca()
                                    {
                                        vNM_Campo = "a.cd_terminal",
                                        vOperador = "=",
                                        vVL_Busca = "'" + Utils.Parametros.pubTerminal.Trim() + "'"
                                    }
                                }, "a.impressorapadrao");
                                string print = obj == null ? string.Empty : obj.ToString();
                                if (!string.IsNullOrEmpty(print))
                                {
                                    bool existe = false;
                                    for (int i = 0; i < System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count; i++)
                                    {
                                        string teste = System.Drawing.Printing.PrinterSettings.InstalledPrinters[i];
                                        if (System.Drawing.Printing.PrinterSettings.InstalledPrinters[i].Trim().ToUpper().Equals(print.Trim().ToUpper()))
                                        {
                                            existe = true;
                                            break;
                                        }
                                    }
                                    if (!existe)
                                    {
                                        print = string.Empty;
                                    }
                                }

                                if (!string.IsNullOrEmpty(print))
                                {
                                    using (ReportPrintDocument rpd = new ReportPrintDocument())
                                    {
                                        decimal copias = CamadaNegocio.ConfigGer.TCN_CadParamGer.BuscaVlNumerico("QTD_VIA_DANFE", null);
                                        rpd.PrinterSettings.Copies      = copias == decimal.Zero ? (short)1 : (short)copias;
                                        rpd.PrinterSettings.PrinterName = print;
                                        rpd.Source = ArquivoRelatorio;
                                        rpd.Print();
                                    }
                                }
                                else
                                {
                                    using (System.Windows.Forms.PrintDialog pd = new PrintDialog())
                                    {
                                        pd.UseEXDialog = true;
                                        if (pd.ShowDialog() == DialogResult.OK)
                                        {
                                            using (ReportPrintDocument rpd = new ReportPrintDocument())
                                            {
                                                rpd.PrinterSettings = pd.PrinterSettings;
                                                rpd.Source          = ArquivoRelatorio;
                                                rpd.Print();
                                            }
                                        }
                                    }
                                }
                            }
                            else if (St_visualizar)
                            {
                                view.WindowState = FormWindowState.Maximized;
                                view.ShowDialog();
                                retorno = true;
                            }
                            else if (St_exportPdf && !string.IsNullOrEmpty(Path_exportPdf))
                            {
                                using (PdfExportFilter pdf = new PdfExportFilter())
                                {
                                    pdf.Export(this.reportManager.Reports[0].Document, Path_exportPdf, false);
                                    retorno = true;
                                }
                            }
                        }
                        if (St_enviaremail)
                        {
                            using (PdfExportFilter pdf = new PdfExportFilter())
                            {
                                string path_anexo = TCN_CadParamGer.BuscaVlString("PATH_ANEXO_EMAIL", null);
                                if (string.IsNullOrEmpty(path_anexo))
                                {
                                    throw new Exception("Não existe path anexo cadastrado nas configurações gerais do sistema!");
                                }
                                if (!System.IO.Directory.Exists(path_anexo))
                                {
                                    System.IO.Directory.CreateDirectory(path_anexo);
                                }
                                if (!path_anexo.EndsWith("\\"))
                                {
                                    path_anexo += System.IO.Path.DirectorySeparatorChar.ToString();
                                }
                                path_anexo += "NFCE" + DateTime.Now.Date.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".pdf";
                                pdf.Export(this.reportManager.Reports[0].Document, path_anexo, false);
                                if (Anexos == null)
                                {
                                    Anexos = new List <string>();
                                }
                                Anexos.Add(path_anexo);
                                new Email(Destinatarios,
                                          Titulo,
                                          Mensagem,
                                          Anexos).EnviarEmail();
                                retorno = true;
                            }
                        }
                    }
                    else
                    {
                        Editar();
                    }
                }
                else
                {
                    Editar();
                }
            }
            catch (Exception erro)
            { MessageBox.Show(erro.Message, "Mensagem"); }
            return(retorno);
        }
Exemplo n.º 8
0
        public bool ImprimiGraficoReduzida(string Print,
                                           bool St_imprimir,
                                           bool St_visualizar,
                                           List <string> Destinatarios,
                                           string Titulo,
                                           string Mensagem,
                                           short copia)
        {
            bool retorno = false;

            try
            {
                //VERIFICA SE JÁ TEM O ITEM LANÇADO
                if (string.IsNullOrEmpty(Cad_Report.DS_Report))
                {
                    Cad_Report.Modulo    = Modulo;
                    Cad_Report.NM_Classe = NM_Classe;
                    Cad_Report.DS_Report = NM_Classe;
                    Cad_Report.Ident     = Ident;
                }

                //Se nao existir relatorio no banco, baixar da net
                if (!BuscaRelatorio())
                {
                    if (AtualizarRDC.VerificarVersaoRDC(Cad_Report, false))
                    {
                        BuscaRelatorio();
                    }
                }

                XmlDocument docXMLRelatorio = new XmlDocument();
                if (Cad_Report.Code_Report != null)
                {
                    docXMLRelatorio.LoadXml(System.Text.ASCIIEncoding.UTF8.GetString(Compact_Data.Descompactar(Cad_Report.Code_Report, string.Empty)));
                }

                //CRIA O ARQUIVO PARA O RELATORIO
                InlineReportSlot ArquivoRelatorio = new InlineReportSlot();
                //ADICIONAR O NOME E OS PARAMETROS
                ArquivoRelatorio.GetReportParameter += new GetReportParameterEventHandler(Parametros);
                Nome_Relatorio = Nome_Relatorio.Replace(' ', '_');
                ArquivoRelatorio.ReportName = Nome_Relatorio;
                reportManager.DataSources.Add("DTS", DTS_Relatorio);

                if (Cad_Report.Code_Report != null)
                {
                    //ADICIONA O STREAM DO RELATORIO (XML)
                    ArquivoRelatorio.DocumentStream = docXMLRelatorio.InnerXml;
                    reportManager.Reports.Add(ArquivoRelatorio);

                    if (!Altera_Relatorio)
                    {
                        reportManager.Reports[0].LoadReport();
                        reportManager.Reports[0].Prepare();
                        reportManager.Reports[0].RenderDocument();

                        using (PerpetuumSoft.Reporting.View.PreviewForm view = new PerpetuumSoft.Reporting.View.PreviewForm(reportManager.Reports[0]))
                        {
                            if (St_imprimir)
                            {
                                using (ReportPrintDocument rpd = new ReportPrintDocument())
                                {
                                    rpd.PrinterSettings.PrinterName = Print;
                                    rpd.Source = ArquivoRelatorio;
                                    for (int i = 0; i < copia; i++)
                                    {
                                        rpd.Print();
                                    }
                                }
                            }
                            else if (St_visualizar)
                            {
                                view.WindowState = FormWindowState.Maximized;
                                view.ShowDialog();
                                retorno = true;
                            }
                        }
                        if (Destinatarios == null ? false : Destinatarios.Count > 0)
                        {
                            using (PdfExportFilter pdf = new PdfExportFilter())
                            {
                                string path_anexo = TCN_CadParamGer.BuscaVlString("PATH_ANEXO_EMAIL", null);
                                if (string.IsNullOrEmpty(path_anexo))
                                {
                                    throw new Exception("Não existe path anexo cadastrado nas configurações gerais do sistema!");
                                }
                                if (!System.IO.Directory.Exists(path_anexo))
                                {
                                    System.IO.Directory.CreateDirectory(path_anexo);
                                }
                                if (!path_anexo.EndsWith("\\"))
                                {
                                    path_anexo += System.IO.Path.DirectorySeparatorChar.ToString();
                                }
                                path_anexo += "NFCE" + DateTime.Now.Date.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + ".pdf";
                                pdf.Export(this.reportManager.Reports[0].Document, path_anexo, false);
                                List <string> Anexos = new List <string>();
                                Anexos.Add(path_anexo);
                                new Email(Destinatarios,
                                          Titulo,
                                          Mensagem,
                                          Anexos).EnviarEmail();
                                retorno = true;
                            }
                        }
                    }
                    else
                    {
                        Editar();
                    }
                }
                else
                {
                    Editar();
                }
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message, "Mensagem");
            }
            return(retorno);
        }
Exemplo n.º 9
0
        private void Print(LocalReport report)
        {
            ReportPrintDocument printDocument = new ReportPrintDocument(report);

            printDocument.Print();
        }
 //protected void Page_Init(object Sender, EventArgs e)
 //{
 //    Response.Cache.SetCacheability(HttpCacheability.NoCache);
 //    Response.Cache.SetExpires(DateTime.Now.AddSeconds(-1));
 //    Response.Cache.SetNoStore();
 //}
 protected void Button1_Click(object sender, EventArgs e)
 {
     LocalReport lr = new LocalReport();
     lr.ReportPath = "Report.rdlc";
     rpd = new ReportPrintDocument(lr);
     rpd.Print();
 }
Exemplo n.º 11
0
        protected void btnPrint_Click(object sender, EventArgs e)
        {
            ReportPrintDocument rp = new ReportPrintDocument(ReportViewer1.ServerReport);

            rp.Print();
        }