private void InitializeData(PartWarehouseDataService dataService, PartWarehouseGroupDataService groupDataService, CostDataService costDataService) { PartWarehouseDataService = dataService; GroupDataService = groupDataService; CostDataService = costDataService; SaveCommand = new Command(Save, CanSave); }
/// <summary> /// Initializes a new instance of the <see cref="PartWarehouseVM"/> class from the model. /// </summary> /// <param name="entity">The model.</param> /// <param name="groupItems">The group view models.</param> /// <param name="access"></param> /// <param name="dataService"></param> /// <param name="groupDataService"></param> /// <param name="costDataService"></param> public PartWarehouseVM(PartWarehouse entity, ListCollectionView groupItems, AccessType access, PartWarehouseDataService dataService, PartWarehouseGroupDataService groupDataService, CostDataService costDataService) : base(access) { InitializeData(dataService, groupDataService, costDataService); _model = entity; Groups = groupItems; foreach (PartWarehouseGroupVM groupVm in groupItems) { if (groupVm.Id == entity.PartWarehouseGroup.Id) { SelectedGroupVM = groupVm; break; } } }
/// <summary> /// Initializes a new instance of the <see cref="PartWarehouseVM"/> class. /// </summary> /// <param name="entity">The entity.</param> /// <param name="access"></param> /// <param name="dataService"></param> /// <param name="groupDataService"></param> /// <param name="costDataService"></param> public PartWarehouseVM(PartWarehouse entity, AccessType access, PartWarehouseDataService dataService, PartWarehouseGroupDataService groupDataService, CostDataService costDataService) : base(access) { _model = entity; InitializeData(dataService, groupDataService, costDataService); Groups = new ListCollectionView(new ObservableCollection<PartWarehouseGroupVM>()); }
private void InitializeData() { UnitOfWork = new SoheilEdmContext(); CostCenterDataService = new CostCenterDataService(UnitOfWork); MachineDataService = new MachineDataService(UnitOfWork); StationDataService = new StationDataService(UnitOfWork); OperatorDataService = new OperatorDataService(UnitOfWork); ActivityDataService = new ActivityDataService(UnitOfWork); WarehouseDataService = new PartWarehouseDataService(UnitOfWork); CostDataService = new CostDataService(UnitOfWork); CostDataService.CostAdded += OnCostAdded; CostCenterDataService.CostCenterAdded += OnCostCenterAdded; ColumnHeaders = new List<ColumnInfo> { new ColumnInfo("Description",0), new ColumnInfo("CostType",1,true), new ColumnInfo("SelectedCostSource","txtCostSource",2,true), new ColumnInfo("CostValue","txtCost",3,true), new ColumnInfo("Mode",4,true) }; AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems); AddGroupCommand = new Command(AddGroup); ViewCommand = new Command(View, CanView); var machineViewModels = new ObservableCollection<MachineInfoVM>(); foreach (var entity in MachineDataService.GetAll()) { machineViewModels.Add(new MachineInfoVM(entity)); } Machines = new ListCollectionView(machineViewModels); var operatorViewModels = new ObservableCollection<OperatorInfoVM>(); foreach (var entity in OperatorDataService.GetAll()) { operatorViewModels.Add(new OperatorInfoVM(entity)); } Operators = new ListCollectionView(operatorViewModels); var stationViewModels = new ObservableCollection<StationInfoVM>(); foreach (var entity in StationDataService.GetAll()) { stationViewModels.Add(new StationInfoVM(entity)); } Stations = new ListCollectionView(stationViewModels); var activityViewModels = new ObservableCollection<ActivityInfoVM>(); foreach (var entity in ActivityDataService.GetAll()) { activityViewModels.Add(new ActivityInfoVM(entity)); } Activities = new ListCollectionView(activityViewModels); var warehouseViewModels = new ObservableCollection<PartWarehouseInfoVM>(); foreach (var entity in WarehouseDataService.GetAll()) { warehouseViewModels.Add(new PartWarehouseInfoVM(entity)); } Warehouses = new ListCollectionView(warehouseViewModels); CreateItems(null); }
public static Cost CreateNew(CostDataService dataService, int groupId) { int id = dataService.AddModel(new Cost { Description = "جدید", CostValue = 0, CostType = 1, Date = DateTime.Now }, groupId); return dataService.GetSingle(id); }
private void InitializeData(CostDataService dataService, CostCenterDataService groupDataService) { CostDataService = dataService; GroupDataService = groupDataService; SaveCommand = new Command(Save, CanSave); }
/// <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>()); }
/// <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; } }