JobBillOfMaterialsItem.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using System;
  2. using System.Linq;
  3. using InABox.Core;
  4. namespace Comal.Classes
  5. {
  6. public class JobBillOfMaterialsItem : DimensionedEntity<StockDimensions>, IRemotable, IPersistent, IOneToMany<Job>,
  7. IOneToMany<JobBillOfMaterials>, ISequenceable, ILicense<ProjectManagementLicense>, IJobMaterial
  8. {
  9. [NullEditor]
  10. [EntityRelationship(DeleteAction.Cascade)]
  11. public JobLink Job { get; set; }
  12. [NullEditor]
  13. [EntityRelationship(DeleteAction.Cascade)]
  14. public JobBillOfMaterialsLink BillOfMaterials { get; set; }
  15. [EditorSequence(1)]
  16. [TextBoxEditor]
  17. public string Section { get; set; }
  18. [EditorSequence(2)]
  19. [EntityRelationship(DeleteAction.SetNull)]
  20. public JobITPLink ITP { get; set; }
  21. [EditorSequence(3)]
  22. [EntityRelationship(DeleteAction.SetNull)]
  23. public ProductLink Product { get; set; }
  24. [EditorSequence(4)]
  25. [EntityRelationship(DeleteAction.SetNull)]
  26. public ProductStyleLink Style { get; set; }
  27. [NullEditor]
  28. [Obsolete("Replaced by Dimensions",true)]
  29. public double UnitSize { get; set; }
  30. [EditorSequence(5)]
  31. public override StockDimensions Dimensions { get; set; }
  32. [EditorSequence(6)]
  33. public double Quantity { get; set; }
  34. [EditorSequence(7)]
  35. public SupplierLink Supplier { get; set; }
  36. [NullEditor]
  37. public long Sequence { get; set; }
  38. protected override void Init()
  39. {
  40. base.Init();
  41. Job = new JobLink();
  42. BillOfMaterials = new JobBillOfMaterialsLink();
  43. ITP = new JobITPLink();
  44. Product = new ProductLink();
  45. Product.PropertyChanged += Product_PropertyChanged;
  46. //LinkProperty<ProductLink, JobBillOfMaterialsItem>(x => x.UnitSize, x => x.UnitSize);
  47. Style = new ProductStyleLink();
  48. LinkProperty<ProductLink, JobBillOfMaterialsItem>(x => x.DefaultStyle.ID, x => x.Style.ID);
  49. Supplier = new SupplierLink();
  50. Dimensions = new StockDimensions();
  51. }
  52. private void Product_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  53. {
  54. }
  55. private static Column<JobRequisitionItem> dimensions = new Column<JobRequisitionItem>(x => x.Product.Dimensions);
  56. private static Column<JobRequisitionItem> style = new Column<JobRequisitionItem>(x => x.Product.DefaultStyle);
  57. private bool bChanging;
  58. protected override void DoPropertyChanged(string name, object before, object after)
  59. {
  60. if (bChanging)
  61. return;
  62. if (dimensions.IsParentOf(name))
  63. {
  64. bChanging = true;
  65. String col = String.Join(".", name.Split('.').Skip(1));
  66. CoreUtils.SetPropertyValue(this, col, after);
  67. bChanging = false;
  68. }
  69. else if (style.IsParentOf(name))
  70. {
  71. bChanging = true;
  72. String col = String.Join(".", name.Split('.').Skip(1));
  73. CoreUtils.SetPropertyValue(this, col, after);
  74. bChanging = false;
  75. }
  76. else
  77. base.DoPropertyChanged(name, before, after);
  78. }
  79. }
  80. }