118 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			118 lines
		
	
	
		
			3.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.ComponentModel;
 | |
| using System.Data;
 | |
| using System.Drawing;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.Windows.Forms;
 | |
| using VEPROMS.CSLA.Library;
 | |
| 
 | |
| namespace Volian.Controls.Library
 | |
| {
 | |
| 	public partial class dlgEnhMissingItem : Form
 | |
| 	{
 | |
| 		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)
 | |
| 		{
 | |
| 			_Initializing = true;
 | |
| 			_SourceItem = srcItem;
 | |
| 			_EnhType = enhType;
 | |
| 			InitializeComponent();
 | |
| 			STRibbon = strbn;
 | |
| 			btnOK.Enabled = true;
 | |
| 			ItemInfoList iil = ItemInfoList.GetListEnhancedForMissing(srcItem, enhType);
 | |
| 			// if none found, only can do 'create'
 | |
| 			if (iil == null || iil.Count == 0)
 | |
| 			{
 | |
| 				rbLinkToExisting.Enabled = false;
 | |
| 				cbUnlinkedEnhancedItems.Enabled = false;
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				rbLinkToExisting.Enabled = true;
 | |
| 				cbUnlinkedEnhancedItems.DataSource = iil;
 | |
| 				cbUnlinkedEnhancedItems.SelectedIndex = -1;
 | |
| 				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)
 | |
| 		{
 | |
| 			if (rbCreateNew.Checked)
 | |
| 			{
 | |
| 				STRibbon.enhUseExist = null;
 | |
| 				STRibbon.enhDoConv = false;
 | |
| 			}
 | |
| 			else
 | |
| 			{
 | |
| 				ItemInfo ii = cbUnlinkedEnhancedItems.SelectedItem as ItemInfo;
 | |
| 				STRibbon.enhUseExist = ii;
 | |
| 			}
 | |
| 			OKSelected = true;
 | |
| 			this.Close();
 | |
| 		}
 | |
| 
 | |
| 		private void rbLinkToExisting_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (rbLinkToExisting.Checked)
 | |
| 			{
 | |
| 				cbUnlinkedEnhancedItems.Enabled = true;
 | |
| 				cbUnlinkedEnhancedItems.SelectedIndex = -1;
 | |
| 				btnOK.Enabled = false;    // disable until user selects an item from combobox
 | |
| 			}
 | |
| 			else
 | |
| 				cbUnlinkedEnhancedItems.Enabled = false;
 | |
| 		}
 | |
| 
 | |
| 		private void rbCreateNew_CheckedChanged(object sender, EventArgs e)
 | |
| 		{
 | |
| 			if (rbCreateNew.Checked) btnOK.Enabled = true;
 | |
| 		}
 | |
| 		private void cbUnlinkedEnhancedItems_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;
 | |
| 			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;
 | |
| 				if (ii == null) return;
 | |
| 				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);   
 | |
| 					}
 | |
| 				}
 | |
| 			}
 | |
| 		}
 | |
| 	}
 | |
| }
 | 
