示例#1
0
        /// <summary>
        /// Sets up the view and its datatable, if necessary
        /// </summary>
        private void ShowViewSelection()
        {
            ViewSelectionDialog viewSelectionDialog = new ViewSelectionDialog(this, CurrentProject);
            DialogResult result = viewSelectionDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                if (this.view != null)
                {
                    if (IsRecordCloseable == false)
                    {
                        return;
                    }

                    if (CloseView() == false)
                    {
                        return;
                    }
                }

                // If the project was changed, update current project. Otherwise, use the current project
                if (CurrentProject == null || (string.Compare(CurrentProject.FilePath, viewSelectionDialog.CurrentProject.FilePath, true) != 0))
                {
                    CurrentProject = viewSelectionDialog.CurrentProject;
                }

                this.view = CurrentProject.Views.GetViewById(viewSelectionDialog.ViewId);
                viewSelectionDialog.Close();
                //--123
                // this.view.VerifyandUpdateViewSystemVars();
                ////
                if (!this.view.IsRelatedView)
                {
                    Project project = view.GetProject();

                    if (CurrentProject.CollectedData.TableExists(view.TableName) == false)
                    {
                        DataTablePropertiesDialog dataTableProperties = new DataTablePropertiesDialog(this, this.CurrentProject, this.View);
                        dataTableProperties.DataTableName = view.TableName;
                        dataTableProperties.ShowDialog();

                        if (dataTableProperties.DialogResult == DialogResult.OK)
                        {
                            view.SetTableName(dataTableProperties.DataTableName);
                            project.CollectedData.CreateDataTableForView(view, dataTableProperties.StartingIndex);

                            foreach (View descendantView in view.GetDescendantViews())
                            {
                                if (!project.CollectedData.TableExists(descendantView.TableName))
                                {
                                    descendantView.SetTableName(descendantView.Name);
                                    project.CollectedData.CreateDataTableForView(descendantView, 1);
                                }
                            }
                        }
                        else
                        {
                            MsgBox.ShowWarning("A form cannot be opened in Enter without first creating a data table.");
                            return;
                        }
                    }

                    if (this.OpenViewEvent != null)
                    {
                        this.OpenViewEvent(this, new Epi.Windows.Enter.PresentationLogic.OpenViewEventArgs(view));
                    }
                }
                else
                {
                    MsgBox.ShowInformation(SharedStrings.CANNOT_OPEN_VIEW_NO_DATA_TABLE);
                    return;
                }
            }
        }
示例#2
0
 private void btnExisting_Click(object sender, EventArgs e)
 {
     ViewSelectionDialog dialog = new ViewSelectionDialog(this.MainForm, page.GetProject());
     DialogResult result = dialog.ShowDialog();
     if (result == DialogResult.OK)
     {
         sourceTableName = dialog.TableName;
         dialog.Close();
         ShowFieldSelection(sourceTableName);
     }
 }