diff --git a/PROMS/VEPROMS User Interface/dlgExportImport.cs b/PROMS/VEPROMS User Interface/dlgExportImport.cs index f98a3e8a..93672738 100644 --- a/PROMS/VEPROMS User Interface/dlgExportImport.cs +++ b/PROMS/VEPROMS User Interface/dlgExportImport.cs @@ -118,7 +118,7 @@ namespace VEPROMS } else if (MyProcedure != null) { - txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, MyProcedure.DisplayNumber.Replace("/","_")); + txtExport.Text = string.Format(@"{0}\{1}.pxml", PEIPath, MyProcedure.DisplayNumber.Replace("/", "_")); } } private void txtExport_TextChanged(object sender, EventArgs e) @@ -182,6 +182,7 @@ namespace VEPROMS } private void btnDoImport_Click(object sender, EventArgs e) { + bool canceledPressed = false; btnImport.Enabled = false; this.Cursor = Cursors.WaitCursor; MyStart = DateTime.Now; @@ -272,14 +273,22 @@ namespace VEPROMS { // procedure numbers that contain a hyphen may have the hyphen represented as the unicode character // '\u8209?' or the '-' character. If proc number is same except for hyphen representation, they - // 2 should be considered the same procedure (fix for B2016-084) - string hyphenNum = pi.MyContent.Number == null ? pi.MyContent.Number : pi.MyContent.Number.Replace(@"\u8209?", "-"); + // should be considered the same procedure (fix for B2016-084) + string hyphenNum = pi.MyContent.Number == null ? "" : pi.MyContent.Number.Replace(@"\u8209?", "-").Replace("\u2011", "-"); string hyphenImpNum = xd.SelectSingleNode("procedure/content/@number").InnerText; - hyphenImpNum = hyphenImpNum == null ? hyphenImpNum : hyphenImpNum.Replace("\u8030?", "-"); + // bug fix C2015-044 - jsj + // - the cancel button would ignor the user's wishes and proceed with the import (overwriting the existing procedure) + // - also found that the message about overwriting or making a copy wasn't appearing because we where not converting the import procedure number + // - our standard unicode dash (\u8209?) before conparing the existing and imported + // - also found the Overrite and make a copy of messages looked too similar - fixed that as well. + //hyphenImpNum = hyphenImpNum == null ? "" : hyphenImpNum.Replace("\u8030?", "-"); -did not find any reason to have this \u8030? - note retest sourcesafe doc for B2016-084 without this logic and it was fine + hyphenImpNum = hyphenImpNum == null ? "" : hyphenImpNum.Replace(@"\u8209?", "-").Replace("\u2011", "-"); - if (pi.ItemID == int.Parse(xd.SelectSingleNode("procedure/@itemid").InnerText) || hyphenNum == hyphenImpNum) + //if (pi.ItemID == int.Parse(xd.SelectSingleNode("procedure/@itemid").InnerText) || hyphenNum == hyphenImpNum) + if (hyphenNum == hyphenImpNum) { - DialogResult dr = MessageBox.Show(this, "The procedure you are importing already exists in this procedure set. Do you want to overwrite the existing procedure?", "Overwrite Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); + string msg = string.Format("The procedure you are importing{0}already exists in this procedure set.\n\nDo you want to OVERWRITE the existing procedure?", !hyphenImpNum.Equals("")?string.Format(" ({0}) ",hyphenImpNum):" "); + DialogResult dr = MessageBox.Show(this, msg, "Overwrite Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); if (dr == DialogResult.Yes) { ImportProcedureOverwrite(xd, pi); @@ -288,7 +297,8 @@ namespace VEPROMS } if (dr == DialogResult.No) { - dr = MessageBox.Show(this, "The procedure you are importing already exists in this procedure set. Do you want to create a copy of the existing procedure?", "Create Copy Of Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); + msg = string.Format("Do you want to import {0} as a COPY of the existing procedure?\n\nThis will prefix the procedure number with \"Copy of\"", !hyphenImpNum.Equals("") ? string.Format("({0})", hyphenImpNum) : "the procedure"); + dr = MessageBox.Show(this, msg , "Create Copy Of Existing Procedure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop); if (dr == DialogResult.Yes) { ImportProcedureCopy(xd); @@ -298,18 +308,34 @@ namespace VEPROMS else resolvedProcNum = false; } + if (dr == System.Windows.Forms.DialogResult.Cancel) + { + canceledPressed = true; + resolvedProcNum = false; + } + break; // user selected No or Cancel so break out of the foreach loop } } - if (!isImported && resolvedProcNum) + if (!canceledPressed && !isImported && resolvedProcNum) { ImportProcedureNew(xd); + isImported = true; } TurnChangeManagerOn.Execute(); + if (isImported) + { + TimeSpan elapsed = DateTime.Now.Subtract(MyStart); + lblImportStatus.Text = "Import Completed in " + elapsed.ToString(); + } + else + { + btnImport.Enabled = true; + btnDoImport.Enabled = true; + } } - TimeSpan elapsed = DateTime.Now.Subtract(MyStart); - lblImportStatus.Text = "Import Completed in " + elapsed.ToString(); this.Cursor = Cursors.Default; btnCloseImport.Enabled = true; + if (canceledPressed) btnCloseImport.PerformClick(); } private void ImportProcedureNew(XmlDocument xd) {