Ejemplo n.º 1
0
        private void FrmPedido_Load(object sender, EventArgs e)
        {
            try {
                Herramientas herramientas = new Herramientas();
                var          recursos     = herramientas.GetResourcesPath2();
                this.reportViewer1.ProcessingMode = ProcessingMode.Local;
                reportViewer1.LocalReport.EnableExternalImages = true;

                reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
                reportViewer1.ZoomMode    = ZoomMode.Percent;
                reportViewer1.ZoomPercent = 100;
                reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.DTPedido.rdlc";


                ReportDataSource datos = new ReportDataSource();
                datos.Name  = "DetalleDocumento";
                datos.Value = lst;
                ReportDataSource datos2 = new ReportDataSource();
                datos2.Name  = "General";
                datos2.Value = general;
                this.reportViewer1.RefreshReport();
                this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(datos);
                this.reportViewer1.LocalReport.DataSources.Add(datos2);
                this.reportViewer1.RefreshReport();

                Warning[] warnings;
                string[]  streamids;
                string    mimeType;
                string    encoding;
                string    filenameExtension;
                //ToString("yyyy-MM-dd")
                byte[] bytes = reportViewer1.LocalReport.Render(
                    "PDF", null, out mimeType, out encoding, out filenameExtension,
                    out streamids, out warnings);

                using (FileStream fs = new FileStream(@"PEDIDOS_PDF\\" + nomdocumento + ".pdf", FileMode.Create))
                {
                    fs.Write(bytes, 0, bytes.Length);
                }
            }
            catch (Exception a) { MessageBox.Show(a.Message); }
        }
        private void FrmFactura2_Load(object sender, EventArgs e)
        {
            Herramientas herramientas = new Herramientas();
            var          recursos     = herramientas.GetResourcesPath2();

            /*FIRMA PDF*/
            var nomdocumento = _documento.Emisor.NroDocumento + "-" + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "-" + _documento.IdDocumento;

            String datosAdicionales_CDB = "";
            String CodigoCertificado    = "";

            datosAdicionales_CDB = _documento.Emisor.NroDocumento + "|" + _documento.TipoDocumento + "|" + _documento.IdDocumento + "|" + _documento.TotalIgv + "|" + _documento.TotalVenta + "|"
                                   + _documento.FechaEmision + "|" + _documento.Receptor.TipoDocumento + "|" + _documento.Receptor.NroDocumento;
            CodigoCertificado = datosAdicionales_CDB + "|" + _documento.FirmaDigital + "|";

            QRCodeGenerator codigobarras = new QRCodeGenerator();
            QRCodeData      qrcode       = codigobarras.CreateQrCode(CodigoCertificado, QRCodeGenerator.ECCLevel.Q);
            QRCode          qrco         = new QRCode(qrcode);

            System.Drawing.Bitmap bm = qrco.GetGraphic(20);

            //bm.Save(@"C:\DOCUMENTOS ELECTRONICOS\CERTIFIK\QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bm.Save(@"QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);


            /*FIN FIRMA*/

            List <ReportParameter> parametro = new List <ReportParameter>();

            //parametro.Add(new ReportParameter("pLogo", @"file:///C:/PIURAMAQ.png"));
            parametro.Add(new ReportParameter("pLogo", @"file:///" + recursos + "/" + nomdocumento + ".jpeg"));
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;
            reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.DTFactura2.rdlc";
            reportViewer1.LocalReport.SetParameters(parametro);

            ReportDataSource datos = new ReportDataSource();

            datos.Name  = "DetalleDocumento";
            datos.Value = lst;
            ReportDataSource datos2 = new ReportDataSource();

            datos2.Name  = "Empresa";
            datos2.Value = empresa;
            ReportDataSource datos3 = new ReportDataSource();

            datos3.Name  = "General";
            datos3.Value = general;
            ReportDataSource datos4 = new ReportDataSource();

            datos4.Name  = "Receptor";
            datos4.Value = receptor;
            ReportDataSource datos5 = new ReportDataSource();

            datos5.Name  = "Otros";
            datos5.Value = otros;


            this.reportViewer1.RefreshReport();
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(datos);
            this.reportViewer1.LocalReport.DataSources.Add(datos2);
            this.reportViewer1.LocalReport.DataSources.Add(datos3);
            this.reportViewer1.LocalReport.DataSources.Add(datos4);
            this.reportViewer1.LocalReport.DataSources.Add(datos5);
            this.reportViewer1.RefreshReport();


            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            //ToString("yyyy-MM-dd")
            byte[] bytes = reportViewer1.LocalReport.Render(
                "PDF", null, out mimeType, out encoding, out filenameExtension,
                out streamids, out warnings);

            using (FileStream fs = new FileStream(@"FACTURAS_PDF\\" + nomdocumento + ".pdf", FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }
            //this.Close();
        }
Ejemplo n.º 3
0
        private void FrmND_Load(object sender, EventArgs e)
        {
            Herramientas herramientas = new Herramientas();
            var          recursos     = herramientas.GetResourcesPath2();

            /*FIRMA PDF*/
            var nomdocumento = _documento.Emisor.NroDocumento + "-" + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "-" + _documento.IdDocumento;

            String datosAdicionales_CDB = "";
            String CodigoCertificado    = "";
            String firmadig             = "";

            datosAdicionales_CDB = _documento.Emisor.NroDocumento + "|" + _documento.TipoDocumento + "|" + _documento.IdDocumento + "|" + _documento.TotalIgv + "|" + _documento.TotalVenta + "|"
                                   + _documento.FechaEmision + "|" + _documento.Receptor.TipoDocumento + "|" + _documento.Receptor.NroDocumento;
            CodigoCertificado = datosAdicionales_CDB + "|" + _documento.FirmaDigital;

            /*BarcodePDF417 codigobarras = new BarcodePDF417();
             * codigobarras.Options = BarcodePDF417.PDF417_USE_ASPECT_RATIO;
             * codigobarras.ErrorLevel = 5;
             * codigobarras.YHeight = 6f;
             * codigobarras.SetText(CodigoCertificado);
             * System.Drawing.Bitmap bm = new System.Drawing.Bitmap(codigobarras.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
             * //bm.Save(@"C:\DOCUMENTOS ELECTRONICOS\CERTIFIK\QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
             * bm.Save(@"QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);*/

            var qrEncoder = new QrEncoder(ErrorCorrectionLevel.H);
            var qrCode    = qrEncoder.Encode(datosAdicionales_CDB);

            var renderer = new GraphicsRenderer(new FixedModuleSize(5, QuietZoneModules.Two), Brushes.Black, Brushes.White);

            using (var stream = new FileStream(recursos + "\\" + nomdocumento + ".jpeg", FileMode.Create))
            {
                renderer.WriteToStream(qrCode.Matrix, ImageFormat.Jpeg, stream);
            }

            //LogoEmp = CargarImagen(@"QR\" + nomdocumento + ".jpeg");



            /*FIN FIRMA*/

            List <ReportParameter> parametro = new List <ReportParameter>();

            //parametro.Add(new ReportParameter("pLogo", @"file:///C:/PIURAMAQ.png"));
            parametro.Add(new ReportParameter("pLogo", @"file:///" + recursos + "/" + nomdocumento + ".jpeg"));
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;
            reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.DTND.rdlc";
            reportViewer1.LocalReport.SetParameters(parametro);
            ReportDataSource datos = new ReportDataSource();

            datos.Name  = "DetalleDocumento";
            datos.Value = lst;
            ReportDataSource datos2 = new ReportDataSource();

            datos2.Name  = "Empresa";
            datos2.Value = empresa;
            ReportDataSource datos3 = new ReportDataSource();

            datos3.Name  = "General";
            datos3.Value = general;
            ReportDataSource datos4 = new ReportDataSource();

            datos4.Name  = "Receptor";
            datos4.Value = receptor;
            ReportDataSource datos5 = new ReportDataSource();

            datos5.Name  = "Discrepancias";
            datos5.Value = this.discrepancia;
            ReportDataSource datos6 = new ReportDataSource();

            datos6.Name  = "Otros";
            datos6.Value = otros;


            this.reportViewer1.RefreshReport();
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(datos);
            this.reportViewer1.LocalReport.DataSources.Add(datos2);
            this.reportViewer1.LocalReport.DataSources.Add(datos3);
            this.reportViewer1.LocalReport.DataSources.Add(datos4);
            this.reportViewer1.LocalReport.DataSources.Add(datos5);
            this.reportViewer1.LocalReport.DataSources.Add(datos6);

            this.reportViewer1.RefreshReport();


            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            //ToString("yyyy-MM-dd")
            byte[] bytes = reportViewer1.LocalReport.Render(
                "PDF", null, out mimeType, out encoding, out filenameExtension,
                out streamids, out warnings);

            using (FileStream fs = new FileStream(@"NOTA_DEBITO_PDF\\" + nomdocumento + ".pdf", FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }
        }
        private void FrmRetencion_Load(object sender, EventArgs e)
        {
            Herramientas herramientas = new Herramientas();
            var          recursos     = herramientas.GetResourcesPath2();

            /*FIRMA PDF*/
            var nomdocumento = _documento.Emisor.NroDocumento + "-" + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "-" + _documento.DocumentoRetencion.IdDocumento;

            String datosAdicionales_CDB = "";
            String CodigoCertificado    = "";

            string[] Serie = _documento.IdDocumento.Split('-');

            datosAdicionales_CDB = _documento.Emisor.NroDocumento + "|" + _documento.TipoDocumento + "|" + Serie[0] + "|" + Serie[1] + "|" + _documento.TotalIgv + "|" + _documento.DocumentoRetencion.ImporteTotalRetenido + "|"
                                   + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "|" + _documento.DocumentoRetencion.Receptor.TipoDocumento + "|" + _documento.DocumentoRetencion.Receptor.NroDocumento + "|" + _documento.ResumenFirma;
            CodigoCertificado = datosAdicionales_CDB;//+ "|" + _documento.FirmaDigital;
            BarcodePDF417 codigobarras = new BarcodePDF417();

            codigobarras.Options    = BarcodePDF417.PDF417_USE_ASPECT_RATIO;
            codigobarras.ErrorLevel = 5;
            codigobarras.YHeight    = 6f;
            codigobarras.SetText(CodigoCertificado);
            System.Drawing.Bitmap bm = new System.Drawing.Bitmap(codigobarras.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
            //bm.Save(@"C:\DOCUMENTOS ELECTRONICOS\CERTIFIK\QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bm.Save(@"QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);

            List <ReportParameter> parametro = new List <ReportParameter>();

            parametro.Add(new ReportParameter("pLogo", @"file:///" + recursos + "/" + nomdocumento + ".jpeg"));
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;
            reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.DTRetencion.rdlc";
            reportViewer1.LocalReport.SetParameters(parametro);

            ReportDataSource datos = new ReportDataSource();

            datos.Name  = "DetalleDocumento";
            datos.Value = lst;
            ReportDataSource datos2 = new ReportDataSource();

            datos2.Name  = "Empresa";
            datos2.Value = empresa;
            ReportDataSource datos3 = new ReportDataSource();

            datos3.Name  = "General";
            datos3.Value = general;
            ReportDataSource datos4 = new ReportDataSource();

            datos4.Name  = "Receptor";
            datos4.Value = receptor;
            ReportDataSource datos5 = new ReportDataSource();

            datos5.Name  = "Otros";
            datos5.Value = otros;
            ReportDataSource datos6 = new ReportDataSource();

            datos6.Name  = "Items";
            datos6.Value = item;
            ReportDataSource datos7 = new ReportDataSource();

            datos7.Name  = "Retencion";
            datos7.Value = retencion;

            /*FIN FIRMA*/
            this.reportViewer1.RefreshReport();
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(datos);
            this.reportViewer1.LocalReport.DataSources.Add(datos2);
            this.reportViewer1.LocalReport.DataSources.Add(datos3);
            this.reportViewer1.LocalReport.DataSources.Add(datos4);
            this.reportViewer1.LocalReport.DataSources.Add(datos5);
            this.reportViewer1.LocalReport.DataSources.Add(datos6);
            this.reportViewer1.LocalReport.DataSources.Add(datos7);


            this.reportViewer1.RefreshReport();


            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            //ToString("yyyy-MM-dd")
            byte[] bytes = reportViewer1.LocalReport.Render(
                "PDF", null, out mimeType, out encoding, out filenameExtension,
                out streamids, out warnings);

            using (FileStream fs = new FileStream(@"RETENCION_PDF\\" + nomdocumento + ".pdf", FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }
        }
Ejemplo n.º 5
0
        private void FrmTFactura_Load(object sender, EventArgs e)
        {
            Herramientas herramientas = new Herramientas();
            var          recursos     = herramientas.GetResourcesPath2();

            /*FIRMA PDF*/
            var nomdocumento = _documento.Emisor.NroDocumento + "-" + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "-" + _documento.IdDocumento;

            String datosAdicionales_CDB = "";
            String CodigoCertificado    = "";

            datosAdicionales_CDB = _documento.Emisor.NroDocumento + "|" + _documento.TipoDocumento + "|" + _documento.IdDocumento + "|" + _documento.TotalIgv + "|" + _documento.TotalVenta + "|"
                                   + _documento.FechaEmision + "|" + _documento.Receptor.TipoDocumento + "|" + _documento.Receptor.NroDocumento;
            CodigoCertificado = datosAdicionales_CDB + "|" + _documento.FirmaDigital;
            BarcodePDF417 codigobarras = new BarcodePDF417();

            codigobarras.Options    = BarcodePDF417.PDF417_USE_ASPECT_RATIO;
            codigobarras.ErrorLevel = 5;
            codigobarras.YHeight    = 6f;
            codigobarras.SetText(CodigoCertificado);
            System.Drawing.Bitmap bm = new System.Drawing.Bitmap(codigobarras.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
            //bm.Save(@"C:\DOCUMENTOS ELECTRONICOS\CERTIFIK\QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bm.Save(@"QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);


            /*FIN FIRMA*/

            List <ReportParameter> parametro = new List <ReportParameter>();

            //parametro.Add(new ReportParameter("pLogo", @"file:///C:/PIURAMAQ.png"));
            parametro.Add(new ReportParameter("pLogo", @"file:///" + recursos + "/" + nomdocumento + ".jpeg"));
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;

            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;
            reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.TFactura.rdlc";
            reportViewer1.LocalReport.SetParameters(parametro);

            ReportDataSource datos = new ReportDataSource();

            datos.Name  = "DetalleDocumento";
            datos.Value = lst;
            ReportDataSource datos2 = new ReportDataSource();

            datos2.Name  = "Empresa";
            datos2.Value = empresa;
            ReportDataSource datos3 = new ReportDataSource();

            datos3.Name  = "General";
            datos3.Value = general;
            ReportDataSource datos4 = new ReportDataSource();

            datos4.Name  = "Receptor";
            datos4.Value = receptor;
            ReportDataSource datos5 = new ReportDataSource();

            datos5.Name  = "Otros";
            datos5.Value = otros;


            this.reportViewer1.RefreshReport();
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(datos);
            this.reportViewer1.LocalReport.DataSources.Add(datos2);
            this.reportViewer1.LocalReport.DataSources.Add(datos3);
            this.reportViewer1.LocalReport.DataSources.Add(datos4);
            this.reportViewer1.LocalReport.DataSources.Add(datos5);
            this.reportViewer1.RefreshReport();


            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            //ToString("yyyy-MM-dd")
            byte[] bytes = reportViewer1.LocalReport.Render(
                "PDF", null, out mimeType, out encoding, out filenameExtension,
                out streamids, out warnings);

            using (FileStream fs = new FileStream(@"FACTURAS_PDF\\" + nomdocumento + "-1.pdf", FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }


            /* PrintDocument printDocument = new PrintDocument();
             * printDocument.PrinterSettings.PrinterName = "\\\\192.168.1.35\\EPSON LX-350 ESC/P";
             *
             * if (!printDocument.PrinterSettings.IsValid)
             *   return; //ImpresoraNoEncontrada
             *
             * //printDocument.PrintPage += new PrintPageEventHandler(PrintPage);
             * //printDocument.PrintPage+=new PrintPageEventHandler();
             * printDocument.Print();*/

            /* try
             * {
             *   var streamToPrint = new StreamReader
             *                      ("C:\\MyFile.txt");
             *   try
             *   {
             *       //printFont = new Font("Arial", 10);
             *       PrintDocument pd = new PrintDocument();
             *       pd.PrintPage += new PrintPageEventHandler
             *          (this.pd_PrintPage);
             *       pd.Print();
             *   }
             *   finally
             *   {
             *       streamToPrint.Close();
             *   }
             * }
             * catch (Exception ex)
             * {
             *   MessageBox.Show(ex.Message);
             * }*/
            //printaFactura( nomdocumento);

            /* ProcessStartInfo info = new ProcessStartInfo();
             * info.Verb = "print";
             * info.FileName = @"FACTURAS_PDF\\" + nomdocumento + ".pdf";
             * info.CreateNoWindow = true;
             * info.WindowStyle = ProcessWindowStyle.Hidden;
             *
             * Process p = new Process();
             * p.StartInfo = info;
             * p.Start();
             *
             * p.WaitForInputIdle();
             * System.Threading.Thread.Sleep(3000);
             * if (false == p.CloseMainWindow())
             *   p.Kill();*/

            /* var informe = herramientas.GetResourcesPath3();
             * PrintDialog pd = new PrintDialog();
             * pd.PrinterSettings = new PrinterSettings();
             * pd.PrinterSettings.PrinterName = "\\\\192.168.1.35\\EPSON LX-350 ESC/P";
             *
             * Process printjob = new Process();
             * printjob.StartInfo.FileName = @"FACTURAS_PDF\\" + nomdocumento + ".pdf";
             * printjob.StartInfo.Arguments = pd.PrinterSettings.PrinterName;
             * printjob.StartInfo.UseShellExecute = true;
             * printjob.StartInfo.CreateNoWindow = true;
             * printjob.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
             * printjob.StartInfo.Verb = "print";
             * printjob.Start();*/


            /*Process impresion = new Process();
             * impresion.StartInfo.FileName = @"FACTURAS_PDF\\" + nomdocumento + ".pdf";
             * impresion.StartInfo.UseShellExecute = true;
             * impresion.StartInfo.CreateNoWindow = true;
             * impresion.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
             * impresion.StartInfo.Verb = "print";
             * impresion.Start();*/
        }
        private void FrmTTicket_Load(object sender, EventArgs e)
        {
            Herramientas herramientas = new Herramientas();
            var          recursos     = herramientas.GetResourcesPath2();
            var          informe      = herramientas.GetResourcesPath3();


            /*FIRMA PDF*/
            var nomdocumento = _documento.Emisor.NroDocumento + "-" + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "-" + _documento.IdDocumento;

            String datosAdicionales_CDB = "";
            String CodigoCertificado    = "";

            datosAdicionales_CDB = _documento.Emisor.NroDocumento + "|" + _documento.TipoDocumento + "|" + _documento.IdDocumento + "|" + _documento.TotalIgv + "|" + _documento.TotalVenta + "|"
                                   + _documento.FechaEmision + "|" + _documento.Receptor.TipoDocumento + "|" + _documento.Receptor.NroDocumento;
            CodigoCertificado = datosAdicionales_CDB + "|" + _documento.ResumenFirma;
            BarcodePDF417 codigobarras = new BarcodePDF417();

            codigobarras.Options    = BarcodePDF417.PDF417_USE_ASPECT_RATIO;
            codigobarras.ErrorLevel = 5;
            codigobarras.YHeight    = 6f;
            codigobarras.SetText(CodigoCertificado);
            System.Drawing.Bitmap bm = new System.Drawing.Bitmap(codigobarras.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
            //bm.Save(@"C:\DOCUMENTOS ELECTRONICOS\CERTIFIK\QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bm.Save(@"QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);


            /*FIN FIRMA*/

            List <ReportParameter> parametro = new List <ReportParameter>();

            //parametro.Add(new ReportParameter("pLogo", @"file:///C:/PIURAMAQ.png"));
            parametro.Add(new ReportParameter("pLogo", @"file:///" + recursos + "/" + nomdocumento + ".jpeg"));
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;
            reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            reportViewer1.ZoomMode    = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;



            reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.TTicket.rdlc";
            reportViewer1.LocalReport.SetParameters(parametro);

            ReportDataSource datos = new ReportDataSource();

            datos.Name  = "DetalleDocumento";
            datos.Value = lst;
            ReportDataSource datos2 = new ReportDataSource();

            datos2.Name  = "Empresa";
            datos2.Value = empresa;
            ReportDataSource datos3 = new ReportDataSource();

            datos3.Name  = "General";
            datos3.Value = general;
            ReportDataSource datos4 = new ReportDataSource();

            datos4.Name  = "Receptor";
            datos4.Value = receptor;
            ReportDataSource datos5 = new ReportDataSource();

            datos5.Name  = "Otros";
            datos5.Value = otros;


            this.reportViewer1.RefreshReport();
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(datos);
            this.reportViewer1.LocalReport.DataSources.Add(datos2);
            this.reportViewer1.LocalReport.DataSources.Add(datos3);
            this.reportViewer1.LocalReport.DataSources.Add(datos4);
            this.reportViewer1.LocalReport.DataSources.Add(datos5);
            this.reportViewer1.RefreshReport();

            // Debe existir al menos una pagina a imprimir

            /*PrintDocument printDocument = new PrintDocument();
             * printDocument.PrinterSettings.PrinterName = "\\\\192.168.1.35\\EPSON LX-350 ESC/P";
             *
             * if (!printDocument.PrinterSettings.IsValid)
             *  return; //ImpresoraNoEncontrada
             *
             * //printDocument.PrintPage += new PrintPageEventHandler(PrintPage);
             * printDocument.Print();*/

            /*CrystalDecisions.CrystalReports.Engine.ReportDocument rd = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
             *
             * CrystalDecisions.CrystalReports.Engine.PrintOptions rptoption = rd.PrintOptions;
             * rptoption.PrinterName= "\\\\192.168.1.35\\EPSON LX-350 ESC/P";
             * rptoption.PaperSize = (CrystalDecisions.Shared.PaperSize)GetIDPaperSize("\\\\192.168.1.35\\EPSON LX-350 ESC/P","A4");
             * rd.PrintToPrinter(1,false,1,1);
             * rd.Dispose();*/
            //printaFactura();



            Warning[] warnings;
            string[]  streamids;
            string    mimeType;
            string    encoding;
            string    filenameExtension;

            //ToString("yyyy-MM-dd")
            byte[] bytes = reportViewer1.LocalReport.Render(
                "PDF", null, out mimeType, out encoding, out filenameExtension,
                out streamids, out warnings);

            using (FileStream fs = new FileStream(@"BOLETAS_PDF\\" + nomdocumento + ".pdf", FileMode.Create))
            {
                fs.Write(bytes, 0, bytes.Length);
            }



            /* Process miProceso = new Process();
             * miProceso.StartInfo.Verb = "Print";
             * miProceso.StartInfo.CreateNoWindow = true;
             * miProceso.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
             * miProceso.StartInfo.FileName = Application.StartupPath + "\\BOLETAS_PDF\\" + nomdocumento + ".pdf";
             * miProceso.Start();
             * miProceso.WaitForExit();
             * miProceso.Close();*/
        }
Ejemplo n.º 7
0
        private void Erwin_Load(object sender, EventArgs e)
        {
            Herramientas herramientas = new Herramientas();
            var          recursos     = herramientas.GetResourcesPath2();
            var          informe      = herramientas.GetResourcesPath3();


            /*FIRMA PDF*/
            var nomdocumento = _documento.Emisor.NroDocumento + "-" + DateTime.Parse(_documento.FechaEmision).ToString("yyyy-MM-dd") + "-" + _documento.IdDocumento;

            String datosAdicionales_CDB = "";
            String CodigoCertificado    = "";

            datosAdicionales_CDB = _documento.Emisor.NroDocumento + "|" + _documento.TipoDocumento + "|" + _documento.IdDocumento + "|" + _documento.TotalIgv + "|" + _documento.TotalVenta + "|"
                                   + _documento.FechaEmision + "|" + _documento.Receptor.TipoDocumento + "|" + _documento.Receptor.NroDocumento;
            CodigoCertificado = datosAdicionales_CDB + "|" + _documento.FirmaDigital;
            BarcodePDF417 codigobarras = new BarcodePDF417();

            codigobarras.Options    = BarcodePDF417.PDF417_USE_ASPECT_RATIO;
            codigobarras.ErrorLevel = 5;
            codigobarras.YHeight    = 6f;
            codigobarras.SetText(CodigoCertificado);
            System.Drawing.Bitmap bm = new System.Drawing.Bitmap(codigobarras.CreateDrawingImage(System.Drawing.Color.Black, System.Drawing.Color.White));
            //bm.Save(@"C:\DOCUMENTOS ELECTRONICOS\CERTIFIK\QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
            bm.Save(@"QR\" + nomdocumento + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);


            /*FIN FIRMA*/

            List <ReportParameter> parametro = new List <ReportParameter>();

            //parametro.Add(new ReportParameter("pLogo", @"file:///C:/PIURAMAQ.png"));
            parametro.Add(new ReportParameter("pLogo", @"file:///" + recursos + "/" + nomdocumento + ".jpeg"));
            this.reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;

            /* reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
             * reportViewer1.ZoomMode = ZoomMode.Percent;
             * reportViewer1.ZoomPercent = 100;
             */


            reportViewer1.LocalReport.ReportEmbeddedResource = "FinalXML.Informes.Report1.rdlc";
            reportViewer1.LocalReport.SetParameters(parametro);

            ReportDataSource datos = new ReportDataSource();

            datos.Name  = "DetalleDocumento";
            datos.Value = lst;
            ReportDataSource datos2 = new ReportDataSource();

            datos2.Name  = "Empresa";
            datos2.Value = empresa;
            ReportDataSource datos3 = new ReportDataSource();

            datos3.Name  = "General";
            datos3.Value = general;
            ReportDataSource datos4 = new ReportDataSource();

            datos4.Name  = "Receptor";
            datos4.Value = receptor;
            ReportDataSource datos5 = new ReportDataSource();

            datos5.Name  = "Otros";
            datos5.Value = otros;


            this.reportViewer1.RefreshReport();
            this.reportViewer1.LocalReport.DataSources.Clear();
            this.reportViewer1.LocalReport.DataSources.Add(datos);
            this.reportViewer1.LocalReport.DataSources.Add(datos2);
            this.reportViewer1.LocalReport.DataSources.Add(datos3);
            this.reportViewer1.LocalReport.DataSources.Add(datos4);
            this.reportViewer1.LocalReport.DataSources.Add(datos5);
            this.reportViewer1.RefreshReport();
        }