JobBillOfMaterialsItem.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. [RequiredColumn]
  32. public override StockDimensions Dimensions { get; set; }
  33. [EditorSequence(6)]
  34. public double Quantity { get; set; }
  35. [EditorSequence(7)]
  36. public SupplierLink Supplier { get; set; }
  37. [NullEditor]
  38. public long Sequence { get; set; }
  39. protected override void Init()
  40. {
  41. base.Init();
  42. Job = new JobLink();
  43. BillOfMaterials = new JobBillOfMaterialsLink();
  44. ITP = new JobITPLink();
  45. Product = new ProductLink();
  46. Product.PropertyChanged += Product_PropertyChanged;
  47. //LinkProperty<ProductLink, JobBillOfMaterialsItem>(x => x.UnitSize, x => x.UnitSize);
  48. Style = new ProductStyleLink();
  49. LinkProperty<ProductLink, JobBillOfMaterialsItem>(x => x.DefaultStyle.ID, x => x.Style.ID);
  50. Supplier = new SupplierLink();
  51. Dimensions = new StockDimensions();
  52. }
  53. private void Product_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
  54. {
  55. }
  56. private static Column<JobRequisitionItem> dimensions = new Column<JobRequisitionItem>(x => x.Product.Dimensions);
  57. private static Column<JobRequisitionItem> style = new Column<JobRequisitionItem>(x => x.Product.DefaultStyle);
  58. private bool bChanging;
  59. protected override void DoPropertyChanged(string name, object before, object after)
  60. {
  61. if (bChanging)
  62. return;
  63. if (dimensions.IsParentOf(name))
  64. {
  65. bChanging = true;
  66. String col = String.Join(".", name.Split('.').Skip(1));
  67. CoreUtils.SetPropertyValue(this, col, after);
  68. bChanging = false;
  69. }
  70. else if (style.IsParentOf(name))
  71. {
  72. bChanging = true;
  73. String col = String.Join(".", name.Split('.').Skip(1));
  74. CoreUtils.SetPropertyValue(this, col, after);
  75. bChanging = false;
  76. }
  77. else
  78. base.DoPropertyChanged(name, before, after);
  79. }
  80. }
  81. }