예제 #1
0
        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);
        }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// <para>
        /// If implemented by a class, allows you to handle Printing System commands (listed in the <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration).
        /// </para>
        /// </summary>
        /// <param name="command">A <see cref="T:DevExpress.XtraPrinting.PrintingSystemCommand"/> enumeration value.
        ///             </param><param name="args">An array of <see cref="T:System.Object"/> values, specifying the command arguments.
        ///             </param><param name="printControl">An object implementing the <see cref="T:DevExpress.XtraPrinting.IPrintControl"/> interface (typically, this is a <see cref="T:DevExpress.XtraPrinting.Control.PrintControl"/> instance).
        ///             </param><param name="handled"><b>true</b> if the command has been handled; otherwise <b>false</b>.
        ///             </param>
        public void HandleCommand(PrintingSystemCommand command, object[] args, IPrintControl printControl, ref bool handled)
        {
            if (!CanHandleCommand(command, printControl))
            {
                return;
            }

            DocumentViewer documentViewer = printControl as DocumentViewer;

            if (documentViewer != null)
            {
                // Set handled to 'true' to prevent the standard exporting procedure from being called.
                handled = true;

                XtraReportFactura xtraReportFactura = documentViewer.DocumentSource as XtraReportFactura;

                if (xtraReportFactura != null)
                {
                    Factura factura = xtraReportFactura.Factura;

                    string escritorio = Settings.Default.carpetaSalidaPDF;

                    string nombreFichero = Path.Combine(escritorio, string.Format("Factura-{0}.pdf", factura.Numero));

                    if (File.Exists(nombreFichero) &&
                        XtraMessageBox.Show(string.Format(@"¿Desea sobreescribir el fichero '{0}'?", nombreFichero),
                                            string.Format("Exportar a PDF la factura {0}", factura.Numero),
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    {
                        return;
                    }

                    xtraReportFactura.ExportToPdf(nombreFichero);
                }
            }
        }
예제 #5
0
        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();
        }