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)); }
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"))); }