| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | using System;using InABox.Core;using PRSClasses;namespace Comal.Classes{    [UserTracking(typeof(Product))]    public class SupplierProduct : StockEntity, IPersistent, IRemotable, ILicense<ProductManagementLicense>, IExportable, IImportable, IManyToMany<Supplier, Product>    {        private bool bChanging;        [EditorSequence(0)]        public SupplierLink SupplierLink { get; set; }        [EntityRelationship(DeleteAction.SetNull)]        [NullEditor]        [Obsolete("Replaced with Product", true)]        public ProductLink ProductLink        {            get { return Product; }            set { Product = value; }        }                [EntityRelationship(DeleteAction.SetNull)]        [EditorSequence(1)]        public override ProductLink Product { get; set; }                [EditorSequence(2)]        public JobLink Job { get; set; }        [CodeEditor(Editable = Editable.Enabled)]        [EditorSequence(3)]        public string SupplierCode { get; set; }        [TextBoxEditor]        [EditorSequence(4)]        public string SupplierDescription { get; set; }                [EditorSequence(5)]        [RequiredColumn]        [DimensionsEditor(typeof(StockDimensions), AllowEditingUnit = false)]        public override StockDimensions Dimensions { get; set; }        [TextBoxEditor]        [EditorSequence(6)]        public string SupplierCategory { get; set; }        [CurrencyEditor(Visible = Visible.Optional)]        [EditorSequence(7)]        public double TradePrice { get; set; }        [DoubleEditor(Visible = Visible.Optional)]        [EditorSequence(8)]        public double Discount { get; set; }        [CurrencyEditor(Visible = Visible.Optional)]        [EditorSequence(9)]        public double CostPrice { get; set; }        [EditorSequence(10)]        public TaxCodeLink TaxCode { get; set; }        [URLEditor]        [EditorSequence(11)]        public string URL { get; set; }        [TimestampEditor]        [EditorSequence(12)]        public DateTime Expired { get; set; }        protected override void Init()        {            base.Init();            SupplierLink = new SupplierLink(() => this);            Job = new JobLink();            TaxCode = new TaxCodeLink();        }                static SupplierProduct()        {            LinkedProperties.Register<SupplierProduct, ProductLink, String>(x => x.Product, x => x.Code, x => x.SupplierCode);            LinkedProperties.Register<SupplierProduct, ProductLink, String>(x => x.Product, x => x.Name, x => x.SupplierDescription);            StockEntity.LinkStockDimensions<SupplierProduct>();        }        protected override void DoPropertyChanged(string name, object before, object after)        {            base.DoPropertyChanged(name, before, after);            if (bChanging)                return;            bChanging = true;            if (name.Equals("TradePrice"))                CostPrice = (double)after * (100.0F - Discount) / 100.0F;            else if (name.Equals("Discount"))                CostPrice = TradePrice * (100.0F - (double)after) / 100.0F;            else if (name.Equals("CostPrice"))                TradePrice = Discount == 100.0F ? double.MaxValue : (double)after / ((100.0F - Discount) / 100.0F);            bChanging = false;        }    }}
 |