public void AlterDatabase() { var dbconn = this.FindDatabaseConnection(ConnPack); if (!AlterDatabaseVisible() || dbconn == null) { return; } var dbmem = new DatabaseStructureMembers(); dbmem.DatabaseOptions = true; var m_db = dbconn.InvokeLoadStructure(dbmem, null); var props = new DatabaseProperties { Name = dbconn.DatabaseName, SpecificData = m_db.SpecificData, }; if (DatabasePropertiesForm.Run(props, dbconn, true)) { var plan = new AlterPlan(); var opts = new DbDiffOptions(); plan.ChangeDatabaseOptions(dbconn.DatabaseName, props.SpecificData); plan.Transform(dbconn.Dialect.DumperCaps, opts, dbconn); string alterSql = dbconn.Dialect.GenerateScript(dmp => plan.CreateRunner().Run(dmp, opts)); if (SqlConfirmForm.Run(alterSql)) { dbconn.AlterDatabase(plan, opts); } } }
public static bool Run(string sql, ISqlDialect dialect, ILogMessageSource warnings, string settingsKey) { SqlConfirmForm win = new SqlConfirmForm(settingsKey); win.codeEditor1.SetCodeText(sql, false); win.codeEditor1.Dialect = dialect; win.messageLogFrame1.Source = warnings; DialogResult res = win.ShowDialogEx(); win.Dispose(); return(res == DialogResult.OK); }
public override bool Save() { if (m_obj == null) { return(SaveAs()); } else { try { ISpecificObjectStructure newStructure = CreateStructure(m_obj.ObjectName); if (m_conn.DatabaseCaps.ExecuteSql) { string sql = Dialect.GenerateScript(dmp => { dmp.DropSpecificObject(m_obj); dmp.CreateSpecificObject(newStructure); }); if (!SqlConfirmForm.Run(sql, Dialect)) { return(false); } } m_conn.AlterObject(m_obj, newStructure); if (m_pars != null && m_pars.SavedCallback != null) { m_pars.SavedCallback(); } m_obj = m_conn.InvokeLoadSpecificObjectDetail(m_obj.ObjectType, m_obj.ObjectName); FillFromStructure(); return(true); } catch (Exception e) { Errors.Report(e); return(false); } } }
public override bool SaveAs() { string name = InputBox.Run(Texts.Get("s_enter_object_name"), "new_table"); if (name != null) { try { ISpecificObjectStructure newStructure = CreateStructure(new NameWithSchema(name)); if (m_conn.DatabaseCaps.ExecuteSql) { string sql = Dialect.GenerateScript(dmp => { dmp.CreateSpecificObject(newStructure); }); if (!SqlConfirmForm.Run(sql, Dialect)) { return(false); } } m_conn.CreateObject(newStructure); if (m_pars != null && m_pars.SavedCallback != null) { m_pars.SavedCallback(); } m_obj = m_conn.InvokeLoadSpecificObjectDetail(newStructure.ObjectType, newStructure.ObjectName); FillFromStructure(); UpdateTitle(); return(true); } catch (Exception err) { Errors.Report(err); } } return(false); }