Handle the deleting of a step marked for copy
This commit is contained in:
parent
75991ef8e3
commit
2ce0990d62
@ -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.
|
// 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);
|
||||||
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
|
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
|
||||||
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.Before);
|
try
|
||||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
{
|
||||||
tmp.UpdateTransitionText();
|
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.Before);
|
||||||
tmp.UpdatePastedStepTransitionText();
|
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||||
OnNewSiblingBefore(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Before));
|
tmp.UpdateTransitionText();
|
||||||
return tmp;
|
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)
|
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.
|
// 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);
|
||||||
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
|
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
|
||||||
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.After);
|
try
|
||||||
using (Item item = Get()) ItemInfo.Refresh(item);
|
{
|
||||||
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, type, EAddpingPart.After);
|
||||||
RefreshNextItems();
|
using (Item item = Get()) ItemInfo.Refresh(item);
|
||||||
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
|
||||||
// of any previous cautions or notes.
|
RefreshNextItems();
|
||||||
if (tmp.IsCaution || tmp.IsNote) ResetOrdinal();
|
// if inserting after a caution or note, refreshes tabs. This will adjust bullets
|
||||||
tmp.UpdateTransitionText();
|
// of any previous cautions or notes.
|
||||||
tmp.UpdatePastedStepTransitionText();
|
if (tmp.IsCaution || tmp.IsNote) ResetOrdinal();
|
||||||
OnNewSiblingAfter(new ItemInfoInsertEventArgs(tmp, EAddpingPart.After));
|
tmp.UpdateTransitionText();
|
||||||
return tmp;
|
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)
|
private ItemInfo CopyPasteItemInfoFetch(int copyStartID, int itemID, int? type, int? fromType, EAddpingPart addType)
|
||||||
{
|
{
|
||||||
@ -1075,37 +1091,47 @@ namespace VEPROMS.CSLA.Library
|
|||||||
{
|
{
|
||||||
if (!CanDeleteObject())
|
if (!CanDeleteObject())
|
||||||
throw new System.Security.SecurityException("User not authorized to remove a Item");
|
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);
|
try
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
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)
|
||||||
else if (newItemInfo.PreviousID != null)
|
|
||||||
{
|
|
||||||
using (ItemInfo itm2 = ItemInfo.Get((int)newItemInfo.PreviousID))
|
|
||||||
{
|
{
|
||||||
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)
|
private static ItemInfo CopyPasteReplaceItemInfoFetch(int copyStartID, ItemInfo itemInfo) // int itemID, int? type, int? fromType)
|
||||||
{
|
{
|
||||||
|
@ -758,7 +758,8 @@ namespace Volian.Controls.Library
|
|||||||
return newFocus;
|
return newFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex)
|
//private void HandleSqlExceptionOnDelete(System.Data.SqlClient.SqlException ex)
|
||||||
|
private void HandleSqlExceptionOnDelete(Exception ex)
|
||||||
{
|
{
|
||||||
if (ex.Message.Contains("has External Transitions and has no next step"))
|
if (ex.Message.Contains("has External Transitions and has no next step"))
|
||||||
{
|
{
|
||||||
@ -1153,6 +1154,7 @@ namespace Volian.Controls.Library
|
|||||||
public void PasteSiblingBefore(int copyStartID)
|
public void PasteSiblingBefore(int copyStartID)
|
||||||
{
|
{
|
||||||
ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID);
|
ItemInfo newItemInfo = MyItemInfo.PasteSiblingBefore(copyStartID);
|
||||||
|
if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
|
||||||
EditItem newEditItem = null;
|
EditItem newEditItem = null;
|
||||||
switch (_MyChildRelation)
|
switch (_MyChildRelation)
|
||||||
{
|
{
|
||||||
@ -1175,6 +1177,7 @@ namespace Volian.Controls.Library
|
|||||||
public void PasteSiblingAfter(int copyStartID)
|
public void PasteSiblingAfter(int copyStartID)
|
||||||
{
|
{
|
||||||
ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID);
|
ItemInfo newItemInfo = MyItemInfo.PasteSiblingAfter(copyStartID);
|
||||||
|
if (newItemInfo.ItemID == MyItemInfo.ItemID) return;
|
||||||
EditItem newEditItem = null;
|
EditItem newEditItem = null;
|
||||||
switch (_MyChildRelation)
|
switch (_MyChildRelation)
|
||||||
{
|
{
|
||||||
@ -1215,7 +1218,8 @@ namespace Volian.Controls.Library
|
|||||||
{
|
{
|
||||||
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID);
|
newItemInfo = Item.PasteReplace(MyItemInfo, copyStartID);
|
||||||
}
|
}
|
||||||
catch (System.Data.SqlClient.SqlException ex)
|
//catch (System.Data.SqlClient.SqlException ex)
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
HandleSqlExceptionOnDelete(ex);
|
HandleSqlExceptionOnDelete(ex);
|
||||||
return this;
|
return this;
|
||||||
|
@ -645,6 +645,7 @@ namespace Volian.Controls.Library
|
|||||||
btnCMGoTo.Enabled = btnGoTo.Enabled = true;
|
btnCMGoTo.Enabled = btnGoTo.Enabled = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if (_MyStepRTB == null) return;
|
||||||
if (_MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength))
|
if (_MyStepRTB.IsSelectionLinked(_MyStepRTB.SelectionStart, _MyStepRTB.SelectionLength))
|
||||||
{
|
{
|
||||||
// if selected text = ?, i.e. a missing/undefined destination, don't allow go to
|
// if selected text = ?, i.e. a missing/undefined destination, don't allow go to
|
||||||
@ -1810,6 +1811,15 @@ namespace Volian.Controls.Library
|
|||||||
|
|
||||||
public void btnDelStep_Click(object sender, EventArgs e)
|
public void btnDelStep_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
bool clearCopyStep = false;
|
||||||
|
StepTabPanel tmp = Parent as StepTabPanel;
|
||||||
|
if (tmp.MyDisplayTabControl.MyCopyStep != null &&
|
||||||
|
tmp.MyDisplayTabControl.MyCopyStep.ItemID == MyEditItem.MyItemInfo.ItemID)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Are you sure?\n\nIf you delete this step you will not able to paste it.\nYou should paste it before you delete it.", "Attempting to delete copied step.", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) return;
|
||||||
|
clearCopyStep = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool surpressMessageBox = (e == null);
|
bool surpressMessageBox = (e == null);
|
||||||
SectionInfo si = MyEditItem.MyItemInfo as SectionInfo;
|
SectionInfo si = MyEditItem.MyItemInfo as SectionInfo;
|
||||||
if (si != null)
|
if (si != null)
|
||||||
@ -1836,7 +1846,7 @@ namespace Volian.Controls.Library
|
|||||||
StepInfo stpi = MyEditItem.MyItemInfo as StepInfo;
|
StepInfo stpi = MyEditItem.MyItemInfo as StepInfo;
|
||||||
if (stpi == null) // not sure that it will every get here!
|
if (stpi == null) // not sure that it will every get here!
|
||||||
{
|
{
|
||||||
MessageBox.Show("Unknown type {0}, cannot delete!",MyEditItem.MyItemInfo.GetType().Name);
|
MessageBox.Show("Unknown type {0}, cannot delete!", MyEditItem.MyItemInfo.GetType().Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!surpressMessageBox)
|
if (!surpressMessageBox)
|
||||||
@ -1858,10 +1868,24 @@ namespace Volian.Controls.Library
|
|||||||
}
|
}
|
||||||
MyEditItem.IdentifyChildren(false);
|
MyEditItem.IdentifyChildren(false);
|
||||||
if (results == DialogResult.Yes)
|
if (results == DialogResult.Yes)
|
||||||
|
{
|
||||||
MyEditItem.RemoveItem();
|
MyEditItem.RemoveItem();
|
||||||
|
if (clearCopyStep)
|
||||||
|
{
|
||||||
|
tmp.MyDisplayTabControl.MyCopyStep = null;
|
||||||
|
SetPasteButtonEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
MyEditItem.RemoveItem();
|
MyEditItem.RemoveItem();
|
||||||
|
if (clearCopyStep)
|
||||||
|
{
|
||||||
|
tmp.MyDisplayTabControl.MyCopyStep = null;
|
||||||
|
SetPasteButtonEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCMIns_PopupClose(object sender, EventArgs e)
|
private void btnCMIns_PopupClose(object sender, EventArgs e)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user