private void FixupCommodityType(CommodityType previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.WarehouseOutLines.Contains(this)) { previousValue.WarehouseOutLines.Remove(this); } if (CommodityType != null) { if (!CommodityType.WarehouseOutLines.Contains(this)) { CommodityType.WarehouseOutLines.Add(this); } CommodityTypeId = CommodityType.Id; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("CommodityType") && (ChangeTracker.OriginalValues["CommodityType"] == CommodityType)) { ChangeTracker.OriginalValues.Remove("CommodityType"); } else { ChangeTracker.RecordOriginalValue("CommodityType", previousValue); } if (CommodityType != null && !CommodityType.ChangeTracker.ChangeTrackingEnabled) { CommodityType.StartTracking(); } } }
public DeliveryLineVM(Commodity commodity, CommodityType commodityType, Brand brand, Specification specification, List<DeliveryLine> deliveryLines, List<DeliveryLine> addDeliveryLines,DeliveryType deliveryType,decimal? qty) { ObjectId = 0; DeliveryType = deliveryType; AllDeliveryPersonList = new List<WarehouseOutDeliveryPerson>(); AddDeliveryPersonList = new List<WarehouseOutDeliveryPerson>(); DeliveryLines = deliveryLines; AddedDeliveryLines = addDeliveryLines; Commodity = commodity; CommodityId = commodity.Id; CommodityTypeId = commodityType.Id; _brandId = brand == null ? 0 : brand.Id; SpecificationId = specification == null ? 0 : specification.Id; _startStatus = true; LoadCommodityType(); LoadCountry(); LoadStatus(); LoadDocumentLineEnableProperty(ObjectId); if (deliveryLines == null || deliveryLines.Count == 0) { //第一次新增 if (deliveryType == DeliveryType.ExternalTDBOL || deliveryType == DeliveryType.ExternalTDWW) { NetWeight = qty; GrossWeight = qty; } else if (deliveryType == DeliveryType.InternalTDBOL || deliveryType == DeliveryType.InternalTDWW) { NetWeight = qty; VerifiedWeight = qty; } } PropertyChanged += OnPropertyChanged; }