From a1e91b689d29efd15b81335b36999e38b6d7d5e3 Mon Sep 17 00:00:00 2001 From: Rich Date: Wed, 10 Apr 2013 14:23:14 +0000 Subject: [PATCH] Fixed error that caused file names to be in lower case when creating pdf Created error handler to warn user when trying to view pdf file already open --- PROMS/Volian.Print.Library/PDFChronologyReport.cs | 11 ++++++++++- PROMS/Volian.Print.Library/PromsPrinter.cs | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/PROMS/Volian.Print.Library/PDFChronologyReport.cs b/PROMS/Volian.Print.Library/PDFChronologyReport.cs index 6deda78a..eb177292 100644 --- a/PROMS/Volian.Print.Library/PDFChronologyReport.cs +++ b/PROMS/Volian.Print.Library/PDFChronologyReport.cs @@ -128,7 +128,16 @@ namespace Volian.Print.Library // Try to open a file for creating the PDF. while (result == false) { - string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); + string fileName = _FileName; + int loc = fileName.IndexOf("."); + if (loc > -1) + { + string fname = fileName.Substring(0, loc); + fileName = fname + suffix + ".pdf"; + } + else + fileName = fileName + suffix + ".pdf"; +// string fileName = _FileName.ToLower().Replace(".pdf", suffix + ".pdf"); try { PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(fileName, FileMode.Create)); diff --git a/PROMS/Volian.Print.Library/PromsPrinter.cs b/PROMS/Volian.Print.Library/PromsPrinter.cs index 83f314df..e74e73d4 100644 --- a/PROMS/Volian.Print.Library/PromsPrinter.cs +++ b/PROMS/Volian.Print.Library/PromsPrinter.cs @@ -238,7 +238,14 @@ namespace Volian.Print.Library } catch (Exception ex) { - MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf"); + StringBuilder sb = new StringBuilder(); + sb.AppendLine("Could not create"); + sb.AppendLine(); + sb.AppendLine(outputFileName + "."); + sb.AppendLine(); + sb.AppendLine("If it is open, close and retry."); + MessageBox.Show(sb.ToString(), "Error on CreatePdf", MessageBoxButtons.OK, MessageBoxIcon.Warning); + //MessageBox.Show("Could not create " + outputFileName + ". If it is open, close and retry.", "Error on CreatePdf"); return null; } document.Open();