Handle the deleting of a step marked for copy
This commit is contained in:
@@ -341,12 +341,20 @@ namespace VEPROMS.CSLA.Library
|
||||
// item, i.e. item inserting after. If it's a section or procedure, use the copied item's type.
|
||||
ItemInfo cpItem = ItemInfo.Get(copyStartID);
|
||||
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
|
||||
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.Before);
|
||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||
tmp.UpdateTransitionText();
|
||||
tmp.UpdatePastedStepTransitionText();
|
||||
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
|
||||
return tmp;
|
||||
try
|
||||
{
|
||||
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.Before);
|
||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||
tmp.UpdateTransitionText();
|
||||
tmp.UpdatePastedStepTransitionText();
|
||||
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
|
||||
return tmp;
|
||||
}
|
||||
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);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
public ItemInfo PasteSiblingAfter(int copyStartID)
|
||||
{
|
||||
@@ -354,17 +362,25 @@ namespace VEPROMS.CSLA.Library
|
||||
// item, i.e. item inserting after. If it's a section or procedure, use the copied item's type.
|
||||
ItemInfo cpItem = ItemInfo.Get(copyStartID);
|
||||
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
|
||||
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.After);
|
||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
RefreshNextItems();
|
||||
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
||||
// of any previous cautions or notes.
|
||||
if (tmp.IsCaution || tmp.IsNote) ResetOrdinal();
|
||||
tmp.UpdateTransitionText();
|
||||
tmp.UpdatePastedStepTransitionText();
|
||||
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
|
||||
return tmp;
|
||||
try
|
||||
{
|
||||
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.After);
|
||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
RefreshNextItems();
|
||||
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
||||
// of any previous cautions or notes.
|
||||
if (tmp.IsCaution || tmp.IsNote) ResetOrdinal();
|
||||
tmp.UpdateTransitionText();
|
||||
tmp.UpdatePastedStepTransitionText();
|
||||
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
|
||||
return tmp;
|
||||
}
|
||||
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);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
private ItemInfo CopyPasteItemInfoFetch(int copyStartID, int itemID, int? type, int? fromType, EAddpingPart addType)
|
||||
{
|
||||
@@ -1075,37 +1091,47 @@ namespace VEPROMS.CSLA.Library
|
||||
{
|
||||
if (!CanDeleteObject())
|
||||
throw new System.Security.SecurityException("User not authorized to remove a Item");
|
||||
ItemInfo newItemInfo = CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
|
||||
// Delete business objects, including remove from tree
|
||||
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children
|
||||
using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item);
|
||||
if (newItemInfo.NextItem != null) using (Item item = newItemInfo.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
newItemInfo.RefreshNextItems();
|
||||
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
||||
// of any previous cautions or notes.
|
||||
if (newItemInfo.IsCaution || newItemInfo.IsNote) newItemInfo.ResetOrdinal();
|
||||
newItemInfo.UpdateTransitionText();
|
||||
newItemInfo.UpdatePastedStepTransitionText();
|
||||
// Add to tree
|
||||
if (newItemInfo.NextItemCount > 0)
|
||||
try
|
||||
{
|
||||
using (ItemInfo itm = ItemInfo.Get(newItemInfo.NextItem.ItemID))
|
||||
ItemInfo newItemInfo = CopyPasteReplaceItemInfoFetch(copyStartID, itemInfo); //itemInfo.ItemID, itemInfo.MyContent.Type, itemInfo.MyContent.Type);
|
||||
// Delete business objects, including remove from tree
|
||||
ItemInfo.DeleteItemInfoAndChildren(itemInfo.ItemID); // Dispose ItemInfo and Children
|
||||
using (Item item = Get(newItemInfo.ItemID)) ItemInfo.Refresh(item);
|
||||
if (newItemInfo.NextItem != null) using (Item item = newItemInfo.NextItem.Get()) ItemInfo.Refresh(item);
|
||||
newItemInfo.RefreshNextItems();
|
||||
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
||||
// of any previous cautions or notes.
|
||||
if (newItemInfo.IsCaution || newItemInfo.IsNote) newItemInfo.ResetOrdinal();
|
||||
newItemInfo.UpdateTransitionText();
|
||||
newItemInfo.UpdatePastedStepTransitionText();
|
||||
// Add to tree
|
||||
if (newItemInfo.NextItemCount > 0)
|
||||
{
|
||||
itm.OnNewSiblingBefore(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Before));
|
||||
using (ItemInfo itm = ItemInfo.Get(newItemInfo.NextItem.ItemID))
|
||||
{
|
||||
itm.OnNewSiblingBefore(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Before));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (newItemInfo.PreviousID != null)
|
||||
{
|
||||
using (ItemInfo itm2 = ItemInfo.Get((int)newItemInfo.PreviousID))
|
||||
else if (newItemInfo.PreviousID != null)
|
||||
{
|
||||
itm2.OnNewSiblingAfter(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.After));
|
||||
using (ItemInfo itm2 = ItemInfo.Get((int)newItemInfo.PreviousID))
|
||||
{
|
||||
itm2.OnNewSiblingAfter(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.After));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newItemInfo.MyParent.OnNewChild(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Child));
|
||||
}
|
||||
return newItemInfo;
|
||||
}
|
||||
else
|
||||
catch (Exception ex)
|
||||
{
|
||||
newItemInfo.MyParent.OnNewChild(new ItemInfoInsertEventArgs(newItemInfo, ItemInfo.EAddpingPart.Child));
|
||||
if (ex.Message.Contains("has External Transitions and has no next step") || ex.Message.Contains("has External Transitions to it's children"))
|
||||
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;
|
||||
}
|
||||
return newItemInfo;
|
||||
}
|
||||
private static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType)
|
||||
{
|
||||
|
Reference in New Issue
Block a user