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 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 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); } }
public bool CanOpenSelectedObjects( ) { 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.DoesObjectTypeHoldsData(data.Type ?? -1)) { result = true; break; } } return(result); }
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 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 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_OpenSelectedObject_Execute(object sender, EventArgs e) { ObjectInfo objInfo = GetObjectInfoForWordAtCursor(); if ((objInfo == null) || (!DBConstants.DoesObjectTypeHoldsData(objInfo.ObjectTypeAbb))) { MessageBox.Show("Object is not a view or table!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } LoadTableOrViewData(objInfo); }
private void OnAction_SelectTop100Rows(object sender, EventArgs e) { ObjectInfo objInfo = GetObjectInfoForWordAtCursor(); if ((objInfo == null) || (!DBConstants.DoesObjectTypeHoldsData(objInfo.ObjectTypeAbb))) { MessageBox.Show("Object is not a table or view!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var script = $"SELECT TOP 100 * FROM {objInfo.FullNameQuoted}"; ExecScript(script, ScriptRunType.Execute, 0, false, false); }
public void OpenSelectedObjects( ) { string error = String.Empty; IList <frmDataViewer> viewers = new List <frmDataViewer>(); 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.DoesObjectTypeHoldsData(data.Type ?? -1)) { continue; } string caption = data.Name + "{" + cmbDatabases.Text + " on " + cmbServers.Text + "}"; string script = " select * from [" + data.Name + "]"; bool isReadOnly = (data.Type == DBObjectType.View) ? true : false; frmDataViewer viewer = DataViewerFactory.CreateDataViewer(_connParams, cmbDatabases.Text, data.Name, caption, script, isReadOnly, false); viewers.Add(viewer); } foreach (frmDataViewer viewer in viewers) { viewer.LoadData(true); DataViewerFactory.ShowDataViewer(viewer); } if (!String.IsNullOrEmpty(error)) { MessageService.ShowError("Objects listed below do not exist in the database!\r\n" + error); } }