/// <summary> /// Loads the pick list from the pick face location /// this is only called if a pick face location is set for the item /// </summary> /// <param name="itemId">The item id.</param> /// <param name="unitID">The unit ID.</param> /// <param name="innitallyApprovedQuantity">The innitally approved quantity.</param> /// <param name="fromstore">The fromstore.</param> /// <param name="isDeliveryNote">if set to <c>true</c> [is delivery note].</param> private void LoadFromPickFace(int itemId, int? unitID, decimal innitallyApprovedQuantity, int fromstore, bool isDeliveryNote) { decimal approvedQuantity = innitallyApprovedQuantity; var pf = new PickFace(); pf.LoadPickFaceFor(itemId, fromstore); if (pf.RowCount > 0) { var rp = new ReceivePallet(); rp.LoadPickFaceAllItemsReadyToDispatch(itemId, unitID, fromstore); var im = new ItemManufacturer(); var imff = new ItemManufacturer(); if (pf.IsColumnNull("Balance")) { pf.Balance = 0; pf.Save(); } if (pf.Balance >= approvedQuantity) { while (!rp.EOF) { int manufId = Convert.ToInt32(rp.GetColumn("ManufacturerID")); im.LoadIMbyLevel(itemId, manufId, Convert.ToInt32(rp.GetColumn("BoxLevel"))); int boxLevel = im.PackageLevel; int buinsku = Convert.ToInt32(rp.GetColumn("QtyPerPack"));//imff.LoadSKUUnit(itemId, manufId); while (boxLevel >= 0 && approvedQuantity > 0) { long dispatchQuantity = Convert.ToInt32(rp.GetColumn("DispatchableStock")); int bUsinBoxLevel = im.QuantityInBasicUnit; decimal dispatch = (approvedQuantity / bUsinBoxLevel) * bUsinBoxLevel; if (dispatch > dispatchQuantity) { dispatch = dispatchQuantity; } while (dispatch / bUsinBoxLevel < 1 && im.PackageLevel > 0) { im.LoadIMbyLevel(im.ItemID, im.ManufacturerID, im.PackageLevel - 1); bUsinBoxLevel = im.QuantityInBasicUnit; } if (dispatch > 0) { _pickList.ImportRow(rp.CurrentDataRow); // pick the currently inserted entry and adjust all the numbers in it. DataRow dr = _pickList.Rows[_pickList.Rows.Count - 1]; // only Adjust the entries that matter to the pick list SetPriceAndQuantity(dr, dispatch, buinsku, rp, itemId, isDeliveryNote); approvedQuantity -= dispatch; } boxLevel--; im.LoadIMbyLevel(itemId, manufId, boxLevel); } rp.MoveNext(); } } } }