private void FixupWarehouseInLine(WarehouseInLine previousValue) { if (IsDeserializing) { return; } if (previousValue != null && previousValue.WarehouseOutLines.Contains(this)) { previousValue.WarehouseOutLines.Remove(this); } if (WarehouseInLine != null) { if (!WarehouseInLine.WarehouseOutLines.Contains(this)) { WarehouseInLine.WarehouseOutLines.Add(this); } WarehouseInLineId = WarehouseInLine.Id; } if (ChangeTracker.ChangeTrackingEnabled) { if (ChangeTracker.OriginalValues.ContainsKey("WarehouseInLine") && (ChangeTracker.OriginalValues["WarehouseInLine"] == WarehouseInLine)) { ChangeTracker.OriginalValues.Remove("WarehouseInLine"); } else { ChangeTracker.RecordOriginalValue("WarehouseInLine", previousValue); } if (WarehouseInLine != null && !WarehouseInLine.ChangeTracker.ChangeTrackingEnabled) { WarehouseInLine.StartTracking(); } } }
protected override void Update() { var warehouseInLine = new WarehouseInLine(); if (AllWarehouseInLines.Count > 0) { List<WarehouseInLine> lines = AllWarehouseInLines.Where(c => c.Id == ObjectId).ToList(); if (lines.Count > 0) { WarehouseInLine line = lines[0]; warehouseInLine.Id = line.Id; warehouseInLine.WarehouseInId = line.WarehouseInId; warehouseInLine.DeliveryLineId = DeliveryLineId; warehouseInLine.IsPBCleared = line.IsPBCleared; warehouseInLine.PBNo = PBNo; warehouseInLine.Quantity = Quantity; warehouseInLine.VerifiedQuantity = VerifiedQuantity; warehouseInLine.IsVerified = IsVerified; warehouseInLine.DeliveryLine = DeliveryLine; warehouseInLine.CommodityTypeId = SelectedCommodityTypeId; using ( var contractService = SvcClientManager.GetSvcClient<ContractServiceClient>(SvcType.ContractSvc)) { Contract contract = contractService.GetById(DeliveryLine.Delivery.Quota.ContractId); warehouseInLine.DeliveryLine.Delivery.Quota.Contract = contract; } using ( var commodityTypeService = SvcClientManager.GetSvcClient<CommodityTypeServiceClient>(SvcType.CommodityTypeSvc)) { CommodityType commodityType = commodityTypeService.GetById(SelectedCommodityTypeId); warehouseInLine.CommodityType = commodityType; } warehouseInLine.BrandId = BrandId; using (var brandService = SvcClientManager.GetSvcClient<BrandServiceClient>(SvcType.BrandSvc)) { Brand brand = brandService.GetById(BrandId); warehouseInLine.Brand = brand; } warehouseInLine.SpecificationId = SpecificationId; warehouseInLine.PackingQuantity = PackingQuantity; warehouseInLine.Comment = WarehouseInLineComment; AllWarehouseInLines.Remove(line); AllWarehouseInLines.Add(warehouseInLine); if (line.Id < 0) { if (AddWarehouseInLines.Count > 0) { WarehouseInLine addLine = AddWarehouseInLines.Where(c => c.Id == line.Id).ToList()[0]; AddWarehouseInLines.Remove(addLine); #region 新建对象去掉外键关联 防止数据溢出 var newAddLine = new WarehouseInLine { Id = warehouseInLine.Id, DeliveryLineId = warehouseInLine.DeliveryLineId, PBNo = warehouseInLine.PBNo, IsPBCleared = warehouseInLine.IsPBCleared, Quantity = warehouseInLine.Quantity, PackingQuantity = warehouseInLine.PackingQuantity, VerifiedQuantity = warehouseInLine.VerifiedQuantity, IsVerified = warehouseInLine.IsVerified, CommodityTypeId = warehouseInLine.CommodityTypeId, BrandId = warehouseInLine.BrandId, SpecificationId = warehouseInLine.SpecificationId, Comment = warehouseInLine.Comment, WarehouseInId = warehouseInLine.WarehouseInId }; #endregion AddWarehouseInLines.Add(newAddLine); } } else { if (UpdateWarehouseInLines.Count > 0) { List<WarehouseInLine> updateLines = UpdateWarehouseInLines.Where(c => c.Id == line.Id).ToList(); if (updateLines.Count > 0) { WarehouseInLine updateLine = updateLines[0]; UpdateWarehouseInLines.Remove(updateLine); } } #region 新建对象去掉外键关联 防止数据溢出 var newUpdateLine = new WarehouseInLine { Id = warehouseInLine.Id, DeliveryLineId = warehouseInLine.DeliveryLineId, PBNo = warehouseInLine.PBNo, IsPBCleared = warehouseInLine.IsPBCleared, Quantity = warehouseInLine.Quantity, PackingQuantity = warehouseInLine.PackingQuantity, VerifiedQuantity = warehouseInLine.VerifiedQuantity, IsVerified = warehouseInLine.IsVerified, CommodityTypeId = warehouseInLine.CommodityTypeId, BrandId = warehouseInLine.BrandId, SpecificationId = warehouseInLine.SpecificationId, Comment = warehouseInLine.Comment, WarehouseInId = warehouseInLine.WarehouseInId }; #endregion UpdateWarehouseInLines.Add(newUpdateLine); } } } }
protected override void Update() { var outLine = new WarehouseOutLine(); List<WarehouseOutLine> lines = WarehouseOutLines.Where(c => c.Id == ObjectId).ToList(); if (lines.Count > 0) { WarehouseOutLine line = lines[0]; outLine.Id = line.Id; outLine.WarehouseOutId = line.WarehouseOutId; outLine.IsVerified = IsVerified; outLine.PackingQuantity = PackingQuantity; outLine.Quantity = Quantity; outLine.VerifiedQuantity = VerifiedQuantity; outLine.WarehouseInLineId = WarehouseInLine.Id; using ( var warehouseInLineService = SvcClientManager.GetSvcClient<WarehouseInLineServiceClient>(SvcType.WarehouseInLineSvc)) { const string str = "it.Id = @p1"; var parameters = new List<object> { WarehouseInLine.Id }; List<WarehouseInLine> inLines = warehouseInLineService.Select(str, parameters, new List<string> { "DeliveryLine", "DeliveryLine.Delivery.Quota.Commodity" }); if (inLines.Count > 0) { WarehouseInLine inLine = inLines[0]; outLine.WarehouseInLine = inLine; } } outLine.Comment = Comment; outLine.CommodityTypeId = CommodityTypeId; using ( var commodityTypeService = SvcClientManager.GetSvcClient<CommodityTypeServiceClient>(SvcType.CommodityTypeSvc)) { CommodityType commodityType = commodityTypeService.GetById(CommodityTypeId); outLine.CommodityType = commodityType; } outLine.BrandId = BrandId; using (var brandService = SvcClientManager.GetSvcClient<BrandServiceClient>(SvcType.BrandSvc)) { Brand brand = brandService.GetById(BrandId); outLine.Brand = brand; } outLine.SpecificationId = SpecificationId; using ( var specificationService = SvcClientManager.GetSvcClient<SpecificationServiceClient>(SvcType.SpecificationSvc)) { Specification specification = specificationService.GetById(SpecificationId); outLine.Specification = specification; } //提货人信息 outLine.WarehouseOutDeliveryPersons.Clear(); foreach (WarehouseOutDeliveryPerson deliveryPerson in AllDeliveryPersonList) { outLine.WarehouseOutDeliveryPersons.Add(deliveryPerson); } if (ValidateAllLine(WarehouseOutLines, outLine)) { #region 更改对应入库单的清卡状态 if (line.Id > 0) { using ( var warehouseInLineService = SvcClientManager.GetSvcClient<WarehouseInLineServiceClient>(SvcType.WarehouseInLineSvc)) { var inLine = new WarehouseInLine(); const string str = "it.Id = @p1"; var parameter = new List<object> { line.WarehouseInLineId }; List<WarehouseInLine> inLines = warehouseInLineService.Select(str, parameter, new List<string> { "DeliveryLine.Delivery.Quota.Contract", "DeliveryLine.Delivery.Quota", "WarehouseIn", "DeliveryLine.Delivery", "DeliveryLine" }); if (inLines.Count > 0) { inLine = inLines[0]; inLine.IsPBCleared = IsPBClear; } if (line.WarehouseInLineId == WarehouseInLine.Id) { WarehouseInLines.Add(inLine); } else { const string strQuery = "it.Id = @p1"; var parameter1 = new List<object> { WarehouseInLine.Id }; List<WarehouseInLine> newLines = warehouseInLineService.Select(strQuery, parameter1, new List<string> { "DeliveryLine.Delivery.Quota.Contract", "DeliveryLine.Delivery.Quota", "WarehouseIn", "DeliveryLine.Delivery", "DeliveryLine" }); if (newLines.Count > 0) { WarehouseInLine newLine = newLines[0]; newLine.IsPBCleared = IsPBClear; WarehouseInLines.Add(newLine); } inLine.IsPBCleared = false; WarehouseInLines.Add(inLine); } } } else { List<WarehouseInLine> oldInLines = WarehouseInLines.Where(c => c.Id == line.WarehouseInLineId).ToList(); if (oldInLines.Count > 0) { WarehouseInLine oldInLine = oldInLines[0]; WarehouseInLines.Remove(oldInLine); } if (WarehouseInLines.Count > 0) { List<WarehouseInLine> inLines = WarehouseInLines.Where(c => c.Id == WarehouseInLine.Id).ToList(); if (inLines.Count > 0) { WarehouseInLine inLine = inLines[0]; WarehouseInLines.Remove(inLine); } } using ( var warehouseInLineService = SvcClientManager.GetSvcClient<WarehouseInLineServiceClient>(SvcType.WarehouseInLineSvc)) { const string strQuery = "it.Id = @p1"; var parameter1 = new List<object> { WarehouseInLine.Id }; List<WarehouseInLine> newLines = warehouseInLineService.Select(strQuery, parameter1, new List<string> { "DeliveryLine.Delivery.Quota.Contract", "DeliveryLine.Delivery.Quota", "WarehouseIn", "DeliveryLine.Delivery", "DeliveryLine" }); if (newLines.Count > 0) { WarehouseInLine newLine = newLines[0]; newLine.IsPBCleared = IsPBClear; WarehouseInLines.Add(newLine); } } } #endregion WarehouseOutLines.Remove(line); WarehouseOutLines.Add(outLine); if (line.Id < 0) { if (AddWarehouseOutLines.Count > 0) { List<WarehouseOutLine> addOutLines = AddWarehouseOutLines.Where(c => c.Id == line.Id).ToList(); if (addOutLines.Count > 0) { WarehouseOutLine addOutLine = addOutLines[0]; AddWarehouseOutLines.Remove(addOutLine); AddWarehouseOutLines.Add(outLine); } } } else { if (UpdateWarehouseOutLines.Count > 0) { List<WarehouseOutLine> updateOutLines = UpdateWarehouseOutLines.Where(c => c.Id == line.Id).ToList(); if (updateOutLines.Count > 0) { WarehouseOutLine updateOutLine = updateOutLines[0]; UpdateWarehouseOutLines.Remove(updateOutLine); } } UpdateWarehouseOutLines.Add(outLine); } } } }
protected override void Create() { var warehouseInLine = new WarehouseInLine(); if (AllWarehouseInLines.Count <= 0) { warehouseInLine.Id = -1; } else { var lineIdList = AllWarehouseInLines.Select(line => Math.Abs(line.Id)).ToList(); int maxID = lineIdList.Max(); warehouseInLine.Id = -(maxID + 1); } warehouseInLine.DeliveryLineId = DeliveryLineId; warehouseInLine.PBNo = PBNo; warehouseInLine.IsPBCleared = false; //新增清卡状态默认为false warehouseInLine.Quantity = Quantity; warehouseInLine.VerifiedQuantity = VerifiedQuantity; warehouseInLine.IsVerified = IsVerified; warehouseInLine.DeliveryLine = DeliveryLine; warehouseInLine.CommodityTypeId = SelectedCommodityTypeId; using (var contractService = SvcClientManager.GetSvcClient<ContractServiceClient>(SvcType.ContractSvc)) { Contract contract = contractService.GetById(DeliveryLine.Delivery.Quota.ContractId); warehouseInLine.DeliveryLine.Delivery.Quota.Contract = contract; } using ( var commodityTypeService = SvcClientManager.GetSvcClient<CommodityTypeServiceClient>(SvcType.CommodityTypeSvc)) { CommodityType commodityType = commodityTypeService.GetById(SelectedCommodityTypeId); warehouseInLine.CommodityType = commodityType; } warehouseInLine.BrandId = BrandId; using (var brandService = SvcClientManager.GetSvcClient<BrandServiceClient>(SvcType.BrandSvc)) { Brand brand = brandService.GetById(BrandId); warehouseInLine.Brand = brand; } warehouseInLine.SpecificationId = SpecificationId; warehouseInLine.PackingQuantity = PackingQuantity; warehouseInLine.Comment = WarehouseInLineComment; AllWarehouseInLines.Add(warehouseInLine); #region 新建对象去掉外键关联 防止数据溢出 var addLine = new WarehouseInLine { Id = warehouseInLine.Id, DeliveryLineId = warehouseInLine.DeliveryLineId, PBNo = warehouseInLine.PBNo, IsPBCleared = warehouseInLine.IsPBCleared, Quantity = warehouseInLine.Quantity, PackingQuantity = warehouseInLine.PackingQuantity, VerifiedQuantity = warehouseInLine.VerifiedQuantity, IsVerified = warehouseInLine.IsVerified, CommodityTypeId = warehouseInLine.CommodityTypeId, BrandId = warehouseInLine.BrandId, SpecificationId = warehouseInLine.SpecificationId, Comment = warehouseInLine.Comment }; #endregion AddWarehouseInLines.Add(addLine); }
protected override void Create() { var line = new WarehouseOutLine(); if (WarehouseOutLines.Count <= 0) { line.Id = -1; } else { var lineIdList = WarehouseOutLines.Select(lineId => Math.Abs(lineId.Id)).ToList(); int maxID = lineIdList.Max(); line.Id = -(maxID + 1); } line.IsVerified = IsVerified; line.PackingQuantity = PackingQuantity; line.Quantity = Quantity; line.VerifiedQuantity = VerifiedQuantity; line.WarehouseInLineId = WarehouseInLineId; using ( var warehouseInLineService = SvcClientManager.GetSvcClient<WarehouseInLineServiceClient>(SvcType.WarehouseInLineSvc)) { const string str = "it.Id = @p1"; var parameters = new List<object> { WarehouseInLineId }; List<WarehouseInLine> inLines = warehouseInLineService.Select(str, parameters, new List<string> { "DeliveryLine", "DeliveryLine.Delivery.Quota.Commodity" }); if (inLines.Count > 0) { WarehouseInLine inLine = inLines[0]; line.WarehouseInLine = inLine; } } line.Comment = Comment; line.CommodityTypeId = CommodityTypeId; using ( var commodityTypeService = SvcClientManager.GetSvcClient<CommodityTypeServiceClient>(SvcType.CommodityTypeSvc)) { CommodityType commodityType = commodityTypeService.GetById(CommodityTypeId); line.CommodityType = commodityType; } line.BrandId = BrandId; using (var brandService = SvcClientManager.GetSvcClient<BrandServiceClient>(SvcType.BrandSvc)) { Brand brand = brandService.GetById(BrandId); line.Brand = brand; } line.SpecificationId = SpecificationId; using ( var specificationService = SvcClientManager.GetSvcClient<SpecificationServiceClient>(SvcType.SpecificationSvc)) { Specification specification = specificationService.GetById(SpecificationId); line.Specification = specification; } //提货人信息 line.WarehouseOutDeliveryPersons.Clear(); foreach (WarehouseOutDeliveryPerson deliveryPerson in AllDeliveryPersonList) { line.WarehouseOutDeliveryPersons.Add(deliveryPerson); } #region 把新增的出库行对应的入库行更改清卡状态后的数据存到list里面 var newWarehouseInLine = new WarehouseInLine(); using ( var warehouseInLineService = SvcClientManager.GetSvcClient<WarehouseInLineServiceClient>(SvcType.WarehouseInLineSvc)) { const string str = "it.Id = @p1"; var parameter = new List<object> { WarehouseInLineId }; List<WarehouseInLine> inLines = warehouseInLineService.Select(str, parameter, new List<string> { "DeliveryLine.Delivery.Quota.Contract", "DeliveryLine.Delivery.Quota", "WarehouseIn", "DeliveryLine.Delivery", "DeliveryLine" }); if (inLines.Count > 0) { newWarehouseInLine = inLines[0]; newWarehouseInLine.IsPBCleared = IsPBClear; } } if (WarehouseInLines.Count > 0) { List<WarehouseInLine> warehouseInLines = WarehouseInLines.Where(c => c.Id == WarehouseInLineId).ToList(); if (warehouseInLines.Count > 0) { WarehouseInLine warehouseInLine = warehouseInLines[0]; WarehouseInLines.Remove(warehouseInLine); } } WarehouseInLines.Add(newWarehouseInLine); #endregion if (ValidateAllLine(WarehouseOutLines, line)) { WarehouseOutLines.Add(line); AddWarehouseOutLines.Add(line); } }