support pasting of step into section and section into procedure; when updating transition text, refresh transinfo

This commit is contained in:
Kathy Ruffing 2015-01-29 13:45:25 +00:00
parent 7e12ec0e09
commit d4be18b454

View File

@ -416,6 +416,7 @@ namespace VEPROMS.CSLA.Library
#region PasteChangeId #region PasteChangeId
public static void PasteSetChangeId(ItemInfo ii, string chgid) public static void PasteSetChangeId(ItemInfo ii, string chgid)
{ {
if (!ii.ActiveFormat.PlantFormat.FormatData.ProcData.ChangeBarData.ChangeIds) return;
if (ii.IsProcedure) if (ii.IsProcedure)
{ {
return; // copy over change bars & change ids as they exist. return; // copy over change bars & change ids as they exist.
@ -428,13 +429,16 @@ namespace VEPROMS.CSLA.Library
else if (ii.IsStep) else if (ii.IsStep)
{ {
StepConfig sc = ii.MyConfig as StepConfig; StepConfig sc = ii.MyConfig as StepConfig;
sc.Step_ChangeID = chgid; if (chgid != null && sc.Step_ChangeID != chgid)
using (Item itm = ii.Get())
{ {
itm.MyContent.Config = sc.ToString(); sc.Step_ChangeID = chgid;
itm.MyContent.DTS = DateTime.Now; using (Item itm = ii.Get())
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID; {
itm.Save(); itm.MyContent.Config = sc.ToString();
itm.MyContent.DTS = DateTime.Now;
itm.MyContent.UserID = Volian.Base.Library.VlnSettings.UserID;
itm.Save();
}
} }
} }
// handle all of the children // handle all of the children
@ -446,7 +450,35 @@ namespace VEPROMS.CSLA.Library
if (ii.Steps != null) foreach (ItemInfo chlds in ii.Steps) PasteSetChangeId(chlds, chgid); if (ii.Steps != null) foreach (ItemInfo chlds in ii.Steps) PasteSetChangeId(chlds, chgid);
} }
#endregion #endregion
#region PasteSiblingBefore #region Paste
public ItemInfo PasteChild(int copyStartID, string chgid)
{
// 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.
ItemInfo cpItem = ItemInfo.Get(copyStartID);
int? type = MyContent.Type >= 20000 ? MyContent.Type : cpItem.MyContent.Type;
int? fromtype = MyContent.Type >= 20000 ? MyContent.Type
: ((int?)(IsProcedure ? E_FromType.Section
: (cpItem.IsSection ? E_FromType.Section : E_FromType.Step)));
try
{
ItemInfo tmp = CopyPasteItemInfoFetch(copyStartID, this.ItemID, type, fromtype, EAddpingPart.Child);
using (Item item = Get()) ItemInfo.Refresh(item);
if (tmp.NextItem != null) using (Item item = tmp.NextItem.Get()) ItemInfo.Refresh(item);
RefreshNextItems();
tmp.UpdateTransitionText();
tmp.UpdatePastedStepTransitionText();
PasteSetChangeId(tmp, chgid);
OnNewChild(new ItemInfoInsertEventArgs(tmp, EAddpingPart.Child));
return tmp;
}
catch (Exception ex)
{
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;
}
}
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
@ -623,6 +655,8 @@ namespace VEPROMS.CSLA.Library
#region B2012-071 fix JCB #region B2012-071 fix JCB
foreach (TransitionInfo tran in trans) foreach (TransitionInfo tran in trans)
{ {
using (Transition trn = tran.Get())
TransitionInfo.Refresh(trn);
Content oldContent = null; Content oldContent = null;
using (Content content = tran.MyContent.Get()) using (Content content = tran.MyContent.Get())
{ {
@ -731,8 +765,8 @@ namespace VEPROMS.CSLA.Library
switch (criteria.AddType) switch (criteria.AddType)
{ {
case EAddpingPart.Child: case EAddpingPart.Child:
//cm.CommandText = "addItemChild"; cm.CommandText = "PasteItemChild";
//cm.Parameters.AddWithValue("@FromType", criteria.FromType); //--C cm.Parameters.AddWithValue("@FromType", criteria.FromType); //--C
break; break;
case EAddpingPart.Before: case EAddpingPart.Before:
cm.CommandText = "PasteItemSiblingBefore"; cm.CommandText = "PasteItemSiblingBefore";