From b5ded05838433a4e38e2ec5480ba90dcfe6626c9 Mon Sep 17 00:00:00 2001 From: Rich Date: Tue, 5 Aug 2014 19:02:02 +0000 Subject: [PATCH] Handle new error when a deleted step is attempted to be copied. Added logic to handle an invalid transition (a transition to a disconnected step. --- .../Extension/ItemInsertExt.cs | 21 ++++++++++++++++--- PROMS/Volian.Controls.Library/EditItem.cs | 12 ++++++++++- PROMS/Volian.Controls.Library/StepTabPanel.cs | 2 +- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index f7a75b6d..6b6a6295 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -431,7 +431,8 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.","Paste Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + if (!HandleSqlExceptionOnCopy(ex)) + System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.","Paste Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return this; } } @@ -457,10 +458,21 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); + if(!HandleSqlExceptionOnCopy(ex)) + System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return this; } } + private bool HandleSqlExceptionOnCopy(Exception ex) + { + if (ex.Message.Contains("This step has been deleted")) + { + System.Windows.Forms.MessageBox.Show("The step being pasted has been deleted!", "Cannot Paste Deleted Step" + , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand); + return true; + } + return false; + } private ItemInfo CopyPasteItemInfoFetch(int copyStartID, int itemID, int? type, int? fromType, EAddpingPart addType) { ItemInfo tmp=null; @@ -1225,7 +1237,10 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if (ex.Message.Contains("has External Transitions and has no next step") || ex.Message.Contains("has External Transitions to it's children")) + if (ex.Message.Contains("has External Transitions and has no next step") + || ex.Message.Contains("has External Transitions to it's children") + || ex.Message.Contains("This step has been deleted") + ) throw ex; System.Windows.Forms.MessageBox.Show("Details were written to the Error Log.", "Paste Replace Failed", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); return itemInfo; diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index e9a41172..79616a63 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -1246,7 +1246,8 @@ namespace Volian.Controls.Library //catch (System.Data.SqlClient.SqlException ex) catch (Exception ex) { - HandleSqlExceptionOnDelete(ex); + if(!HandleSqlExceptionOnCopy(ex)) + HandleSqlExceptionOnDelete(ex); return this; } // Remove the EditItem that was the replaced item. @@ -1299,6 +1300,15 @@ namespace Volian.Controls.Library MyStepPanel.MyStepTabPanel.MyDisplayTabControl.OnItemPaste(this, new vlnTreeItemInfoPasteEventArgs(newItemInfo, copyStartID, ItemInfo.EAddpingPart.Replace, newItemInfo.MyContent.Type)); return newEditItem; } + private bool HandleSqlExceptionOnCopy(Exception ex) + { + if (ex.Message.Contains("This step has been deleted")) + { + MessageBox.Show("The step being pasted has been deleted", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand); + return true; + } + return false; + } public void IdentifyChildren(bool highlight) { // Highlight children of EditItem: diff --git a/PROMS/Volian.Controls.Library/StepTabPanel.cs b/PROMS/Volian.Controls.Library/StepTabPanel.cs index c6825900..e451ca8c 100644 --- a/PROMS/Volian.Controls.Library/StepTabPanel.cs +++ b/PROMS/Volian.Controls.Library/StepTabPanel.cs @@ -280,7 +280,7 @@ namespace Volian.Controls.Library if (args.MyLinkText.LinkInfoText.IndexOf("Transition") > -1) { ItemInfo item = args.MyLinkText.MyTranToItemInfo; - if (item == null || (item.PreviousID == null && item.ItemPartCount == 0 && item.ItemDocVersionCount == 0)) + if (item == null || item.MyDocVersion == null || (item.PreviousID == null && item.ItemPartCount == 0 && item.ItemDocVersionCount == 0)) { MessageBox.Show("This transition is invalid", "Invalid Transition", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; // Not a valid transition