Пример #1
0
        private void InitializeData()
        {
            UnitOfWork = new SoheilEdmContext();
            RootDataService = new RootDataService(UnitOfWork);
            RootDataService.RootAdded += OnRootAdded;

            ColumnHeaders = new List<ColumnInfo> 
            { 
                new ColumnInfo("Code",0), 
                new ColumnInfo("Name",1), 
                new ColumnInfo("Status",2) ,
                new ColumnInfo("Mode",3,true) 
            };

            AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems);
            AddGroupCommand = new Command(Add, CanAddGroup);
            CreateItems(null);
        }
Пример #2
0
 public static Root CreateNew(RootDataService dataService)
 {
     int id = dataService.AddModel(new Root { Name = "جدید", Code = string.Empty, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now });
     return dataService.GetSingle(id);
 }
Пример #3
0
 private void InitializeData(RootDataService dataService)
 {
     RootDataService = dataService;
     ProductDefectionDataService = new ProductDefectionDataService();
     SaveCommand = new Command(Save, CanSave);
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 public RootVM(Root entity, AccessType access, RootDataService dataService)
     : base(access)
 {
     InitializeData(dataService);
     _model = entity;
     if(entity.ProductDefection != null)
         CurrentProductDefection = new ProductDefectionVM(entity.ProductDefection, Access, ProductDefectionDataService, RelationDirection.Straight);
     FishbonesVM = new RootFishbonesVM(this, CurrentProductDefection, Access);
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public RootVM(AccessType access, RootDataService dataService):base(access)
 {
     InitializeData(dataService);
 }
Пример #6
0
        public RootFishbonesVM(RootVM root, ProductDefectionVM productDefection, AccessType access) : base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentRoot = root;
            RootDataService = new RootDataService(UnitOfWork);
            RootDataService.FishboneAdded += OnFishboneNodeAdded;
            RootDataService.FishboneRemoved += OnFishboneNodeRemoved;
            ProductDefectionDataService = new ProductDefectionDataService(UnitOfWork);
            ProductDataService = new ProductDataService(UnitOfWork);
            DefectionDataService = new DefectionDataService(UnitOfWork);
            SwitchItemsCommand = new Command(SetProductDefections);
            ViewProductDefectionsCommand = new Command(ViewProductDefections);
            InitializeFishboneCommand = new Command(InitializeFishbone);
            FishboneNodeDataService = new FishboneNodeDataService(UnitOfWork);

            RootNode = new FishboneNodeVM(Access, FishboneNodeDataService) { Title = string.Empty, Id = -1, ParentId = -2 };

            var selectedVms = new ObservableCollection<FishboneNodeVM>();
            foreach (var rootFishboneNode in RootDataService.GetFishboneNodes(root.Id))
            {
                selectedVms.Add(new FishboneNodeVM(rootFishboneNode, Access, FishboneNodeDataService));
            }

            SetProductDefections();

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeTreeCommand = new Command(ExcludeTree, CanExcludeTree);


            foreach (FishboneNodeVM item in selectedVms)
            {
                if (item.ParentId == RootNode.Id)
                {
                    RootNode.ChildNodes.Add(item);
                    break;
                }
            }

            CurrentNode = RootNode;

            if (productDefection != null)
            {
                foreach (IInfoViewModel item in DefectionList)
                {
                    if (item.Id == productDefection.DefectionId)
                    {
                        CurrentDefection = item;
                        ViewProductDefections(null);
                        break;
                    }
                }
				if(AllItems!=null)
                foreach (ProductDefectionVM item in AllItems)
                {
                    if (item.Id == productDefection.Id)
                    {
                        CurrentProductDefection = item;
                        IsEnabled = false;
                        break;
                    }
                }
            }

        }