B2018-120: change of step type (caution/note) that has enhanced was not changing enhanced type.

This commit is contained in:
Kathy Ruffing 2018-08-29 15:48:40 +00:00
parent a2c3844ffd
commit e868ce2e9e

View File

@ -511,6 +511,7 @@ namespace Volian.Controls.Library
{
ItemInfo startitm = CurItemInfo.FirstSibling;
topEditItem = MyEditItem.MyStepPanel._LookupEditItems[startitm.ItemID];
bool chgEnh = false;
while (startitm != null)
{
using (Content cnt = Content.Get(startitm.MyContent.ContentID))
@ -520,6 +521,8 @@ namespace Volian.Controls.Library
cnt.UserID = Volian.Base.Library.VlnSettings.UserID;
cnt.Save();
}
// B2018-120: if caution/note steps have enhanced - change their type too
if (startitm.IsNote || startitm.IsCaution) chgEnh = ChangeTypesEnhanced(startitm);
//using (Item itm = Item.Get(startitm.ItemID))
//{
// itm.DTS = DateTime.Now;
@ -528,7 +531,9 @@ namespace Volian.Controls.Library
//}
startitm = startitm.GetNext();
}
msgBox = string.Format("All Step Types at this level were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
msgBox = chgEnh ? string.Format("All Step Types at this level and associated enhanced steps were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]) :
string.Format("All Step Types at this level were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
}
else
{
@ -539,13 +544,17 @@ namespace Volian.Controls.Library
cnt1.UserID = Volian.Base.Library.VlnSettings.UserID;
cnt1.Save();
}
bool chgEnh = false;
// B2018-120: if caution/note steps have enhanced - change their type too
if (CurItemInfo.IsNote || CurItemInfo.IsCaution) chgEnh = ChangeTypesEnhanced(CurItemInfo);
//using (Item itm1 = Item.Get(CurItemInfo.ItemID))
//{
// itm1.DTS = DateTime.Now;
// itm1.UserID = Volian.Base.Library.VlnSettings.UserID;
// itm1.Save();
//}
msgBox = string.Format("This Step Type was changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
msgBox = chgEnh ? string.Format("This Step Type and associated enhanced step were changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]):
string.Format("This Step Type was changed to {0}", listBoxStepTypes.Items[listBoxStepTypes.SelectedIndex]);
}
// the follow line was to try and fix a refresh problem when you change the type of a new substep
//topEditItem.MyStepPanel.Reset();
@ -554,6 +563,31 @@ namespace Volian.Controls.Library
MessageBox.Show(msgBox);
}
private bool ChangeTypesEnhanced(ItemInfo startitm)
{
bool retval = false;
EnhancedDocuments eds = startitm.GetMyEnhancedDocuments();
if (eds != null && eds.Count > 0)
{
foreach (EnhancedDocument ed in eds)
{
ItemInfo eii = ItemInfo.Get(ed.ItemID);
if (eii != null)
{
retval = true;
using (Content cnt = Content.Get(eii.MyContent.ContentID))
{
cnt.Type = startitm.IsCaution ? 20006 : 20007; // use base types in the enhanced.
cnt.DTS = DateTime.Now;
cnt.UserID = Volian.Base.Library.VlnSettings.UserID;
cnt.Save();
}
}
}
}
return retval;
}
private void groupPanelCheckoff_VisibleChanged(object sender, EventArgs e)
{
// If it becomes visible, update the panel