/// <summary> /// Instantiate a NsDataAccess object from a record ID. /// </summary> /// <param name="state">dataset state object</param> /// <param name="instantiateNewForm">Indicates whether to create a new form object if it doesn't exist.</param> /// <param name="parentFormHandle">Form handle of the parent form. Applicable only to subforms.</param> /// <param name="parentControlName">controlName of the control in the parent form representing the subform. Applicable only to subforms.</param> /// <param name="instantiatedForm"> True if and only if a new form was instantiated.</param> /// <returns>A new NsDataObject.</returns> public static NsDataAccess Create( NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName, out Boolean instantiatedForm) { instantiatedForm = false; if (state.IsResourceDefinedForm) { return(new NsTableDataAccess(ApplicationFactory.GetResourceDefinedFormTable(state.FormId))); } else if (state.FormId != 0 || state.ServerFormHandle != Guid.Empty) { NavConnection connection = NavConnection.Current; // Try to retrieve an existing instance of the form. NavForm form = connection.GetForm(state.ServerFormHandle); if (form == null) { if (instantiateNewForm) { // Not found - create new instance. if ((parentFormHandle != Guid.Empty) && (!String.IsNullOrEmpty(parentControlName))) { // Subform information provided - try to instantiate through the parent form NavForm parentForm = connection.GetForm(parentFormHandle); using (parentForm) { if (parentForm.TryGetUIPart(parentControlName, out form)) { form.AddReference(); } } } if (form == null) { // Form not instantiated as subform, try to instantiate as independent form form = NavEnvironment.Instance.ApplicationFactory.GetForm(state.FormId); } if (form != null) { instantiatedForm = true; state.ServerFormHandle = form.Handle; Debug.Assert(state.FormId == form.FormId); } } else { throw new NavException(NavException.NCL.ErrFormNotOpen); } } return(new NsFormDataAccess(form)); } else { Debug.Assert(state.TableId != 0); return(new NsTableDataAccess(state.TableId)); } }
public static NsDataAccess Create( NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName) { Boolean unusedResult; return(Create(state, instantiateNewForm, parentFormHandle, parentControlName, out unusedResult)); }
/// <summary> /// Instantiate a NsDataAccess object from a record ID. /// </summary> /// <param name="state">The record state.</param> /// <returns>A new NsDataObject.</returns> public static NsDataAccess Create(NavRecordState state) { Boolean instantiatedForm; NsDataAccess access = Create(state, false, Guid.Empty, String.Empty, out instantiatedForm); Debug.Assert(!instantiatedForm); return(access); }
internal void GetCommittedData(object sender, EventArgs e) { NavDataSet dataSet = new NavDataSet(); NavDataTable dataTable = new NavDataTable(); dataSet.Tables.Add(dataTable); NSPage.BuildCLRDataTable(dataTable, null, this); NavDataRow row = dataTable.NewRow(); NavRecord cached = (this.Record != null) ? this.Record.Clone(this.Record.IsTemporary) : null; try { // Get the latest persisted copy of the record if (this.Record != null) { if (!this.Record.ALGet(DataError.TrapError, this.Record.ALRecordId)) { return; } } NSRecordBase.PopulateCLRTable(dataTable, this, row); dataTable.Rows.Add(row); } finally { if (cached != null) { this.Record.Assign(cached); cached.Dispose(); } } NavRecordState dataSetState = NSDatasetState.Create(this); NSClientCallback.SendCommittedDataToClient(dataSet, dataSetState); }
/// <summary> /// Instantiate a NsDataAccess object from a record ID. /// </summary> /// <param name="state">dataset state object</param> /// <param name="instantiateNewForm">Indicates whether to create a new form object if it doesn't exist.</param> /// <param name="parentFormHandle">Form handle of the parent form. Applicable only to subforms.</param> /// <param name="parentControlName">controlName of the control in the parent form representing the subform. Applicable only to subforms.</param> /// <param name="instantiatedForm"> True if and only if a new form was instantiated.</param> /// <returns>A new NsDataObject.</returns> public static NsDataAccess Create( NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName, out Boolean instantiatedForm) { instantiatedForm = false; if (state.IsResourceDefinedForm) { return new NsTableDataAccess(ApplicationFactory.GetResourceDefinedFormTable(state.FormId)); } else if (state.FormId != 0 || state.ServerFormHandle != Guid.Empty) { NavConnection connection = NavConnection.Current; // Try to retrieve an existing instance of the form. NavForm form = connection.GetForm(state.ServerFormHandle); if (form == null) { if (instantiateNewForm) { // Not found - create new instance. if ((parentFormHandle != Guid.Empty) && (!String.IsNullOrEmpty(parentControlName))) { // Subform information provided - try to instantiate through the parent form NavForm parentForm = connection.GetForm(parentFormHandle); using (parentForm) { if (parentForm.TryGetUIPart(parentControlName, out form)) { form.AddReference(); } } } if (form == null) { // Form not instantiated as subform, try to instantiate as independent form form = NavEnvironment.Instance.ApplicationFactory.GetForm(state.FormId); } if (form != null) { instantiatedForm = true; state.ServerFormHandle = form.Handle; Debug.Assert(state.FormId == form.FormId); } } else { throw new NavException(NavException.NCL.ErrFormNotOpen); } } return new NsFormDataAccess(form); } else { Debug.Assert(state.TableId != 0); return new NsTableDataAccess(state.TableId); } }
public static NsDataAccess Create( NavRecordState state, Boolean instantiateNewForm, Guid parentFormHandle, String parentControlName) { Boolean unusedResult; return Create(state, instantiateNewForm, parentFormHandle, parentControlName, out unusedResult); }
/// <summary> /// Instantiate a NsDataAccess object from a record ID. /// </summary> /// <param name="state">The record state.</param> /// <returns>A new NsDataObject.</returns> public static NsDataAccess Create(NavRecordState state) { Boolean instantiatedForm; NsDataAccess access = Create(state, false, Guid.Empty, String.Empty, out instantiatedForm); Debug.Assert(!instantiatedForm); return access; }