protected override void SaveRelative(WarehouseTransfer warehouseTransfer, SaveRelativeOption saveRelativeOption) { base.SaveRelative(warehouseTransfer, saveRelativeOption); if (warehouseTransfer.OneStep) { GRHelperService grHelperService = new GRHelperService(this.GetGROption(warehouseTransfer.NMVNTaskID), this.GenericWithDetailRepository.TotalSmartPortalEntities, this.UserID); IGoodsReceiptAPIRepository goodsReceiptAPIRepository = new GoodsReceiptAPIRepository(this.GenericWithDetailRepository.TotalSmartPortalEntities); if (saveRelativeOption == SaveRelativeOption.Update) { IGoodsReceiptDTO goodsReceiptDTO = grHelperService.NewGoodsReceiptDTO(); goodsReceiptDTO.EntryDate = warehouseTransfer.EntryDate; goodsReceiptDTO.GoodsReceiptTypeID = (int)GlobalEnums.GoodsReceiptTypeID.WarehouseTransfer; goodsReceiptDTO.WarehouseTransferID = warehouseTransfer.WarehouseTransferID; goodsReceiptDTO.ShiftID = warehouseTransfer.ShiftID; goodsReceiptDTO.OneStep = warehouseTransfer.OneStep; goodsReceiptDTO.Warehouse = new TotalDTO.Commons.WarehouseBaseDTO() { WarehouseID = warehouseTransfer.WarehouseReceiptID }; goodsReceiptDTO.WarehouseIssue = new TotalDTO.Commons.WarehouseBaseDTO() { WarehouseID = warehouseTransfer.WarehouseID }; goodsReceiptDTO.StorekeeperID = warehouseTransfer.StorekeeperID; goodsReceiptDTO.PreparedPersonID = warehouseTransfer.PreparedPersonID; goodsReceiptDTO.ApproverID = warehouseTransfer.PreparedPersonID; goodsReceiptDTO.Purposes = warehouseTransfer.Caption; goodsReceiptDTO.Description = warehouseTransfer.Description; goodsReceiptDTO.Remarks = warehouseTransfer.Remarks; goodsReceiptDTO.Approved = warehouseTransfer.Approved; goodsReceiptDTO.ApprovedDate = warehouseTransfer.ApprovedDate; List <GoodsReceiptPendingWarehouseTransferDetail> pendingWarehouseTransferDetails = goodsReceiptAPIRepository.GetPendingWarehouseTransferDetails((int)goodsReceiptDTO.NMVNTaskID, null, goodsReceiptDTO.WarehouseTransferID, goodsReceiptDTO.WarehouseID, goodsReceiptDTO.WarehouseIssueID, null, goodsReceiptDTO.OneStep); foreach (GoodsReceiptPendingWarehouseTransferDetail pendingWarehouseTransferDetail in pendingWarehouseTransferDetails) { GoodsReceiptDetailDTO goodsReceiptDetailDTO = new GoodsReceiptDetailDTO() { GoodsReceiptID = goodsReceiptDTO.GoodsReceiptID, WarehouseTransferID = pendingWarehouseTransferDetail.WarehouseTransferID, WarehouseTransferDetailID = pendingWarehouseTransferDetail.WarehouseTransferDetailID, WarehouseTransferReference = pendingWarehouseTransferDetail.WarehouseTransferReference, WarehouseTransferEntryDate = pendingWarehouseTransferDetail.WarehouseTransferEntryDate, GoodsReceiptReference = pendingWarehouseTransferDetail.GoodsReceiptReference, GoodsReceiptEntryDate = pendingWarehouseTransferDetail.GoodsReceiptEntryDate, BatchID = pendingWarehouseTransferDetail.BatchID, BatchEntryDate = pendingWarehouseTransferDetail.BatchEntryDate, CommodityID = pendingWarehouseTransferDetail.CommodityID, CommodityCode = pendingWarehouseTransferDetail.CommodityCode, CommodityName = pendingWarehouseTransferDetail.CommodityName, CommodityTypeID = pendingWarehouseTransferDetail.CommodityTypeID, LabID = pendingWarehouseTransferDetail.LabID, Barcode = pendingWarehouseTransferDetail.Barcode, BatchCode = pendingWarehouseTransferDetail.BatchCode, SealCode = pendingWarehouseTransferDetail.SealCode, LabCode = pendingWarehouseTransferDetail.LabCode, ProductionDate = pendingWarehouseTransferDetail.ProductionDate, ExpiryDate = pendingWarehouseTransferDetail.ExpiryDate, BinLocationID = pendingWarehouseTransferDetail.BinLocationID, BinLocationCode = pendingWarehouseTransferDetail.BinLocationCode, UnitWeight = pendingWarehouseTransferDetail.UnitWeight, TareWeight = pendingWarehouseTransferDetail.TareWeight, QuantityRemains = (decimal)pendingWarehouseTransferDetail.QuantityRemains, Quantity = (decimal)pendingWarehouseTransferDetail.QuantityRemains, }; goodsReceiptDTO.ViewDetails.Add(goodsReceiptDetailDTO); } goodsReceiptDTO.TotalQuantity = goodsReceiptDTO.GetTotalQuantity(); grHelperService.Save(goodsReceiptDTO); } if (saveRelativeOption == SaveRelativeOption.Undo) {//NOTES: THIS UNDO REQUIRE: JUST SAVE ONLY ONE GoodsReceipt FOR AN WarehouseTransfer int?goodsReceiptID = goodsReceiptAPIRepository.GetGoodsReceiptID(null, null, warehouseTransfer.WarehouseTransferID, null); grHelperService.Delete(goodsReceiptID); } } }
protected override void SaveRelative(WarehouseAdjustment warehouseAdjustment, SaveRelativeOption saveRelativeOption) { base.SaveRelative(warehouseAdjustment, saveRelativeOption); if (warehouseAdjustment.HasPositiveLine) { GRHelperService grHelperService = new GRHelperService(this.GetGROption(warehouseAdjustment.NMVNTaskID), this.GenericWithDetailRepository.TotalSmartPortalEntities, this.UserID); IGoodsReceiptAPIRepository goodsReceiptAPIRepository = new GoodsReceiptAPIRepository(this.GenericWithDetailRepository.TotalSmartPortalEntities); if (saveRelativeOption == SaveRelativeOption.Update) { IGoodsReceiptDTO goodsReceiptDTO = grHelperService.NewGoodsReceiptDTO(); goodsReceiptDTO.EntryDate = warehouseAdjustment.EntryDate; goodsReceiptDTO.ShiftID = 1; // warehouseAdjustment.ShiftID; goodsReceiptDTO.GoodsReceiptTypeID = (int)GlobalEnums.GoodsReceiptTypeID.WarehouseAdjustments; goodsReceiptDTO.WarehouseAdjustmentID = warehouseAdjustment.WarehouseAdjustmentID; goodsReceiptDTO.Warehouse = new TotalDTO.Commons.WarehouseBaseDTO() { WarehouseID = warehouseAdjustment.WarehouseReceiptID }; goodsReceiptDTO.Customer = new TotalDTO.Commons.CustomerBaseDTO() { CustomerID = warehouseAdjustment.CustomerID }; goodsReceiptDTO.StorekeeperID = warehouseAdjustment.StorekeeperID; goodsReceiptDTO.PreparedPersonID = warehouseAdjustment.PreparedPersonID; goodsReceiptDTO.ApproverID = warehouseAdjustment.PreparedPersonID; goodsReceiptDTO.Purposes = warehouseAdjustment.AdjustmentJobs; goodsReceiptDTO.Description = warehouseAdjustment.Description; goodsReceiptDTO.Remarks = warehouseAdjustment.Remarks; goodsReceiptDTO.Approved = warehouseAdjustment.Approved; goodsReceiptDTO.ApprovedDate = warehouseAdjustment.ApprovedDate; List <PendingWarehouseAdjustmentDetail> pendingWarehouseAdjustmentDetails = goodsReceiptAPIRepository.GetPendingWarehouseAdjustmentDetails(warehouseAdjustment.LocationID, null, goodsReceiptDTO.WarehouseAdjustmentID, goodsReceiptDTO.WarehouseID, null, false); foreach (PendingWarehouseAdjustmentDetail pendingWarehouseAdjustmentDetail in pendingWarehouseAdjustmentDetails) { GoodsReceiptDetailDTO goodsReceiptDetailDTO = new GoodsReceiptDetailDTO() { GoodsReceiptID = goodsReceiptDTO.GoodsReceiptID, WarehouseAdjustmentID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentID, WarehouseAdjustmentDetailID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentDetailID, WarehouseAdjustmentReference = pendingWarehouseAdjustmentDetail.PrimaryReference, WarehouseAdjustmentEntryDate = pendingWarehouseAdjustmentDetail.PrimaryEntryDate, WarehouseAdjustmentTypeID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentTypeID, BatchID = pendingWarehouseAdjustmentDetail.BatchID, BatchCode = pendingWarehouseAdjustmentDetail.BatchCode, BatchEntryDate = pendingWarehouseAdjustmentDetail.BatchEntryDate, CommodityID = pendingWarehouseAdjustmentDetail.CommodityID, CommodityCode = pendingWarehouseAdjustmentDetail.CommodityCode, CommodityName = pendingWarehouseAdjustmentDetail.CommodityName, LabID = -1, QuantityRemains = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains, Quantity = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains, }; goodsReceiptDTO.ViewDetails.Add(goodsReceiptDetailDTO); } goodsReceiptDTO.TotalQuantity = goodsReceiptDTO.GetTotalQuantity(); grHelperService.Save(goodsReceiptDTO); } if (saveRelativeOption == SaveRelativeOption.Undo) {//NOTES: THIS UNDO REQUIRE: JUST SAVE ONLY ONE GoodsReceipt FOR AN WarehouseAdjustment int?goodsReceiptID = goodsReceiptAPIRepository.GetGoodsReceiptID(null, null, null, warehouseAdjustment.WarehouseAdjustmentID); grHelperService.Delete(goodsReceiptID); } } }
protected override void SaveRelative(WarehouseAdjustment warehouseAdjustment, SaveRelativeOption saveRelativeOption) { base.SaveRelative(warehouseAdjustment, saveRelativeOption); if (warehouseAdjustment.HasPositiveLine) { IGoodsReceiptAPIRepository goodsReceiptAPIRepository = new GoodsReceiptAPIRepository(this.GenericWithDetailRepository.TotalSmartCodingEntities); IGoodsReceiptBaseService goodsReceiptBaseService = new GoodsReceiptBaseService(new GoodsReceiptRepository(this.GenericWithDetailRepository.TotalSmartCodingEntities)); //VERY IMPORTANT: THE BaseService.UserID IS AUTOMATICALLY SET BY CustomControllerAttribute OF CONTROLLER, ONLY WHEN BaseService IS INITIALIZED BY CONTROLLER. BUT HERE, THE this.goodsReceiptBaseService IS INITIALIZED BY VehiclesInvoiceService => SO SHOULD SET goodsReceiptBaseService.UserID = this.UserID goodsReceiptBaseService.UserID = this.UserID; if (saveRelativeOption == SaveRelativeOption.Update) { GoodsReceiptDTO goodsReceiptDTO = new GoodsReceiptDTO(); goodsReceiptDTO.EntryDate = warehouseAdjustment.EntryDate; goodsReceiptDTO.WarehouseID = warehouseAdjustment.WarehouseReceiptID; goodsReceiptDTO.WarehouseAdjustmentID = warehouseAdjustment.WarehouseAdjustmentID; goodsReceiptDTO.GoodsReceiptTypeID = (int)GlobalEnums.GoodsReceiptTypeID.WarehouseAdjustments; goodsReceiptDTO.StorekeeperID = warehouseAdjustment.StorekeeperID; goodsReceiptDTO.Description = warehouseAdjustment.Description; goodsReceiptDTO.Remarks = warehouseAdjustment.Remarks; List <PendingWarehouseAdjustmentDetail> pendingWarehouseAdjustmentDetails = goodsReceiptAPIRepository.GetPendingWarehouseAdjustmentDetails(warehouseAdjustment.LocationID, null, warehouseAdjustment.WarehouseAdjustmentID, warehouseAdjustment.WarehouseID, null, false); foreach (PendingWarehouseAdjustmentDetail pendingWarehouseAdjustmentDetail in pendingWarehouseAdjustmentDetails) { GoodsReceiptDetailDTO goodsReceiptDetailDTO = new GoodsReceiptDetailDTO() { GoodsReceiptID = goodsReceiptDTO.GoodsReceiptID, WarehouseAdjustmentID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentID, WarehouseAdjustmentDetailID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentDetailID, WarehouseAdjustmentReference = pendingWarehouseAdjustmentDetail.PrimaryReference, WarehouseAdjustmentEntryDate = pendingWarehouseAdjustmentDetail.PrimaryEntryDate, BatchID = pendingWarehouseAdjustmentDetail.BatchID, BatchEntryDate = pendingWarehouseAdjustmentDetail.BatchEntryDate, BinLocationID = pendingWarehouseAdjustmentDetail.BinLocationID, BinLocationCode = pendingWarehouseAdjustmentDetail.BinLocationCode, CommodityID = pendingWarehouseAdjustmentDetail.CommodityID, CommodityCode = pendingWarehouseAdjustmentDetail.CommodityCode, CommodityName = pendingWarehouseAdjustmentDetail.CommodityName, Quantity = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains, LineVolume = (decimal)pendingWarehouseAdjustmentDetail.LineVolumeRemains, PackID = pendingWarehouseAdjustmentDetail.PackID, PackCode = pendingWarehouseAdjustmentDetail.PackCode, CartonID = pendingWarehouseAdjustmentDetail.CartonID, CartonCode = pendingWarehouseAdjustmentDetail.CartonCode, PalletID = pendingWarehouseAdjustmentDetail.PalletID, PalletCode = pendingWarehouseAdjustmentDetail.PalletCode, PackCounts = pendingWarehouseAdjustmentDetail.PackCounts, CartonCounts = pendingWarehouseAdjustmentDetail.CartonCounts, PalletCounts = pendingWarehouseAdjustmentDetail.PalletCounts }; goodsReceiptDTO.ViewDetails.Add(goodsReceiptDetailDTO); } goodsReceiptBaseService.Save(goodsReceiptDTO, true); } if (saveRelativeOption == SaveRelativeOption.Undo) {//NOTES: THIS UNDO REQUIRE: JUST SAVE ONLY ONE GoodsReceipt FOR AN WarehouseAdjustment int?goodsReceiptID = goodsReceiptAPIRepository.GetGoodsReceiptIDofWarehouseAdjustment(warehouseAdjustment.WarehouseAdjustmentID); if (goodsReceiptID != null) { goodsReceiptBaseService.Delete((int)goodsReceiptID, true); } else { throw new Exception("Lỗi không tìm thấy phiếu nhập kho cũ của phiếu điều chỉnh kho này!" + "\r\n" + "\r\n" + "Vui lòng kiểm tra lại dữ liệu trước khi tiếp tục."); } } } }
protected override void SaveRelative(WarehouseAdjustment warehouseAdjustment, SaveRelativeOption saveRelativeOption) { base.SaveRelative(warehouseAdjustment, saveRelativeOption); if (warehouseAdjustment.HasPositiveLine) { IGoodsReceiptAPIRepository goodsReceiptAPIRepository = new GoodsReceiptAPIRepository(this.GenericWithDetailRepository.TotalSmartPortalEntities); if (saveRelativeOption == SaveRelativeOption.Update) { IGoodsReceiptDTO goodsReceiptDTO = this.NewGoodsReceiptDTO(warehouseAdjustment.NMVNTaskID); goodsReceiptDTO.EntryDate = warehouseAdjustment.EntryDate; goodsReceiptDTO.Warehouse = new TotalDTO.Commons.WarehouseBaseDTO() { WarehouseID = warehouseAdjustment.WarehouseReceiptID }; goodsReceiptDTO.WarehouseAdjustmentID = warehouseAdjustment.WarehouseAdjustmentID; goodsReceiptDTO.GoodsReceiptTypeID = (int)GlobalEnums.GoodsReceiptTypeID.WarehouseAdjustments; goodsReceiptDTO.StorekeeperID = warehouseAdjustment.StorekeeperID; goodsReceiptDTO.PreparedPersonID = warehouseAdjustment.PreparedPersonID; goodsReceiptDTO.ApproverID = warehouseAdjustment.PreparedPersonID; goodsReceiptDTO.Customer = new TotalDTO.Commons.CustomerBaseDTO() { CustomerID = warehouseAdjustment.CustomerID }; goodsReceiptDTO.Purposes = warehouseAdjustment.AdjustmentJobs; goodsReceiptDTO.Description = warehouseAdjustment.Description; goodsReceiptDTO.Remarks = warehouseAdjustment.Remarks; goodsReceiptDTO.Approved = warehouseAdjustment.Approved; goodsReceiptDTO.ApprovedDate = warehouseAdjustment.ApprovedDate; List <PendingWarehouseAdjustmentDetail> pendingWarehouseAdjustmentDetails = goodsReceiptAPIRepository.GetPendingWarehouseAdjustmentDetails(warehouseAdjustment.LocationID, null, warehouseAdjustment.WarehouseAdjustmentID, warehouseAdjustment.WarehouseReceiptID, null, false); foreach (PendingWarehouseAdjustmentDetail pendingWarehouseAdjustmentDetail in pendingWarehouseAdjustmentDetails) { GoodsReceiptDetailDTO goodsReceiptDetailDTO = new GoodsReceiptDetailDTO() { GoodsReceiptID = goodsReceiptDTO.GoodsReceiptID, WarehouseAdjustmentID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentID, WarehouseAdjustmentDetailID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentDetailID, WarehouseAdjustmentReference = pendingWarehouseAdjustmentDetail.PrimaryReference, WarehouseAdjustmentEntryDate = pendingWarehouseAdjustmentDetail.PrimaryEntryDate, WarehouseAdjustmentTypeID = pendingWarehouseAdjustmentDetail.WarehouseAdjustmentTypeID, BatchID = pendingWarehouseAdjustmentDetail.BatchID, BatchEntryDate = pendingWarehouseAdjustmentDetail.BatchEntryDate, CommodityID = pendingWarehouseAdjustmentDetail.CommodityID, CommodityCode = pendingWarehouseAdjustmentDetail.CommodityCode, CommodityName = pendingWarehouseAdjustmentDetail.CommodityName, QuantityRemains = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains, Quantity = (decimal)pendingWarehouseAdjustmentDetail.QuantityRemains, }; goodsReceiptDTO.ViewDetails.Add(goodsReceiptDetailDTO); } goodsReceiptDTO.TotalQuantity = goodsReceiptDTO.GetTotalQuantity(); this.DoSaveOrDeleteGoodsReceipt(warehouseAdjustment.NMVNTaskID, true, goodsReceiptDTO, null); } if (saveRelativeOption == SaveRelativeOption.Undo) {//NOTES: THIS UNDO REQUIRE: JUST SAVE ONLY ONE GoodsReceipt FOR AN WarehouseAdjustment int?goodsReceiptID = goodsReceiptAPIRepository.GetGoodsReceiptIDofWarehouseAdjustment(warehouseAdjustment.WarehouseAdjustmentID); if (goodsReceiptID != null) { this.DoSaveOrDeleteGoodsReceipt(warehouseAdjustment.NMVNTaskID, false, null, goodsReceiptID); } else { throw new Exception("Lỗi không tìm thấy phiếu nhập kho cũ của phiếu điều chỉnh kho này!" + "\r\n" + "\r\n" + "Vui lòng kiểm tra lại dữ liệu trước khi tiếp tục."); } } } }