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(); }
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; }
//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(); }
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; }
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); }
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(); } }
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; } }
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(); }
public QueryDesignColumnPopupMenu(QueryDesignTableFrame frame, int colindex) { m_frame = frame; m_colindex = colindex; }
public ColWrapper(QueryDesignFrame frame, QueryDesignTableFrame table, string colname) { m_frame = frame; m_colname = colname; m_table = table; }
public void AddTable(FullDatabaseRelatedName tname, QueryDesignTableFrame srctbl, IForeignKey join) { var ts = LoadTable(tname); AddTable(ts, srctbl, join, tname.ObjectType); }
public void AddTable(NameWithSchema tname, QueryDesignTableFrame srctbl, IForeignKey join) { AddTable(new FullDatabaseRelatedName { ObjectName = tname, ObjectType = "table" }); }
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(); }
public DesignedTable(QueryDesignFrame frame, QueryDesignTableFrame table) { m_table = table; m_frame = frame; }