private void dgvIndexes_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == this.colColumns.Index) { DataGridViewRow row = this.dgvIndexes.Rows[e.RowIndex]; DataGridViewCell cell = row.Cells[this.colColumns.Name]; if (cell.ReadOnly) { return; } string indexName = DataGridViewHelper.GetCellStringValue(row, this.colIndexName.Name); string type = DataGridViewHelper.GetCellStringValue(row, this.colType.Name); if (!string.IsNullOrEmpty(indexName)) { TableIndexDesignerInfo indexDesignerInfo = row.Tag as TableIndexDesignerInfo; if (this.OnColumnSelect != null) { this.OnColumnSelect(DatabaseObjectType.TableIndex, indexDesignerInfo?.Columns == null ? Enumerable.Empty <IndexColumn>() : indexDesignerInfo?.Columns, type == IndexType.Primary.ToString() ); } } } }
private void dgvIndexes_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == this.colType.Index) { this.ShowIndexExtraPropertites(); DataGridViewRow row = this.dgvIndexes.Rows[e.RowIndex]; DataGridViewCell nameCell = row.Cells[this.colIndexName.Name]; string type = DataGridViewHelper.GetCellStringValue(row, this.colType.Name); string indexName = DataGridViewHelper.GetCellStringValue(nameCell); if (string.IsNullOrEmpty(indexName)) { nameCell.Value = type == IndexType.Primary.ToString() ? IndexManager.GetPrimaryKeyDefaultName(this.Table) : IndexManager.GetIndexDefaultName(this.Table); } } }
public List <TableIndexDesignerInfo> GetIndexes() { List <TableIndexDesignerInfo> indexDesingerInfos = new List <TableIndexDesignerInfo>(); foreach (DataGridViewRow row in this.dgvIndexes.Rows) { TableIndexDesignerInfo index = new TableIndexDesignerInfo(); string indexName = row.Cells[this.colIndexName.Name].Value?.ToString(); if (!string.IsNullOrEmpty(indexName)) { TableIndexDesignerInfo tag = row.Tag as TableIndexDesignerInfo; index.OldName = tag?.OldName; index.OldType = tag?.OldType; index.Name = indexName; index.Type = DataGridViewHelper.GetCellStringValue(row, this.colType.Name); index.Columns = tag?.Columns; index.Comment = DataGridViewHelper.GetCellStringValue(row, this.colComment.Name); index.ExtraPropertyInfo = tag?.ExtraPropertyInfo; index.IsPrimary = tag?.IsPrimary == true; row.Tag = index; indexDesingerInfos.Add(index); } } return(indexDesingerInfos); }
public List <TableConstraintDesignerInfo> GetConstraints() { List <TableConstraintDesignerInfo> constraintDesingerInfos = new List <TableConstraintDesignerInfo>(); foreach (DataGridViewRow row in this.dgvConstraints.Rows) { TableConstraintDesignerInfo constraint = new TableConstraintDesignerInfo(); string constraintName = row.Cells[this.colName.Name].Value?.ToString(); if (!string.IsNullOrEmpty(constraintName)) { TableConstraintDesignerInfo tag = row.Tag as TableConstraintDesignerInfo; constraint.OldName = tag?.OldName; constraint.Name = constraintName; constraint.Definition = DataGridViewHelper.GetCellStringValue(row, this.colDefinition.Name); constraint.Comment = DataGridViewHelper.GetCellStringValue(row, this.colComment.Name); row.Tag = constraint; constraintDesingerInfos.Add(constraint); } } return(constraintDesingerInfos); }
private void dgvColumns_DragDrop(object sender, DragEventArgs e) { Point clientPoint = this.dgvColumns.PointToClient(new Point(e.X, e.Y)); rowIndexOfItemUnderMouseToDrop = this.dgvColumns.HitTest(clientPoint.X, clientPoint.Y).RowIndex; if (rowIndexOfItemUnderMouseToDrop == -1) { return; } if (rowIndexFromMouseDown >= 0 && rowIndexOfItemUnderMouseToDrop < this.dgvColumns.Rows.Count) { if (this.dgvColumns.Rows[rowIndexOfItemUnderMouseToDrop].IsNewRow) { return; } } if (e.Effect == DragDropEffects.Move) { DataGridViewRow rowToMove = e.Data.GetData(typeof(DataGridViewRow)) as DataGridViewRow; if (rowToMove.Index >= 0) { this.dgvColumns.Rows.RemoveAt(rowIndexFromMouseDown); this.dgvColumns.Rows.Insert(rowIndexOfItemUnderMouseToDrop, rowToMove); string columnName = DataGridViewHelper.GetCellStringValue(rowToMove, this.colColumnName.Name); DataGridViewHelper.SetRowColumnsReadOnly(this.dgvColumns, rowToMove, string.IsNullOrEmpty(columnName), this.colColumnName); this.SetColumnCellsReadonly(rowToMove); } } }
public List <TableForeignKeyDesignerInfo> GetForeignKeys() { List <TableForeignKeyDesignerInfo> keyDesingerInfos = new List <TableForeignKeyDesignerInfo>(); foreach (DataGridViewRow row in this.dgvForeignKeys.Rows) { TableForeignKeyDesignerInfo key = new TableForeignKeyDesignerInfo(); string keyName = row.Cells[this.colKeyName.Name].Value?.ToString(); if (!string.IsNullOrEmpty(keyName)) { TableForeignKeyDesignerInfo tag = row.Tag as TableForeignKeyDesignerInfo; key.OldName = tag?.OldName; key.Name = keyName; key.Columns = tag?.Columns; key.ReferencedTableName = DataGridViewHelper.GetCellStringValue(row, this.colReferenceTable.Name); key.UpdateCascade = DataGridViewHelper.GetCellBoolValue(row, this.colUpdateCascade.Name); key.DeleteCascade = DataGridViewHelper.GetCellBoolValue(row, this.colDeleteCascade.Name); key.Comment = DataGridViewHelper.GetCellStringValue(row, this.colComment.Name); row.Tag = key; keyDesingerInfos.Add(key); } } return(keyDesingerInfos); }
private void SetColumnCellsReadonly(DataGridViewRow row) { DataGridViewCell lengthCell = row.Cells[this.colLength.Name]; DataGridViewCell primaryCell = row.Cells[this.colPrimary.Name]; DataGridViewCell identityCell = row.Cells[this.colIdentity.Name]; string dataType = DataGridViewHelper.GetCellStringValue(row, this.colDataType.Name); if (!string.IsNullOrEmpty(dataType)) { UserDefinedType userDefindedType = this.GetUserDefinedType(dataType); if (userDefindedType != null) { dataType = userDefindedType.Type; } DataTypeSpecification dataTypeSpec = this.dataTypeSpecifications.FirstOrDefault(item => item.Name == dataType); if (dataTypeSpec != null) { bool isLengthReadOnly = userDefindedType != null || string.IsNullOrEmpty(dataTypeSpec.Args); bool isPrimaryReadOnly = dataTypeSpec.IndexForbidden; bool isIdentityReadOnly = !dataTypeSpec.AllowIdentity; lengthCell.ReadOnly = isLengthReadOnly; primaryCell.ReadOnly = isPrimaryReadOnly; identityCell.ReadOnly = isIdentityReadOnly; if (isLengthReadOnly) { lengthCell.Value = null; } if (isPrimaryReadOnly) { primaryCell.Value = false; } if (isIdentityReadOnly) { identityCell.Value = false; } } } else { lengthCell.ReadOnly = true; primaryCell.ReadOnly = true; identityCell.ReadOnly = true; } }
private void dgvSettings_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e) { foreach (DataGridViewRow row in this.dgvSettings.Rows) { string dbType = DataGridViewHelper.GetCellStringValue(row, this.colDatabaseType.Name); if (dbType == DatabaseType.SqlServer.ToString()) { row.Cells[this.colClientToolFilePath.Name].ReadOnly = true; row.Cells[this.colZipBackupFile.Name].ReadOnly = true; } } }
public List <TableColumnDesingerInfo> GetColumns() { List <TableColumnDesingerInfo> columnDesingerInfos = new List <TableColumnDesingerInfo>(); int order = 1; foreach (DataGridViewRow row in this.dgvColumns.Rows) { TableColumnDesingerInfo col = new TableColumnDesingerInfo() { Order = order }; string colName = row.Cells[this.colColumnName.Name].Value?.ToString(); if (!string.IsNullOrEmpty(colName)) { TableColumnDesingerInfo tag = row.Tag as TableColumnDesingerInfo; string dataType = DataGridViewHelper.GetCellStringValue(row, this.colDataType.Name); col.OldName = tag?.OldName; col.Name = colName; col.DataType = dataType; col.Length = DataGridViewHelper.GetCellStringValue(row, this.colLength.Name); col.IsNullable = DataGridViewHelper.GetCellBoolValue(row, this.colNullable.Name); col.IsPrimary = DataGridViewHelper.GetCellBoolValue(row, this.colPrimary.Name); col.IsIdentity = DataGridViewHelper.GetCellBoolValue(row, this.colIdentity.Name); col.DefaultValue = DataGridViewHelper.GetCellStringValue(row, this.colDefaultValue.Name); col.Comment = DataGridViewHelper.GetCellStringValue(row, this.colComment.Name); col.ExtraPropertyInfo = tag?.ExtraPropertyInfo; UserDefinedType userDefinedType = this.GetUserDefinedType(dataType); if (userDefinedType != null) { col.IsUserDefined = true; col.TypeOwner = userDefinedType.Owner; } row.Tag = col; columnDesingerInfos.Add(col); order++; } } return(columnDesingerInfos); }
private void ShowIndexExtraPropertites() { var row = DataGridViewHelper.GetSelectedRow(this.dgvIndexes); if (row != null) { string indexName = DataGridViewHelper.GetCellStringValue(row, this.colIndexName.Name); if (string.IsNullOrEmpty(indexName)) { return; } TableIndexDesignerInfo index = row.Tag as TableIndexDesignerInfo; if (index == null) { index = new TableIndexDesignerInfo(); row.Tag = index; } TableIndexExtraPropertyInfo extralProperty = index?.ExtraPropertyInfo; DataGridViewCell typeCell = row.Cells[this.colType.Name]; if (extralProperty == null) { extralProperty = new TableIndexExtraPropertyInfo(); index.ExtraPropertyInfo = extralProperty; if (DataGridViewHelper.GetCellStringValue(typeCell) != IndexType.Primary.ToString()) { index.ExtraPropertyInfo.Clustered = false; } } if (this.DatabaseType == DatabaseType.Oracle) { this.indexPropertites.HiddenProperties = new string[] { nameof(extralProperty.Clustered) }; } else { this.indexPropertites.HiddenProperties = null; } this.indexPropertites.SelectedObject = extralProperty; this.indexPropertites.Refresh(); } }
private void dgvIndexes_CellClick(object sender, DataGridViewCellEventArgs e) { this.dtTypeCellClick = DateTime.Now; if (e.RowIndex < 0) { return; } if (this.lbIndexType.Visible) { Rectangle?rectangle = this.GetCurrentCellRectangle(); if (rectangle.HasValue && this.lbIndexType.Tag != null && (Rectangle)this.lbIndexType.Tag == rectangle.Value) { this.lbIndexType.Visible = false; return; } } this.lbIndexType.Visible = false; DataGridViewRow row = this.dgvIndexes.Rows[e.RowIndex]; bool isPrimary = (row.Tag as TableIndexDesignerInfo)?.IsPrimary == true; if (e.ColumnIndex == this.colType.Index) { DataGridViewCell cell = row.Cells[this.colType.Name]; if (isPrimary) { return; } string value = DataGridViewHelper.GetCellStringValue(row, this.colType.Name); if (value != IndexType.Primary.ToString()) { if (!string.IsNullOrEmpty(value)) { this.lbIndexType.SelectedItem = value; } this.SetListBoxPostition(); } } }
private List <BackupSetting> GetSettings() { List <BackupSetting> settings = new List <BackupSetting>(); foreach (DataGridViewRow row in this.dgvSettings.Rows) { BackupSetting setting = new BackupSetting(); setting.DatabaseType = DataGridViewHelper.GetCellStringValue(row, this.colDatabaseType.Name); setting.ClientToolFilePath = DataGridViewHelper.GetCellStringValue(row, this.colClientToolFilePath.Name); setting.SaveFolder = DataGridViewHelper.GetCellStringValue(row, this.colSaveFolder.Name); setting.ZipFile = DataGridViewHelper.GetCellBoolValue(row, this.colZipBackupFile.Name); settings.Add(setting); } return(settings); }
private void dgvForeignKeys_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } DataGridViewRow row = this.dgvForeignKeys.Rows[e.RowIndex]; if (e.ColumnIndex == this.colReferenceTable.Index) { string referencedTableName = DataGridViewHelper.GetCellStringValue(row, this.colReferenceTable.Name); string keyName = DataGridViewHelper.GetCellStringValue(row, this.colKeyName.Name); if (!string.IsNullOrEmpty(referencedTableName) && string.IsNullOrEmpty(keyName)) { row.Cells[this.colKeyName.Name].Value = IndexManager.GetForeignKeyDefaultName(this.Table.Name, referencedTableName); } } }
private void dgvForeignKeys_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == this.colColumns.Index) { DataGridViewRow row = this.dgvForeignKeys.Rows[e.RowIndex]; string keyName = DataGridViewHelper.GetCellStringValue(row, this.colKeyName.Name); string referenceTableName = DataGridViewHelper.GetCellStringValue(row, this.colReferenceTable.Name); if (!string.IsNullOrEmpty(keyName) && !string.IsNullOrEmpty(referenceTableName)) { if (this.OnColumnMappingSelect != null) { this.OnColumnMappingSelect(referenceTableName, (row.Tag as TableForeignKeyDesignerInfo)?.Columns); } } } }
private void dgvIndexes_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { DataGridViewRow row = DataGridViewHelper.GetSelectedRow(this.dgvIndexes); if (row != null) { bool isEmptyNewRow = row.IsNewRow && DataGridViewHelper.IsEmptyRow(row); string type = DataGridViewHelper.GetCellStringValue(row, this.colType.Name); bool?isPrimary = (row.Tag as TableIndexDesignerInfo)?.IsPrimary; this.tsmiDeleteIndex.Enabled = !isEmptyNewRow && !(isPrimary == true) && !(!string.IsNullOrEmpty(type) && type == IndexType.Primary.ToString()); } else { this.tsmiDeleteIndex.Enabled = false; } this.contextMenuStrip1.Show(this.dgvIndexes, e.Location); } }
private void dgvSettings_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0) { return; } DataGridViewCell cell = this.dgvSettings.Rows[e.RowIndex].Cells[e.ColumnIndex]; if (cell.ReadOnly) { return; } string value = DataGridViewHelper.GetCellStringValue(cell); if (e.ColumnIndex == this.colClientToolFilePath.Index) { if (this.openFileDialog1 == null) { this.openFileDialog1 = new OpenFileDialog(); } if (!string.IsNullOrEmpty(value) && File.Exists(value)) { this.openFileDialog1.FileName = value; } else { this.openFileDialog1.FileName = ""; } DialogResult result = this.openFileDialog1.ShowDialog(); if (result == DialogResult.OK) { this.SetCellValue(cell, this.openFileDialog1.FileName); } } else if (e.ColumnIndex == this.colSaveFolder.Index) { if (this.folderBrowserDialog1 == null) { this.folderBrowserDialog1 = new FolderBrowserDialog(); } if (!string.IsNullOrEmpty(value) && File.Exists(value)) { this.folderBrowserDialog1.SelectedPath = value; } else { this.folderBrowserDialog1.SelectedPath = ""; } DialogResult result = this.folderBrowserDialog1.ShowDialog(); if (result == DialogResult.OK) { this.SetCellValue(cell, this.folderBrowserDialog1.SelectedPath); } } }