diff --git a/PROMS/DataLoader/PROMSFixes.Sql b/PROMS/DataLoader/PROMSFixes.Sql index f2a005dc..b7b39543 100644 --- a/PROMS/DataLoader/PROMSFixes.Sql +++ b/PROMS/DataLoader/PROMSFixes.Sql @@ -53,6 +53,11 @@ BEGIN TRY -- Try Block ContentID INT ) + if exists (select * from tblitems where itemid = @ItemID and DeleteStatus !=0) + BEGIN + RAISERROR ('###Cannot Paste Step###This current step has been deleted in another session',16,1) + RETURN + END -- First check if the replaced item can be deleted, i.e. it doesn't have transitions -- pointing to it or children. @@ -419,6 +424,11 @@ WITH EXECUTE AS OWNER AS BEGIN TRY -- Try Block BEGIN TRANSACTION + if exists (select * from tblitems where itemid = @ItemID and DeleteStatus !=0) + BEGIN + RAISERROR ('###Cannot Paste Step###This current step has been deleted in another session',16,1) + RETURN + END -- First make a copy of the input StartItemID -- DestFormatID is the formatid for the destination parent's format DECLARE @DestFormatID int @@ -526,6 +536,11 @@ WITH EXECUTE AS OWNER AS BEGIN TRY -- Try Block BEGIN TRANSACTION + if exists (select * from tblitems where itemid = @ItemID and DeleteStatus !=0) + BEGIN + RAISERROR ('###Cannot Paste Step###This current step has been deleted in another session',16,1) + RETURN + END -- First make a copy of the input CopyStartID -- DestFormatID is the formatid for the destination parent's format DECLARE @DestFormatID int diff --git a/PROMS/VEPROMS User Interface/frmVEPROMS.cs b/PROMS/VEPROMS User Interface/frmVEPROMS.cs index 97c04434..baeddd36 100644 --- a/PROMS/VEPROMS User Interface/frmVEPROMS.cs +++ b/PROMS/VEPROMS User Interface/frmVEPROMS.cs @@ -245,7 +245,9 @@ namespace VEPROMS tv.InsertItemInfo += new vlnTreeViewItemInfoInsertEvent(tv_InsertItemInfo); tv.NodeInsert += new vlnTreeViewEvent(tv_NodeInsert); tv.PasteItemInfo += new vlnTreeViewItemInfoPasteEvent(tv_PasteItemInfo); - tc.ItemPaste += new StepPanelItemPastedEvent(tc_ItemPasted); + tv.NodeCopy += new vlnTreeViewEvent(tv_NodeCopy); + tv.ClipboardStatus += new vlnTreeViewClipboardStatusEvent(tv_ClipboardStatus); + tc.ItemPaste += new StepPanelItemPastedEvent(tc_ItemPasted); displayHistory.HistorySelectionChanged += new DisplayHistoryEvent(displayHistory_HistorySelectionChanged); _CommentTitleBckColor = epAnnotations.TitleStyle.BackColor1.Color; if (!btnAnnoDetailsPushPin.Checked) @@ -280,7 +282,16 @@ namespace VEPROMS displayApplicability.ApplicabilityViewModeChanged += new DisplayApplicability.DisplayApplicabilityEvent(displayApplicability_ApplicabilityViewModeChanged); tv.ExportImportProcedureSets += new vlnTreeViewEvent(tv_ExportImportProcedureSets); } - + ItemInfo tv_ClipboardStatus(object sender, vlnTreeEventArgs args) + { + return tc.MyCopyStep; + } + void tv_NodeCopy(object sender, vlnTreeEventArgs args) + { + VETreeNode tn = args.Node as VETreeNode; + ItemInfo ii = tn.VEObject as ItemInfo; + tc.MyCopyStep = ii; + } void tv_ExportImportProcedureSets(object sender, vlnTreeEventArgs args) { FolderInfo fi = null; @@ -349,7 +360,7 @@ namespace VEPROMS } } - private void MakeDatabaseChanges() + private void MakeDatabaseChanges() { // September 2012: Decided to store roimages as zipped. Any previous data may not have them zipped. // Check the top folders config to see, and if needed, zip them: diff --git a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs index 6b6a6295..11af8bc3 100644 --- a/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs +++ b/PROMS/VEPROMS.CSLA.Library/Extension/ItemInsertExt.cs @@ -471,7 +471,13 @@ namespace VEPROMS.CSLA.Library , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand); return true; } - return false; + if(ex.Message.Contains("This current step has been deleted in another session")) + { + System.Windows.Forms.MessageBox.Show("The highlighted step has been deleted by another user!", "Cannot Paste 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) { @@ -717,9 +723,12 @@ namespace VEPROMS.CSLA.Library } catch (Exception ex) { - if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex); - _ErrorMessage = ex.Message; - throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex); + if (!ex.Message.Contains("This step has been deleted") && !ex.Message.Contains("This current step has been deleted in another session")) + { + if (_MyLog.IsErrorEnabled) _MyLog.Error("ItemInfo.DataPortal_Fetch", ex); + } + _ErrorMessage = ex.Message; + throw new DbCslaException("ItemInfo.DataPortal_Fetch", ex); } } private void DataPortal_Fetch(AddingPartCriteria criteria) @@ -1237,15 +1246,36 @@ 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") - || 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; + if (!HandleSqlExceptionOnCopy(ex)) + { + 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; + } + else + return itemInfo; } } #endregion - } + private static 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; + } + if (ex.Message.Contains("This current step has been deleted in another session")) + { + System.Windows.Forms.MessageBox.Show("The highlighted step has been deleted by another user!", "Cannot Paste Step" + , System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Hand); + return true; + } + return false; + } + } } diff --git a/PROMS/Volian.Controls.Library/DisplayTabControl.cs b/PROMS/Volian.Controls.Library/DisplayTabControl.cs index e18e98ae..edb91aba 100644 --- a/PROMS/Volian.Controls.Library/DisplayTabControl.cs +++ b/PROMS/Volian.Controls.Library/DisplayTabControl.cs @@ -449,8 +449,12 @@ namespace Volian.Controls.Library edtitm.PasteSiblingAfter(copyStartID); break; case ItemInfo.EAddpingPart.Replace: - edtitm.PasteReplace(copyStartID); - edtitm.Dispose(); + EditItem ei = edtitm.PasteReplace(copyStartID); + if (ei.MyItemInfo.ItemID != edtitm.MyItemInfo.ItemID) + { + edtitm.Dispose(); + MyCopyStep = ei.MyItemInfo; + } break; default: return false; ; diff --git a/PROMS/Volian.Controls.Library/EditItem.cs b/PROMS/Volian.Controls.Library/EditItem.cs index 79616a63..55457c8e 100644 --- a/PROMS/Volian.Controls.Library/EditItem.cs +++ b/PROMS/Volian.Controls.Library/EditItem.cs @@ -1246,8 +1246,8 @@ namespace Volian.Controls.Library //catch (System.Data.SqlClient.SqlException ex) catch (Exception ex) { - if(!HandleSqlExceptionOnCopy(ex)) - HandleSqlExceptionOnDelete(ex); + if (HandleSqlExceptionOnCopy(ex)) return this; + HandleSqlExceptionOnDelete(ex); return this; } // Remove the EditItem that was the replaced item. @@ -1307,7 +1307,12 @@ namespace Volian.Controls.Library MessageBox.Show("The step being pasted has been deleted", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand); return true; } - return false; + if(ex.Message.Contains("This current step has been deleted in another session")) + { + MessageBox.Show("The highlighted step has been deleted by another user.", "Cannot Paste Step", MessageBoxButtons.OK, MessageBoxIcon.Hand); + return true; + } + return false; } public void IdentifyChildren(bool highlight) {