using System; using System.Linq; using InABox.Core; namespace Comal.Classes { public class JobBillOfMaterialsItem : DimensionedEntity, IRemotable, IPersistent, IOneToMany, IOneToMany, ISequenceable, ILicense, IJobMaterial { [NullEditor] [EntityRelationship(DeleteAction.Cascade)] public JobLink Job { get; set; } [NullEditor] [EntityRelationship(DeleteAction.Cascade)] public JobBillOfMaterialsLink BillOfMaterials { get; set; } [EditorSequence(1)] [TextBoxEditor] public string Section { get; set; } [EditorSequence(2)] [EntityRelationship(DeleteAction.SetNull)] public JobITPLink ITP { get; set; } [EditorSequence(3)] [EntityRelationship(DeleteAction.SetNull)] public ProductLink Product { get; set; } [EditorSequence(4)] [EntityRelationship(DeleteAction.SetNull)] public ProductStyleLink Style { get; set; } [NullEditor] [Obsolete("Replaced by Dimensions",true)] public double UnitSize { get; set; } [EditorSequence(5)] [RequiredColumn] public override StockDimensions Dimensions { get; set; } [EditorSequence(6)] public double Quantity { get; set; } [EditorSequence(7)] public SupplierLink Supplier { get; set; } [NullEditor] public long Sequence { get; set; } protected override void Init() { base.Init(); Job = new JobLink(); BillOfMaterials = new JobBillOfMaterialsLink(); ITP = new JobITPLink(); Product = new ProductLink(); Product.PropertyChanged += Product_PropertyChanged; //LinkProperty(x => x.UnitSize, x => x.UnitSize); Style = new ProductStyleLink(); LinkProperty(x => x.DefaultStyle.ID, x => x.Style.ID); Supplier = new SupplierLink(); Dimensions = new StockDimensions(); } private void Product_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { } private static Column dimensions = new Column(x => x.Product.Dimensions); private static Column style = new Column(x => x.Product.DefaultStyle); private bool bChanging; protected override void DoPropertyChanged(string name, object before, object after) { if (bChanging) return; if (dimensions.IsParentOf(name)) { bChanging = true; String col = String.Join(".", name.Split('.').Skip(1)); CoreUtils.SetPropertyValue(this, col, after); bChanging = false; } else if (style.IsParentOf(name)) { bChanging = true; String col = String.Join(".", name.Split('.').Skip(1)); CoreUtils.SetPropertyValue(this, col, after); bChanging = false; } else base.DoPropertyChanged(name, before, after); } } }