Exemple #1
0
        protected void CallMatchFieldDialogs()
        {
            ViewSelectionDialog dialog = new ViewSelectionDialog(MainForm, page.GetProject());
            DialogResult        result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                sourceTableName = dialog.TableName;
                dialog.Close();
                btnOK.Enabled = true;
            }
        }
Exemple #2
0
        // USE EXISTING
        protected override void btnUseExisting_Click(object sender, System.EventArgs e)
        {
            creationMode = CreationMode.UseExisting;

            ViewSelectionDialog dialog = new ViewSelectionDialog(MainForm, page.GetProject());
            DialogResult        result = dialog.ShowDialog();

            if (result == DialogResult.OK)
            {
                sourceTableName = dialog.TableName;
                dialog.Close();
                if (page.GetProject().CollectedData.TableExists(sourceTableName))
                {
                    codeTable = page.GetProject().GetTableData(sourceTableName);
                }
                else
                {
                    string separator = " - ";

                    if (sourceTableName.Contains(separator))
                    {
                        string[] view_page        = sourceTableName.Replace(separator, "^").Split('^');
                        string   viewName         = view_page[0].ToString();
                        string   pageName         = view_page[1].ToString();
                        string   filterExpression = string.Empty;
                        string   tableName        = null;
                        View     targetView       = page.GetProject().Metadata.GetViewByFullName(viewName);

                        if (targetView != null)
                        {
                            DataTable targetPages = page.GetProject().Metadata.GetPagesForView(targetView.Id);
                            DataView  dataView    = new DataView(targetPages);

                            filterExpression = string.Format("Name = '{0}'", pageName);

                            DataRow[] pageArray = targetPages.Select(filterExpression);

                            if (pageArray.Length > 0)
                            {
                                int pageId = (int)pageArray[0]["PageId"];
                                tableName = viewName + pageId;
                            }
                        }
                        if (page.GetProject().CollectedData.TableExists(tableName))
                        {
                            codeTable = page.GetProject().GetTableData(tableName);
                        }
                    }
                }

                if (codeTable != null)
                {
                    dgCodes.Visible     = true;
                    codeTable.TableName = sourceTableName;
                    dgCodes.DataSource  = codeTable;

                    if (DdlField != null)
                    {
                        cbxSort.Checked = !DdlField.ShouldSort;
                    }
                    if (DdlColumn != null)
                    {
                        cbxSort.Checked = !DdlColumn.ShouldSort;
                    }

                    btnCreate.Enabled       = false;
                    btnFromExisting.Enabled = false;
                    btnUseExisting.Enabled  = false;
                    btnDelete.Enabled       = true;

                    btnMatchFields.Enabled = true;
                }
                else
                {
                    btnCreate.Enabled       = true;
                    btnFromExisting.Enabled = true;
                    btnUseExisting.Enabled  = true;
                    btnDelete.Enabled       = false;

                    btnMatchFields.Enabled = false;
                }

                isExclusiveTable = true;
            }
        }