ManufacturingPacketComponent.cs 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using InABox.Core;
  2. using System;
  3. namespace Comal.Classes
  4. {
  5. [UserTracking(typeof(ManufacturingPacket))]
  6. [Caption("Components")]
  7. public class ManufacturingPacketComponent : DimensionedEntity<ProductDimensions>, IRemotable, IPersistent, IOneToMany<ManufacturingPacket>, ILicense<ManufacturingLicense>, ISequenceable
  8. {
  9. // Used to be Cascade, but now must be delete, because you might delete a packet when on the staging screen, and not want to get rid of the components, obviously.
  10. [EntityRelationship(DeleteAction.SetNull)]
  11. public ManufacturingPacketLink Packet { get; set; }
  12. [NullEditor]
  13. [EntityRelationship(DeleteAction.Cascade)]
  14. public SetoutLink Setout { get; set; }
  15. [EntityRelationship(DeleteAction.SetNull)]
  16. [EditorSequence(1)]
  17. public ProductLink Product { get; set; }
  18. [TextBoxEditor]
  19. [EditorSequence(2)]
  20. public string Description { get; set; }
  21. [DimensionsEditor(typeof(ProductDimensions))]
  22. [EditorSequence(4)]
  23. public override ProductDimensions Dimensions { get; set; }
  24. [EditorSequence(5)]
  25. public int Quantity { get; set; }
  26. [NullEditor]
  27. public int Consumed { get; set; }
  28. /// <summary>
  29. /// When a picking list is creating for a <see cref="ManufacturingPacketComponent"/>, we save a link to the requisition,
  30. /// so that we don't require the same component twice.
  31. /// </summary>
  32. [NullEditor]
  33. public RequisitionLink Requisition { get; set; }
  34. [NullEditor]
  35. public long Sequence { get; set; }
  36. static ManufacturingPacketComponent()
  37. {
  38. LinkedProperties.Register<ManufacturingPacketComponent, ProductLink, string>(x => x.Product, x => x.Name, x => x.Description);
  39. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, Guid>(x => x.Product.UnitOfMeasure, x => x.ID, x => x.Dimensions.Unit.ID);
  40. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, string>(x => x.Product.UnitOfMeasure, x => x.Code, x => x.Dimensions.Unit.Code);
  41. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, string>(x => x.Product.UnitOfMeasure, x => x.Description, x => x.Dimensions.Unit.Description);
  42. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, bool>(x => x.Product.UnitOfMeasure, x => x.HasLength, x => x.Dimensions.Unit.HasLength);
  43. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, bool>(x => x.Product.UnitOfMeasure, x => x.HasHeight, x => x.Dimensions.Unit.HasHeight);
  44. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, bool>(x => x.Product.UnitOfMeasure, x => x.HasQuantity, x => x.Dimensions.Unit.HasQuantity);
  45. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, bool>(x => x.Product.UnitOfMeasure, x => x.HasWeight, x => x.Dimensions.Unit.HasWeight);
  46. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, bool>(x => x.Product.UnitOfMeasure, x => x.HasWidth, x => x.Dimensions.Unit.HasWidth);
  47. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, string>(x => x.Product.UnitOfMeasure, x => x.Formula, x => x.Dimensions.Unit.Formula);
  48. LinkedProperties.Register<ManufacturingPacketComponent, ProductDimensionUnitLink, string>(x => x.Product.UnitOfMeasure, x => x.Format, x => x.Dimensions.Unit.Format);
  49. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, double>(x => x.Product.DefaultInstance.Dimensions, x => x.Height, x => x.Dimensions.Height);
  50. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, double>(x => x.Product.DefaultInstance.Dimensions, x => x.Length, x => x.Dimensions.Length);
  51. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, double>(x => x.Product.DefaultInstance.Dimensions, x => x.Quantity, x => x.Dimensions.Quantity);
  52. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, double>(x => x.Product.DefaultInstance.Dimensions, x => x.Weight, x => x.Dimensions.Weight);
  53. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, double>(x => x.Product.DefaultInstance.Dimensions, x => x.Width, x => x.Dimensions.Width);
  54. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, double>(x => x.Product.DefaultInstance.Dimensions, x => x.Value, x => x.Dimensions.Value);
  55. LinkedProperties.Register<ManufacturingPacketComponent, StockDimensions, string>(x => x.Product.DefaultInstance.Dimensions, x => x.UnitSize, x => x.Dimensions.UnitSize);
  56. }
  57. }
  58. }