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 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); } }
public bool CanModifySelectedObjects( ) { bool result = false; if (tv.SelectedNodes.Count == 0) { return(result); } foreach (TreeNode node in tv.SelectedNodes) { ObjectGroupingItemData data = ObjectGroupingItemDataFactory.GetNodeData(node); if (data == null) { continue; } if (DBConstants.DoesObjectTypeHasScript(data.Type ?? -1)) { result = true; break; } } return(result); }
private void RenderContextMenu() { mnuItemOpen.Visible = false; mnuItemModify.Visible = false; mnuItemDiff.Visible = false; if (_bs.Current == null) { return; } DataRowView rw = _bs.Current as DataRowView; int objId = (int)rw.Row.ItemArray[0]; string objName = (string)rw.Row.ItemArray[2]; string objType = (string)rw.Row.ItemArray[3]; if (!mnuItemOpen.Visible && DBConstants.DoesObjectTypeHoldsData(objType)) { mnuItemOpen.Visible = true; } if (!mnuItemModify.Visible && DBConstants.DoesObjectTypeHasScript(objType)) { mnuItemModify.Visible = true; mnuItemDiff.Visible = true; } }
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); } }
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 RenderContextMenuEx() { mnuItemOpen.Visible = false; mnuItemModify.Visible = false; mnuItemDiff.Visible = false; if (grd.SelectedRows.Count == 0) { return; } int objId = -1; string objType = String.Empty; string objName = String.Empty; 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 (!mnuItemOpen.Visible && DBConstants.DoesObjectTypeHoldsData(objType)) { mnuItemOpen.Visible = true; } if (!mnuItemModify.Visible && DBConstants.DoesObjectTypeHasScript(objType)) { mnuItemModify.Visible = true; mnuItemDiff.Visible = true; } } }
private void OnAction_ModifySelectedObject_Execute(object sender, EventArgs e) { ObjectInfo objInfo = GetObjectInfoForWordAtCursor(); if ((objInfo == null) || (!DBConstants.DoesObjectTypeHasScript(objInfo.ObjectTypeAbb))) { MessageBox.Show("Object is not a procedure or function!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } OpenObjectScripInNewEditor(objInfo); }
private void OnAction_ShowObjectChangeHist_Execute(object sender, EventArgs e) { ObjectInfo objInfo = GetObjectInfoForWordAtCursor(); if ((objInfo == null) || (!DBConstants.DoesObjectTypeHasScript(objInfo.ObjectTypeAbb))) { MessageBox.Show("Object does not have script!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } ShowObjectChangeHistory(objInfo); }
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(); } }
public void ModifySelectedObjects( ) { string error = String.Empty; IList <frmScriptEditor> editors = new List <frmScriptEditor>(); foreach (TreeNode node in tv.SelectedNodes) { ObjectGroupingItemData data = ObjectGroupingItemDataFactory.GetNodeData(node); if (data == null) { continue; } ObjectInfo objInfo = ProgrammabilityHelper.GetObjectInfo(_connParams, String.Empty, data.Name); if (objInfo == null) { error += " - " + data.Name + "\r\n"; continue; } if (!DBConstants.DoesObjectTypeHasScript(data.Type ?? -1)) { continue; } string script = ScriptingHelper.GetAlterScript(_connParams, _connParams.Database, objInfo.ObjectID, objInfo.ObjectType); frmScriptEditor editor = ScriptEditorFactory.Create(objInfo.ObjectName, script, objInfo.ObjectID, objInfo.ObjectType, _connParams, cmbDatabases.Text); editors.Add(editor); } foreach (frmScriptEditor editor in editors) { ScriptEditorFactory.ShowScriptEditor(editor); } if (!String.IsNullOrEmpty(error)) { MessageService.ShowError("Objects listed below do not exist in the database!\r\n" + error); } }
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; } } }