Exemplo n.º 1
0
        /// <summary>
        /// 填充字段信息
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="lstParam"></param>
        private void FillParams(EntityConfig entity, List <EntityParam> lstParam, List <TableRelationAttribute> lstRelation)
        {
            foreach (EntityParamField param in entity.EParamFields)
            {
                if (!param.IsGenerate)
                {
                    continue;
                }

                DbType      dbt   = (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), param.DbType).Value;
                EntityParam pInfo = new EntityParam("",
                                                    param.ParamName, "", dbt,
                                                    param.EntityPropertyType, param.Summary, param.Length, param.AllowNull, param.ReadOnly);

                lstParam.Add(pInfo);
            }
            foreach (EntityRelationItem relation in entity.ERelation)
            {
                if (relation.IsToDB && relation.IsGenerate && relation.IsParent)
                {
                    EntityConfig parent = new EntityConfig(relation.FInfo.MemberType, DesignerInfo);
                    if (parent == null)
                    {
                        continue;
                    }
                    EntityParamField childProperty = entity.GetParamInfoByPropertyName(relation.SourceProperty);
                    if (childProperty == null)
                    {
                        continue;
                    }
                    EntityParamField parentProperty = parent.GetParamInfoByPropertyName(relation.TargetProperty);
                    if (parentProperty == null)
                    {
                        continue;
                    }
                    lstRelation.Add(new TableRelationAttribute("", "", entity.TableName,
                                                               parent.TableName, childProperty.ParamName, parentProperty.ParamName, "", relation.IsParent));
                }
            }
        }
Exemplo n.º 2
0
        private void gvField_CurrentCellChanged(object sender, EventArgs e)
        {
            if (gvField.CurrentCell == null)
            {
                return;
            }
            string colName = gvField.Columns[gvField.CurrentCell.ColumnIndex].Name;

            if (colName == "ColParamType")
            {
                EntityParamField epf = gvField.Rows[gvField.CurrentCell.RowIndex].DataBoundItem as EntityParamField;
                if (epf != null)
                {
                    DataTypeInfos info = EntityFieldBase.GetTypeInfo(epf.FInfo);
                    if (info != null)
                    {
                        _cmbCell.SetDataSource(info.DbTypes);
                        _cmbCell.ShowComboBox(gvField.CurrentCell);
                    }
                }
            }

            if (colName == "ColPropertyType")
            {
                EntityParamField epf = gvField.Rows[gvField.CurrentCell.RowIndex].DataBoundItem as EntityParamField;
                if (epf != null)
                {
                    DataTypeInfos info = EntityFieldBase.GetTypeInfo(epf.FInfo);
                    if (info != null)
                    {
                        _cmbCell.SetDataSource(EntityFieldBase.PropertyTypeItems);
                        _cmbCell.ShowComboBox(gvField.CurrentCell);
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 初始化属性
        /// </summary>
        private void InitPropertys()
        {
            _lstProperty = new List <UIModelItem>();


            List <ClrProperty>   lstClrProperty = EntityConfig.GetAllMember <ClrProperty>(_classType, true);
            EntityConfig         entity         = new EntityConfig(_classType, DesignerInfo);
            Stack <EntityConfig> stkEntity      = EntityConfig.GetEntity(entity, DesignerInfo);

            foreach (ClrProperty property in lstClrProperty)
            {
                UIModelItem item = new UIModelItem(property);


                EntityParamField finfo = EntityConfig.FindParamInfoByName(stkEntity, item.PropertyName);
                if (finfo != null)
                {
                    bool      isPK  = EnumUnit.ContainerValue((int)finfo.EntityPropertyType, (int)EntityPropertyType.PrimaryKey);
                    TableInfo tinfo = new TableInfo(isPK, finfo.ParamName, finfo.Length, finfo.ReadOnly, (DbType)EnumUnit.GetEnumInfoByName(typeof(DbType), finfo.DbType).Value);
                    item.TabInfo = tinfo;
                }
                else
                {
                    EntityRelationItem rel = EntityConfig.FindRelInfoByName(stkEntity, item.PropertyName);
                    if (rel != null)
                    {
                        RelationInfo rinfo = new RelationInfo(rel.TargetProperty, rel.SourceProperty, rel.IsParent, rel.TypeName, rel.TypeFullName);
                        item.RelInfo = rinfo;
                    }
                }



                _lstProperty.Add(item);
            }
        }