Esempio n. 1
0
        public SelectReferenceForm(ITableStructure table, string activeColumn, List <string> availcols, ISqlDialect dialect)
        {
            InitializeComponent();
            m_table     = table;
            m_dialect   = dialect;
            m_availcols = availcols;

            FillList(lsvDetailReferences, m_table.GetReferencedFrom(), null, AcceptDetail);
            FillList(lsvMasterReferences, m_table.GetConstraints <IForeignKey>(), activeColumn, AcceptMaster);
            tbxBaseTable.Text = table.ToString();
        }
Esempio n. 2
0
        private void FillData()
        {
            var pk = m_table.FindConstraint <IPrimaryKey>();

            if (pk != null)
            {
                m_pkCols.AddRange(pk.Columns.GetNames());
            }
            foreach (var fk in m_table.GetConstraints <IForeignKey>())
            {
                m_fkCols.AddRange(fk.Columns.GetNames());
            }
            using (var g = Graphics.FromHwnd(IntPtr.Zero))
            {
                m_lineHeight = (int)(g.MeasureString("M", Font).Height + 0.99);
                if (m_lineHeight < 16)
                {
                    m_lineHeight = 16;
                }
                m_checkWidth = CheckBoxRenderer.GetGlyphSize(g, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal).Width;
            }
            panCols.Height    = m_table.Columns.Count * m_lineHeight;
            labTableName.Text = m_table.FullName.ToString();
        }
Esempio n. 3
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();
        }