Beispiel #1
0
     private void FixupCost(Cost previousValue)
     {
         if (previousValue != null && ReferenceEquals(previousValue.PartWarehouse, this))
         {
             previousValue.PartWarehouse = null;
         }
 
         if (Cost != null)
         {
             Cost.PartWarehouse = this;
         }
     }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CostVM"/> class.
 /// </summary>
 /// <param name="entity">The entity.</param>
 /// <param name="access"></param>
 /// <param name="dataService"></param>
 /// <param name="groupDataService"></param>
 public CostVM(Cost entity, AccessType access, CostDataService dataService, CostCenterDataService groupDataService)
     : base(access)
 {
     _model = entity;
     InitializeData(dataService, groupDataService);
     Groups = new ListCollectionView(new ObservableCollection<CostCenterVM>());
 }
Beispiel #3
0
 public override void Save(object param)
 {
     if (CostType == CostType.Stock && !IsCostValueSet)
         SetCostParams();
     CostDataService.UpdateModel(_model, 
         SelectedGroupVM.Id, SelectedWarehouseVM == null? null : SelectedWarehouseVM.Model, 
         SelectedCostSource == null? -1 : SelectedCostSource.Id);
     _model = CostDataService.GetSingle(_model.Id); OnPropertyChanged("ModifiedBy");OnPropertyChanged("ModifiedDate");Mode = ModificationStatus.Saved;
 }
Beispiel #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CostVM"/> class from the model.
        /// </summary>
        /// <param name="entity">The model.</param>
        /// <param name="groupItems">The group view models.</param>
        /// <param name="warehouseItems">the warehouse view models</param>
        /// <param name="costSourceItems">machines, operators or stations</param>
        /// <param name="access"></param>
        /// <param name="dataService"></param>
        /// <param name="groupDataService"></param>
        public CostVM(Cost entity, ListCollectionView groupItems, ListCollectionView warehouseItems, ListCollectionView costSourceItems, AccessType access, CostDataService dataService, CostCenterDataService groupDataService)
            : base(access)
        {
            InitializeData(dataService, groupDataService);
            _model = entity;
            Groups = groupItems;
            CostSources = costSourceItems;
            Warehouses = warehouseItems;

            foreach (CostCenterVM groupVm in groupItems)
            {
                if (groupVm.Id == entity.CostCenter.Id)
                {
                    SelectedGroupVM = groupVm;
                    break;
                }
            }
            if (entity.PartWarehouse != null)
            {
                foreach (PartWarehouseInfoVM warehouse in Warehouses)
                {
                    if (warehouse.Id == entity.PartWarehouse.Id)
                    {
                        SelectedWarehouseVM = warehouse;
                        break;
                    }
                }
            }

            switch (SourceType)
            {
                case CostSourceType.Machines:
                    if(entity.Machine == null) break;
                    foreach (IInfoViewModel infoVM in CostSources)
                    {
                        if (infoVM.Id == entity.Machine.Id)
                        {
                            SelectedCostSource = infoVM;
                            break;
                        }
                    }
                    break;
                case CostSourceType.Operators:
                    if (entity.Operator == null) break;
                    foreach (IInfoViewModel infoVM in CostSources)
                    {
                        if (infoVM.Id == entity.Operator.Id)
                        {
                            SelectedCostSource = infoVM;
                            break;
                        }
                    }
                    break;
                case CostSourceType.Stations:
                    if (entity.Station == null) break;
                    foreach (IInfoViewModel infoVM in CostSources)
                    {
                        if (infoVM.Id == entity.Station.Id)
                        {
                            SelectedCostSource = infoVM;
                            break;
                        }
                    }
                    break;
                case CostSourceType.Activities:
                    if (entity.Activity == null) break;
                    foreach (IInfoViewModel infoVM in CostSources)
                    {
                        if (infoVM.Id == entity.Activity.Id)
                        {
                            SelectedCostSource = infoVM;
                            break;
                        }
                    }
                    break;
            }
        }