示例#1
0
        public override void Open()
        {
            var pars = new OpenQueryParameters();

            pars.File = new DiskFile(QueryFile);
            //pars.SavedContext = Context;
            var frm = new QueryFrame(null, pars);

            MainWindow.Instance.OpenContent(frm);
        }
示例#2
0
        public void DesignQuery()
        {
            OpenQueryParameters pars = new OpenQueryParameters();

            pars.GoToDesign     = true;
            pars.AddDesignTable = new FullDatabaseRelatedName {
                ObjectName = TableSource.FullName, ObjectType = "table"
            };
            MainWindow.Instance.OpenContent(new QueryFrame(TableSource.Database.CloneConnection(), pars));
        }
示例#3
0
        public override void Open()
        {
            var pars = new OpenQueryParameters();

            pars.SavedContext = Context;
            pars.GoToDesign   = true;
            pars.SavedDesign  = Design;
            var frm = new QueryFrame(null, pars);

            MainWindow.Instance.OpenContent(frm);
        }
示例#4
0
        public override void OpenAction()
        {
            if (QueryFrame.FindOpenedFile(m_file.DataDiskPath))
            {
                return;
            }
            OpenQueryParameters pars = new OpenQueryParameters();
            IPhysicalConnection conn = MainWindowExtension.SelectedConnection;

            if (conn != null)
            {
                conn = conn.Clone();
            }
            pars.File = m_file;
            MainWindow.Instance.OpenContent(new QueryFrame(conn, pars));
        }
示例#5
0
        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);
            }
        }
示例#7
0
        public void EditScript()
        {
            if (QueryFrame.FindOpenedFile(m_file.DataDiskPath))
            {
                return;
            }
            IPhysicalConnection conn = MainWindowExtension.SelectedConnection;

            if (conn != null)
            {
                conn = conn.Clone();
            }
            OpenQueryParameters pars = new OpenQueryParameters();
            string dbname            = MainWindowExtension.SelectedDatabaseName;

            pars.File           = m_file;
            pars.DisableContext = m_conn != null;
            if (dbname != null && conn != null)
            {
                conn.AfterOpen += ConnTools.ChangeDatabaseCallback(dbname);
            }
            MainWindow.Instance.OpenContent(new QueryFrame(conn, pars));
        }