From 365f6a23c8a05f38c7b737575c4c997cacf5a199 Mon Sep 17 00:00:00 2001 From: John Jenko Date: Tue, 14 May 2024 14:24:01 -0400 Subject: [PATCH] B2024-030 On the Working Draft properties page, added a check to see if we need to create the folder(s) for the path typed into the PDF Location text box. --- .../frmVersionsProperties.Designer.cs | 4 +- .../frmVersionsProperties.cs | 37 +++++++++++++++---- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/PROMS/VEPROMS User Interface/frmVersionsProperties.Designer.cs b/PROMS/VEPROMS User Interface/frmVersionsProperties.Designer.cs index 67a8a068..cf799479 100644 --- a/PROMS/VEPROMS User Interface/frmVersionsProperties.Designer.cs +++ b/PROMS/VEPROMS User Interface/frmVersionsProperties.Designer.cs @@ -254,7 +254,7 @@ namespace VEPROMS // this.ppBtnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.ppBtnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.ppBtnCancel.Location = new System.Drawing.Point(742, 342); + this.ppBtnCancel.Location = new System.Drawing.Point(742, 338); this.ppBtnCancel.Margin = new System.Windows.Forms.Padding(2); this.ppBtnCancel.Name = "ppBtnCancel"; this.ppBtnCancel.Size = new System.Drawing.Size(56, 21); @@ -266,7 +266,7 @@ namespace VEPROMS // ppBtnOK // this.ppBtnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.ppBtnOK.Location = new System.Drawing.Point(669, 342); + this.ppBtnOK.Location = new System.Drawing.Point(669, 338); this.ppBtnOK.Margin = new System.Windows.Forms.Padding(2); this.ppBtnOK.Name = "ppBtnOK"; this.ppBtnOK.Size = new System.Drawing.Size(56, 21); diff --git a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs index 68aec555..b0aa638f 100644 --- a/PROMS/VEPROMS User Interface/frmVersionsProperties.cs +++ b/PROMS/VEPROMS User Interface/frmVersionsProperties.cs @@ -29,6 +29,7 @@ namespace VEPROMS private List _DeletedApples; private List _Enhanced; private DocVersionConfig _DocVersionConfig; + private string _OrgPDFPath; // B2024-030 used to save last PDF path // Default values private string _DefaultFormatName = null; @@ -97,6 +98,7 @@ namespace VEPROMS _Initializing = true; InitializeComponent(); + _OrgPDFPath = _DocVersionConfig.Print_PDFLocation; // B2024-030 save last PDF path btnGeneral.PerformClick(); // always start with General tab or button _Initializing = false; @@ -323,8 +325,6 @@ namespace VEPROMS tiApplicability.Visible = false; } - ppTxtBxPDFLoc.TextChanged += new EventHandler(ppTxtBxPDFLoc_TextChanged); - //end add new applicability stuff lblProcSetRev.Visible = ppRTxtProcSetRev.Visible = _DocVersionConfig.MyDocVersion.MyDocVersionInfo.ActiveFormat.MyStepSectionPrintData.UseXtraRevNumber; @@ -538,11 +538,32 @@ namespace VEPROMS } } - // The following code was added to fix Bug B2013-117 - private void ppTxtBxPDFLoc_TextChanged(object sender, EventArgs e) + //B2024-030 Check the PDF Location path and prompt to create the folders if needed + private void CheckPDFLocationPath() { - if (_Initializing == false) - _DocVersionConfig.Print_PDFLocation = ppTxtBxPDFLoc.Text; + string pdfloc = ppTxtBxPDFLoc.Text; + if (pdfloc == string.Empty) return; + if (!Directory.Exists(ppTxtBxPDFLoc.Text)) + { + string msg = string.Format(" The Folder: '{0}' does not exist. \n\nCreate it?", ppTxtBxPDFLoc.Text); + DialogResult dr = MessageBox.Show(msg, "PDF Location Folder Not Found", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dr == DialogResult.Yes) + { + try + { + Directory.CreateDirectory(ppTxtBxPDFLoc.Text); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Error trying to create folder", MessageBoxButtons.OK, MessageBoxIcon.Error); + _DocVersionConfig.Print_PDFLocation = _OrgPDFPath; // reset to the path we started with + } + } + else + { + _DocVersionConfig.Print_PDFLocation = _OrgPDFPath; // reset to the path we started with + } + } } private string AddSlaveNode(MiniConfig mc) @@ -588,6 +609,9 @@ namespace VEPROMS private void btnVersionsPropOK_Click(object sender, EventArgs e) { + //B2024-030 Check the PDF Location path and prompt to create the folders if needed + CheckPDFLocationPath(); + docVersionConfigBindingSource.EndEdit(); // need to end the edit session first or any format selection chanage will not stick B2015-157 // if there is a change to the format, clean up any overridden formats that point to the selected item before saving the format change: @@ -773,7 +797,6 @@ namespace VEPROMS // B2019-132 update the association count for this working draft _DocVersionConfig.MyDocVersion.MyDocVersionInfo.RefreshDocVersionAssociations(); - this.Close(); }