Enhanced: rename a method name for clarification

Enhanced: convert 16-32 bit link data at procedure level
Enhanced: convert 16-32 bit link data at procedure level.
This commit is contained in:
Kathy Ruffing 2016-05-12 12:48:34 +00:00
parent 1934a6b5e9
commit 15f3b2ce09
5 changed files with 90 additions and 25 deletions

View File

@ -1626,7 +1626,7 @@ namespace VEPROMS.CSLA.Library
} }
return newEnh; return newEnh;
} }
public void DoCreateLinksEnhancedSteps(ItemInfo enhii, int enhtype) public void DoCreateLinksEnhancedSingleItem(ItemInfo enhii, int enhtype)
{ {
// Link the 2 items, srcII & enhii: // Link the 2 items, srcII & enhii:
if (IsStep) if (IsStep)

View File

@ -1399,11 +1399,27 @@ namespace Volian.Controls.Library
} }
} }
} }
public void CreateLinksEnhancedSteps(ItemInfo srcII, ItemInfo enhII, int enhtype) public void CreateLinksEnhancedSingleItem(ItemInfo srcII, ItemInfo enhII, int enhtype)
{ {
srcII.DoCreateLinksEnhancedSteps(enhII, enhtype); srcII.DoCreateLinksEnhancedSingleItem(enhII, enhtype);
SetFocus(); SetFocus();
} }
public void CreateLinksEnhancedAllInProcedure(ItemInfo srcII, ItemInfo enhII, int enhtype)
{
using (ContentInfoList cil = ContentInfoList.Convert16To32EnhancedContents(srcII.ItemID, enhII.ItemID, enhtype))
{
foreach (ContentInfo ci in cil)
{
using (Content c = ci.Get())
{
// first refresh configs because the ContentInfo.Refresh causes events to occur that refresh screen
// and if configs aren't done first, the screen refresh, if based on config data, will not be correct.
foreach (ItemInfo ii in ci.ContentItems) ii.RefreshConfig();
ContentInfo.Refresh(c);
}
}
}
}
public void UnlinkEnhanced(ItemInfo enhII) public void UnlinkEnhanced(ItemInfo enhII)
{ {
enhII.DoUnlinkEnhanced(enhII); enhII.DoUnlinkEnhanced(enhII);

View File

@ -263,6 +263,7 @@ namespace Volian.Controls.Library
#endregion #endregion
} }
public ItemInfo enhUseExist = null; public ItemInfo enhUseExist = null;
public bool enhDoConv = false;
void btnEnhancedGoTo_Click(object sender, EventArgs e) void btnEnhancedGoTo_Click(object sender, EventArgs e)
{ {
DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem; DevComponents.DotNetBar.BaseItem btn = sender as DevComponents.DotNetBar.BaseItem;
@ -286,15 +287,17 @@ namespace Volian.Controls.Library
int enhtype = System.Convert.ToInt32(btn.Name.Replace("btnEnhancedTo", "")); int enhtype = System.Convert.ToInt32(btn.Name.Replace("btnEnhancedTo", ""));
dlgEnhMissingItem enhMissDlg = new dlgEnhMissingItem(this, ii, enhtype); dlgEnhMissingItem enhMissDlg = new dlgEnhMissingItem(this, ii, enhtype);
DialogResult dr = enhMissDlg.ShowDialog(this.Parent); DialogResult dr = enhMissDlg.ShowDialog(this.Parent);
if (dr == DialogResult.OK) if (enhMissDlg.OKSelected || dr == DialogResult.OK)
{ {
if (enhUseExist == null) if (enhUseExist == null)
{ {
ItemInfo newEnh = MyEditItem.AddMissingEnhancedStep(ii, enhtype); ItemInfo newEnh = MyEditItem.AddMissingEnhancedStep(ii, enhtype);
if (ii.IsProcedure && newEnh != null) OnAddProcToDVInTree(new StepTabRibbonEventArgs(newEnh)); if (ii.IsProcedure && newEnh != null) OnAddProcToDVInTree(new StepTabRibbonEventArgs(newEnh));
} }
else if (!enhDoConv)
MyEditItem.CreateLinksEnhancedSingleItem(ii, enhUseExist, enhtype);
else else
MyEditItem.CreateLinksEnhancedSteps(ii, enhUseExist, enhtype); MyEditItem.CreateLinksEnhancedAllInProcedure(ii, enhUseExist, enhtype);
MyEditItem.SetFocus(); MyEditItem.SetFocus();
} }
} }

