private void AddSelectFromColumnOption(string selectedValue, int desiredIndex)
        {
            DataItemModel fromTable = this.uxFromTable.SelectedItem.To <DataItemModel>();

            bool haveChild = desiredIndex < this.uxSelectColumnsStack.Children.Count;

            ComboBoxTool resultBox = haveChild ?
                                     this.uxSelectColumnsStack.Children[desiredIndex].To <ComboBoxTool>()
                                :
                                     new ComboBoxTool();

            if (!haveChild)
            {
                resultBox.Items.Add(new DataItemModel {
                    DisplayValue = Constants.None, ItemKey = Constants.None
                });

                foreach (DataItemModel tableColumn in Integrity.GetColumnsForTable(fromTable.DisplayValue).OrderBy(t => t.DisplayValue))
                {
                    DataItemModel optionColumn = new DataItemModel
                    {
                        DisplayValue = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}",
                        ItemKey      = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}"
                    };

                    resultBox.Items.Add(optionColumn);
                }
                resultBox.SelectionChanged += this.SelectColumnChanged;

                this.uxSelectColumnsStack.Children.Add(resultBox);
            }

            resultBox.SelectedValue = selectedValue;
        }
        private void SetColumnOptions()
        {
            this.valueSelectColumns.Clear();

            DataItemModel fromTable = this.uxTableName.SelectedItem.To <DataItemModel>();

            if (fromTable == null)
            {
                return;
            }

            this.valueSelectColumns.Add(new DataItemModel {
                DisplayValue = Constants.None, ItemKey = Constants.None
            });

            foreach (DataItemModel tableColumn in Integrity.GetColumnsForTable(fromTable.DisplayValue).OrderBy(t => t.DisplayValue))
            {
                DataItemModel optionColumn = new DataItemModel
                {
                    DisplayValue = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}",
                    ItemKey      = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}"
                };

                this.valueSelectColumns.Add(optionColumn);
            }
        }
Exemple #3
0
        private void DataBaseTypeLink()
        {
            this.uxRelationName.Content = Integrity.BuildForeighKeyName(this.SelectedParentTable.ItemKey.ToString(), this.SelectedChildTable.ItemKey.ToString());

            foreach (ColumnObjectModel keyColumn in Integrity.GetObjectModel(this.SelectedParentTable.ItemKey.ToString()).Where(pk => pk.InPrimaryKey))
            {
                ComboBoxTool parentBox = new ComboBoxTool();

                ComboBoxTool childBox = new ComboBoxTool();

                parentBox.Name = $"{parentComboName}{this.uxParentColumns.Children.Count}";

                childBox.Name = $"{childComboName}{this.uxChildColumns.Children.Count}";

                parentBox.Items.Add(new DataItemModel {
                    DisplayValue = keyColumn.ColumnName, ItemKey = keyColumn.ColumnName
                });

                foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedChildTable.ItemKey.ToString()))
                {
                    childBox.Items.Add(item);
                }

                parentBox.SelectedValue = keyColumn.ColumnName;

                this.uxParentColumns.Children.Add(parentBox);

                this.uxChildColumns.Children.Add(childBox);
            }
        }
        private void FromTable_Changed(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            try
            {
                this.replaceWheres.Clear();

                this.uxSelectColumnsStack.Children.Clear();

                this.uxWhereOptions.Children.Clear();

                this.whereOptions.Clear();

                this.AddSelectFromColumnOption(string.Empty, 0);

                DataItemModel fromTable = this.uxFromTable.SelectedItem.To <DataItemModel>();

                this.whereOptions.Add(new DataItemModel {
                    DisplayValue = Constants.None, ItemKey = Constants.None
                });

                foreach (DataItemModel tableColumn in Integrity.GetColumnsForTable(fromTable.DisplayValue).OrderBy(t => t.DisplayValue))
                {
                    DataItemModel optionColumn = new DataItemModel
                    {
                        DisplayValue = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}",
                        ItemKey      = $"{fromTable.DisplayValue}.{tableColumn.DisplayValue}"
                    };

                    this.whereOptions.Add(optionColumn);
                }

                if (this.uxFromTable.SelectedValue.ParseToString() != Constants.None)
                {
                    this.AddReplaceWhere();
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.InnerExceptionMessage());
            }
        }
Exemple #5
0
        private void VirtualTypeLink()
        {
            this.uxRelationName.Content = Integrity.BuildForeighKeyName(this.SelectedParentTable.ItemKey.ToString(), this.SelectedChildTable.ItemKey.ToString());

            if (!this.wasLoaded)
            {
                foreach (ColumnRelationMapModel column in this.DatabaseRelation.Columns)
                {
                    ComboBoxTool parentBox = new ComboBoxTool();

                    ComboBoxTool childBox = new ComboBoxTool();

                    parentBox.Name = $"{parentComboName}{this.uxParentColumns.Children.Count}";

                    childBox.Name = $"{childComboName}{this.uxChildColumns.Children.Count}";

                    foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedParentTable.ItemKey.ToString()))
                    {
                        parentBox.Items.Add(item);
                    }

                    foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedChildTable.ItemKey.ToString()))
                    {
                        childBox.Items.Add(item);
                    }

                    childBox.DropDownClosed += this.ChildBox_Closed;

                    parentBox.SelectedValue = column.ParentColumn;

                    this.uxParentColumns.Children.Add(parentBox);

                    this.uxChildColumns.Children.Add(childBox);
                }
            }

            ComboBoxTool emptyParentBox = new ComboBoxTool();

            ComboBoxTool emptyChildBox = new ComboBoxTool();

            emptyParentBox.Name = $"{parentComboName}{this.uxParentColumns.Children.Count}";

            emptyChildBox.Name = $"{childComboName}{this.uxChildColumns.Children.Count}";

            foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedParentTable.ItemKey.ToString()))
            {
                emptyParentBox.Items.Add(item);
            }

            foreach (DataItemModel item in Integrity.GetColumnsForTable(this.SelectedChildTable.ItemKey.ToString()))
            {
                emptyChildBox.Items.Add(item);
            }

            emptyChildBox.DropDownClosed += this.ChildBox_Closed;

            //parentBox.SelectedValue = keyColumn.ColumnName;

            this.uxParentColumns.Children.Add(emptyParentBox);

            this.uxChildColumns.Children.Add(emptyChildBox);
        }