C2020-018 made a more accurate description of the message for transitions when deleting a Procedure, Section, or Step

This commit is contained in:
John Jenko 2020-07-06 13:46:06 +00:00
parent 4e7d93aab5
commit 82124d1299
3 changed files with 41 additions and 17 deletions

View File

@ -5418,6 +5418,19 @@ namespace VEPROMS.CSLA.Library
} }
} }
#endregion #endregion
// C2020-018 used for a more descriptive warning message when deleting Procedures, Sections, Steps that have external transitions pointing to them
public string GetTypeDescription()
{
if (this != null)
{
if (this.IsProcedure) return "Procedure";
if (this.IsSection) return "Section";
if (this.IsHigh) return "Step";
if (this.IsSubStep) return "SubStep";
}
return "Item";
}
} }
#endregion ItemInfo #endregion ItemInfo
#region Tab #region Tab

View File

@ -36,15 +36,18 @@ namespace VEPROMS.CSLA.Library
{ {
public ItemInfo HandleSqlExceptionOnDelete(Exception ex) public ItemInfo HandleSqlExceptionOnDelete(Exception ex)
{ {
string itemDesc = this.GetTypeDescription(); // C2020-018 made the message more accurate when deleting a Procedure, Section, or Step
if (ex.Message.Contains("has External Transitions and has no next step")) if (ex.Message.Contains("has External Transitions and has no next step"))
{ {
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ItemID)) using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ItemID))
{ {
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this step and cannot be adjusted automatically." + //C2020-018 build the message based on the type description
"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + string msg1 = string.Format("Transitions exist to this {0} and cannot be adjusted automatically.", itemDesc);
"\r\n\r\nSubsteps with Problem Transitions" + DialogResult ans = FlexibleMessageBox.Show(msg1 +
"\r\n\r\nDo you want to be placed at the " + (exTrans.Count > 1 ? "first " : "") + "location with the problem Transition?" +
"\r\n\r\nLocations with Problem Transitions" +
exTrans.Summarize(), exTrans.Summarize(),
"Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Cannot Delete This " + itemDesc, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.Yes) if (ans == DialogResult.Yes)
{ {
return exTrans[0].MyContent.ContentItems[0]; return exTrans[0].MyContent.ContentItems[0];
@ -56,8 +59,8 @@ namespace VEPROMS.CSLA.Library
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ItemID)) using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ItemID))
{ {
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this procedure and cannot be adjusted automatically." + DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this procedure and cannot be adjusted automatically." +
"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + "\r\n\r\nDo you want to be placed at the " + (exTrans.Count > 1 ? "first " : "") + "location with the problem Transition?" +
"\r\n\r\nSubsteps with Problem Transitions" + "\r\n\r\nLocations with Problem Transitions" +
exTrans.Summarize(), exTrans.Summarize(),
"Cannot Delete This Procedure", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Cannot Delete This Procedure", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.Yes) if (ans == DialogResult.Yes)
@ -70,11 +73,13 @@ namespace VEPROMS.CSLA.Library
{ {
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ItemID)) using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(ItemID))
{ {
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to substeps of this step and cannot be adjusted automatically." + //C2020-018 build the message based on the type description
"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + string msg1 = string.Format("Transitions exist to {0} this {1} and cannot be adjusted automatically.", (this.IsSection) ? "steps in" : "children of", itemDesc);
"\r\n\r\nSubsteps with Problem Transitions:" + DialogResult ans = FlexibleMessageBox.Show(msg1 +
"\r\n\r\nDo you want to be placed at the " + (exTrans.Count > 1 ? "first " : "") + "location with the problem Transition?" +
"\r\n\r\nLocations with Problem Transitions:" +
exTrans.Summarize(), exTrans.Summarize(),
"Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Cannot Delete This "+itemDesc, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.No) return this;// If answer "NO" then return self if (ans == DialogResult.No) return this;// If answer "NO" then return self
if (ans == DialogResult.Yes) if (ans == DialogResult.Yes)
{ {

View File

@ -1029,13 +1029,14 @@ namespace Volian.Controls.Library
//private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex) //private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex)
private void HandleSqlExceptionOnDelete(Exception ex) private void HandleSqlExceptionOnDelete(Exception ex)
{ {
// C2020-018 made the messaging consistent in the message boxes
if (ex.Message.Contains("has External Transitions and has no next step")) if (ex.Message.Contains("has External Transitions and has no next step"))
{ {
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(MyID)) using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitions(MyID))
{ {
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this step and cannot be adjusted automatically." + DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this step and cannot be adjusted automatically." +
"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + "\r\n\r\nDo you want to be placed at the " + (exTrans.Count > 1 ? "first " : "") + "location with the problem Transition?" +
"\r\n\r\nSubsteps with Problem Transitions" + "\r\n\r\nLocations with Problem Transitions" +
exTrans.Summarize(), exTrans.Summarize(),
"Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.Yes) if (ans == DialogResult.Yes)
@ -1059,8 +1060,8 @@ namespace Volian.Controls.Library
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID)) using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
{ {
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this procedure." + DialogResult ans = FlexibleMessageBox.Show("Transitions exist to this procedure." +
"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + "\r\n\r\nDo you want to be placed at the " + (exTrans.Count > 1 ? "first " : "") + "location with the problem Transition?" +
"\r\n\r\nSubsteps with Problem Transitions" + "\r\n\r\nLocations with Problem Transitions" +
exTrans.Summarize(), exTrans.Summarize(),
"Cannot Delete This Procedure", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Cannot Delete This Procedure", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.Yes) if (ans == DialogResult.Yes)
@ -1084,9 +1085,14 @@ namespace Volian.Controls.Library
{ {
using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID)) using (TransitionInfoList exTrans = TransitionInfoList.GetExternalTransitionsToChildren(MyID))
{ {
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to substeps of this step and cannot be adjusted automatically." + //DialogResult ans = FlexibleMessageBox.Show("Transitions exist to substeps of this step and cannot be adjusted automatically." +
"\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" + // "\r\n\r\nDo you want to be placed on the " + (exTrans.Count > 1 ? "first " : "") + "substep with the problem Transition?" +
"\r\n\r\nSubsteps with Problem Transitions:" + // "\r\n\r\nLocations with Problem Transitions:" +
// exTrans.Summarize(),
// "Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
DialogResult ans = FlexibleMessageBox.Show("Transitions exist to the substeps of this step and cannot be adjusted automatically." +
"\r\n\r\nDo you want to be placed at the " + (exTrans.Count > 1 ? "first " : "") + "location with the problem Transition?" +
"\r\n\r\nLocations with Problem Transitions:" +
exTrans.Summarize(), exTrans.Summarize(),
"Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question); "Cannot Delete This Step", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (ans == DialogResult.Yes) if (ans == DialogResult.Yes)