Exemplo n.º 1
0
 public static IConstraint FindConstraint(this ITableStructure table, string type, string name)
 {
     if (type == "primary_key")
     {
         return(table.FindConstraint <IPrimaryKey>());
     }
     return(table.FindConstraint(name));
 }
        //private void cbxBindingTable_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    if (m_loadingRelation) return;

        //    foreach (var cond in m_loadedRelation.Conditions)
        //    {
        //        cond.RightExpr = new DmlfStringExpression { Value = "" };
        //    }
        //    ClearRelationCtrls();
        //    CreateRelationCtrls();
        //    RefreshLoadedRelation();
        //}

        private void cbxReferencedTable_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (m_loadingRelation)
            {
                return;
            }
            if (m_loadedRelation == null)
            {
                return;
            }

            m_loadedRelation.Conditions.Clear();

            m_loadedRelation.Reference = new DmlfSource
            {
                TableOrView = (NameWithSchema)cbxReferencedTable.SelectedItem,
                Alias       = tbxAlias.Text
            };

            ITableStructure refts = null;
            var             reft  = m_loadedRelation.Reference;

            if (reft != null)
            {
                refts = GetTableStruct(reft.TableOrView);
            }
            //var bind = m_loadedRelation.GetRelationSource();

            if (refts != null)
            {
                foreach (string pkcol in refts.FindConstraint <IPrimaryKey>().Columns.GetNames())
                {
                    m_loadedRelation.Conditions.Add(new DmlfEqualCondition
                    {
                        LeftExpr = new DmlfColumnRefExpression
                        {
                            Column = new DmlfColumnRef
                            {
                                Source     = reft,
                                ColumnName = pkcol
                            }
                        },
                        RightExpr = new DmlfStringExpression {
                            Value = ""
                        }
                    });
                }
            }

            ClearRelationCtrls();
            CreateRelationCtrls();
            RefreshLoadedRelation();
        }
Exemplo n.º 3
0
        public static IEnumerable <IColumnStructure> GetPkColumns(this ITableStructure table)
        {
            IPrimaryKey pk = table.FindConstraint <IPrimaryKey>();

            if (pk == null)
            {
                yield break;
            }
            foreach (var col in pk.Columns)
            {
                yield return(table.Columns[col.ColumnName]);
            }
        }
Exemplo n.º 4
0
        public static IEnumerable <IColumnStructure> GetNoPkColumns(this ITableStructure table)
        {
            IPrimaryKey pk = table.FindConstraint <IPrimaryKey>();

            if (pk == null)
            {
                return(table.Columns);
            }
            var res = new List <IColumnStructure>();

            foreach (var col in table.Columns)
            {
                if (pk.Columns.FindIndex(c => c.ColumnName == col.ColumnName) >= 0)
                {
                    continue;
                }
                res.Add(col);
            }
            return(res);
        }
Exemplo n.º 5
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();
        }