private void PerformActionOnCurrentRow() { if (_bs.Current == null) { return; } DataRowView rw = _bs.Current as DataRowView; if (rw == null) return; int objId = (int)rw.Row.ItemArray[0]; string objType = (string)rw.Row.ItemArray[3]; string objName = (string)rw.Row.ItemArray[2]; if (DBConstants.DoesObjectTypeHasScript(objType)) { int type = DBConstants.GetDBObjectType(objType); string script = ScriptingHelper.GetAlterScript(_connParams, _connParams.Database, objId, type); frmScriptEditor editor = ScriptEditorFactory.Create(objName, script, objId, type, _connParams, _connParams.Database); ScriptEditorFactory.ShowScriptEditor(editor); } else if (DBConstants.DoesObjectTypeHoldsData(objType)) { int type = DBConstants.GetDBObjectType(objType); string caption = objName + "{" + _connParams.InfoDbServer + "}"; string script = " select * from [" + objName + "]"; bool isReadOnly = (type == DBObjectType.View) ? true : false; frmDataViewer viewer = DataViewerFactory.CreateDataViewer(_connParams, _connParams.Database, objName, caption, script, isReadOnly, true); DataViewerFactory.ShowDataViewer(viewer); } }
private void OpenCurrentObject() { if (_bs.Current == null) { return; } DataRowView rw = _bs.Current as DataRowView; if (rw == null) return; int objId = (int)rw.Row.ItemArray[0]; string objOwner = (string)rw.Row.ItemArray[1]; string objName = (string)rw.Row.ItemArray[2]; string objType = (string)rw.Row.ItemArray[3]; string objQuotedFullName = (string)rw.Row.ItemArray[4]; string objFullName = (string)rw.Row.ItemArray[5]; if (DBConstants.DoesObjectTypeHoldsData(objType)) { int type = DBConstants.GetDBObjectType(objType); string caption = objFullName + " [" + _connParams.InfoDbServer + "]"; string script = " select * from " + objQuotedFullName; bool isReadOnly = (type == DBObjectType.View) ? true : false; frmDataViewer viewer = DataViewerFactory.CreateDataViewer(_connParams, _connParams.Database, objName, caption, script, isReadOnly, false); viewer.LoadData(true); DataViewerFactory.ShowDataViewer(viewer); } }
private void GetObjectInfo( ) { string script = ResManager.GetDBScript("Script_GetObjectInfoByName"); script = String.Format(script, _wordAtCursor); SqlCommand cmd = new SqlCommand(script, _conn); cmd.CommandTimeout = 0; SqlDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { _objectInfo = new ObjectInfo(); _objectInfo.ObjectID = (int)reader["id"]; _objectInfo.ObjectName = (string)reader["name"]; _objectInfo.ObjectTypeAbb = (string)reader["xtype"]; _objectInfo.ObjectType = DBConstants.GetDBObjectType((reader["xtype"] as string)); } } finally { reader.Close(); } }
private void ModifyCurrentObject() { if (_bs.Current == null) { return; } DataRowView rw = _bs.Current as DataRowView; if (rw == null) return; int objId = (int)rw.Row.ItemArray[0]; string objName = (string)rw.Row.ItemArray[2]; string objType = (string)rw.Row.ItemArray[3]; if (DBConstants.DoesObjectTypeHasScript(objType)) { int type = DBConstants.GetDBObjectType(objType); string script = ScriptingHelper.GetAlterScript(_connParams.ConnectionString, _connParams.Database, objId, type); frmScriptEditor editor = ScriptEditorFactory.Create(objName, script, objId, type, _connParams, _connParams.Database); ScriptEditorFactory.ShowScriptEditor(editor); } }
private void PerformActionOnFirstSelectedRow( ) { if (grd.SelectedRows.Count == 0) { return; } int objId = -1; string objType = String.Empty; string objName = String.Empty; DataGridViewRow row = grd.SelectedRows[0]; DataGridViewCell cellName = row.Cells[0]; DataGridViewCell cellType = row.Cells[1]; DataGridViewCell cellObjid = row.Cells[2]; if (cellName.ValueType != typeof(string) || cellName.Value == null) { return; } if (cellType.ValueType != typeof(string) || cellType.Value == null) { return; } if (cellObjid.ValueType != typeof(int) || cellObjid.Value == null) { return; } objId = (int)cellObjid.Value; objType = (string)cellType.Value; objName = (string)cellName.Value; if (DBConstants.DoesObjectTypeHasScript(objType)) { int type = DBConstants.GetDBObjectType(objType); string script = String.Empty; using (SqlConnection conn = _connParams.CreateSqlConnection(true, false)) { script = ScriptingHelper.GetAlterScript(conn, objId, type); } frmScriptEditor editor = ScriptEditorFactory.Create(objName, script, objId, type, _connParams, _dbName); ScriptEditorFactory.ShowScriptEditor(editor); } else if (DBConstants.DoesObjectTypeHoldsData(objType)) { int type = DBConstants.GetDBObjectType(objType); string caption = objName + "{" + _dbName + " on " + _connParams.Server + "}"; string script = " select * from [" + objName + "]"; bool isReadOnly = (type == DBObjectType.View) ? true : false; frmDataViewer viewer = DataViewerFactory.CreateDataViewer(_connParams, _dbName, objName, caption, script, isReadOnly, true); DataViewerFactory.ShowDataViewer(viewer); } }
public IList<ObjectInfo> GetSelectedObjects() { ObjectInfo objInfo = null; IList<ObjectInfo> result = new List<ObjectInfo>(); if (grd.SelectedRows.Count == 0) { return result; } int objId = -1; string objType = String.Empty; string objName = String.Empty; string objOwner = String.Empty; IList<frmDataViewer> viewers = new List<frmDataViewer>(); foreach (DataGridViewRow row in grd.SelectedRows) { DataGridViewCell cellObjid = row.Cells[0]; DataGridViewCell cellObjOwner = row.Cells[1]; DataGridViewCell cellName = row.Cells[2]; DataGridViewCell cellType = row.Cells[3]; if (cellName.ValueType != typeof(string) || cellName.Value == null) { continue; } if (cellObjOwner.ValueType != typeof(string) || cellObjOwner.Value == null) { continue; } if (cellType.ValueType != typeof(string) || cellType.Value == null) { continue; } if (cellObjid.ValueType != typeof(int) || cellObjid.Value == null) { continue; } objId = (int)cellObjid.Value; objType = (string)cellType.Value; objName = (string)cellName.Value; objOwner = (string)cellObjOwner.Value; objInfo = new ObjectInfo(); objInfo.ObjectID = objId; objInfo.ObjectName = objName; objInfo.ObjectTypeAbb = objType; objInfo.ObjectType = DBConstants.GetDBObjectType(objInfo.ObjectTypeAbb); objInfo.ObjectOwner = objOwner; result.Add(objInfo); } return result; }
private void OpenSelectedObjectsEx() { if (grd.SelectedRows.Count == 0) { return; } int objId = -1; string objType = String.Empty; string objName = String.Empty; IList<frmDataViewer> viewers = new List<frmDataViewer>(); foreach (DataGridViewRow row in grd.SelectedRows) { DataGridViewCell cellObjid = row.Cells[0]; DataGridViewCell cellName = row.Cells[2]; DataGridViewCell cellType = row.Cells[3]; if (cellName.ValueType != typeof(string) || cellName.Value == null) { continue; } if (cellType.ValueType != typeof(string) || cellType.Value == null) { continue; } if (cellObjid.ValueType != typeof(int) || cellObjid.Value == null) { continue; } objId = (int)cellObjid.Value; objType = (string)cellType.Value; objName = (string)cellName.Value; if (DBConstants.DoesObjectTypeHoldsData(objType)) { int type = DBConstants.GetDBObjectType(objType); string caption = objName + "{" + _connParams.InfoDbServer + "}"; string script = " select * from [" + objName + "]"; bool isReadOnly = (type == DBObjectType.View) ? true : false; frmDataViewer viewer = DataViewerFactory.CreateDataViewer(_connParams, _connParams.Database, objName, caption, script, isReadOnly, false); viewers.Add(viewer); } } foreach (frmDataViewer viewer in viewers) { viewer.LoadData(true); DataViewerFactory.ShowDataViewer(viewer); } }
private void ModifySelectedObjects( ) { if (grd.SelectedRows.Count == 0) { return; } int objId = -1; string objType = String.Empty; string objName = String.Empty; IList <frmScriptEditor> editors = new List <frmScriptEditor>(); foreach (DataGridViewRow row in grd.SelectedRows) { DataGridViewCell cellName = row.Cells[0]; DataGridViewCell cellType = row.Cells[1]; DataGridViewCell cellObjid = row.Cells[2]; if (cellName.ValueType != typeof(string) || cellName.Value == null) { continue; } if (cellType.ValueType != typeof(string) || cellType.Value == null) { continue; } if (cellObjid.ValueType != typeof(int) || cellObjid.Value == null) { continue; } objId = (int)cellObjid.Value; objType = (string)cellType.Value; objName = (string)cellName.Value; if (DBConstants.DoesObjectTypeHasScript(objType)) { int type = DBConstants.GetDBObjectType(objType); string script = String.Empty; using (SqlConnection conn = _connParams.CreateSqlConnection(true, false)) { script = ScriptingHelper.GetAlterScript(conn, objId, type); } frmScriptEditor editor = ScriptEditorFactory.Create(objName, script, objId, type, _connParams, _dbName); editors.Add(editor); } } foreach (frmScriptEditor editor in editors) { ScriptEditorFactory.ShowScriptEditor(editor); } }
private void SendCurrentObjectToTextDiff(bool isSource) { if (_bs.Current == null) { return; } DataRowView rw = _bs.Current as DataRowView; if (rw == null) return; int objId = (int)rw.Row.ItemArray[0]; string objType = (string)rw.Row.ItemArray[3]; string objName = (string)rw.Row.ItemArray[2]; if (DBConstants.DoesObjectTypeHasScript(objType)) { int type = DBConstants.GetDBObjectType(objType); string script = ScriptingHelper.GetAlterScript(_connParams, _connParams.Database, objId, type); frmTextDiff diffForm = frmTextDiff.ActiveTextDiff; if (diffForm == null) { diffForm = TextDiffFactory.CreateDiff(); } if (isSource) { diffForm.diffControl.SourceText = script; diffForm.diffControl.SourceHeaderText = objName; } else { diffForm.diffControl.DestText = script; diffForm.diffControl.DestHeaderText = objName; } diffForm.Show(); diffForm.BringToFront(); } }
private void SendSelectedObjectToTextDiffEx(bool isSource) { if (grd.SelectedRows.Count == 0) { return; } int objId = -1; string objType = String.Empty; string objName = String.Empty; IList<frmScriptEditor> editors = new List<frmScriptEditor>(); foreach (DataGridViewRow row in grd.SelectedRows) { DataGridViewCell cellObjid = row.Cells[0]; DataGridViewCell cellName = row.Cells[2]; DataGridViewCell cellType = row.Cells[3]; if (cellName.ValueType != typeof(string) || cellName.Value == null) { continue; } if (cellType.ValueType != typeof(string) || cellType.Value == null) { continue; } if (cellObjid.ValueType != typeof(int) || cellObjid.Value == null) { continue; } objId = (int)cellObjid.Value; objType = (string)cellType.Value; objName = (string)cellName.Value; if (DBConstants.DoesObjectTypeHasScript(objType)) { int type = DBConstants.GetDBObjectType(objType); string script = ScriptingHelper.GetAlterScript(_connParams, _connParams.Database, objId, type); frmTextDiff diffForm = frmTextDiff.ActiveTextDiff; if (diffForm == null) { diffForm = TextDiffFactory.CreateDiff(); } if (isSource) { diffForm.diffControl.SourceText = script; diffForm.diffControl.SourceHeaderText = objName; } else { diffForm.diffControl.DestText = script; diffForm.diffControl.DestHeaderText = objName; } diffForm.Show(); diffForm.BringToFront(); break; } } }