/// <summary> /// Moves the balance. /// </summary> /// <param name="rpSource">The rp source.</param> /// <param name="rpDestination">The rp destination.</param> /// <param name="quantityToBeMoved">The quantity to be moved.</param> /// <exception cref="System.Exception"></exception> public static void MoveBalance(ReceivePallet rpSource, ReceivePallet rpDestination, long quantityToBeMoved) { TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr(); transaction.BeginTransaction(); try { //DropProcedureReceiveDocReceivePallet(); if (rpSource.Balance < quantityToBeMoved) { throw new Exception("Quantity to be moved must be less than or equal to the balance!"); } if (rpDestination.IsColumnNull("Balance")) { rpDestination.Balance = 0; } rpDestination.Balance += quantityToBeMoved; rpDestination.BoxSize = 0; rpDestination.IsOriginalReceive = rpSource.IsOriginalReceive; rpDestination.Save(); rpSource.BoxSize = 0; rpSource.Balance -= quantityToBeMoved; rpSource.Save(); //CreateProcedureReceiveDocReceivePallet(); transaction.CommitTransaction(); } catch { transaction.RollbackTransaction(); CreateProcedureReceiveDocReceivePallet(); } }
private void btnFixLocationStuff_Click(object sender, EventArgs e) { int storeID = Convert.ToInt32(lkStoreLocation.EditValue); BLL.ReceiveDoc rd = new BLL.ReceiveDoc(); rd.LoadReceivesForStores(storeID); while (!rd.EOF) { BLL.ReceivePallet rp = new BLL.ReceivePallet(); rp.LoadByReceiveDocID(rd.ID); decimal receivedQuantity = 0, balance = 0; if (rp.RowCount == 1)// rp.RowCount > 0) { while (!rp.EOF) { receivedQuantity += rp.IsColumnNull("ReceivedQuantity") ? 0 : rp.ReceivedQuantity; balance += rp.IsColumnNull("Balance") ? 0 : rp.Balance; rp.MoveNext(); } rp.Rewind(); while (!rp.EOF && rp.IsColumnNull("ReceivedQuantity")) { rp.MoveNext(); } if (rd.Quantity != receivedQuantity && rd.Quantity > receivedQuantity) { rp.ReceivedQuantity += (rd.Quantity - receivedQuantity); } if (rd.QuantityLeft != balance && rd.QuantityLeft > 0)//rd.QuantityLeft > balance) { rp.Balance += (rd.QuantityLeft - balance); } rp.Save(); } rd.MoveNext(); } XtraMessageBox.Show("Completed!"); }
/// <summary> /// Moves the balance. /// </summary> /// <param name="rpSource">The rp source.</param> /// <param name="rpDestination">The rp destination.</param> /// <param name="quantityToBeMoved">The quantity to be moved.</param> /// <exception cref="System.Exception"></exception> public static void MoveBalance(ReceivePallet rpSource, ReceivePallet rpDestination, long quantityToBeMoved) { TransactionMgr transaction = TransactionMgr.ThreadTransactionMgr(); transaction.BeginTransaction(); try { //DropProcedureReceiveDocReceivePallet(); if (rpSource.Balance < quantityToBeMoved) { throw new Exception("Quantity to be moved must be less than or equal to the balance!"); } if (rpDestination.IsColumnNull("Balance")) { rpDestination.Balance = 0; } rpDestination.Balance += quantityToBeMoved; rpDestination.BoxSize = 0; rpDestination.IsOriginalReceive = rpSource.IsOriginalReceive; rpDestination.Save(); rpSource.BoxSize = 0; rpSource.Balance -= quantityToBeMoved; rpSource.Save(); //CreateProcedureReceiveDocReceivePallet(); transaction.CommitTransaction(); } catch { transaction.RollbackTransaction(); CreateProcedureReceiveDocReceivePallet(); } }
private void OnReplenishClicked(object sender, EventArgs e) { PalletLocation pl = new PalletLocation(); PickFace pf = new PickFace(); DataRow dr = gridPickFaceStockLevelView.GetFocusedDataRow(); DataRow dr2 = gridReplenishmentChoiceView.GetFocusedDataRow(); if (dr2 != null) { // check if the replenishment is from allowed location. // if (!Convert.ToBoolean(dr2["CanReplenish"])) { XtraMessageBox.Show("Please choose replenishment from the first to expire items", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } pl.LoadByPrimaryKey(_palletLocationID); pf.LoadByPrimaryKey(_pickFaceID); if (pf.IsColumnNull("Balance")) { pf.Balance = 0; } if (pl.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.StorageTypeID = Convert.ToInt32(StorageType.PickFace); pallet.Save(); pl.PalletID = pallet.ID; pl.Save(); } ReceivePallet rp = new ReceivePallet(); ReceivePallet rp2 = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); rp.LoadByPrimaryKey(Convert.ToInt32(dr2["ReceivePalletID"])); rp2.AddNew(); rp2.IsOriginalReceive = false; rp2.PalletID = pl.PalletID; rp2.ReceiveID = rp.ReceiveID; rp2.BoxSize = rp.BoxSize; // calculate the new balance BLL.ItemManufacturer im = new BLL.ItemManufacturer(); im.LoadIMbyLevel(_designatedItemID, Convert.ToInt32(dr2["ManufacturerID"]),Convert.ToInt32(dr2["BoxSize"])); if (rp.IsColumnNull("ReservedStock")) { rp.ReservedStock = 0; } //if (rp.Balance - rp.ReservedStock < im.QuantityInBasicUnit ) //{ // XtraMessageBox.Show("You cannot replenish the pick face from this location because the items are reserved for Issue. Please replenish from another receive.","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); // return; //} BLL.ItemManufacturer imff = new BLL.ItemManufacturer(); imff.LoadOuterBoxForItemManufacturer(im.ItemID,im.ManufacturerID); if (imff.PackageLevel > im.PackageLevel && rp.Balance < imff.QuantityInBasicUnit) { rp2.Balance = rp.Balance; } else if (rp.Balance - rp.ReservedStock > im.QuantityInBasicUnit) { rp2.ReceivedQuantity = rp2.Balance = im.QuantityInBasicUnit; } else { rp2.Balance = rp.Balance; } rp2.ReservedStock = 0; rp.Balance -= rp2.Balance; if (rp.IsColumnNull("ReceivedQuantity")) { rp.ReceivedQuantity = rp.Balance + rp2.Balance; } rp.ReceivedQuantity -= rp2.Balance; rp.Save(); rp2.Save(); pl.Confirmed = false; pl.Save(); pf.Balance += Convert.ToInt32(rp2.Balance); pf.Save(); PalletLocation pl2 = new PalletLocation(); pl2.LoadLocationForPallet(rp.PalletID); rd.LoadByPrimaryKey(rp2.ReceiveID); // Now update the screen accordingly. dr["Balance"] = pf.Balance;// Convert.ToInt32(dr["Balance"]) + rp2.Balance; InternalTransfer it = new InternalTransfer(); it.AddNew(); it.ItemID = _designatedItemID; it.BoxLevel = im.PackageLevel; it.ExpireDate = rd.ExpDate; it.BatchNumber = rd.BatchNo; it.ManufacturerID = im.ManufacturerID; it.FromPalletLocationID = pl2.ID; it.ToPalletLocationID = _palletLocationID; it.IssuedDate = DateTimeHelper.ServerDateTime; it.QtyPerPack = im.QuantityInBasicUnit; it.Packs = 1; it.ReceiveDocID = rp.ReceiveID; it.QuantityInBU = it.Packs * it.QtyPerPack; it.Type = "PickFace"; it.Status = 0; it.Save(); BindPickFaceDetailAndReplenismehmnent(); XtraMessageBox.Show("Your Pick Face is updated, please print the replenishment list and confirm the stock movement", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Saves issue order details /// </summary> /// <param name="orderID"></param> /// <param name="dvPickListMakeup"></param> public void SavePickList(int orderID, DataView dvPickListMakeup, int userID) { //~ Check if This Order has a previous Printed Picklist with detail: Note a header only doesnt affect us! // var pickList = new PickList(); pickList.LoadByOrderID(orderID); if (pickList.RowCount > 0) { var pldetail = new PickListDetail(); pldetail.LoadByPickListID(pickList.ID); if (pldetail.RowCount > 0) { RemoveFakePartialCommitPickListDetails(orderID); var pickL = new PickList(); pickL.LoadByOrderID(orderID); if (pickL.RowCount > 0) { throw new Exception("Picklist has already been printed for this Order "); // This error has been apprearing for the last one year so funny! I hope it won't come again! day: 10/21/2014 @yido // } } } // Create a pick list entry Order ord = new Order(); ord.LoadByPrimaryKey(orderID); PickList pl = new PickList(); PalletLocation plocation = new PalletLocation(); plocation.LoadByPrimaryKey(Convert.ToInt32(dvPickListMakeup[0]["PalletLocationID"])); pl.AddNew(); pl.OrderID = orderID; pl.PickType = "Pick"; pl.PickedBy = userID; pl.IsConfirmed = false; pl.IssuedDate = DateTimeHelper.ServerDateTime; pl.SavedDate = DateTimeHelper.ServerDateTime; pl.PickedDate = DateTimeHelper.ServerDateTime; pl.IsWarehouseConfirmed = 0; pl.WarehouseID = plocation.WarehouseID; pl.Save(); PickListDetail pld = new PickListDetail(); ReceivePallet rp = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); PickFace pf = new PickFace(); foreach (DataRowView drv in dvPickListMakeup) { pld.AddNew(); pld.PickListID = pl.ID; pld.OrderDetailID = Convert.ToInt32(drv["OrderDetailID"]); pld.ItemID = Convert.ToInt32(drv["ItemID"]); pld.BatchNumber = (drv["BatchNo"].ToString()); if (drv["ExpDate"] != DBNull.Value) { pld.ExpireDate = Convert.ToDateTime(drv["ExpDate"]); } pld.ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]); pld.BoxLevel = Convert.ToInt32(drv["BoxLevel"]); pld.QtyPerPack = Convert.ToInt32(drv["QtyPerPack"]); pld.Packs = Convert.ToDecimal(drv["Pack"]); pld.PalletLocationID = Convert.ToInt32(drv["PalletLocationID"]); pld.QuantityInBU = Convert.ToDecimal(drv["QtyInBU"]); pld.ReceiveDocID = Convert.ToInt32(drv["ReceiveDocID"]); pld.ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]); if (drv["CalculatedCost"] != DBNull.Value) { pld.Cost = Convert.ToDouble(drv["CalculatedCost"]); } if (drv["UnitPrice"] != DBNull.Value) { pld.UnitPrice = Convert.ToDouble(drv["UnitPrice"]); } int ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]); rp.LoadByPrimaryKey(ReceivePalletID); pld.StoreID = Convert.ToInt32(drv["StoreID"]); if (drv["DeliveryNote"] != null) { pld.DeliveryNote = Convert.ToBoolean(drv["DeliveryNote"]); } else { pld.DeliveryNote = false; } if (rp.IsColumnNull("ReservedStock")) { rp.ReservedStock = Convert.ToDecimal(pld.QuantityInBU); } else { rp.ReservedStock += Convert.ToDecimal(pld.QuantityInBU); } if (drv["UnitID"] != DBNull.Value) { pld.UnitID = Convert.ToInt32(drv["UnitID"]); } plocation.LoadByPrimaryKey(Convert.ToInt32(drv["PalletLocationID"])); pld.PhysicalStoreID = plocation.PhysicalStoreID; rp.Save(); if (drv["StorageTypeID"].ToString() == StorageType.PickFace) { pf.LoadByPalletLocation(Convert.ToInt32(drv["PalletLocationID"])); //pf.Balance -= Convert.ToDecimal(pld.QuantityInBU); pf.Save(); } } pld.Save(); ord.ChangeStatus(OrderStatus.Constant.PICK_LIST_GENERATED, CurrentContext.UserId); ord.Save(); }
/// <summary> /// Saves issue order details /// </summary> /// <param name="orderID"></param> /// <param name="dvPickListMakeup"></param> public void SavePickList(int orderID, DataView dvPickListMakeup, int userID) { //~ Check if This Order has a previous Printed Picklist with detail: Note a header only doesnt affect us! // var pickList = new PickList(); pickList.LoadByOrderID(orderID); if(pickList.RowCount>0) { var pldetail = new PickListDetail(); pldetail.LoadByPickListID(pickList.ID); if (pldetail.RowCount > 0) { RemoveFakePartialCommitPickListDetails(orderID); var pickL = new PickList(); pickL.LoadByOrderID(orderID); if (pickL.RowCount > 0) { throw new Exception("Picklist has already been printed for this Order "); // This error has been apprearing for the last one year so funny! I hope it won't come again! day: 10/21/2014 @yido // } } } // Create a pick list entry Order ord = new Order(); ord.LoadByPrimaryKey(orderID); PickList pl = new PickList(); PalletLocation plocation = new PalletLocation(); plocation.LoadByPrimaryKey(Convert.ToInt32(dvPickListMakeup[0]["PalletLocationID"])); pl.AddNew(); pl.OrderID = orderID; pl.PickType = "Pick"; pl.PickedBy = userID; pl.IsConfirmed = false; pl.IssuedDate = DateTimeHelper.ServerDateTime; pl.SavedDate = DateTimeHelper.ServerDateTime; pl.PickedDate = DateTimeHelper.ServerDateTime; pl.IsWarehouseConfirmed = 0; pl.WarehouseID = plocation.WarehouseID; pl.Save(); PickListDetail pld = new PickListDetail(); ReceivePallet rp = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); PickFace pf = new PickFace(); foreach (DataRowView drv in dvPickListMakeup) { pld.AddNew(); pld.PickListID = pl.ID; pld.OrderDetailID = Convert.ToInt32(drv["OrderDetailID"]); pld.ItemID = Convert.ToInt32(drv["ItemID"]); pld.BatchNumber = (drv["BatchNo"].ToString()); if (drv["ExpDate"] != DBNull.Value) { pld.ExpireDate = Convert.ToDateTime(drv["ExpDate"]); } pld.ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]); pld.BoxLevel = Convert.ToInt32(drv["BoxLevel"]); pld.QtyPerPack = Convert.ToInt32(drv["QtyPerPack"]); pld.Packs = Convert.ToDecimal(drv["Pack"]); pld.PalletLocationID = Convert.ToInt32(drv["PalletLocationID"]); pld.QuantityInBU = Convert.ToDecimal(drv["QtyInBU"]); pld.ReceiveDocID = Convert.ToInt32(drv["ReceiveDocID"]); pld.ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]); if (drv["CalculatedCost"] != DBNull.Value) pld.Cost = Convert.ToDouble(drv["CalculatedCost"]); if (drv["UnitPrice"] != DBNull.Value) pld.UnitPrice = Convert.ToDouble(drv["UnitPrice"]); int ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]); rp.LoadByPrimaryKey(ReceivePalletID); pld.StoreID = Convert.ToInt32(drv["StoreID"]); if (drv["DeliveryNote"] != null) pld.DeliveryNote = Convert.ToBoolean(drv["DeliveryNote"]); else pld.DeliveryNote = false; if (rp.IsColumnNull("ReservedStock")) { rp.ReservedStock = Convert.ToDecimal(pld.QuantityInBU); } else { rp.ReservedStock += Convert.ToDecimal(pld.QuantityInBU); } if (drv["UnitID"] != DBNull.Value) { pld.UnitID = Convert.ToInt32(drv["UnitID"]); } plocation.LoadByPrimaryKey(Convert.ToInt32(drv["PalletLocationID"])); pld.PhysicalStoreID = plocation.PhysicalStoreID; rp.Save(); if (drv["StorageTypeID"].ToString() == StorageType.PickFace) { pf.LoadByPalletLocation(Convert.ToInt32(drv["PalletLocationID"])); //pf.Balance -= Convert.ToDecimal(pld.QuantityInBU); pf.Save(); } } pld.Save(); ord.ChangeStatus(OrderStatus.Constant.PICK_LIST_GENERATED,CurrentContext.UserId); ord.Save(); }
private void btnFixLocationStuff_Click(object sender, EventArgs e) { int storeID = Convert.ToInt32(lkStoreLocation.EditValue); BLL.ReceiveDoc rd = new BLL.ReceiveDoc(); rd.LoadReceivesForStores(storeID); while(!rd.EOF) { BLL.ReceivePallet rp = new BLL.ReceivePallet(); rp.LoadByReceiveDocID(rd.ID); decimal receivedQuantity = 0, balance = 0; if (rp.RowCount==1)// rp.RowCount > 0) { while (!rp.EOF) { receivedQuantity += rp.IsColumnNull("ReceivedQuantity") ? 0 : rp.ReceivedQuantity; balance += rp.IsColumnNull("Balance") ? 0 : rp.Balance; rp.MoveNext(); } rp.Rewind(); while (!rp.EOF && rp.IsColumnNull("ReceivedQuantity")) { rp.MoveNext(); } if (rd.Quantity != receivedQuantity && rd.Quantity > receivedQuantity) { rp.ReceivedQuantity += (rd.Quantity - receivedQuantity); } if (rd.QuantityLeft != balance && rd.QuantityLeft > 0)//rd.QuantityLeft > balance) { rp.Balance += (rd.QuantityLeft - balance); } rp.Save(); } rd.MoveNext(); } XtraMessageBox.Show("Completed!"); }
//, string guid) private void SavePalletization(ReceiveDoc rec, DataRowView drow) { if ((rec.Quantity == 0 && !rec.IsColumnNull("ShortageReasonID") && rec.ShortageReasonID == ShortageReasons.Constants.NOT_RECEIVED) || (rec.Quantity == 0 && rec.IsColumnNull("ShortageReasonID"))) { HandleFullNotReceivedAndMultipleBatchPalletlization(rec,drow); return; } string guid; BLL.ReceivePallet rp = new ReceivePallet(); Pallet pallet = new Pallet(); PalletLocation pl = new PalletLocation(); ItemUnit itemUnit = new ItemUnit(); BLL.ItemManufacturer im = new BLL.ItemManufacturer(); guid = rec.GetColumn("GUID").ToString(); var isDamaged = Convert.ToBoolean(rec.GetColumn("IsDamaged")); //DataRow[] r = _dtPalletizedItemList.Select(string.Format("Index = '{0}'", i)); DataRow[] r = _dtPalletizedItemList.Select(string.Format("GUID = '{0}' AND IsDamaged = {1}", guid, isDamaged)); if (r.Length > 0) { foreach (DataRow rw in r) { rp.AddNew(); rp.IsOriginalReceive = true; if (Convert.ToBoolean(rw["Consolidate"])) { try { DataRow dr = _dtPutAwayPalletized.Select(string.Format("PalletNumber={0}", Convert.ToInt32(rw["PalletNumber"])))[0]; //Assuming we only need one. if (rw["IsStoredInFreeStorageType"] != null) { if (Convert.ToBoolean(rw["IsStoredInFreeStorageType"]) == true) { pl.LoadByPrimaryKey(Convert.ToInt32(dr["PutAwayLocation"])); } } } catch { pl.LoadByPalletNumber(Convert.ToInt32(rw["PalletNumber"])); } try { rp.PalletID = pl.PalletID; rp.PalletLocationID = pl.ID; } catch { rp.PalletID = GetPalletID(rw["PalletNumber"].ToString()); try { rp.PalletLocationID = PalletLocation.GetPalletLocationID(rp.PalletID); } catch { DataRow dr = _dtPutAwayPalletized.Select(string.Format("PalletNumber={0}", Convert.ToInt32(rw["PalletNumber"])))[0]; pl.LoadByPrimaryKey(Convert.ToInt32(dr["PutAwayLocation"])); pl.PalletID = rp.PalletID; pl.Save(); rp.PalletLocationID = pl.ID; } } //// if the putaway is on a pick face, increase the amount stored on the pick face //if (pl.StorageTypeID.ToString() == StorageType.PickFace) //{ // PickFace pf = new PickFace(); // pf.LoadPickFaceFor(rec.ItemID, Convert.ToInt32(cboStores.EditValue)); // if (pf.RowCount > 0) // { // if (pf.IsColumnNull("Balance")) // { // pf.Balance = 0; // } // pf.Balance += Convert.ToInt32(rp.Balance); // pf.Save(); // } //} } else { var palletNumber = Convert.ToInt32(rw["PalletNumber"]); DataRow dr = _dtPutAwayPalletized.Select(string.Format("PalletNumber={0}", palletNumber))[0]; //Assuming we only need one. pl.LoadByPrimaryKey(Convert.ToInt32(dr["PutAwayLocation"])); rp.PalletID = GetPalletID(rw["PalletNumber"].ToString()); pl.PalletID = rp.PalletID; rp.PalletLocationID = pl.ID; //PalletLocation.GetPalletLocationID(rp.PalletID); pl.Save(); } rp.ReservedStock = 0; im.LoadIMbyLevel(Convert.ToInt32(rw["ID"]), Convert.ToInt32(rw["Manufacturer"]), Convert.ToInt32(rw["BoxLevel"])); int qtyPerPack = im.QuantityInBasicUnit; if (rw["UnitID"] != DBNull.Value) { itemUnit.LoadByPrimaryKey(Convert.ToInt32(rw["UnitID"])); qtyPerPack = itemUnit.QtyPerUnit; } rp.ReceivedQuantity = rp.Balance = (Convert.ToDecimal(rw["Pack Qty"]) * Convert.ToDecimal(qtyPerPack)); rp.BoxSize = Convert.ToInt32(rw["BoxLevel"]); if (rec.IsColumnNull("PhysicalStoreID") && !rp.IsColumnNull("PalletLocationID")) { PalletLocation l = new PalletLocation(); l.LoadByPrimaryKey(rp.PalletLocationID); rec.PhysicalStoreID = (l.PhysicalStoreID); PhysicalStore physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(l.PhysicalStoreID); rec.InventoryPeriodID = physicalStore.CurrentInventoryPeriodID; } if (Convert.ToBoolean(rw["Consolidate"])) { try { // if the putaway is on a pick face, increase the amount stored on the pick face if (pl.StorageTypeID.ToString() == StorageType.PickFace) { PickFace pf = new PickFace(); pf.LoadPickFaceFor(rec.ItemID, Convert.ToInt32(lkAccounts.EditValue)); if (pf.RowCount > 0) { if (pf.IsColumnNull("Balance")) { pf.Balance = 0; } pf.Balance += Convert.ToInt32(rp.Balance); pf.Save(); } } } catch { } } } } //r = _dtPutAwayNonPalletized.Select(string.Format("Index = '{0}'", i)); string filterQuery = _revDocRelatePalletGuid.ContainsKey(guid) ? string.Format("{0} AND IsDamaged = {1}", GetFilterByGuid(_revDocRelatePalletGuid[guid]), isDamaged) : string.Format("GUID = '{0}' AND IsDamaged = {1} ", guid, isDamaged); r = _dtPutAwayNonPalletized.Select(filterQuery); if (r.Length > 0) { // Save the palletization and the putaway here,// this was supposed to be out of here but it is easlier to implement here. foreach (DataRow rw in r) { pl.LoadByPrimaryKey(Convert.ToInt32(rw["PutAwayLocation"])); if (pl.IsColumnNull("PalletID")) { pallet.AddNew(); pallet.Save(); } else { pallet.LoadByPrimaryKey(pl.PalletID); } rp.AddNew(); rp.IsOriginalReceive = true; rp.PalletID = pallet.ID; rp.PalletLocationID = pl.ID; // rp.ReceiveID = rec.ID; rp.ReservedStock = 0; im.LoadIMbyLevel(Convert.ToInt32(rw["ID"]), Convert.ToInt32(rw["Manufacturer"]), Convert.ToInt32(rw["BoxLevel"])); int qtyPerPack = im.QuantityInBasicUnit; if (rw["UnitID"] != DBNull.Value) { itemUnit.LoadByPrimaryKey(Convert.ToInt32(rw["UnitID"])); qtyPerPack = itemUnit.QtyPerUnit; } rp.ReceivedQuantity = rp.Balance = (Convert.ToDecimal(rw["Palletized Quantity"]) * Convert.ToDecimal(qtyPerPack)); rp.BoxSize = Convert.ToInt32(rw["BoxLevel"]); //Get the putaway location pl.Save(); if (pl.IsColumnNull("PalletID")) { pl.PalletID = pallet.ID; pl.Confirmed = false; pl.Save(); } } } if (rec.IsColumnNull("PhysicalStoreID") && !rp.IsColumnNull("PalletLocationID")) { PalletLocation l = new PalletLocation(); l.LoadByPrimaryKey(rp.PalletLocationID); PhysicalStore physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(l.PhysicalStoreID); rec.PhysicalStoreID = (l.PhysicalStoreID); // we can take any of the pallet location physical store. as we have one entry on receiveDoc per Store. if (physicalStore.IsColumnNull("CurrentInventoryPeriodID")) { XtraMessageBox.Show(string.Format("Please Set InventoryPeriod for '{0}' PhysicalStore!", physicalStore.Name), "Empty InventoryPeriod", MessageBoxButtons.OK, MessageBoxIcon.Error); throw new Exception(string.Format("Please Set InventoryPeriod for '{0}' PhysicalStore!", physicalStore.Name)); } rec.InventoryPeriodID = physicalStore.CurrentInventoryPeriodID; } rec.Save(); rp.Rewind(); while (!rp.EOF) { rp.ReceiveID = rec.ID; rp.MoveNext(); } rp.Save(); SavePutAwayItems(); }
private void btnAdjustments_Click(object sender, EventArgs e) { if (ValidateMoveToAdjustments()) { if (DialogResult.Yes == XtraMessageBox.Show("Are you sure you would like to commit this adjustment?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { PalletLocation pl = new PalletLocation(); Pallet p = new Pallet(); ReceiveDoc rdoc = new ReceiveDoc(); ReceivePallet rp = new ReceivePallet(); int printNubmer = InternalTransfer.GetNewPrintNumber() + 1 ; for (int i = 0; i < gridView3.RowCount; i++) { DataRow dr = gridView3.GetDataRow(i); if (dr["Adjust"] != DBNull.Value) { int amount = Convert.ToInt32(dr["Adjust"]); rp.LoadByPrimaryKey(Convert.ToInt32(dr["ReceivePalletID"])); rdoc.LoadByPrimaryKey(rp.ReceiveID); rdoc.NoOfPack += amount; amount *= rdoc.QtyPerPack; rp.Balance += amount; if (rp.IsColumnNull("ReceivedQuantity")) { rp.ReceivedQuantity = 0; } rp.ReceivedQuantity += amount; rdoc.QuantityLeft += amount; rdoc.Quantity += amount; BLL.LossAndAdjustment d = new BLL.LossAndAdjustment(); d.AddNew(); d.GenerateRefNo(); d.ItemID = Convert.ToInt32(dr["ItemID"]); d.ReasonId = Convert.ToInt32(dr["Reason"]); d.RecID = rdoc.ID; d.Quantity = amount; d.BatchNo = rdoc.BatchNo; CalendarLib.DateTimePickerEx edate = new CalendarLib.DateTimePickerEx(); edate.Value = DateTime.Today; edate.CustomFormat = "MM/dd/yyyy"; d.Date = ConvertDate.DateConverter(edate.Text); d.EurDate = DateTime.Today; if (!rdoc.IsColumnNull("Cost")) { d.Cost = Math.Abs(rdoc.Cost*amount); } d.StoreId = rdoc.StoreID; d.Losses = false; d.ApprovedBy = CurrentContext.UserId.ToString(); d.Save(); rdoc.Save(); rp.Save(); } } PopulateItemDetails(); XtraMessageBox.Show("Items adjusted successfully.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void btnMove_Click(object sender, EventArgs e) { // Validation foreach (DataRowView drv in _rpl.DefaultView) { int Balance = Convert.ToInt32(drv["Balance"]); int splited = Convert.ToInt32(drv["BalanceToMove"]); if (Balance < splited) { XtraMessageBox.Show("Couldn't split to the numbers you specified. Please specify number less than the balance.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } // validate the selected pallet location if (lkFreePalletLocations.EditValue == null) { XtraMessageBox.Show("Please select a valid destination pallet location.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // PalletLocation destinationPalletLocatin = new PalletLocation(); destinationPalletLocatin.LoadByPrimaryKey(Convert.ToInt32(lkFreePalletLocations.EditValue)); if (destinationPalletLocatin.IsColumnNull("PalletID"))//The Pallet Location is empty { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.Save(); destinationPalletLocatin.PalletID = pallet.ID; destinationPalletLocatin.Save(); } // THIS HAS BEEN REMOVED AS PER RUTH'S SUGGESTION THAT: THE SYSTEM SHOULD NOT BLOCK IF THE WAREHOUSE MANAGER WANTES TO USE //else if (destinationPalletLocatin.StorageTypeID.ToString() != BLL.StorageType.Free) //If the pallet location is not empty and it is not free storage, you can't put more on it. //{ // // the thingy has not been moved // XtraMessageBox.Show("The selected Pallet location is not Empty. Please select another location.", "Error splitting"); // return; //} foreach (DataRowView drv in _rpl.DefaultView) { int balanceToMove = Convert.ToInt32(drv["BalanceToMove"]); int qtyPerPack = Convert.ToInt32(drv["QtyPerPack"]); balanceToMove *= qtyPerPack; if (balanceToMove > 0) { ReceivePallet rpSource = new ReceivePallet(); ReceivePallet rpDestination = new ReceivePallet(); rpSource.LoadByPrimaryKey(Convert.ToInt32(drv["ID"])); rpDestination.AddNew(); //rpDestination.Balance = balanceToMove;// if (!rpSource.IsColumnNull("BoxSize")) { rpDestination.BoxSize = rpSource.BoxSize; } else { rpDestination.BoxSize = 1; } rpDestination.ReceivedQuantity = balanceToMove; rpDestination.PalletID = destinationPalletLocatin.PalletID;//pallet.ID; rpDestination.PalletLocationID = destinationPalletLocatin.ID; rpDestination.ReceiveID = rpSource.ReceiveID; if (!rpSource.IsColumnNull("ReceivedQuantity")) rpSource.ReceivedQuantity -= balanceToMove; //rpSource.Balance -= balanceToMove;// rpDestination.ReservedStock = 0; rpDestination.IsOriginalReceive = false; BLL.ReceivePallet.MoveBalance(rpSource, rpDestination, balanceToMove); //rpSource.Save(); //rpDestination.Save(); } } XtraMessageBox.Show("The pallet was split.", "Success"); this.Close(); }
/// <summary> /// Saves the whole transaction for /// </summary> /// <param name="orderID">The order ID.</param> /// <param name="dvOutstandingPickList">The dv outstanding pick list.</param> /// <param name="remark">The remark.</param> /// <param name="issuedBy">The issued by.</param> /// <param name="etCurrentDate">The et current date.</param> /// <returns></returns> /// <exception cref="System.Exception"></exception> public static Order SaveIssueTransaction(int orderID, ref DataView dvOutstandingPickList, string remark, string issuedBy, DateTime etCurrentDate) { // Add the IssueDocID field dvOutstandingPickList.Table.Columns.Add("IssueDocID"); PickList plst = new PickList(); IssueDoc issDoc = new IssueDoc(); ReceiveDoc recDoc = new ReceiveDoc(); BLL.Order ord = new BLL.Order(); ord.LoadByPrimaryKey(orderID); plst.LoadByOrderID(ord.ID); foreach (DataRowView drv in dvOutstandingPickList) { // Pseudo: // for each row in the picklist // undate the issue document // subtract the issued quantity from the receive doc // subtract the issued quantity from recieve pallet // subtract the issued the reserved quantity irregardless of the quantity issued. //Saving the new Issue issue if (Convert.ToDecimal(drv["BUPICKED"]) == 0) { continue; } if (Convert.ToDecimal(drv["SKUPicked"]) != Convert.ToDecimal(drv["SKUTOPICK"])) { drv["Cost"] = Convert.ToDecimal(drv["SKUPicked"]) * Convert.ToDecimal(drv["UnitPrice"]); } // Select the receive doc that is associated with this issue. recDoc.LoadByPrimaryKey(Convert.ToInt32(drv["ReceiveDocID"])); issDoc.AddNew(); issDoc.StoreId = Convert.ToInt32(drv["StoreID"]); issDoc.RefNo = ord.RefNo; if (!ord.IsColumnNull("RequestedBy")) { issDoc.ReceivingUnitID = ord.RequestedBy; } // TOFIX: // TODO: // Lord have mercy kind of hack to avoid the feb date problem // this needs to be fixed for pagume also issDoc.Date = etCurrentDate; issDoc.EurDate = DateTimeHelper.ServerDateTime; issDoc.RecievDocID = Convert.ToInt32(drv["ReceiveDocID"]); issDoc.IsApproved = true; issDoc.IsTransfer = false; issDoc.Remark = remark; issDoc.ItemID = Convert.ToInt32(drv["ItemID"]); issDoc.Quantity = Convert.ToDecimal(drv["BUPICKED"]); issDoc.NoOfPack = Convert.ToDecimal(drv["SKUPICKED"]); issDoc.QtyPerPack = Convert.ToInt32(drv["SKUBU"]); issDoc.BatchNo = drv["BatchNumber"].ToString(); issDoc.UnitID = recDoc.UnitID; issDoc.ManufacturerID = recDoc.ManufacturerId; if (drv["Cost"] != DBNull.Value) { issDoc.Cost = Convert.ToDouble(drv["Cost"]); issDoc.SellingPrice = Convert.ToDecimal(drv["UnitPrice"]); if (!recDoc.IsColumnNull("Cost")) { issDoc.UnitCost = Convert.ToDecimal(recDoc.Cost); } } issDoc.OrderID = orderID; issDoc.IssuedBy = issuedBy; // TODO: is this the right place where we need to pick the physical store ID from? // check it against the receipt pallet physical store. if (!recDoc.IsColumnNull("PhysicalStoreID")) { issDoc.PhysicalStoreID = recDoc.PhysicalStoreID; } if (!recDoc.IsColumnNull("InventoryPeriodID")) { //Todo: Remove for Inventory issDoc.InventoryPeriodID = recDoc.InventoryPeriodID; } if (!recDoc.IsColumnNull("Margin")) { issDoc.Margin = (decimal)recDoc.Margin; } //Replaced by issDoc.PLDetailID = Convert.ToInt32(drv["PLDetailID"]); BLL.Balance bal = new Balance(); BLL.ReceiveDoc rd = new ReceiveDoc(); rd.LoadByPrimaryKey(issDoc.RecievDocID); decimal currentBalance = bal.GetSoh(issDoc.ItemID, rd.UnitID, issDoc.StoreId, issDoc.Date.Month, issDoc.Date.Year); if (currentBalance < issDoc.NoOfPack) { throw new Exception(string.Format("The item {0} is not available in {1} Qty.", drv["FullItemName"].ToString(), issDoc.NoOfPack)); } // This is a field that is not applicable on the hub edition // It is about the dispensing unit quantity and there is no such thing as Dispensing unit // in the hub edition issDoc.DUSOH = 0; issDoc.RecomendedQty = 0;// ((recQty > 0) ? Convert.ToInt64(recQty) : 0); // End DU issDoc.DispatchConfirmed = false; issDoc.Save(); drv["IssueDocID"] = issDoc.ID; // updating the receiving doc //long prevQuantityLeft = recDoc.QuantityLeft; recDoc.QuantityLeft = recDoc.QuantityLeft - issDoc.Quantity; if (recDoc.QuantityLeft < 0) { //Possibly the wrong ReceiveDoc Entry chosen BLL.Item itm = new Item(); itm.LoadByPrimaryKey(recDoc.ItemID); throw new Exception(string.Format("Quantity problem detected for the item {0}", itm.FullItemName)); } //long recDoc.Out = (recDoc.QuantityLeft == 0) ? true : false; recDoc.Save(); ReceivePallet rp = new ReceivePallet(); int id = Convert.ToInt32(drv["ReceivePalletID"]); rp.LoadByPrimaryKey(id); if (rp.IsColumnNull("Balance")) { rp.Balance = rp.ReceivedQuantity; } rp.Balance -= issDoc.Quantity; if (rp.Balance < 0) { BLL.Item itm = new Item(); itm.LoadByPrimaryKey(recDoc.ItemID); throw new Exception(string.Format("Quantity problem detected for the item {0}", itm.FullItemName)); } decimal totReservedQty = Convert.ToDecimal(drv["QuantityInBU"]); if (rp.IsColumnNull("ReservedStock")) { rp.ReservedStock = 0; } rp.ReservedStock -= totReservedQty; if (rp.ReservedStock < 0) //If there has been a quantity problem somewhere { rp.ReservedStock = 0; } rp.Save(); } plst.IsConfirmed = true; ord.ChangeStatus(OrderStatus.Constant.ISSUED, CurrentContext.UserId); plst.Save(); ord.Save(); return(ord); }