Exemple #1
0
		public Rework(Product parentVm, Model.ProductRework model, bool isRowHeader)
		{
			ProductReworkId = model.Id;

			if (model.Rework != null)
			{
				Name = (string.IsNullOrEmpty(model.Name)) ? model.Rework.Name : model.Name;
				Code = (string.IsNullOrEmpty(model.Name)) ? model.Rework.Code : model.Code;
			}
			else
			{
				Name = model.Name;
				Code = model.Code;
			}
			Product = parentVm;
			Checkbox = new CheckboxCell(this);
			Warmup = new WarmupCell(parentVm.ProductGroup.Station.Id, this, model.Warmups.First());
			IsValid = true;
			_isRowHeader = isRowHeader;
			if (model.Rework != null)
			{
				CellType = isRowHeader ? CellType.ReworkRowHeaderCell : CellType.ReworkColumnHeaderCell;
				ReworkId = model.Rework.Id;
				IsRework = true;
			}
			else
			{
				CellType = isRowHeader ? CellType.ProductRowHeaderCell : CellType.ProductColumnHeaderCell;
				ReworkId = -1;
				IsRework = false;
			}
			CopyCommand = new Commands.Command(o => _clipboard = this, () => { return IsValid || _isRowHeader; });
			PasteCommand = new Commands.Command(o =>
			{
				if (_clipboard == null) return;

				if (_isRowHeader)
				{
					//save warmup
					Warmup.Save(_clipboard.Warmup.Seconds, involveCheckbox: false);

					//load changeovers
					var copiedList = _clipboard.Product.ProductGroup.Station.ChangeoverCells.OfType<ChangeoverCell>()
						.Where(x => x.Row.ProductReworkId == _clipboard.ProductReworkId);
					var targetList = Product.ProductGroup.Station.ChangeoverCells.OfType<ChangeoverCell>()
						.Where(x => x.Row.ProductReworkId == ProductReworkId);

					//save changeovers
					foreach (var copiedC in copiedList)
					{
						var cell = targetList.FirstOrDefault(x => x.Column.ProductReworkId == copiedC.Column.ProductReworkId);
						if (cell != null)
							cell.Save(copiedC.Seconds, false);
					}
				}
				else
				{
					//load changeovers
					var copiedList = _clipboard.Product.ProductGroup.Station.ChangeoverCells.OfType<ChangeoverCell>()
						.Where(x => x.Column.ProductReworkId == _clipboard.ProductReworkId);
					var targetList = Product.ProductGroup.Station.ChangeoverCells.OfType<ChangeoverCell>()
						.Where(x => x.Column.ProductReworkId == ProductReworkId);

					//save changeovers
					foreach (var copiedC in copiedList)
					{
						var cell = targetList.FirstOrDefault(x => x.Row.ProductReworkId == copiedC.Row.ProductReworkId);
						if (cell != null)
							cell.Save(copiedC.Seconds, false);
					}
				}
			},
			() =>
			{
				if (_clipboard == null) return false;
				return _clipboard._isRowHeader == _isRowHeader;
			});
		}
Exemple #2
0
		/// <summary>
		/// this means this remork works differently (as a grouping tool)
		/// </summary>
		/// <param name="product"></param>
		/// <param name="isRowHeader"></param>
		/// <returns></returns>
		public static Rework InvalidMainProduct(Product product, bool isRowHeader)
		{
			Rework rework = new Rework();
			rework.ProductReworkId = new DataServices.ProductReworkDataService(null).GetMainForProduct(product.Id).Id;
			rework.ReworkId = -1;
			rework.CellType = isRowHeader ? CellType.ProductRowHeaderCell : CellType.ProductColumnHeaderCell;
			rework.IsRework = false;
			rework.Name = product.Name;
			rework.Code = product.Code;
			rework.Product = product;
			if (isRowHeader)
			{
				rework.Checkbox = new CheckboxCell(rework);
				rework.Warmup = new WarmupCell(rework.Product.ProductGroup.Station.Id, rework, null);
			}
			rework._isRowHeader = isRowHeader;
			rework.IsValid = false;
			rework.IsDurationsVisible = false;
			return rework;
		}