public void InitializePrimaryKeys(TableKeyEditorMode mode, bool loadProps, TableWrapper initialTable) { try { _initializing = true; Mode = mode; DbCmd.PopulatePrimaryKeysCombo(cmbPk, _cp, loadProps, (initialTable != null ? initialTable.ID : -1)); _initialTable = initialTable; DbCmd.PopulateUserDefinedTablesCombo(cmbTables, _cp, (initialTable != null ? initialTable.ID : -1)); } finally { _initializing = false; } if (cmbPk.Items.Count > 0) { cmbPk.SelectedIndex = 0; } else { CreateNewKey(); } }
public void InitializeForeignKeys(TableKeyEditorMode mode, TableWrapper hostTable, long keyid) { try { _initializing = true; Mode = mode; cmbFk.Items.Clear(); _hostTable = null; _newKey = null; _hostTable = hostTable; cmbFk.Enabled = true; // Populate host tables. If host table is not null select proper table DbCmd.PopulateUserDefinedTablesCombo(cmbHostTables, _cp, ((_hostTable != null && Mode == TableKeyEditorMode.SingleTable) ? _hostTable.ID : -1)); if (_hostTable != null) { cmbHostTables.SelectedIndex = cmbHostTables.FindStringExact(_hostTable.Name); PopulateHostColumnsCombo(); } cmbHostTables.Enabled = (_hostTable != null && Mode == TableKeyEditorMode.SingleTable); //Populate reference tables combo DbCmd.PopulateUserDefinedTablesCombo(cmbRefTables, _cp, -1); ForeignKeyWrapper fk = new ForeignKeyWrapper(_cp); fk.ID = keyid; fk.LoadProperties(); fk.GetKey(); cmbFk.Items.Add(fk); cmbFk.SelectedIndex = 0; RenderKeyProperties(); } finally { _initializing = false; if (cmbFk.Items.Count == 0) { InitializeNewKey(); } } }
public void InitializeForeignKeys(TableKeyEditorMode mode, TableWrapper hostTable, bool renderLast) { try { _initializing = true; Mode = mode; _hostTable = null; _newKey = null; _hostTable = hostTable; cmbFk.Enabled = true; // Populate host tables. If host table is not null select proper table DbCmd.PopulateUserDefinedTablesCombo(cmbHostTables, _cp, ((_hostTable != null && Mode == TableKeyEditorMode.SingleTable) ? _hostTable.ID : -1)); if (_hostTable != null) { cmbHostTables.SelectedIndex = cmbHostTables.FindStringExact(_hostTable.Name); PopulateHostColumnsCombo(); } cmbHostTables.Enabled = (_hostTable != null && Mode == TableKeyEditorMode.SingleTable); //Populate reference tables combo DbCmd.PopulateUserDefinedTablesCombo(cmbRefTables, _cp, -1); //Populate foreign keys combo box DbCmd.PopulateForeignKeysComboSimple(cmbFk, _cp, _hostTable != null ? _hostTable.ID : -1); //Select first item in the foreign keys combo box if (cmbFk.Items.Count > 0) { if (renderLast) { cmbFk.SelectedIndex = cmbFk.Items.Count - 1; } else { cmbFk.SelectedIndex = 0; } ForeignKeyWrapper fk = cmbFk.SelectedItem as ForeignKeyWrapper; if (fk != null && !fk.AllPropsLoaded) { fk.LoadAllProperties(); } RenderKeyProperties(); } else { cmbFk.SelectedIndex = -1; } } finally { _initializing = false; if (cmbFk.Items.Count == 0) { InitializeNewKey(); } } }