private void frmDataViewer_FormClosed(object sender, FormClosedEventArgs e) { TableDataEditorManager.Forget(_windowId); if (_conn != null) { if (_conn.State == ConnectionState.Open) { _conn.Close(); } _conn.Dispose(); } }
public void InitializeDataViewer(string windowId, string caption, string script, bool isReadonly, ConnectionParams connParams) { if (connParams == null) { throw new NullParameterException("Connection params object is null!"); } _windowId = windowId; TableDataEditorManager.Remember(windowId, this); _connParams = connParams.CreateCopy(); Caption = caption; Script = script; IsReadOnly = isReadonly; }
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); }