protected override void InternalExecute(INode sender, EventParams paramsValue) { if (_document != String.Empty) { _params = paramsValue; if ((_mode == FormMode.Delete) && !ConfirmDelete) { SourceLink.Source.DataView.Delete(); } else { _mainSourceParams = paramsValue["AParams"] as DataParams; try { IFormInterface form = HostNode.Session.LoadForm(this, _document, new FormInterfaceHandler(InternalBeforeActivateForm)); try { form.OnClosed += new EventHandler(OnClosedHandler); form.TopMost = TopMost; InternalAfterActivateForm(form); bool forceAcceptReject = (_onFormAccepted != null) || (_onFormRejected != null) || (OnFormAcceptedEvent != null) || (OnFormRejectedEvent != null); if ((_mode != FormMode.None) || (SourceLinkType != SourceLinkType.None) || forceAcceptReject) { if (forceAcceptReject) { form.ForceAcceptReject = true; } form.Show ( (IFormInterface)FindParent(typeof(IFormInterface)), new FormInterfaceHandler(FormAccepted), new FormInterfaceHandler(FormRejected), _mode ); } else { form.Show(_mode); } } catch { form.Dispose(); throw; } } finally { _mainSourceParams = null; } } } }
public static void DoLookup(ILookup lookupNode, FormInterfaceHandler onFormAccept, FormInterfaceHandler onFormReject, System.Collections.IDictionary state) { bool isReadOnly = (lookupNode is ILookupElement) && ((ILookupElement)lookupNode).ReadOnly; if (!isReadOnly && (lookupNode.Document != String.Empty) && (lookupNode.Source != null) && (lookupNode.Source.DataView != null)) { lookupNode.Source.DataView.Edit(); lookupNode.Source.DataView.RequestSave(); IFormInterface form = lookupNode.HostNode.Session.LoadForm(lookupNode, lookupNode.Document, new FormInterfaceHandler(new LookupContext(lookupNode).PreLookup)); try { // Append the specified state if (state != null) { foreach (KeyValuePair <string, object> entry in state) { form.UserState.Add(entry.Key, entry.Value); } } lookupNode.LookupFormInitialize(form); string[] columnNames = GetColumnNames(lookupNode.MasterKeyNames, lookupNode.GetColumnNames()); string[] lookupColumnNames = GetColumnNames(lookupNode.DetailKeyNames, lookupNode.GetLookupColumnNames()); form.CheckMainSource(); LookupUtility.FindNearestRow ( form.MainSource.DataSource, lookupColumnNames, lookupNode.Source.DataSource, columnNames ); form.Show ( (IFormInterface)lookupNode.FindParent(typeof(IFormInterface)), onFormAccept, onFormReject, FormMode.Query ); } catch { form.HostNode.Dispose(); throw; } } }