View File

@ -30,7 +30,7 @@
{ {
this.rbCreateNew = new System.Windows.Forms.RadioButton(); this.rbCreateNew = new System.Windows.Forms.RadioButton();
this.rbLinkToExisting = new System.Windows.Forms.RadioButton(); this.rbLinkToExisting = new System.Windows.Forms.RadioButton();
this.cbUnlinkEnhancedItems = new System.Windows.Forms.ComboBox(); this.cbUnlinkedEnhancedItems = new System.Windows.Forms.ComboBox();
this.btnOK = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button(); this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
@ -59,14 +59,14 @@
this.rbLinkToExisting.UseVisualStyleBackColor = true; this.rbLinkToExisting.UseVisualStyleBackColor = true;
this.rbLinkToExisting.CheckedChanged += new System.EventHandler(this.rbLinkToExisting_CheckedChanged); this.rbLinkToExisting.CheckedChanged += new System.EventHandler(this.rbLinkToExisting_CheckedChanged);
// //
// cbUnlinkEnhancedItems // cbUnlinkedEnhancedItems
// //
this.cbUnlinkEnhancedItems.FormattingEnabled = true; this.cbUnlinkedEnhancedItems.FormattingEnabled = true;
this.cbUnlinkEnhancedItems.Location = new System.Drawing.Point(57, 102); this.cbUnlinkedEnhancedItems.Location = new System.Drawing.Point(57, 102);
this.cbUnlinkEnhancedItems.Name = "cbUnlinkEnhancedItems"; this.cbUnlinkedEnhancedItems.Name = "cbUnlinkedEnhancedItems";
this.cbUnlinkEnhancedItems.Size = new System.Drawing.Size(506, 24); this.cbUnlinkedEnhancedItems.Size = new System.Drawing.Size(506, 24);
this.cbUnlinkEnhancedItems.TabIndex = 2; this.cbUnlinkedEnhancedItems.TabIndex = 2;
this.cbUnlinkEnhancedItems.SelectedIndexChanged += new System.EventHandler(this.cbUnlinkEnhancedItems_SelectedIndexChanged); this.cbUnlinkedEnhancedItems.SelectedIndexChanged += new System.EventHandler(this.cbUnlinkedEnhancedItems_SelectedIndexChanged);
// //
// btnOK // btnOK
// //
@ -96,7 +96,7 @@
this.ClientSize = new System.Drawing.Size(612, 242); this.ClientSize = new System.Drawing.Size(612, 242);
this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK); this.Controls.Add(this.btnOK);
this.Controls.Add(this.cbUnlinkEnhancedItems); this.Controls.Add(this.cbUnlinkedEnhancedItems);
this.Controls.Add(this.rbLinkToExisting); this.Controls.Add(this.rbLinkToExisting);
this.Controls.Add(this.rbCreateNew); this.Controls.Add(this.rbCreateNew);
this.Name = "dlgEnhMissingItem"; this.Name = "dlgEnhMissingItem";
@ -110,7 +110,7 @@
private System.Windows.Forms.RadioButton rbCreateNew; private System.Windows.Forms.RadioButton rbCreateNew;
private System.Windows.Forms.RadioButton rbLinkToExisting; private System.Windows.Forms.RadioButton rbLinkToExisting;
private System.Windows.Forms.ComboBox cbUnlinkEnhancedItems; private System.Windows.Forms.ComboBox cbUnlinkedEnhancedItems;
private System.Windows.Forms.Button btnOK; private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnCancel;
} }

View File

