예제 #1
0
        public string Gera_ModeloNF(TRegistro_CFGImpNF RegCfgImpNf)
        {
            TList_RegLanFaturamento listNF = new TList_RegLanFaturamento();

            this.reportManager.DataSources.Add("DTS", listNF);

            return(DefineDesigner(RegCfgImpNf));
        }
예제 #2
0
        private void Imprime(TRegistro_CFGImpNF CfgImpNf,
                             string Nr_notafiscal,
                             bool St_imprimir,
                             bool St_visualizar,
                             bool St_enviaremail,
                             List <string> Destinatarios,
                             string Titulo,
                             string Mensagem
                             )
        {
            if (CfgImpNf.Modelorst.Trim() != string.Empty)
            {
                InlineReportSlot InlineNF = new InlineReportSlot();
                InlineNF.DocumentStream = CfgImpNf.Modelorst;
                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 += "NF" + Nr_notafiscal.Trim() + 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 { }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        private string DefineDesigner(TRegistro_CFGImpNF RegCfgImpNf)
        {
            InlineReportSlot InlineNF = new InlineReportSlot();
            XmlDocument      docXML   = new XmlDocument();
            XmlNode          no;

            this.reportManager.Reports.Add(InlineNF);

            if (RegCfgImpNf.Modelorst.Trim().Equals(string.Empty))
            {
                Document doc = new Document();
                doc.Name           = "NotaFiscal";
                doc.IsTemplate     = true;
                doc.ScriptLanguage = ScriptLanguage.CSharp;

                Page page = new Page();
                page.Name         = "pageNotaFiscal";
                page.Size         = new PerpetuumSoft.Framework.Drawing.Vector(Convert.ToDouble(RegCfgImpNf.Larguranf), Convert.ToDouble(RegCfgImpNf.Alturanf)).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                page.TemplateSize = new PerpetuumSoft.Framework.Drawing.Vector(Convert.ToDouble(RegCfgImpNf.Larguranf), Convert.ToDouble(RegCfgImpNf.Alturanf)).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                page.PaperKind    = PaperKind.Custom;
                page.CustomSize   = new PerpetuumSoft.Framework.Drawing.Vector(Convert.ToDouble(RegCfgImpNf.Larguranf), Convert.ToDouble(RegCfgImpNf.Alturanf)).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                doc.Pages.Add(page);

                Picture imagemFundo = new Picture();
                imagemFundo.Name     = "ImagemNF";
                imagemFundo.Location = new PerpetuumSoft.Framework.Drawing.Vector(0f, 0f).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                imagemFundo.Size     = new PerpetuumSoft.Framework.Drawing.Vector(Convert.ToDouble(RegCfgImpNf.Larguranf), Convert.ToDouble(RegCfgImpNf.Alturanf)).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                if (RegCfgImpNf.Img != null)
                {
                    imagemFundo.Image = RegCfgImpNf.Imagem;
                }
                else
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    ms.Write(Convert.FromBase64String(imagemBranco), 0, Convert.FromBase64String(imagemBranco).Length);
                    imagemFundo.Image = Image.FromStream(ms);
                }
                page.Controls.Add(imagemFundo);

                DataBand dataBand = new DataBand();
                dataBand.Name = "BandaDadosGeral";
                page.Controls.Add(dataBand);
                dataBand.Location     = new PerpetuumSoft.Framework.Drawing.Vector(0f, 0.3f).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                dataBand.Size         = new PerpetuumSoft.Framework.Drawing.Vector(Convert.ToDouble(RegCfgImpNf.Larguranf), Convert.ToDouble(RegCfgImpNf.Alturanf)).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                dataBand.DataSource   = "DTS";
                dataBand.ColumnsCount = 1;
                dataBand.ColumnsGap   = Unit.Convert(0.5f, Unit.Centimeter, Unit.InternalUnit);

                DataBand dataBandProduto = new DataBand();
                dataBandProduto.Name = "BandaDadosProdutos";
                dataBand.Controls.Add(dataBandProduto);
                dataBandProduto.Location     = new PerpetuumSoft.Framework.Drawing.Vector(0f, 0.5f).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                dataBandProduto.Size         = new PerpetuumSoft.Framework.Drawing.Vector(21.5f, 0.5f).ConvertUnits(Unit.Centimeter, Unit.InternalUnit);
                dataBandProduto.DataSource   = "DTS.ItensNota";
                dataBandProduto.ColumnsCount = 1;
                dataBandProduto.ColumnsGap   = Unit.Convert(0.5f, Unit.Centimeter, Unit.InternalUnit);

                InlineNF.SaveReport(doc);
            }
            else
            {
                docXML.LoadXml(RegCfgImpNf.Modelorst);

                if (RegCfgImpNf.Img != null)
                {
                    no = docXML.SelectSingleNode(String.Format("/root/Pages/Item/Controls/Item"));
                    XmlNode noImg = no.SelectSingleNode("./Image");

                    if (noImg != null)
                    {
                        if (RegCfgImpNf.Img == null)
                        {
                            no.SelectSingleNode("./Image").InnerText = imagemBranco;
                        }
                        else
                        {
                            no.SelectSingleNode("./Image").InnerText = Convert.ToBase64String(RegCfgImpNf.Img);
                        }
                    }
                }

                InlineNF.DocumentStream = docXML.InnerXml;
            }

            InlineNF.DesignTemplate();
            docXML.LoadXml(InlineNF.DocumentStream);

            no = docXML.SelectSingleNode(String.Format("/root/Pages/Item/Controls/Item"));
            XmlNode noImage = no.SelectSingleNode("./Image");

            if (noImage != null)
            {
                no.SelectSingleNode("./Image").InnerText = imagemBranco;
            }

            return(docXML.InnerXml);
        }