public void CreateNewObject() { if (m_conn.DatabaseCaps.ExecuteSql) { OpenQueryParameters pars = new OpenQueryParameters(); IPhysicalConnection newconn = GetConnection().Clone(); string dbname = TreeNodeExtension.GetDatabaseName(this); if (dbname != null) { newconn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname); } pars.GenerateSql = delegate(IPhysicalConnection conn) { return(m_dbtype.GenerateCreateNew(conn.SystemConnection, TreeNodeExtension.GetAnyObjectPath(this))); }; pars.HideDesign = true; pars.ExecutedCallback = this.CompleteRefresh; MainWindow.Instance.OpenContent(new QueryFrame(newconn, pars)); } else { string sql = m_dbtype.GenerateCreateNew(m_conn.Connection.SystemConnection, TreeNodeExtension.GetAnyObjectPath(this)); var pars = new ObjectEditorPars { SavedCallback = this.CompleteRefresh }; var frm = new SpecificObjectFrame(m_conn, m_repr.ObjectType, sql, pars); MainWindow.Instance.OpenContent(frm); } }
public override void CreateNew(AppObject appobj, ConnectionPack connpack) { var tp = _Type; if (tp.ObjectType == "table") { var pars = new AlterTableEditorPars { SavedCallback = RefreshList }; MainWindow.Instance.OpenContent(new TableEditFrame(appobj.CreateDatabaseConnection(), null, pars)); } else { var dbconn = appobj.FindDatabaseConnection(connpack); var dbtype = dbconn.Dialect.GetSpecificObjectType(tp.ObjectType); if (dbconn.DatabaseCaps.ExecuteSql) { OpenQueryParameters pars = new OpenQueryParameters(); IPhysicalConnection newconn = dbconn.Connection.Clone(); string dbname = appobj.FindDatabaseName(); if (dbname != null) { newconn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname); } pars.GenerateSql = delegate(IPhysicalConnection conn) { return(dbtype.GenerateCreateNew(conn.SystemConnection, appobj.GetObjectPath())); }; pars.HideDesign = true; pars.ExecutedCallback = RefreshList; MainWindow.Instance.OpenContent(new QueryFrame(newconn, pars)); } else { string sql = dbtype.GenerateCreateNew(dbconn.Connection.SystemConnection, appobj.GetObjectPath()); var pars = new ObjectEditorPars { SavedCallback = RefreshList }; var frm = new SpecificObjectFrame(dbconn, tp.ObjectType, sql, pars); MainWindow.Instance.OpenContent(frm); } } }
public void Edit() { if (!EditEnabled()) { return; } var dbconn = this.FindDatabaseConnection(ConnPack); if (dbconn.DatabaseCaps.ExecuteSql) { OpenQueryParameters pars = new OpenQueryParameters(); IPhysicalConnection newconn = Connection.CreateConnection(); string dbname = DatabaseName; if (dbname != null) { newconn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname); } pars.GenerateSql = delegate(IPhysicalConnection conn) { var props = new SqlFormatProperties { OmitVersionTests = true }; var dbs = conn.PhysicalFactory.CreateDatabaseSource(conn, dbname); var so = new SpecificObjectStructure(dbs.LoadSpecificObjectDetail(DbObjectType, DbObjectName)); if (dbconn.Dialect != null) { so.CreateSql = dbconn.Dialect.ReformatSpecificObject(so.ObjectType, so.CreateSql); } string drop = newconn.Dialect.GenerateScript(dmp => { dmp.DropSpecificObject(so); }, props); string create = newconn.Dialect.GenerateScript(dmp => { dmp.CreateSpecificObject(so); }, props); return(drop + "\n\nGO\n\n" + create); }; MainWindow.Instance.OpenContent(new QueryFrame(newconn, pars)); } else { var frm = new SpecificObjectFrame(dbconn.CloneSource(), LoadStructure(), new ObjectEditorPars { }); MainWindow.Instance.OpenContent(frm); } }