Exemplo n.º 1
0
        /// <summary>
        /// Диалог изменения сущности в БД.
        /// </summary>
        /// <param name="sign">Идентификатор сущности.</param>
        public static void EditDialog(EntitySign sign)
        {
            if (sign == null)
            {
                return;
            }
            var strategy = new EditStrategy();

            strategy.EntityChanged += ent => TreeView.NodeRename(ent as Hierarchy);
            FormEntity frmEdit = null;

            if (sign.Type.IsSubclassOf(typeof(KindBase)))
            {
                frmEdit = new FormWorkKind(sign, strategy);
            }
            if (sign.Type == typeof(Location))
            {
                frmEdit = new FormWorkLocation(sign, strategy);
                (frmEdit as FormWorkLocation).LocationEntityChanged += Plan.LoadImage;
            }
            else if (sign.Type.IsSubclassOf(typeof(Equipment)))
            {
                if (sign.Type == typeof(Extinguisher))
                {
                    frmEdit = new FormWorkExtinguisher(sign, strategy);
                }
                else
                {
                    frmEdit = new FormWorkEquipment(sign, strategy);
                }
            }

            frmEdit.ShowDialog(Owner);
            frmEdit.Dispose();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Диалог добавления сущности в БД.
        /// </summary>
        /// <param name="typeEntity">Тип сущности.</param>
        /// <param name="parentSign">Идентификатор родителя новой сущности.</param>
        public static void AddDialog(Type typeEntity, EntitySign parentSign = null)
        {
            var strategy = new AddStrategy();

            strategy.HierarchyChangedRange += TreeView.NodeAddRange;
            FormEntity frmAdd = null;

            if (typeEntity.IsSubclassOf(typeof(KindBase)))
            {
                frmAdd = new FormWorkKind(typeEntity, strategy);
            }
            else if (typeEntity == typeof(Location))
            {
                frmAdd = new FormWorkLocation(strategy);
                (frmAdd as FormWorkLocation).LocationEntityChanged += Plan.LoadImage;
            }
            else if (typeEntity.IsSubclassOf(typeof(Equipment)))
            {
                if (typeEntity == typeof(Extinguisher))
                {
                    frmAdd = new FormWorkExtinguisher(typeEntity, parentSign, strategy);
                }
                else
                {
                    frmAdd = new FormWorkEquipment(typeEntity, parentSign, strategy);
                }
            }

            frmAdd.ShowDialog(Owner);
            frmAdd.Dispose();
        }