public void SaveKey( ) { string err = String.Empty; if (!ValidateInput(ref err)) { MessageService.ShowError(err); return; } try { if (_newKey != null) { _newKey.Create(); _initializing = true; cmbPk.Items.Add(_newKey); cmbPk.SelectedItem = _newKey; _newKey = null; _initializing = false; } else if (SelectedKey != null) { SelectedKey.DropAndRecreate(); } } catch (Exception ex) { if (ex.GetType() != typeof(CancelledByUserException)) { Utils.ShowException(ex); } } }
private void RenderKeyProperties( ) { try { _initializing = true; ClearKeyPropertyControls(); if (SelectedKey == null) { return; } PrimaryKeyWrapper key = SelectedKey; SelectedTable = key.Table.Name; txtName.Text = key.Name; chkClustered.Checked = key.Clustered; txtFillFactor.Text = key.FillFactor.ToString(); cmbFileGroup.SelectedIndex = cmbFileGroup.FindStringExact(key.Filegroup); InitializeKeyColumns(); InitializeTableColumns(); } finally { _initializing = false; } }
private void cmbPk_SelectedIndexChanged(object sender, EventArgs e) { SetKeyDefinitionControlVisibility(false); if (_initializing) { return; } _newKey = null; RenderKeyProperties(); }
public void CreateNewKey( ) { ClearKeyPropertyControls(); _newKey = new PrimaryKeyWrapper(_cp); SetKeyDefinitionControlVisibility(true); txtName.Text = "PK_" + _initialTable.Name; if (_initialTable != null) { SelectedTable = _initialTable.Name; } else if (cmbTables.Items.Count > 0) { cmbTables.SelectedIndex = 0; } }
private void RenameKey( ) { if (SelectedKey == null) { return; } string newName = SelectedKey.Name; if (InputDialog.ShowDialog("Rename Primary Key", "New Name", ref newName) != DialogResult.OK) { return; } if (SelectedKey.Name.ToLowerInvariant() == newName.ToLowerInvariant()) { return; } try { SelectedKey.Rename(newName); txtName.Text = newName; PrimaryKeyWrapper key = SelectedKey; int index = cmbPk.SelectedIndex; cmbPk.Items.Remove(key); cmbPk.Items.Insert(index, key); cmbPk.SelectedIndex = index; } catch (Exception ex) { if (ex.GetType() != typeof(CancelledByUserException)) { Utils.ShowException(ex); } } }