Пример #1
0
        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);
                }
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        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);
        }