private XtraReportFactura CalcularReport()
        {
            Factura factura = Factura;

            factura.Lineas.Clear();
            factura.Lineas.AddRange(bsLineas.Cast<LineaFactura>());

            factura.CalcularSubtotales();

            XtraReportFactura xtraReport = new XtraReportFactura();

            var cliente = Cliente ?? new Cliente();

            try
            {
                using (var ms = new MemoryStream(cliente.ModeloDocumento))
                {
                    ms.Position = 0;

                    xtraReport.LoadLayout(ms);
                }
            }
            catch (Exception)
            {
            }

            xtraReport.Factura = factura;
            xtraReport.RequestParameters = false;

            ParameterCollection parameters = xtraReport.Parameters;

            parameters["licenciaMunicipal"].Value = Settings.Default.licencia;
            parameters["email"].Value = Settings.Default.email;
            parameters["Movil"].Value = Settings.Default.movil;
            parameters["Nif"].Value = Settings.Default.nif;
            parameters["Telefono"].Value = Settings.Default.telefono;
            parameters["nombre"].Value = Settings.Default.nombre;
            parameters["direccion"].Value = Settings.Default.direccion;
            parameters["poblacion"].Value = Settings.Default.poblacionCP;

            if (!string.IsNullOrEmpty(Settings.Default.Iban))
            {
                parameters["iban"].Value = string.Format("IBAN: {0}", Settings.Default.Iban);
            }
            else
            {
                parameters["iban"].Value = string.Format("IBAN: {0}", Settings.Default.ccc);
            }
            return xtraReport;
        }
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            Factura factura = bsFactura.Current as Factura;

            if (factura != null)
            {
                XtraReportFactura xtraReport = new XtraReportFactura
                {
                    Factura = factura
                };
                ReportDesignTool dt = new ReportDesignTool(xtraReport);

                // Invoke the Ribbon End-User Designer form modally.
                dt.ShowRibbonDesignerDialog();
            }
        }
        public void Disenyar()
        {
            Factura factura = bsFactura.Current as Factura;

            if (factura != null)
            {
                var cliente = Cliente ?? new Cliente();

                XtraReportFactura xtraReport = new XtraReportFactura
                {
                    Factura = factura
                };

                try
                {
                    using (var ms = new MemoryStream(cliente.ModeloDocumento))
                    {
                        ms.Position = 0;

                        xtraReport.LoadLayout(ms);
                    }
                }
                catch (Exception)
                {
                }

                ReportDesignTool dt = new ReportDesignTool(xtraReport);

                // Invoke the Ribbon End-User Designer form modally.
                dt.ShowRibbonDesignerDialog();

                using (var ms = new MemoryStream())
                {
                    xtraReport.SaveLayout(ms);

                    ms.Position = 0;

                    cliente.ModeloDocumento = ms.ToArray();
                }
            }
        }
        private void GenerarFicheroFacturaPdfToolStripMenuItemClick(object sender, EventArgs e)
        {
            if (!DatosLineaValido()) return;
            bsFactura.EndEdit();
            Factura factura = bsFactura.Current as Factura;

            ActualizarContadoresLineas();

            try
            {
                XtraReportFactura xtraReport=new XtraReportFactura
                {
                    Factura=factura
                };

                xtraReport.Parameters["licenciaMunicipal"].Value = Settings.Default.licencia;
                xtraReport.Parameters["email"].Value = Settings.Default.email;
                xtraReport.Parameters["Movil"].Value = Settings.Default.movil;
                xtraReport.Parameters["Nif"].Value = Settings.Default.nif;
                xtraReport.Parameters["Telefono"].Value = Settings.Default.telefono;
                xtraReport.Parameters["nombre"].Value = Settings.Default.nombre;
                xtraReport.Parameters["direccion"].Value = Settings.Default.direccion;
                xtraReport.Parameters["poblacion"].Value = Settings.Default.poblacionCP;

                if (!string.IsNullOrEmpty(Settings.Default.Iban))
                {
                    xtraReport.Parameters["poblacion"].Value = string.Format("IBAN: {0}", Settings.Default.Iban);
                }
                else
                {
                    xtraReport.Parameters["poblacion"].Value = string.Format("IBAN: {0}", Settings.Default.ccc);
                }

                SetTextWatermark(xtraReport);

                using (ReportPrintTool printTool = new ReportPrintTool(xtraReport))
                {
                    // Invoke the Ribbon Print Preview form modally,
                    // and load the report document into it.
                    printTool.ShowRibbonPreviewDialog();

                    // Invoke the Ribbon Print Preview form
                    // with the specified look and feel setting.
                    printTool.ShowRibbonPreview(UserLookAndFeel.Default);
                }
                //(new PdfGenerador(factura)).Run();
            }
            catch (Exception exception)
            {
                XtraMessageBox.Show(exception.Message, "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            }

            if (factura != null) Settings.Default.ultimaFactura = factura.Numero;
            Settings.Default.Save();
        }