Beispiel #1
0
        public void RemoveTable(QueryDesignTableFrame table)
        {
            m_tables.Remove(table);
            table.Dispose();
            List <QueryDesignJoinControl> joins = new List <QueryDesignJoinControl>();

            joins.AddRange(from j in m_joins where j.LeftTable == table || j.RightTable == table select j);
            m_joins.RemoveAll(j => joins.Contains(j));
            var todel = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in dataGridColumns.Rows)
            {
                if (row.Tag == table)
                {
                    todel.Add(row);
                }
            }
            foreach (var row in todel)
            {
                dataGridColumns.Rows.Remove(row);
            }
            foreach (var j in joins)
            {
                j.Dispose();
            }
            ReloadAll();
        }
Beispiel #2
0
 public void AddColumn(QueryDesignTableFrame table, string col)
 {
     dataGridColumns.Rows.Add(col, "", table.GetNameTitle(), true, "-", "", "", "");
     dataGridColumns.Rows[dataGridColumns.Rows.Count - 1].Tag = table;
     FillSortColumns();
     ReloadAll();
 }
 public QueryDesignJoinControl(QueryDesignFrame frame, QueryDesignTableFrame tbl1, string col1, QueryDesignTableFrame tbl2, string col2)
 {
     Initialize();
     m_leftTable  = tbl1;
     m_leftCol    = col1;
     m_rightTable = tbl2;
     m_rightCol   = col2;
     m_frame      = frame;
 }
Beispiel #4
0
        //private DataGridViewRow FindColumn(NameWithSchema table, string col)
        //{
        //    foreach (DataGridViewRow row in dataGridColumns.Rows)
        //    {
        //        if (row.Cells[0].ToString() == col && row.Cells[2].ToString() == table.ToString())
        //        {
        //            return row;
        //        }
        //    }
        //    return null;
        //}

        public void RemoveColumn(QueryDesignTableFrame table, string col)
        {
            DataGridViewRow row = FindColumn(table, col);

            if (row != null)
            {
                dataGridColumns.Rows.Remove(row);
            }
            ReloadAll();
        }
Beispiel #5
0
        public void AddFilter(QueryDesignTableFrame table, string col)
        {
            string colname = table.AliasOrName + "." + col;
            var    cond    = new ExpressionConditionNode(m_condDesign, m_condDesign.Root);

            cond.LeftExprData = colname;
            m_condDesign.Root.Children.Add(cond);
            m_condDesign.UpdatePlacements();
            tabControl1.SelectedIndex = 1;
        }
Beispiel #6
0
 DataGridViewRow FindColumn(QueryDesignTableFrame table, string col)
 {
     foreach (DataGridViewRow row in dataGridColumns.Rows)
     {
         if (row.Tag == table && row.Cells[0].Value.ToString() == col)
         {
             return(row);
         }
     }
     return(null);
 }
Beispiel #7
0
        public void AddJoin(QueryDesignTableFrame tbl1, string col1, QueryDesignTableFrame tbl2, string col2, bool refresh)
        {
            QueryDesignJoinControl join = new QueryDesignJoinControl(this, tbl1, col1, tbl2, col2);

            m_joins.Add(join);
            panel1.Controls.Add(join);
            if (refresh)
            {
                Redraw();
                ReflectChanges();
            }
        }
Beispiel #8
0
        void PlaceTable(QueryDesignTableFrame table)
        {
            int vsplit = 30, hsplit = 30;
            int ymax;

            try
            {
                ymax = (from t in m_tables select t.Bottom).Max();
            }
            catch
            {
                ymax = 0;
            }
            int y1;

            try
            {
                y1 = (from t in m_tables where t.Bottom == ymax select t.Top).Max();
            }
            catch
            {
                y1 = vsplit;
            }
            Interval yint    = new Interval(y1, y1 + table.Size.Height);
            int      hspace  = hsplit;
            int      newleft = hspace;
            int      maxwi   = panel1.Width;

            foreach (var t in m_tables)
            {
                if (!Interval.Intersection(new Interval(t.Top, t.Bottom), yint).IsEmpty)
                {
                    newleft = Math.Max(newleft, t.Right + hspace);
                }
            }
            if (newleft + table.Size.Width > maxwi)
            {
                table.Left = hspace;
                table.Top  = ymax + vsplit;
            }
            else
            {
                table.Left = newleft;
                table.Top  = y1;
            }
        }
