public void SplitTable()
        {
            if (Context.SelectEntity == null || Context.SelectColumns == null || Context.SelectColumns.Count == 0)
            {
                return;
            }
            var oldTable = Context.SelectEntity;
            var newTable = new EntityConfig();

            newTable.CopyValue(oldTable, true);
            if (!CommandIoc.NewConfigCommand(newTable))
            {
                return;
            }
            if (oldTable.PrimaryColumn != null)
            {
                var kc = new PropertyConfig();
                kc.CopyFrom(oldTable.PrimaryColumn);
                newTable.Properties.Add(kc);
            }
            foreach (var col in Context.SelectColumns.OfType <PropertyConfig>().ToArray())
            {
                oldTable.Properties.Remove(col);
                newTable.Properties.Add(col);
            }
            Context.Entities.Add(newTable);
            Model.Tree.SetSelect(newTable);
            Context.SelectColumns = null;
        }
        public void AddEntity()
        {
            if (Context.SelectProject == null)
            {
                MessageBox.Show("请选择一个项目");
                return;
            }
            EntityConfig entity;

            if (!Model.CreateNew(out entity))
            {
                return;
            }
            entity.Parent  = Context.SelectProject;
            entity.Project = Context.SelectProject.Name;
            //Context.SelectProject.Entities.Add(entity);
            //Context.Entities.Add(entity);
            Model.Tree.SetSelect(entity);
            Context.SelectColumns = null;
            var nentity = CommandIoc.AddFieldsCommand();

            if (nentity == null)
            {
                return;
            }
            entity.Properties.AddRange(nentity.Properties);
        }
        /// <summary>
        /// 复制字段
        /// </summary>
        public void AddProperty(object arg)
        {
            var perperty = new PropertyConfig();

            if (CommandIoc.NewConfigCommand("新增字段", perperty))
            {
                Context.SelectEntity.Add(perperty);
            }
        }
Exemple #4
0
        public void EditEnum(PropertyConfig property)
        {
            var cfg = CommandIoc.EditPropertyEnumCommand(property);

            if (cfg == null)
            {
                return;
            }
            property.EnumConfig = cfg;
            Model.Tree.SelectItem.Items.Clear();
            Model.Tree.PropertyChildTreeItem(Model.Tree.SelectItem, property);
        }
        public void AddFields(EntityConfig entity)
        {
            if (entity == null)
            {
                return;
            }
            var nentity = CommandIoc.AddFieldsCommand();

            if (nentity == null)
            {
                return;
            }
            entity.Properties.AddRange(nentity.Properties);
        }
        /// <summary>
        /// 新增属性
        /// </summary>
        /// <param name="entity"></param>
        public void AddNewProperty(EntityConfig entity)
        {
            var config = new PropertyConfig
            {
                Parent = entity,
                Name   = "NewField",
                CsType = "string"
            };

            if (CommandIoc.NewConfigCommand(config))
            {
                entity.Properties.Add(config);
            }
        }
        /// <summary>
        /// 新增属性
        /// </summary>
        public void AddNewProperty()
        {
            EntityConfig entity = Context.SelectEntity;
            var          config = new PropertyConfig
            {
                Parent = entity,
                Name   = "NewField",
                CsType = "string"
            };

            if (CommandIoc.NewConfigCommand("新增字段", config))
            {
                entity.Add(config);
            }
        }
        private void AddRelation(PropertyConfig column)
        {
            var config = new TableReleation
            {
                Parent     = Context.SelectRelationTable,
                Name       = column.Parent.Name,
                Friend     = column.Parent.Name,
                ForeignKey = column.Name,
                PrimaryKey = Context.SelectRelationColumn.Name
            };

            if (CommandIoc.NewConfigCommand(config))
            {
                Context.SelectRelationTable.Releations.Add(config);
            }
        }
        public void AddEntity(object arg)
        {
            if (Context.SelectProject == null)
            {
                MessageBox.Show("请选择一个项目");
                return;
            }

            var project = Context.SelectProject;
            var entity  = new EntityConfig();

            if (CommandIoc.EditEntityCommand(entity))
            {
                project.Add(entity);
                Model.Tree.SetSelectEntity(entity);
                return;
            }
            project.Remove(entity);
        }
Exemple #10
0
 /// <summary>
 /// 新增对象
 /// </summary>
 /// <typeparam name="TConfig"></typeparam>
 /// <param name="config"></param>
 /// <returns></returns>
 public bool CreateNew <TConfig>(out TConfig config)
     where TConfig : ConfigBase, new()
 {
     config = new TConfig();
     return(CommandIoc.NewConfigCommand(config));
 }
        //private void AddRelation(PropertyConfig column)
        //{
        //    var config = new TableReleation
        //    {
        //        Parent = Context.SelectRelationTable,
        //        Name = column.Parent.Name,
        //        Friend = column.Parent.Name,
        //        ForeignKey = column.Name,
        //        PrimaryKey = Context.SelectRelationColumn.Name
        //    };
        //    if (CommandIoc.NewConfigCommand("新增关联信息", config))
        //        Context.SelectRelationTable.Releations.Add(config);
        //}

        /// <summary>
        /// 新增属性
        /// </summary>
        /// <param name="entity"></param>
        public void AddNewProperty(EntityConfig entity)
        {
            CommandIoc.AddFieldsCommand(entity);
        }