예제 #1
0
        private void WizardDetail_Load(object sender, EventArgs e)
        {
            try
            {
                GoodsReceiptAPIs goodsReceiptAPIs = new GoodsReceiptAPIs(CommonNinject.Kernel.Get <IGoodsReceiptAPIRepository>());
                this.goodsReceiptDetailAvailables = goodsReceiptAPIs.GetGoodsReceiptDetailAvailables(this.warehouseAdjustmentViewModel.LocationID, this.warehouseAdjustmentViewModel.WarehouseID, null, null, null, string.Join(",", this.warehouseAdjustmentViewModel.ViewDetails.Select(d => d.GoodsReceiptDetailID)), true, false);

                this.fastPendingPallets.SetObjects(goodsReceiptDetailAvailables.Where(w => w.PalletID != null));
                this.fastPendingCartons.SetObjects(goodsReceiptDetailAvailables.Where(w => w.CartonID != null));

                this.ShowRowCount(true, true);
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
예제 #2
0
        public override void Loading()
        {
            try
            {
                List <GoodsReceiptDetailAvailable> goodsReceiptDetailAvailables = goodsReceiptAPIs.GetGoodsReceiptDetailAvailables(this.LocationID, null, null, null, null, null, this.OnlyApproved, this.OnlyIssuable);

                this.fastAvailablePallets.SelectedObject = null; this.fastAvailablePallets.SelectedObjects = null;
                this.fastAvailableCartons.SelectedObject = null; this.fastAvailableCartons.SelectedObjects = null;

                this.fastAvailablePallets.SetObjects(goodsReceiptDetailAvailables.Where(w => w.PalletID != null));
                this.fastAvailableCartons.SetObjects(goodsReceiptDetailAvailables.Where(w => w.CartonID != null));

                this.ShowRowCount();

                base.Loading();
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
        }
예제 #3
0
        private void WizardDetail_Load(object sender, EventArgs e)
        {
            try
            {
                string commodityIDs = "";
                Dictionary <int, int> filterBatchPerCommodity = new Dictionary <int, int>();  //Dictionary with pair: [CommodityID, BatchID]

                if (this.fileName != null)
                {
                    foreach (IPendingPrimaryDetail ipendingPrimaryDetail in this.pendingPrimaryDetails)
                    {
                        if (commodityIDs.IndexOf(ipendingPrimaryDetail.CommodityID.ToString()) < 0)
                        {
                            commodityIDs = commodityIDs + (commodityIDs != "" ? "," : "") + ipendingPrimaryDetail.CommodityID.ToString();
                        }

                        if (ipendingPrimaryDetail.BatchID != null)
                        {
                            filterBatchPerCommodity[ipendingPrimaryDetail.CommodityID] = (int)ipendingPrimaryDetail.BatchID;
                        }
                    }
                }

                GoodsReceiptAPIs goodsReceiptAPIs = new GoodsReceiptAPIs(CommonNinject.Kernel.Get <IGoodsReceiptAPIRepository>());

                List <GoodsReceiptDetailAvailable>        goodsReceiptDetailAvailables = goodsReceiptAPIs.GetGoodsReceiptDetailAvailables(this.goodsIssueViewModel.LocationID, this.goodsIssueViewModel.WarehouseID, this.fileName == null ? this.pendingPrimaryDetail.CommodityID : (int?)null, this.fileName == null ? null : commodityIDs, this.fileName == null ? this.pendingPrimaryDetail.BatchID : (int?)null, string.Join(",", this.goodsIssueViewModel.ViewDetails.Select(d => d.GoodsReceiptDetailID)), true);
                IEnumerable <GoodsReceiptDetailAvailable> goodsReceiptPalletAvailables = null;
                IEnumerable <GoodsReceiptDetailAvailable> goodsReceiptCartonAvailables = null;
                IEnumerable <GoodsReceiptDetailAvailable> goodsReceiptPackAvailables   = null;

                List <MismatchedBarcode> mismatchedBarcodes = new List <MismatchedBarcode>();

                if (this.fileName == null)
                {
                    goodsReceiptDetailAvailables.Each(goodsReceiptDetailAvailable =>
                    {
                        goodsReceiptDetailAvailable.DeliveryAdviceID       = this.pendingPrimaryDetail.DeliveryAdviceID;
                        goodsReceiptDetailAvailable.DeliveryAdviceDetailID = this.pendingPrimaryDetail.DeliveryAdviceDetailID;

                        goodsReceiptDetailAvailable.TransferOrderID       = this.pendingPrimaryDetail.TransferOrderID;
                        goodsReceiptDetailAvailable.TransferOrderDetailID = this.pendingPrimaryDetail.TransferOrderDetailID;

                        goodsReceiptDetailAvailable.PrimaryReference = this.pendingPrimaryDetail.PrimaryReference;
                        goodsReceiptDetailAvailable.PrimaryEntryDate = this.pendingPrimaryDetail.PrimaryEntryDate;

                        goodsReceiptDetailAvailable.QuantityRemains   = (decimal)this.pendingPrimaryDetail.QuantityRemains;
                        goodsReceiptDetailAvailable.LineVolumeRemains = (decimal)this.pendingPrimaryDetail.LineVolumeRemains;
                    });

                    goodsReceiptPalletAvailables = goodsReceiptDetailAvailables.Where(w => w.PalletID != null);
                    goodsReceiptCartonAvailables = goodsReceiptDetailAvailables.Where(w => w.CartonID != null);
                    if (this.UsingPack)
                    {
                        goodsReceiptPackAvailables = goodsReceiptDetailAvailables.Where(w => w.PackID != null);
                    }
                }
                else
                {
                    string[] barcodes = System.IO.File.ReadAllLines(fileName);
                    if (barcodes.Count() > 0)
                    {
                        if (filterBatchPerCommodity.Count > 0) //Remove row that does not match pair: [CommodityID, BatchID]
                        {
                            foreach (KeyValuePair <int, int> change in filterBatchPerCommodity)
                            { //LƯU Ý: CÂU LỆNH SAU ĐÂY SẼ REMOVE TẤT CẢ CommodityID NOT MATCH WITH BatchID => DO ĐÓ: NẾU 1 D.A/ T.O: VỪA CÓ CHỈ ĐỊNH BATCH, VỪA KHÔNG CHỈ ĐỊNH BATCH => THÌ PHẢI IMPORT BATCH TRƯỚC, SAU ĐÓ IMPORT NON-BATCH SAU (HOẶC ĐƠN GIẢN HƠN LÀ TÁCH THÀNH 2 GOODSISSUE)
                                goodsReceiptDetailAvailables.RemoveAll(w => w.CommodityID == change.Key && w.BatchID != change.Value);
                            }
                        }

                        foreach (string barcode in barcodes)
                        {
                            GoodsReceiptDetailAvailable goodsReceiptDetailAvailable = goodsReceiptDetailAvailables.Find(w => (w.PalletCode == barcode || w.CartonCode == barcode || w.PackCode == barcode));
                            if (goodsReceiptDetailAvailable != null)
                            {
                                if (goodsReceiptDetailAvailable.IsSelected == false)
                                {
                                    IPendingPrimaryDetail pendingPrimaryDetail = this.pendingPrimaryDetails.ToList().Find(w => w.CommodityID == goodsReceiptDetailAvailable.CommodityID && (w.BatchID == null || w.BatchID == goodsReceiptDetailAvailable.BatchID) && (w.QuantityRemains - w.QuantityIssue) >= goodsReceiptDetailAvailable.QuantityAvailable && (w.LineVolumeRemains - w.LineVolumeIssue) >= goodsReceiptDetailAvailable.LineVolumeAvailable);
                                    if (pendingPrimaryDetail != null)
                                    {
                                        //WHEN THIS FORM IS LOADED, pendingPrimaryDetail.QuantityIssue AND pendingPrimaryDetail.LineVolumeIssue IS ALWAYS = 0. THESE PROPERTIES (QuantityIssue, LineVolumeIssue) ARE USED TO CHECK (w.QuantityRemains - w.QuantityIssue) > goodsReceiptDetailAvailable.QuantityAvailable && (w.LineVolumeRemains - w.LineVolumeIssue) > goodsReceiptDetailAvailable.LineVolumeAvailable. THESE PROPERTIES ARE USED FOR THIS PURPOSE ONLY
                                        pendingPrimaryDetail.QuantityIssue   = Math.Round(pendingPrimaryDetail.QuantityIssue + (decimal)goodsReceiptDetailAvailable.QuantityAvailable, GlobalEnums.rndQuantity, MidpointRounding.AwayFromZero);
                                        pendingPrimaryDetail.LineVolumeIssue = Math.Round(pendingPrimaryDetail.LineVolumeIssue + (decimal)goodsReceiptDetailAvailable.LineVolumeAvailable, GlobalEnums.rndVolume, MidpointRounding.AwayFromZero);

                                        goodsReceiptDetailAvailable.DeliveryAdviceID       = pendingPrimaryDetail.DeliveryAdviceID;
                                        goodsReceiptDetailAvailable.DeliveryAdviceDetailID = pendingPrimaryDetail.DeliveryAdviceDetailID;

                                        goodsReceiptDetailAvailable.TransferOrderID       = pendingPrimaryDetail.TransferOrderID;
                                        goodsReceiptDetailAvailable.TransferOrderDetailID = pendingPrimaryDetail.TransferOrderDetailID;

                                        goodsReceiptDetailAvailable.PrimaryReference = pendingPrimaryDetail.PrimaryReference;
                                        goodsReceiptDetailAvailable.PrimaryEntryDate = pendingPrimaryDetail.PrimaryEntryDate;

                                        goodsReceiptDetailAvailable.QuantityRemains   = (decimal)pendingPrimaryDetail.QuantityRemains;
                                        goodsReceiptDetailAvailable.LineVolumeRemains = (decimal)pendingPrimaryDetail.LineVolumeRemains;

                                        goodsReceiptDetailAvailable.IsSelected = true;
                                    }
                                    else
                                    {
                                        mismatchedBarcodes.Add(new MismatchedBarcode()
                                        {
                                            Barcode = barcode, Description = "Số lượng xuất vượt quá yêu cầu. Vui lòng kiểm tra lại.", QuantityAvailable = goodsReceiptDetailAvailable.QuantityAvailable, LineVolumeAvailable = goodsReceiptDetailAvailable.LineVolumeAvailable
                                        });
                                    }
                                }
                                else
                                {
                                    mismatchedBarcodes.Add(new MismatchedBarcode()
                                    {
                                        Barcode = barcode, Description = "Trùng mã vạch. Bạn đã quét mã vạch này nhiều lần?", QuantityAvailable = goodsReceiptDetailAvailable.QuantityAvailable, LineVolumeAvailable = goodsReceiptDetailAvailable.LineVolumeAvailable
                                    });
                                }
                            }
                            else
                            {
                                mismatchedBarcodes.Add(new MismatchedBarcode()
                                {
                                    Barcode = barcode, Description = "Không tìm thấy. Bạn đã xả pallet ra chưa?"
                                });
                            }
                        }
                    }

                    goodsReceiptPalletAvailables = goodsReceiptDetailAvailables.Where(w => w.PalletID != null && w.IsSelected == true);
                    goodsReceiptCartonAvailables = goodsReceiptDetailAvailables.Where(w => w.CartonID != null && w.IsSelected == true);
                    if (this.UsingPack)
                    {
                        goodsReceiptPackAvailables = goodsReceiptDetailAvailables.Where(w => w.PackID != null && w.IsSelected == true);
                    }
                }

                this.fastAvailablePallets.SetObjects(goodsReceiptPalletAvailables);
                this.fastAvailableCartons.SetObjects(goodsReceiptCartonAvailables);
                if (this.UsingPack)
                {
                    this.fastAvailablePacks.SetObjects(goodsReceiptPackAvailables);
                }
                if (this.fileName != null)
                {
                    this.fastMismatchedBarcodes.SetObjects(mismatchedBarcodes);
                }

                this.ShowRowCount();
            }
            catch (Exception exception)
            {
                ExceptionHandlers.ShowExceptionMessageBox(this, exception);
            }
            finally
            {
                this.pendingPrimaryDetails.Each(p => { p.QuantityIssue = 0; p.LineVolumeIssue = 0; });
            }
        }