Пример #1
0
        public static async Task <bool> PrintOrExportReceiptsBook(int[] liquidationFixedDatasId, bool hideHeader, bool showTotals, int folioN, string period, bool print)
        {
            ReceiptBookRPT receiptBookRPT = await GetReports.GetReceiptsBook(liquidationFixedDatasId, hideHeader, showTotals, folioN);

            Nullable <Boolean> printed  = null;
            Nullable <Boolean> exported = null;

            if (print)
            {
                PrintDialog printDialog = new PrintDialog();
                printed = printDialog.ShowDialog();

                if (printed == true)
                {
                    receiptBookRPT.PrintToPrinter(1, false, 0, 0);
                }
            }
            else
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.FileName = "LIBRO_DE_SUELDOS_" + period;
                saveFileDialog.Filter   = "Documento PDF (.pdf)|*.pdf|Document CrystalReports (*.rpt)|*.rpt";
                exported = saveFileDialog.ShowDialog();

                if (exported == true)
                {
                    receiptBookRPT.ExportToDisk(saveFileDialog.FilterIndex == 1 ?
                                                CrystalDecisions.Shared.ExportFormatType.PortableDocFormat :
                                                CrystalDecisions.Shared.ExportFormatType.CrystalReport, saveFileDialog.FileName);
                }
            }

            return((bool)(printed ?? exported));
        }
Пример #2
0
        public static async Task <ReceiptBookRPT> GetReceiptsBook(int[] liquidationFixedDatasId, bool hideHeader, bool showTotals, int folioN)
        {
            ReceiptBookRPT receiptBookRPT = new ReceiptBookRPT();

            await Task.Run(() =>
            {
                receiptBookRPT.DataSourceConnections[0].SetConnection(builder.DataSource, builder.InitialCatalog, true);

                receiptBookRPT.SetParameterValue(receiptBookRPT.Parameter_LiquidationFixedDataId.ParameterFieldName, liquidationFixedDatasId);
                receiptBookRPT.SetParameterValue(receiptBookRPT.Parameter_hideHeader.ParameterFieldName, hideHeader);
                receiptBookRPT.SetParameterValue(receiptBookRPT.Parameter_showTotals.ParameterFieldName, showTotals);
                receiptBookRPT.SetParameterValue(receiptBookRPT.Parameter_folio.ParameterFieldName, folioN);
            });

            return(receiptBookRPT);
        }
Пример #3
0
        public static async Task BackupReceiptsBook(int[] liquidationFixedDatasId, bool hideHeader, bool showTotals, int folioN, string period)
        {
            string docsDirec     = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string suuxDirec     = Path.Combine(docsDirec, "SUUX");
            string receiptsDirec = Path.Combine(suuxDirec, "Libros");

            await Task.Run(() =>
            {
                if (!Directory.Exists(suuxDirec))
                {
                    Directory.CreateDirectory(suuxDirec);
                }
                if (!Directory.Exists(receiptsDirec))
                {
                    Directory.CreateDirectory(receiptsDirec);
                }
            });

            ReceiptBookRPT receiptBookRPT = await GetReports.GetReceiptsBook(liquidationFixedDatasId, hideHeader, showTotals, folioN);

            await Task.Run(() => receiptBookRPT.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat,
                                                             Path.Combine(receiptsDirec, period + ".pdf")));
        }