C2022-019 Added a Cancel button to the message box that informs the user that the destination you are pasting to is a different step type than what is being copied.

This commit is contained in:
John Jenko 2022-06-16 20:06:45 +00:00
parent 08fe520ffa
commit 6eabc4efd1
2 changed files with 28 additions and 8 deletions

View File

@ -593,7 +593,8 @@ namespace VEPROMS.CSLA.Library
} }
// B2016-009 - added a message box explaining to the user that the copyed step will take on the destination type. 16-bit PROMS had also done this way. // B2016-009 - added a message box explaining to the user that the copyed step will take on the destination type. 16-bit PROMS had also done this way.
// - this one is used for Paste Replace with copyed step // - this one is used for Paste Replace with copyed step
public static void CheckSourceDestinationType(int copyStartID, ItemInfo itemInfo) // C2022-017 Added a Cancel button to the message box to allow the user to cancel the paste operation
public static bool CheckSourceDestinationType(int copyStartID, ItemInfo itemInfo)
{ {
ItemInfo cpyItem = ItemInfo.Get(copyStartID); ItemInfo cpyItem = ItemInfo.Get(copyStartID);
// B2017-065 use MyContent instead of _Mycontent so that if null it will get the needed content // B2017-065 use MyContent instead of _Mycontent so that if null it will get the needed content
@ -601,26 +602,34 @@ namespace VEPROMS.CSLA.Library
int? DestType = itemInfo.MyContent.Type; int? DestType = itemInfo.MyContent.Type;
if (DestType >= 20000 && DestType != SourceType) if (DestType >= 20000 && DestType != SourceType)
{ {
string msg = "The step you are copying TO is a different type than the step you are copying FROM.\n\nThe copied step will inherit the destination step type.\n\nOnce copied, the step type can be changed from the Tags tab on the Step Properties panel."; string msg = "The step you are copying TO is a different type than the step you are copying FROM.\n\nThe copied step will inherit the destination step type.\n\nOnce copied, the step type can be changed from the Tags tab on the Step Properties panel.";
FlexibleMessageBox.Show(msg, "Different Step Types", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult msgBoxResult = FlexibleMessageBox.Show(msg, "Different Step Types", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (msgBoxResult == DialogResult.Cancel)
return false;
} }
return true;
} }
// B2016-009 - added a message box explaining to the user that the copyed step will take on the destination type. 16-bit PROMS had also done this way. // B2016-009 - added a message box explaining to the user that the copyed step will take on the destination type. 16-bit PROMS had also done this way.
// - this one is used for Insert Copyed step Before or After // - this one is used for Insert Copyed step Before or After
private void CheckSourceDestinationType(int? DestType, int? SourceType) // C2022-017 Added a Cancel button to the message box to allow the user to cancel the paste operation
private bool CheckSourceDestinationType(int? DestType, int? SourceType)
{ {
if (DestType >= 20000 && DestType != SourceType) if (DestType >= 20000 && DestType != SourceType)
{ {
string msg = "The step you are copying TO is a different type than the step you are copying FROM.\n\nThe copied step will inherit the destination step type.\n\nOnce copied, the step type can be changed from the Tags tab on the Step Properties panel."; string msg = "The step you are copying TO is a different type than the step you are copying FROM.\n\nThe copied step will inherit the destination step type.\n\nOnce copied, the step type can be changed from the Tags tab on the Step Properties panel.";
FlexibleMessageBox.Show(msg, "Different Step Types", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult msgBoxResult = FlexibleMessageBox.Show(msg, "Different Step Types", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (msgBoxResult == DialogResult.Cancel)
return false;
} }
return true;
} }
public ItemInfo PasteSiblingBefore(int copyStartID, string chgid) public ItemInfo PasteSiblingBefore(int copyStartID, string chgid)
{ {
// To determine 'type' of pasted item, if it's a step (type >=20000), use the originating // To determine 'type' of pasted item, if it's a step (type >=20000), use the originating
// item, i.e. item inserting after. If it's a section or procedure, use the copied item's type. // item, i.e. item inserting after. If it's a section or procedure, use the copied item's type.
ItemInfo cpItem = ItemInfo.Get(copyStartID); ItemInfo cpItem = ItemInfo.Get(copyStartID);
CheckSourceDestinationType(MyContent.Type, cpItem.MyContent.Type); // B2016-009 check source and desintation types and display message box if needed // B2016-009 check source and desintation types and display message box if needed
// C2022-017 moved the CheckSourceDestinationType call to btnPasteReplace_Click in StepTabRibbon
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type; int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
try try
{ {
@ -646,7 +655,8 @@ namespace VEPROMS.CSLA.Library
// To determine 'type' of pasted item, if it's a step (type >=20000), use the originating // To determine 'type' of pasted item, if it's a step (type >=20000), use the originating
// item, i.e. item inserting after. If it's a section or procedure, use the copied item's type. // item, i.e. item inserting after. If it's a section or procedure, use the copied item's type.
ItemInfo cpItem = ItemInfo.Get(copyStartID); ItemInfo cpItem = ItemInfo.Get(copyStartID);
CheckSourceDestinationType(MyContent.Type, cpItem.MyContent.Type); // B2016-009 check source and desintation types and display message box if needed // B2016-009 check source and desintation types and display message box if needed
// C2022-017 moved the CheckSourceDestinationType call to btnPasteReplace_Click in StepTabRibbon
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type; int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
try try
{ {
@ -2484,7 +2494,8 @@ namespace VEPROMS.CSLA.Library
throw new System.Security.SecurityException("User not authorized to remove a Item"); throw new System.Security.SecurityException("User not authorized to remove a Item");
try try
{ {
ItemInfo.CheckSourceDestinationType(copyStartID, itemInfo); // B2016-009 check source and desintation types and display message box if needed // B2016-009 check source and desintation types and display message box if needed
// C2022-017 moved the CheckSourceDestinationType call to btnPasteReplace_Click in StepTabRibbon
ItemInfo newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type); ItemInfo newItemInfo = ItemInfo.CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
// Delete business objects, including remove from tree // Delete business objects, including remove from tree
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children

View File

@ -3989,6 +3989,9 @@ namespace Volian.Controls.Library
{ {
StepTabPanel tmp = Parent as StepTabPanel; StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep == null) return; if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
// B2016-009 check source and desintation types and display message box if needed
// C2022-017 check for user canceling the paste step
if (!ItemInfo.CheckSourceDestinationType(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo)) return;
SaveTableChanges(); // B2018-055 Save Current Changes to the table SaveTableChanges(); // B2018-055 Save Current Changes to the table
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format // F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, false); ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, false);
@ -3998,6 +4001,9 @@ namespace Volian.Controls.Library
{ {
StepTabPanel tmp = Parent as StepTabPanel; StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep == null) return; if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
// B2016-009 check source and desintation types and display message box if needed
// C2022-017 check for user canceling the paste step
if (!ItemInfo.CheckSourceDestinationType(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo)) return;
SaveTableChanges(); // B2018-055 Save Current Changes to the table SaveTableChanges(); // B2018-055 Save Current Changes to the table
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format // F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, false); ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, false);
@ -4039,6 +4045,9 @@ namespace Volian.Controls.Library
{ {
StepTabPanel tmp = Parent as StepTabPanel; StepTabPanel tmp = Parent as StepTabPanel;
if (tmp.MyDisplayTabControl.MyCopyStep == null) return; if (tmp.MyDisplayTabControl.MyCopyStep == null) return;
// B2016-009 check source and desintation types and display message box if needed
// C2022-017 check for user canceling the paste step
if (!ItemInfo.CheckSourceDestinationType(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo)) return;
// F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format // F2021-009 display a message if pasting step will results in more sub-step levels than are defined in the format
ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, true); ItemInfo.PasteStepIsWithinDefinedSubStepLevels(tmp.MyDisplayTabControl.MyCopyStep.ItemID, MyItemInfo, true);
EditItem oldEditItem = MyEditItem; EditItem oldEditItem = MyEditItem;