@ -13,8 +13,15 @@ namespace Volian.Controls.Library
public partial class dlgEnhMissingItem : Form public partial class dlgEnhMissingItem : Form
{ {
StepTabRibbon STRibbon = null; StepTabRibbon STRibbon = null;
private ItemInfo _SourceItem = null;
private int _EnhType = -1;
private bool _Initializing = false;
public bool OKSelected = false;
public dlgEnhMissingItem(StepTabRibbon strbn, ItemInfo srcItem, int enhType) public dlgEnhMissingItem(StepTabRibbon strbn, ItemInfo srcItem, int enhType)
{ {
_Initializing = true;
_SourceItem = srcItem;
_EnhType = enhType;
InitializeComponent(); InitializeComponent();
STRibbon = strbn; STRibbon = strbn;
btnOK.Enabled = true; btnOK.Enabled = true;
@ -23,48 +30,87 @@ namespace Volian.Controls.Library
if (iil == null || iil.Count == 0) if (iil == null || iil.Count == 0)
{ {
rbLinkToExisting.Enabled = false; rbLinkToExisting.Enabled = false;
cbUnlinkEnhancedItems.Enabled = false; cbUnlinkedEnhancedItems.Enabled = false;
} }
else else
{ {
rbLinkToExisting.Enabled = true; rbLinkToExisting.Enabled = true;
cbUnlinkEnhancedItems.DataSource = iil; cbUnlinkedEnhancedItems.DataSource = iil;
cbUnlinkEnhancedItems.SelectedIndex = -1; cbUnlinkedEnhancedItems.SelectedIndex = -1;
cbUnlinkEnhancedItems.Enabled = false; cbUnlinkedEnhancedItems.Enabled = false;
} }
if (srcItem.IsProcedure) this.Text = "Create Missing Enhanced Item for " + srcItem.DisplayNumber;
else this.Text = "Create Missing Enhanced Item";
_Initializing = false;
} }
private void btnOK_Click(object sender, EventArgs e) private void btnOK_Click(object sender, EventArgs e)
{ {
if (rbCreateNew.Checked) if (rbCreateNew.Checked)
{
STRibbon.enhUseExist = null; STRibbon.enhUseExist = null;
STRibbon.enhDoConv = false;
}
else else
{ {
ItemInfo ii = cbUnlinkEnhancedItems.SelectedItem as ItemInfo; ItemInfo ii = cbUnlinkedEnhancedItems.SelectedItem as ItemInfo;
STRibbon.enhUseExist = ii; STRibbon.enhUseExist = ii;
} }
OKSelected = true;
this.Close();
} }
private void rbLinkToExisting_CheckedChanged(object sender, EventArgs e) private void rbLinkToExisting_CheckedChanged(object sender, EventArgs e)
{ {
if (rbLinkToExisting.Checked) if (rbLinkToExisting.Checked)
{ {
cbUnlinkEnhancedItems.Enabled = true; cbUnlinkedEnhancedItems.Enabled = true;
cbUnlinkEnhancedItems.SelectedIndex = -1; cbUnlinkedEnhancedItems.SelectedIndex = -1;
btnOK.Enabled = false; // disable until user selects an item from combobox btnOK.Enabled = false; // disable until user selects an item from combobox
} }
else else
cbUnlinkEnhancedItems.Enabled = false; cbUnlinkedEnhancedItems.Enabled = false;
} }
private void rbCreateNew_CheckedChanged(object sender, EventArgs e) private void rbCreateNew_CheckedChanged(object sender, EventArgs e)
{ {
if (rbCreateNew.Checked) btnOK.Enabled = true; if (rbCreateNew.Checked) btnOK.Enabled = true;
} }
private void cbUnlinkedEnhancedItems_SelectedIndexChanged(object sender, EventArgs e)
private void cbUnlinkEnhancedItems_SelectedIndexChanged(object sender, EventArgs e)
{ {
if (_Initializing) return;
// cbUnlinkedEnhancedItems combo box has a list of all items in the enhanced document
// that can be linked to from this item.
btnOK.Enabled = true; btnOK.Enabled = true;
STRibbon.enhDoConv = false;
// if on a procedure, take the selected enhanced procedure & see if there are non-procedure items
// within it that can be linked based on old 16 bit data. If no sections/steps are returned, only the
// procedure can be linked so it really isn't a match. Otherwise, prompt user to see if they want to
// convert the data. If so, convert all items within it that can be linked. If not, just link as before.
if (_SourceItem.IsProcedure)
{
ItemInfo ii = cbUnlinkedEnhancedItems.SelectedItem as ItemInfo;
ContentInfoList cil = ContentInfoList.Get16BitEnhancedContents(_SourceItem.ItemID, ii.ItemID, _EnhType);
bool foundSubItem = false; // in returned list, see if there are any sections/steps. If none, don't prompt
foreach (ContentInfo ci in cil)
{
if (ci.Type >= 10000)
{
foundSubItem = true;
break;
}
}
if (foundSubItem)
{
DialogResult dr = MessageBox.Show("The procedure that is selected has enhanced data. Do you want to convert it (this will link any section/steps that can be linked)?", "Enhanced Links", MessageBoxButtons.YesNo);
if (dr == DialogResult.Yes)
{
STRibbon.enhUseExist = ii;
STRibbon.enhDoConv = true;
btnOK_Click(sender, e);
}
}
}
} }
} }
} }