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 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 OnShowObjectGroupingStatistics(object sender, EventArgs e) { #if PERSONAL_EDITION throw new PersonalEditionLimitation(); #endif FireBeforeContextMenuActionExecuted(sender, ObjectExplorerAction.ShowObjectGroupingStatistics); NodeData data = GetCurrentSelectedNodeData(); if (data == null) { return; } ObjectGroupingService svc = new ObjectGroupingService(); svc.ConnParams = data.ConnParams.CreateCopy(); svc.ConnParams.Database = data.DBName; svc.ConnParams.Server = data.ServerName; if (!svc.IsObjectGroupingSupportInstalled()) { MessageBox.Show("Object grouping not installed to this database!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string caption = "Obj. Grp. Stat. for " + data.Name + " {" + data.DBName + " on " + data.ServerName + "}"; string script = String.Format(PragmaSQL.Core.ResManager.GetDBScript("Script_ObjectGroupingSupportGroupStats"), data.Name); frmDataViewer editor = DataViewerFactory.CreateDataViewer(data, caption, script, true, true); editor.Icon = global::PragmaSQL.Properties.Resources.library_icon; DataViewerFactory.ShowDataViewer(editor); FireAfterContextMenuActionExecuted(sender, ObjectExplorerAction.ShowObjectGroupingStatistics); }
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); } }
public static frmDataViewer CreateDataViewer(NodeData data, string caption, string script, bool isReadonly, bool autoLoad) { if (data == null) { throw new NullParameterException("NodeData paremeter is null!"); } frmDataViewer result = CreateDataViewer(data.ConnParams, data.DBName, data.Name, caption, script, isReadonly, autoLoad); return(result); }
public static void Remember(string id, frmDataViewer editor) { if (String.IsNullOrEmpty(id) || editor == null) { return; } if (_editors.ContainsKey(id)) { _editors[id] = editor; } else { _editors.Add(id, editor); } }
public static void ShowDataViewer(frmDataViewer frm) { if (frm == null) { return; } if (Program.MainForm.DockPanel.DocumentStyle == DocumentStyle.SystemMdi) { frm.MdiParent = Program.MainForm; frm.Show(); frm.WindowState = System.Windows.Forms.FormWindowState.Maximized; } else { frm.Show(Program.MainForm.DockPanel); } }
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); } }
public static frmDataViewer CreateDataViewer(ConnectionParams connParams, string dbName, string tableName, string caption, string script, bool isReadonly, bool autoLoad) { if (connParams == null) { throw new NullParameterException("connParams paremeter is null!"); } ConnectionParams cp = connParams.CreateCopy(); cp.Database = dbName; string windowId = TableDataEditorManager.ProduceWindowId(tableName, cp.Server, dbName); if (TableDataEditorManager.Contains(windowId)) { return(TableDataEditorManager.Get(windowId)); } frmDataViewer result = new frmDataViewer(); result.TableName = tableName; result.InitializeDataViewer(windowId, caption, script, isReadonly, cp); if (autoLoad) { try { result.LoadData(true); } catch (Exception ex) { MessageBox.Show("Can not load data!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); result.Close(); result.Dispose(); result = null; } } return(result); }
private void OnOpenViewDataEditorClick(object sender, EventArgs e) { FireBeforeContextMenuActionExecuted(sender, ObjectExplorerAction.ViewDataEditor); NodeData data = GetCurrentSelectedNodeData(); if (data == null) { return; } if (data.Type != DBObjectType.View) { return; } string caption = data.QualifiedFullName + " [ " + data.DBName + " on " + data.ServerName + " ]"; string script = "select * from " + data.QualifiedFullName; frmDataViewer editor = DataViewerFactory.CreateDataViewer(data, caption, script, true, true); editor.Icon = global::PragmaSQL.Properties.Resources.Preview; DataViewerFactory.ShowDataViewer(editor); FireAfterContextMenuActionExecuted(sender, ObjectExplorerAction.ViewDataEditor); }