123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- using System;
- using System.ComponentModel;
- using System.Linq;
- using System.Linq.Expressions;
- using InABox.Core;
- namespace Comal.Classes
- {
- public enum JobRequisitionItemStatus
- {
- NotChecked,
- Reserved,
- TreatmentRequired,
- OrderRequired,
- TreatmentOnOrder,
- OnOrder,
- Received,
- TreatmentReceived,
- Cancelled,
- Archived
- }
- public class JobRequisitionItemTotalQtyFormula : IFormula<JobRequisitionItem, double>
- {
- public Expression<Func<JobRequisitionItem, double>> Value => x => x.Qty;
- public Expression<Func<JobRequisitionItem, double>>[] Modifiers => new Expression<Func<JobRequisitionItem, double>>[] { x => x.Dimensions.Value };
- public FormulaOperator Operator => FormulaOperator.Multiply;
- public FormulaType Type => FormulaType.Virtual;
- }
- [Caption("Items")]
- [UserTracking(typeof(Job))]
- public class JobRequisitionItem : DimensionedEntity<StockDimensions>, IRemotable, IPersistent, IOneToMany<JobRequisition>,
- ILicense<ProjectManagementLicense>, IJobMaterial
- {
- [EntityRelationship(DeleteAction.Cascade)]
- public JobLink Job { get; set; }
-
- [EntityRelationship(DeleteAction.Cascade)]
- public JobRequisitionLink Requisition { get; set; }
- [EntityRelationship(DeleteAction.SetNull)]
- [EditorSequence(0)]
- public ProductLink Product { get; set; }
- [EditorSequence(1)]
- [MemoEditor]
- public string Notes { get; set; }
- [EditorSequence(2)]
- public ProductStyleLink Style { get; set; }
- [EditorSequence(3)]
- public double Qty { get; set; }
- [NullEditor]
- [Obsolete("Replaced with Dimensions", true)]
- public double UnitSize { get; set; }
-
- [EditorSequence(4)]
- public override StockDimensions Dimensions { get; set; }
- [EditorSequence(5)]
- public SupplierLink Supplier { get; set; }
- [DoubleEditor(Editable = Editable.Hidden)]
- [Formula(typeof(JobRequisitionItemTotalQtyFormula))]
- public double TotalQty { get; set; }
- [EnumLookupEditor(typeof(JobRequisitionItemStatus))]
- public JobRequisitionItemStatus Status { get; set; }
- [IntegerEditor(Visible = Visible.Default, Editable = Editable.Disabled)] //currently no way to disable editor but we need the columns
- public PurchaseOrderItemLink PurchaseOrderItem { get; set; }
- protected override void Init()
- {
- base.Init();
- Job = new JobLink();
- Requisition = new JobRequisitionLink();
- Product = new ProductLink();
- //Product.PropertyChanged += Product_PropertyChanged;
- //Product.DefaultStyle.PropertyChanged += DefaultStyle_PropertyChanged;
- Style = new ProductStyleLink();
- Status = JobRequisitionItemStatus.NotChecked;
- PurchaseOrderItem = new PurchaseOrderItemLink();
- Supplier = new SupplierLink();
- Dimensions = new StockDimensions();
- }
- // private void DefaultStyle_PropertyChanged(object sender, PropertyChangedEventArgs e)
- // {
- // Style = Product.DefaultStyle;
- // }
- //private void Product_PropertyChanged(object sender, PropertyChangedEventArgs e)
- //{
- // if (new Column<Product>(x=>x.UnitSize).IsEqualTo(e.PropertyName))
- // UnitSize = Product.UnitSize;
- // //else if (e.PropertyName.Equals("DefaultStyle"))
- // // Style = Product.DefaultStyle;
- //}
- private static Column<JobRequisitionItem> dimensions = new Column<JobRequisitionItem>(x => x.Product.Dimensions);
- private static Column<JobRequisitionItem> style = new Column<JobRequisitionItem>(x => x.Product.DefaultStyle);
-
- private bool bChanging;
- protected override void DoPropertyChanged(string name, object before, object after)
- {
- if (bChanging)
- return;
- bChanging = true;
- if (dimensions.IsParentOf(name))
- {
- String col = String.Join(".", name.Split('.').Skip(1));
- CoreUtils.SetPropertyValue(this, col, after);
- }
- else if (dimensions.IsParentOf(name))
- {
- String col = String.Join(".", name.Split('.').Skip(1));
- CoreUtils.SetPropertyValue(this, col, after);
- }
- bChanging = false;
- base.DoPropertyChanged(name, before, after);
- }
- }
- }
|