Beispiel #9
0
        public new void Load(XmlElement xml)
        {
            m_loading = true;
            this.LoadPropertiesCore(xml);
            foreach (XmlElement xtbl in xml.SelectNodes("Table"))
            {
                var tbl = new QueryDesignTableFrame(xtbl, this);
                m_tables.Add(tbl);
                panel1.Controls.Add(tbl);
            }
            foreach (XmlElement xjoin in xml.SelectNodes("Join"))
            {
                var join = new QueryDesignJoinControl(xjoin, this);
                m_joins.Add(join);
                panel1.Controls.Add(join);
            }
            foreach (XmlElement xcol in xml.SelectNodes("Column"))
            {
                int newrow = dataGridColumns.Rows.Add();
                var col    = new DesignedColumn(this, dataGridColumns.Rows[newrow], xcol);
                col.Table.m_table.CheckColumn(col.ColumnName);
            }
            foreach (XmlElement xord in xml.SelectNodes("OrderBy"))
            {
                var ord = new DesignedOrder(xord, this);
                lbxSortedColumns.Items.Add(ord);
            }
            var cx = xml.FindElement("Filter");

            if (cx != null)
            {
                m_condDesign.LoadFromXml(cx);
            }
            m_loading = false;
            ReloadAll();
            Redraw();
        }
Beispiel #10
0
 public QueryDesignColumnPopupMenu(QueryDesignTableFrame frame, int colindex)
 {
     m_frame    = frame;
     m_colindex = colindex;
 }
Beispiel #11
0
 public ColWrapper(QueryDesignFrame frame, QueryDesignTableFrame table, string colname)
 {
     m_frame   = frame;
     m_colname = colname;
     m_table   = table;
 }
Beispiel #12
0
        public void AddTable(FullDatabaseRelatedName tname, QueryDesignTableFrame srctbl, IForeignKey join)
        {
            var ts = LoadTable(tname);

            AddTable(ts, srctbl, join, tname.ObjectType);
        }
Beispiel #13
0
 public void AddTable(NameWithSchema tname, QueryDesignTableFrame srctbl, IForeignKey join)
 {
     AddTable(new FullDatabaseRelatedName {
         ObjectName = tname, ObjectType = "table"
     });
 }
Beispiel #14
0
        void AddTable(ITableStructure ts, QueryDesignTableFrame srctbl, IForeignKey join, string objtype)
        {
            try
            {
                QueryDesignTableFrame tbl = new QueryDesignTableFrame(ts, this, objtype);

                if (join != null)
                {
                    for (int i = 0; i < join.Columns.Count; i++)
                    {
                        if (srctbl.FullName == join.Table.FullName)
                        {
                            AddJoin(srctbl, join.Columns[i].ColumnName, tbl, join.PrimaryKeyColumns[i].ColumnName, false);
                        }
                        else
                        {
                            AddJoin(srctbl, join.PrimaryKeyColumns[i].ColumnName, tbl, join.Columns[i].ColumnName, false);
                        }
                    }
                }
                else
                {
                    // add implicit joins
                    foreach (var fk in ts.GetConstraints <IForeignKey>())
                    {
                        foreach (var t in m_tables)
                        {
                            if (t.FullName == fk.PrimaryKeyTable)
                            {
                                for (int index = 0; index < fk.Columns.Count; index++)
                                {
                                    AddJoin(tbl, fk.Columns[index].ColumnName, t, fk.PrimaryKeyColumns[index].ColumnName, false);
                                }
                            }
                        }
                    }
                    foreach (var t in m_tables)
                    {
                        foreach (var fk in t.Structure.GetConstraints <IForeignKey>())
                        {
                            if (tbl.FullName == fk.PrimaryKeyTable)
                            {
                                for (int index = 0; index < fk.Columns.Count; index++)
                                {
                                    AddJoin(t, fk.Columns[index].ColumnName, tbl, fk.PrimaryKeyColumns[index].ColumnName, false);
                                }
                            }
                        }
                    }
                }

                PlaceTable(tbl);
                m_tables.Add(tbl);
                panel1.Controls.Add(tbl);
            }
            catch (Exception e)
            {
                Errors.Report(e);
            }
            ReloadAll();
        }
Beispiel #15
0
 public DesignedTable(QueryDesignFrame frame, QueryDesignTableFrame table)
 {
     m_table = table;
     m_frame = frame;
 }