/// <summary> /// This happes when there is plenty of transaction at the same time /// and will result a partial commit. /// This fake rows should be deleted from DB. /// </summary> /// <param name="orderID"></param> private void RemoveFakePartialCommitPickListDetails(int orderID) { var order = new Order(); order.LoadByPrimaryKey(orderID); if (order.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED) { var pickList = new PickList(); pickList.LoadByOrderID(order.ID); if (pickList.RowCount == 0) //~ If there is no picklist, there is nothing to delete. ~// { return; } var picklistDetail = new PickListDetail(); picklistDetail.LoadByPickListID(pickList.ID); picklistDetail.Rewind(); while (!picklistDetail.EOF) { PickListDetailDeleted.AddNewLog(picklistDetail, CurrentContext.UserId); picklistDetail.MarkAsDeleted(); picklistDetail.MoveNext(); } picklistDetail.Save(); pickList.MarkAsDeleted(); pickList.Save(); } }
internal static PickListDetail GeneratePickListDetail(ReceivePallet receivePallet, int pickListId, decimal qtyInBU) { ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID); decimal pack = qtyInBU / Convert.ToDecimal(receiveDoc.QtyPerPack); PickListDetail pkDetail = new PickListDetail(); pkDetail.AddNew(); pkDetail.PickListID = pickListId; pkDetail.ItemID = receiveDoc.ItemID; PalletLocation palletLocation = new PalletLocation(); palletLocation.loadByPalletID(receivePallet.PalletID); int palletLocationId; try { palletLocationId = palletLocation.ID; } catch (Exception exp) { palletLocationId = receivePallet.PalletLocationID; palletLocation.LoadByPrimaryKey(palletLocationId); } pkDetail.PalletLocationID = palletLocationId; if (!receiveDoc.IsColumnNull("BatchNo")) { pkDetail.BatchNumber = receiveDoc.BatchNo; } if (!receiveDoc.IsColumnNull("ExpDate")) { pkDetail.ExpireDate = receiveDoc.ExpDate; } pkDetail.StoreID = receiveDoc.StoreID; pkDetail.UnitID = receiveDoc.UnitID; pkDetail.ReceiveDocID = receiveDoc.ID; if (!receiveDoc.IsColumnNull("Cost")) { pkDetail.Cost = Convert.ToDouble(pack) * Math.Round(receiveDoc.Cost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); pkDetail.UnitPrice = Math.Round(receiveDoc.Cost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } pkDetail.Packs = pack; pkDetail.QtyPerPack = receiveDoc.QtyPerPack; pkDetail.QuantityInBU = qtyInBU; pkDetail.StoreID = receiveDoc.StoreID; pkDetail.ReceivePalletID = receivePallet.ID; pkDetail.ManufacturerID = receiveDoc.ManufacturerId; pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; pkDetail.PhysicalStoreID = palletLocation.PhysicalStoreID; pkDetail.Save(); return(pkDetail); }
/// <summary> /// Undo pick list that has been printed /// </summary> /// <param name="orderID">The order ID.</param> public void CancelOrderWithPickList(int orderID) { // Create a pick list entry Order ord = new Order(); PickList pl = new PickList(); PickListDetail pld = new PickListDetail(); ReceivePallet rp = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); PickFace pf = new PickFace(); PalletLocation palletLocation = new PalletLocation(); ord.LoadByPrimaryKey(orderID); pl.LoadByOrderID(orderID); pld.LoadByPickListID(pl.ID); while (!pld.EOF) { rp.LoadByPrimaryKey(pld.ReceivePalletID); rp.ReservedStock -= Convert.ToInt32(pld.QuantityInBU); if (rp.ReservedStock < 0) { rp.ReservedStock = 0; //If there has been no reservation, allow to cancel the picklist too. No need for it to be blocked by the constraint. } rp.Save(); palletLocation.LoadByPrimaryKey(pld.PalletLocationID); if (palletLocation.StorageTypeID.ToString() == StorageType.PickFace) { pf.LoadByPalletLocation(pld.PalletLocationID); pf.Balance += Convert.ToInt32(pld.QuantityInBU); pf.Save(); } //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); pld.MoveNext(); } pld.Save(); ord.ChangeStatus(OrderStatus.Constant.CANCELED, CurrentContext.UserId); pl.MarkAsDeleted(); pl.Save(); }
public static PickListDetail GeneratePickListDetail(decimal pack, double?unitPrice, int receiveDocId, int manufacturerId, int receivePalletId, int qtyPerPack, int activityId, int unitId, int itemId, int picklistId, int palletId, string expireDate, string batchNumber) { PalletLocation plocation = new PalletLocation(); PickListDetail pkDetail = new PickListDetail(); pkDetail.AddNew(); pkDetail.PickListID = picklistId; pkDetail.ItemID = itemId; PalletLocation palletLocation = new PalletLocation(); palletLocation.loadByPalletID(palletId); pkDetail.PalletLocationID = palletLocation.ID; pkDetail.BatchNumber = batchNumber; if (expireDate != "") { pkDetail.ExpireDate = DateTime.Parse(expireDate); } pkDetail.StoreID = activityId; pkDetail.UnitID = unitId; pkDetail.ReceiveDocID = receiveDocId; if (unitPrice != null) { pkDetail.Cost = Convert.ToDouble(pack) * Math.Round(unitPrice.Value, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); pkDetail.UnitPrice = Math.Round(unitPrice.Value, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } pkDetail.Packs = pack; pkDetail.QtyPerPack = qtyPerPack; pkDetail.QuantityInBU = pack * qtyPerPack; pkDetail.StoreID = activityId; pkDetail.ReceivePalletID = receivePalletId; pkDetail.ManufacturerID = manufacturerId; pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; plocation.LoadByPrimaryKey(pkDetail.PalletLocationID); pkDetail.PhysicalStoreID = plocation.PhysicalStoreID; pkDetail.Save(); return(pkDetail); }
public static PickListDetail GeneratePickListDetail(decimal pack, double? unitPrice, int receiveDocId, int manufacturerId, int receivePalletId, int qtyPerPack, int activityId, int unitId, int itemId, int picklistId, int palletId, string expireDate, string batchNumber) { PalletLocation plocation = new PalletLocation(); PickListDetail pkDetail = new PickListDetail(); pkDetail.AddNew(); pkDetail.PickListID = picklistId; pkDetail.ItemID = itemId; PalletLocation palletLocation = new PalletLocation(); palletLocation.loadByPalletID(palletId); pkDetail.PalletLocationID = palletLocation.ID; pkDetail.BatchNumber = batchNumber; if (expireDate != "") pkDetail.ExpireDate = DateTime.Parse(expireDate); pkDetail.StoreID = activityId; pkDetail.UnitID = unitId; pkDetail.ReceiveDocID = receiveDocId; if (unitPrice != null) { pkDetail.Cost = Convert.ToDouble(pack) * Math.Round(unitPrice.Value, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); pkDetail.UnitPrice = Math.Round(unitPrice.Value, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } pkDetail.Packs = pack; pkDetail.QtyPerPack = qtyPerPack; pkDetail.QuantityInBU = pack * qtyPerPack; pkDetail.StoreID = activityId; pkDetail.ReceivePalletID = receivePalletId; pkDetail.ManufacturerID = manufacturerId; pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; plocation.LoadByPrimaryKey(pkDetail.PalletLocationID); pkDetail.PhysicalStoreID = plocation.PhysicalStoreID; pkDetail.Save(); return pkDetail; }
/// <summary> /// Fix For Delivery Note When Converting Do not use under any other situation /// </summary> /// <param name="issueDocID"></param> /// <param name="picklistID"></param> /// <returns></returns> public PickListDetail FixDeliveryNoteCostReceiveDoc(int issueDocID, int picklistID) { IssueDoc issueDoc = new IssueDoc(); issueDoc.LoadByPrimaryKey(issueDocID); PickListDetail pickList = new PickListDetail(); pickList.LoadByPrimaryKey(picklistID); //safety first if (issueDoc.RecievDocID != pickList.ReceiveDocID) { Item item = new Item(); item.LoadByPrimaryKey(picklistID); throw new Exception(String.Format("PicklistDetail vs IssueDoc Inconsistancy for Item {0}", item.FullItemName)); } // now we are sure we have one ReceiveDocID ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(pickList.ReceiveDocID); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); receiveDocConfirmation.LoadByReceiveDocID(receiveDoc.ID); //Check if it has been Printed and that Selling Price and Cost is set if (receiveDocConfirmation.ReceiptConfirmationStatusID == ReceiptConfirmationStatus.Constants.GRV_PRINTED) { double unitPrice, unitCost, margin; if (Settings.IsCenter == true && !receiveDoc.IsColumnNull("Cost") && receiveDoc.Cost != 0) { unitPrice = Math.Round(receiveDoc.Cost, 2); unitCost = Math.Round(receiveDoc.Cost, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else if (!receiveDoc.IsColumnNull("SellingPrice") && receiveDoc.SellingPrice != 0) { unitPrice = Math.Round(receiveDoc.SellingPrice, 2); unitCost = Math.Round(receiveDoc.SellingPrice, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("Price Not set For item: {0}", item.FullItemName)); } pickList.UnitPrice = unitPrice; pickList.Cost = Convert.ToDouble(pickList.Packs) * unitPrice; issueDoc.SellingPrice = Convert.ToDecimal(unitPrice); issueDoc.Cost = Convert.ToDouble(issueDoc.NoOfPack) * unitPrice; issueDoc.UnitCost = Convert.ToDecimal(unitCost); issueDoc.Margin = Convert.ToDecimal(margin); pickList.Save(); issueDoc.Save(); } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("GRV/IGRV Not Printed For Item: {0}", item.FullItemName)); } return pickList; }
internal void Commit(DateTime ethiopianDate, BackgroundWorker backgroundWorker = null) { InventoryCommitMemberInstance.Transaction.BeginTransaction(); //TODO: Create the order detail, pass the order id above this inventory object int count = 0; if (backgroundWorker != null) { backgroundWorker.ReportProgress(0, "Detail"); } //Add the System Damaged quantity, System Sound Quantity and System Expired Quantity to generate this. decimal endingSoundBalance, endingDamagedBalance, endExpiredBalance; endingSoundBalance = !IsColumnNull("SystemSoundQuantity") ? SystemSoundQuantity : 0; endingDamagedBalance = !IsColumnNull("SystemDamagedQuantity") ? SystemDamagedQuantity : 0; endExpiredBalance = !IsColumnNull("SystemExpiredQuantity") ? SystemExpiredQuantity : 0; decimal endingTotalBalance = endingSoundBalance + endingDamagedBalance + endExpiredBalance; ItemUnit itemUnit = new ItemUnit(); itemUnit.LoadByPrimaryKey(UnitID); if (IsColumnNull("ReceiveDocID") && IsColumnNull("DamagedReceiveDocID")) // This has been recently added to { if (endingTotalBalance > 0) { OrderDetail.GenerateOrderDetail(UnitID, ActivityID, endingTotalBalance, InventoryCommitMemberInstance.Order.ID, itemUnit.QtyPerUnit, ItemID); //TODO: Get the receive doc details for this inventory object ReceivePallet receivePallet = new ReceivePallet(); receivePallet.LoadForInventory(this); receivePallet.Rewind(); while (!receivePallet.EOF) { //Review: New Code PickListDetail pickListDetail = PickListDetail.GeneratePickListDetail(receivePallet, InventoryCommitMemberInstance .PickList.ID, Convert.ToDecimal( receivePallet.Balance)); //TODO: Create the issueDoc, pass the picklistdetail, orderid and picklist above IssueService issueService = new IssueService(); IssueDoc issueDoc = issueService.CreateIssueFromPicklist(pickListDetail, InventoryCommitMemberInstance.Order, ethiopianDate, InventoryCommitMemberInstance.Issue, InventoryCommitMemberInstance.User); //Link IssueDoc to InventoryTable // Could have put it on the issueService method but it would have decrease the useablity IssueDocInventory issueDocInventory = new IssueDocInventory(); issueDocInventory.AddNew(); issueDocInventory.InventoryID = ID; issueDocInventory.IssueDocID = issueDoc.ID; issueDocInventory.Save(); receivePallet.MoveNext(); count++; if (backgroundWorker != null) { backgroundWorker.ReportProgress( Convert.ToInt32((Convert.ToDecimal(count) / Convert.ToDecimal(receivePallet.RowCount)) * 100), "Detail"); } } } //TODO: Create the receive (use the inventory object itself) ReceiveService receiveService = new ReceiveService(); if (!IsColumnNull("InventorySoundQuantity") && InventorySoundQuantity > 0) { ReceiveDoc receiveDoc = receiveService.CreateInventoryReceive(this, InventoryCommitMemberInstance.Receipt. ID, QuantityType.Sound, ethiopianDate, InventoryCommitMemberInstance.User); ReceiveDocID = receiveDoc.ID; } if (!IsColumnNull("InventoryExpiredQuantity") && InventoryExpiredQuantity > 0) { ReceiveDoc receiveDoc = receiveService.CreateInventoryReceive(this, InventoryCommitMemberInstance.Receipt. ID, QuantityType.Expired, ethiopianDate, InventoryCommitMemberInstance.User); ReceiveDocID = receiveDoc.ID; } if (!IsColumnNull("InventoryDamagedQuantity") && InventoryDamagedQuantity > 0) { ReceiveDoc receiveDoc = receiveService.CreateInventoryReceive(this, InventoryCommitMemberInstance.Receipt. ID, QuantityType.Damaged, ethiopianDate, InventoryCommitMemberInstance.User); DamagedReceiveDocID = receiveDoc.ID; } if (backgroundWorker != null) { backgroundWorker.ReportProgress(100, "Detail"); } } else { if (!IsColumnNull("ReceiveDocID")) { ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(ReceiveDocID); receiveDoc.ChangeQuantity(!IsColumnNull("InventorySoundQuantity") ? InventorySoundQuantity : !IsColumnNull("InventoryExpiredQuantity") ? InventoryExpiredQuantity : 0); } if (!IsColumnNull("DamagedReceiveDocID")) { ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(DamagedReceiveDocID); receiveDoc.ChangeQuantity(InventoryDamagedQuantity); } } IsDraft = false; Save(); InventoryCommitMemberInstance.Transaction.CommitTransaction(); }
/// <summary> /// Releases the reservation. /// </summary> public void ReleaseReservation() { PickList pickList = new PickList(); pickList.LoadByOrderID(this.ID); if (pickList.RowCount == 0) //If there is no picklist, there is nothing to release. return; PickListDetail pld = new PickListDetail(); pld.LoadByPickListID(pickList.ID); pld.Rewind(); while (!pld.EOF) { ReceivePallet receivePallet = new ReceivePallet(); receivePallet.LoadByPrimaryKey(pld.ReceivePalletID); ReceiveDoc rdoc = new ReceiveDoc(); rdoc.LoadByPrimaryKey(pld.ReceiveDocID); receivePallet.ReservedStock = receivePallet.ReservedStock - Convert.ToInt32(pld.QuantityInBU); if (receivePallet.ReservedStock < 0) receivePallet.ReservedStock = 0; receivePallet.Save(); //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); pld.MoveNext(); //Delete issues if the order has any var iss = new Issue(); iss.GetIssueByOrderID(this.ID); iss.Rewind(); if (iss.RowCount > 0) { while (!iss.EOF) { iss.MarkAsDeleted(); iss.MoveNext(); } iss.Save(); } } pld.Save(); pickList.MarkAsDeleted(); pickList.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(); }
//~ Dic(Pld.ID,Dic<pld.Pack,pld.QuanInBU>) Just to make things simple~// private Dictionary<int, Dictionary<decimal, decimal>> MergePickListsOfSameInfo(PickListDetail pld) { var mergedPickLists = new Dictionary<int, Dictionary<decimal, decimal>>(); var valid = _receiveDocConstraintHelper.IsValid(pld.DefaultView.Table); if(valid) { pld.Rewind(); while (!pld.EOF) { var pack_QInBU = new Dictionary<decimal, decimal> {{pld.Packs, pld.QuantityInBU}}; mergedPickLists[pld.ID] = pack_QInBU; pld.MoveNext(); } return mergedPickLists; } var groupedPickLists = _receiveDocConstraintHelper.GroupByConstraints(pld.DefaultView.Table); foreach (DataRow groupedPickList in groupedPickLists.Rows) { var pack_QInBU = new Dictionary<decimal, decimal> { {Convert.ToDecimal(groupedPickList["Packs"]), Convert.ToDecimal(groupedPickList["QuantityInBU"])} }; mergedPickLists[Convert.ToInt32(groupedPickList["ID"])] = pack_QInBU; } pld.Rewind(); while (!pld.EOF) { if (mergedPickLists.ContainsKey(pld.ID)) { var packs = mergedPickLists[pld.ID].FirstOrDefault().Key; pld.Packs = packs; pld.QuantityInBU = mergedPickLists[pld.ID][packs]; } pld.MoveNext(); } return mergedPickLists; }
/// <summary> /// Commits the account to account transfer. /// </summary> /// <param name="orderID">The order ID.</param> /// <param name="userID">The user ID.</param> /// <param name="convertedEthDate">The converted eth date.</param> public void CommitAccountToAccountTransfer(int orderID, int userID, DateTime convertedEthDate) { int?supplierID = null; BLL.Transfer transfer = new Transfer(); transfer.LoadByOrderID(orderID); if (transfer.RowCount == 0) { return; } int newStoreID, newPhysicalStoreID; newStoreID = transfer.ToStoreID; newPhysicalStoreID = transfer.ToPhysicalStoreID; PhysicalStore toPhysicalStore = new PhysicalStore(); toPhysicalStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID); BLL.PickList picklist = new PickList(); picklist.LoadByOrderID(orderID); BLL.PickListDetail pld = new PickListDetail(); pld.LoadByPickListIDWithStvlogID(picklist.ID); BLL.ReceiveDoc rdOriginal = new ReceiveDoc(); rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID); BLL.Order order = new Order(); order.LoadByPrimaryKey(orderID); if (order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { var activity = new Activity(); activity.LoadByPrimaryKey(newStoreID); supplierID = activity.SupplierID; } else if (order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER) { var activity = new Activity(); activity.LoadByPrimaryKey(newPhysicalStoreID); supplierID = activity.SupplierID; } PO po = PO.CreatePOforStandard((int)order.GetColumn("OrderTypeID"), transfer.ToStoreID, supplierID, "Transfer", CurrentContext.LoggedInUser.ID); int IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted")); int receiptTypeID = order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER ? ReceiptType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER :order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER ? ReceiptType.CONSTANTS.STORE_TO_STORE_TRANSFER : order.OrderTypeID == OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER ? ReceiptType.CONSTANTS.ERROR_CORRECTION:ReceiptType.CONSTANTS.STANDARD_RECEIPT; Receipt receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID, po.ID, toPhysicalStore.PhysicalStoreTypeID, IDPrinted, userID); var mergedPickLists = MergePickListsOfSameInfo(pld); // Picklists of the same info means: Based on all constraints we have on receiveDoc(Batch,Exp,ItemID,UnitID...): should be merged with summed quantity. pld.Rewind(); while (!pld.EOF) { if (IDPrinted != Convert.ToInt32(pld.GetColumn("IDPrinted"))) { IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted")); receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID, po.ID, toPhysicalStore.PhysicalStoreTypeID, IDPrinted, userID); } var rDoc = new ReceiveDoc(); if (!mergedPickLists.ContainsKey(pld.ID)) { pld.MoveNext(); continue; } rDoc.SaveNewReceiveDocEntryFromPicklistDetail(pld, userID, newStoreID, newPhysicalStoreID, convertedEthDate, receipt.ID, supplierID); pld.MoveNext(); } }
public void DeleteAnIssue(int issueDociD) { ReceiveDoc rdoc = new ReceiveDoc(); ReceivePallet rp = new ReceivePallet(); IssueDoc idoc = new IssueDoc(); idoc.LoadByPrimaryKey(issueDociD); if (idoc.IsThereSRM) { throw new Exception("There is an SRM for this issue. You can't void it."); } PickListDetail pld = new PickListDetail(); //pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID, idoc.NoOfPack); pld.LoadByPrimaryKey(idoc.PLDetailID); string RefNo = idoc.RefNo; rdoc.LoadByPrimaryKey(idoc.RecievDocID); //if (pld.RowCount == 0) //{ // pld.LoadByOrderAndItem(idoc.OrderID, idoc.ItemID); //} rp.LoadByReceiveDocID(idoc.RecievDocID); PalletLocation pl = new PalletLocation(); pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { pl.LoadByPrimaryKey(pld.PalletLocationID); if (pl.IsColumnNull("PalletID")) { pl.PalletID = rp.PalletID; pl.Save(); } } if (rp.RowCount == 0) { XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error"); return; } if (rp.RowCount > 0) { rdoc.QuantityLeft += idoc.Quantity; rp.Balance += idoc.Quantity; //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); // are we adding it the pick face? // if so add it to the balance of the pick face also pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { PutawayLocation plocation = new PutawayLocation(rdoc.ItemID); // we don't have a location for this yet, // select a new location //PutawayLocataion pl = new PutawayLocataion(); if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pl.LoadByPrimaryKey(plocation.PalletLocationID); if (pl.RowCount > 0) { pl.PalletID = rp.PalletID; pl.Save(); } } } if (pl.RowCount > 0) { PickFace pf = new PickFace(); pf.LoadByPalletLocation(pl.ID); if (pf.RowCount > 0) { pf.Balance += Convert.ToInt32(idoc.Quantity); pf.Save(); } IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId); idoc.MarkAsDeleted(); rdoc.Save(); rp.Save(); idoc.Save(); pld.Save(); } else { XtraMessageBox.Show( "This delete is not successful because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Receives from account transfer. /// </summary> /// <param name="PicklistID">The picklist ID.</param> /// <param name="StoreID">The store ID.</param> /// <param name="User">The user.</param> /// <param name="UserID">The user ID.</param> /// <returns></returns> public static String ReceiveFromAccountTransfer(int PicklistID, int StoreID, string User, int UserID) { PickListDetail pickListDetail = new PickListDetail(); pickListDetail.LoadByPickListID(PicklistID); DataView dv = pickListDetail.DefaultView; ReceiveDoc NewReceiveDoc = new ReceiveDoc(); String ReferenceID = ReceiveDoc.GetNextRefForTransfer(); foreach (DataRowView dvr in dv) { //Get ReceiveDoc information. int receiveDocID = Convert.ToInt32(dvr["ReceiveDocID"]); ReceiveDoc receiveDocFromPicklist = new ReceiveDoc(); receiveDocFromPicklist.LoadByPrimaryKey(receiveDocID); //We have all the Receivedoc information that we want NewReceiveDoc.AddNew(); if (receiveDocFromPicklist.s_BatchNo == null) NewReceiveDoc.BatchNo = receiveDocFromPicklist.BatchNo; NewReceiveDoc.ItemID = receiveDocFromPicklist.ItemID; NewReceiveDoc.SupplierID = receiveDocFromPicklist.SupplierID; if (receiveDocFromPicklist.s_ExpDate == null) NewReceiveDoc.ExpDate = receiveDocFromPicklist.ExpDate; NewReceiveDoc.StoreID = StoreID; NewReceiveDoc.ReceivedBy = User; NewReceiveDoc.Remark = receiveDocFromPicklist.Remark; NewReceiveDoc.RefNo = "TA" + receiveDocFromPicklist.RefNo; if (!receiveDocFromPicklist.IsColumnNull("Cost")) NewReceiveDoc.Cost = receiveDocFromPicklist.Cost; NewReceiveDoc.ManufacturerId = receiveDocFromPicklist.ManufacturerId; NewReceiveDoc.Quantity = Convert.ToInt32(dvr["Packs"]) * Convert.ToInt32(dvr["QtyPerPack"]); NewReceiveDoc.NoOfPack = Convert.ToInt32(dvr["Packs"]); NewReceiveDoc.QtyPerPack = Convert.ToInt32(dvr["QtyPerPack"]); if (!receiveDocFromPicklist.IsColumnNull("PricePerPack")) NewReceiveDoc.PricePerPack = receiveDocFromPicklist.PricePerPack; if (!receiveDocFromPicklist.IsColumnNull("SellingPrice")) NewReceiveDoc.SellingPrice = receiveDocFromPicklist.SellingPrice; NewReceiveDoc.UnitID = receiveDocFromPicklist.UnitID; NewReceiveDoc.DeliveryNote = receiveDocFromPicklist.DeliveryNote; //NewReceiveDoc.PricePerPack = receiveDocFromPicklist.PricePerPack; NewReceiveDoc.QuantityLeft = Convert.ToInt32(dvr["Packs"]) * Convert.ToInt32(dvr["QtyPerPack"]); NewReceiveDoc.EurDate = DateTimeHelper.ServerDateTime; NewReceiveDoc.Date = EthiopianDate.EthiopianDate.Now.ToGregorianDate(); NewReceiveDoc.IsDamaged = receiveDocFromPicklist.IsDamaged; NewReceiveDoc.Save(); NewReceiveDoc.SetStatusAsReceived(UserID); PalletizeTransfer(NewReceiveDoc); } return ReferenceID; }
private static void HandleReceiveDocDeleting(int receiveDocID, int userID, ReceiveDoc rd) { //Check if there is a Related Picklists var pld = new PickListDetail(); pld.LoadByReceiveDocID(receiveDocID); pld.Rewind(); if(pld.RowCount > 0) { var pl = new PickList(); pl.LoadByPrimaryKey(pld.PickListID); var order = new Order(); order.LoadByPrimaryKey(pl.OrderID); string printedIDs = ""; var stvs = new BLL.Issue(); stvs.Where.PickListID.Value = pl.ID; stvs.Query.Load(); stvs.Rewind(); while (!stvs.EOF) { printedIDs += stvs.IDPrinted.ToString(CultureInfo.InvariantCulture) + " ,"; stvs.MoveNext(); } printedIDs = printedIDs.Remove(printedIDs.Length - 1, 1); throw new Exception( string.Format("Please cancel/void the following Stvs: Ref No = {0} With PrintedIDs : {1}", order.RefNo,printedIDs)); } // Add new record on ReceiveDocDeleted var recDel = ReceiveDocDeleted.AddNewLog(rd, userID); // Delete related ReceivePallet var receivePallet = new BLL.ReceivePallet(); receivePallet.LoadByReceiveDocID(receiveDocID); receivePallet.Rewind(); while(!receivePallet.EOF) { receivePallet.MarkAsDeleted(); receivePallet.MoveNext(); } // Delete related ReceivePriceConfirmation var receivePriceConfirmation = new ReceivePriceConfirmation(); receivePriceConfirmation.LoadByReceiveDocID(rd.ID); receivePriceConfirmation.MarkAsDeleted(); // Delete related ReceiveDocShortage var rdShr = new ReceiveDocShortage(); rdShr.Where.ReceiveDocID.Value = rd.ID; rdShr.Query.Load(); rdShr.Rewind(); while(!rdShr.EOF) { rdShr.MarkAsDeleted(); rdShr.MoveNext(); } // Delete related ReceiveDocConfirmation var rdConf = new ReceiveDocConfirmation(); rdConf.Where.ReceiveDocID.Value = rd.ID; rdConf.Query.Load(); rdConf.Rewind(); while(!rdConf.EOF) { rdConf.MarkAsDeleted(); rdConf.MoveNext(); } rd.MarkAsDeleted(); var transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); transaction.BeginTransaction(); try { receivePallet.Save(); receivePriceConfirmation.Save(); rdShr.Save(); rdConf.Save(); recDel.Save(); rd.Save(); transaction.CommitTransaction(); } catch (Exception exception) { transaction.RollbackTransaction(); throw; } }
/// <summary> /// Saves the new receive doc entry from picklist detail. /// </summary> /// <param name="pld">The PLD.</param> /// <param name="userID">The user ID.</param> /// <param name="activityID">The new store ID.</param> /// <param name="newPhysicalStoreID">The new physical store ID.</param> /// <param name="convertedEthDate">The converted eth date.</param> /// <param name="supplierID">Activity or Store where it has Transfered from </param> /// <exception cref="System.Exception"></exception> internal void SaveNewReceiveDocEntryFromPicklistDetail(PickListDetail pld, int userID, int activityID, int newPhysicalStoreID, DateTime convertedEthDate,int receiptID,int? supplierID) { BLL.User user = new User(); user.LoadByPrimaryKey(userID); BLL.ReceiveDoc rdOriginal = new ReceiveDoc(); rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID); //Now Save the receive doc entry this.AddNew(); this.SetColumn("BatchNo", pld.GetColumn("BatchNumber")); this.ItemID = pld.ItemID; if (supplierID != null) this.SupplierID = supplierID.Value; this.Quantity = pld.QuantityInBU; //this.Date= this.Date = convertedEthDate; this.SetColumn("ExpDate", rdOriginal.GetColumn("ExpDate")); this.Out = false; this.ReceivedBy = user.UserName; this.StoreID = activityID; SetColumn("LocalBatchNo", rdOriginal.GetColumn("LocalBatchNo")); this.RefNo = receiptID.ToString(); this.SetColumn("Cost", rdOriginal.GetColumn("Cost")); this.SetColumn("IsApproved", rdOriginal.GetColumn("IsApproved")); this.ManufacturerId = rdOriginal.ManufacturerId; this.QuantityLeft = this.Quantity; this.NoOfPack = pld.Packs; this.QtyPerPack = rdOriginal.QtyPerPack; this.EurDate = DateTimeHelper.ServerDateTime; this.SetColumn("SellingPrice", rdOriginal.GetColumn("SellingPrice")); this.SetColumn("UnitCost", rdOriginal.GetColumn("Cost")); this.SetColumn("Cost", rdOriginal.GetColumn("Cost")); this.SetColumn("PricePerPack", rdOriginal.GetColumn("Cost")); this.SetColumn("UnitID", rdOriginal.GetColumn("UnitID")); this.SetColumn("DeliveryNote", rdOriginal.GetColumn("DeliveryNote")); this.Confirmed = false; this.ConfirmedDateTime = DateTimeHelper.ServerDateTime; this.ReturnedStock = false; this.ReceiptID = receiptID; this.PhysicalStoreID = newPhysicalStoreID; PhysicalStore physicalStore = new PhysicalStore(); physicalStore.LoadByPrimaryKey(newPhysicalStoreID); this.InventoryPeriodID = physicalStore.CurrentInventoryPeriodID; this.SetColumn("Margin", rdOriginal.GetColumn("Margin")); this.InvoicedNoOfPack = pld.Packs; this.IsDamaged = (bool) rdOriginal.GetColumn("IsDamaged"); this.Save(); //Now Save the ReceiveDocConfirmation ReceiveDocConfirmation rdConf = new ReceiveDocConfirmation(); rdConf.AddNew(); rdConf.ReceiveDocID = this.ID; rdConf.ReceivedByUserID = userID; rdConf.ReceiptConfirmationStatusID = BLL.ReceiptConfirmationStatus.Constants.RECEIVE_ENTERED; rdConf.Save(); //Now Save the palletization. ReceivePallet rp = new ReceivePallet(); rp.AddNew(); rp.ReceivedQuantity = this.Quantity; rp.Balance = this.Quantity; rp.ReservedStock = 0; rp.ReceiveID = this.ID; PalletLocation pLocation = new PalletLocation(); pLocation.LoadFirstOrDefault(newPhysicalStoreID, int.Parse(BLL.StorageType.BulkStore)); if (pLocation.RowCount == 0) { throw new Exception("No locations created in the destination store. Please check if there are Bulk store pallet locations in the physical store."); } else { if (pLocation.IsColumnNull("PalletID")) { Pallet pallet = new Pallet(); pallet.AddNew(); pallet.PalletNo = BLL.Pallet.GetLastPanelNumber() + 1; pallet.StorageTypeID = int.Parse(BLL.StorageType.Free); pallet.Save(); pLocation.PalletID = pallet.ID; } rp.PalletID = pLocation.PalletID; rp.PalletLocationID = pLocation.ID; rp.BoxSize = 0; rp.IsOriginalReceive = true; rp.Save(); } }
private void tpDelete_Click(object sender, EventArgs e) { DataRow dr = gridViewBinCard.GetFocusedDataRow(); if (Convert.ToInt32(dr["Precedance"]) != 3) { XtraMessageBox.Show("You cannot delete this"); return; } if (CurrentContext.LoggedInUser.UserType == UserType.Constants.DISTRIBUTION_MANAGER_WITH_DELETE) { if ( XtraMessageBox.Show( "Are you sure you want to delete this transaction? You will not be able to undo this.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyGeneration.dOOdads.TransactionMgr tranMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { tranMgr.BeginTransaction(); ReceiveDoc rdoc = new ReceiveDoc(); ReceivePallet rp = new ReceivePallet(); IssueDoc idoc = new IssueDoc(); PickListDetail pld = new PickListDetail(); int issueID = Convert.ToInt32(dr["ID"]); //pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"]), // Convert.ToInt32(dr["Quantity"])); idoc.LoadByPrimaryKey(issueID); pld.LoadByPrimaryKey(idoc.PLDetailID); string RefNo = idoc.RefNo; rdoc.LoadByPrimaryKey(idoc.RecievDocID); //if (pld.RowCount == 0) //{ // pld.LoadByOrderAndItem(Convert.ToInt32(dr["OrderID"]), Convert.ToInt32(dr["ItemID"])); //} rp.LoadByPrimaryKey(pld.ReceivePalletID); PalletLocation pl = new PalletLocation(); pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { pl.LoadByPrimaryKey(pld.PalletLocationID); if (pl.IsColumnNull("PalletID")) { pl.PalletID = rp.PalletID; pl.Save(); } //rp.LoadNonZeroRPByReceiveID(rdoc.ID); } if (rp.RowCount == 0) { XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error"); return; } if (rp.RowCount > 0) { rdoc.QuantityLeft += idoc.Quantity; rp.Balance += idoc.Quantity; pld.QuantityInBU = 0; // are we adding it the pick face? // if so add it to the balance of the pick face also pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { PutawayLocation plocation = new PutawayLocation(rdoc.ItemID); // we don't have a location for this yet, // select a new location //PutawayLocataion pl = new PutawayLocataion(); if (plocation.ShowDialog() == System.Windows.Forms.DialogResult.OK) { pl.LoadByPrimaryKey(plocation.PalletLocationID); if (pl.RowCount > 0) { pl.PalletID = rp.PalletID; pl.Save(); } } } if (pl.RowCount > 0) { PickFace pf = new PickFace(); pf.LoadByPalletLocation(pl.ID); if (pf.RowCount > 0) { pf.Balance += Convert.ToInt32(idoc.Quantity); pf.Save(); } IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId); idoc.MarkAsDeleted(); rdoc.Save(); rp.Save(); idoc.Save(); // now refresh the window XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); tranMgr.CommitTransaction(); //TODO: refresh the list // gridViewReferences_FocusedRowChanged(null, null); } } else { XtraMessageBox.Show( "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error); tranMgr.RollbackTransaction(); } } catch { XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); tranMgr.RollbackTransaction(); } } } else { XtraMessageBox.Show( "You cannot delete this transaction because you don't have previlage. Please contact the administrator if you thing this is an error.", "Delete is not allowed"); } }
/// <summary> /// Commits the account to account transfer. /// </summary> /// <param name="orderID">The order ID.</param> /// <param name="userID">The user ID.</param> /// <param name="convertedEthDate">The converted eth date.</param> public void CommitAccountToAccountTransfer(int orderID, int userID, DateTime convertedEthDate) { int? supplierID = null; BLL.Transfer transfer = new Transfer(); transfer.LoadByOrderID(orderID); if (transfer.RowCount == 0) return; int newStoreID, newPhysicalStoreID; newStoreID = transfer.ToStoreID; newPhysicalStoreID = transfer.ToPhysicalStoreID; PhysicalStore toPhysicalStore = new PhysicalStore(); toPhysicalStore.LoadByPrimaryKey(transfer.ToPhysicalStoreID); BLL.PickList picklist = new PickList(); picklist.LoadByOrderID(orderID); BLL.PickListDetail pld = new PickListDetail(); pld.LoadByPickListIDWithStvlogID(picklist.ID); BLL.ReceiveDoc rdOriginal = new ReceiveDoc(); rdOriginal.LoadByPrimaryKey(pld.ReceiveDocID); BLL.Order order=new Order(); order.LoadByPrimaryKey(orderID); if(order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER) { var activity = new Activity(); activity.LoadByPrimaryKey(newStoreID); supplierID = activity.SupplierID; } else if(order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER) { var activity = new Activity(); activity.LoadByPrimaryKey(newPhysicalStoreID); supplierID = activity.SupplierID; } PO po = PO.CreatePOforStandard( (int) order.GetColumn("OrderTypeID"),transfer.ToStoreID,supplierID,"Transfer",CurrentContext.LoggedInUser.ID); int IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted")); int receiptTypeID = order.OrderTypeID == OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER ? ReceiptType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER :order.OrderTypeID == OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER ? ReceiptType.CONSTANTS.STORE_TO_STORE_TRANSFER : order.OrderTypeID == OrderType.CONSTANTS.ERROR_CORRECTION_TRANSFER ? ReceiptType.CONSTANTS.ERROR_CORRECTION:ReceiptType.CONSTANTS.STANDARD_RECEIPT; Receipt receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID,po.ID,toPhysicalStore.PhysicalStoreTypeID,IDPrinted,userID); var mergedPickLists = MergePickListsOfSameInfo(pld); // Picklists of the same info means: Based on all constraints we have on receiveDoc(Batch,Exp,ItemID,UnitID...): should be merged with summed quantity. pld.Rewind(); while (!pld.EOF) { if(IDPrinted != Convert.ToInt32(pld.GetColumn("IDPrinted"))) { IDPrinted = Convert.ToInt32(pld.GetColumn("IDPrinted")); receipt = ReceiptInvoice.CreateReceiptInvoiceAndReceiptForTransfer(receiptTypeID,po.ID, toPhysicalStore.PhysicalStoreTypeID, IDPrinted, userID); } var rDoc = new ReceiveDoc(); if (!mergedPickLists.ContainsKey(pld.ID)) { pld.MoveNext(); continue; } rDoc.SaveNewReceiveDocEntryFromPicklistDetail(pld, userID, newStoreID, newPhysicalStoreID, convertedEthDate,receipt.ID,supplierID); pld.MoveNext(); } }
private Dictionary <int, Dictionary <decimal, decimal> > MergePickListsOfSameInfo(PickListDetail pld) //~ Dic(Pld.ID,Dic<pld.Pack,pld.QuanInBU>) Just to make things simple~// { var mergedPickLists = new Dictionary <int, Dictionary <decimal, decimal> >(); var valid = _receiveDocConstraintHelper.IsValid(pld.DefaultView.Table); if (valid) { pld.Rewind(); while (!pld.EOF) { var pack_QInBU = new Dictionary <decimal, decimal> { { pld.Packs, pld.QuantityInBU } }; mergedPickLists[pld.ID] = pack_QInBU; pld.MoveNext(); } return(mergedPickLists); } var groupedPickLists = _receiveDocConstraintHelper.GroupByConstraints(pld.DefaultView.Table); foreach (DataRow groupedPickList in groupedPickLists.Rows) { var pack_QInBU = new Dictionary <decimal, decimal> { { Convert.ToDecimal(groupedPickList["Packs"]), Convert.ToDecimal(groupedPickList["QuantityInBU"]) } }; mergedPickLists[Convert.ToInt32(groupedPickList["ID"])] = pack_QInBU; } pld.Rewind(); while (!pld.EOF) { if (mergedPickLists.ContainsKey(pld.ID)) { var packs = mergedPickLists[pld.ID].FirstOrDefault().Key; pld.Packs = packs; pld.QuantityInBU = mergedPickLists[pld.ID][packs]; } pld.MoveNext(); } return(mergedPickLists); }
/// <summary> /// Undo pick list that has been printed /// </summary> /// <param name="orderID">The order ID.</param> public void CancelOrderWithPickList(int orderID) { // Create a pick list entry Order ord = new Order(); PickList pl = new PickList(); PickListDetail pld = new PickListDetail(); ReceivePallet rp = new ReceivePallet(); ReceiveDoc rd = new ReceiveDoc(); PickFace pf = new PickFace(); PalletLocation palletLocation = new PalletLocation(); ord.LoadByPrimaryKey(orderID); pl.LoadByOrderID(orderID); pld.LoadByPickListID(pl.ID); while (!pld.EOF) { rp.LoadByPrimaryKey(pld.ReceivePalletID); rp.ReservedStock -= Convert.ToInt32(pld.QuantityInBU); if (rp.ReservedStock < 0) rp.ReservedStock = 0; //If there has been no reservation, allow to cancel the picklist too. No need for it to be blocked by the constraint. rp.Save(); palletLocation.LoadByPrimaryKey(pld.PalletLocationID); if (palletLocation.StorageTypeID.ToString() == StorageType.PickFace) { pf.LoadByPalletLocation(pld.PalletLocationID); pf.Balance += Convert.ToInt32(pld.QuantityInBU); pf.Save(); } //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); pld.MoveNext(); } pld.Save(); ord.ChangeStatus(OrderStatus.Constant.CANCELED,CurrentContext.UserId); pl.MarkAsDeleted(); pl.Save(); }
private void SaveOrder() { var order = GenerateOrder(); var picklist = PickList.GeneratePickList(order.ID); int lineNo = 0; // This is a kind of initializing the data table. OrderDetail ord = new OrderDetail(); PickListDetail pkDetail = new PickListDetail(); DataView dv = orderGrid.DataSource as DataView; foreach (DataRowView r in dv) { if (r["ApprovedPacks"] != null && r["ApprovedPacks"] != DBNull.Value && r["ApprovedPacks"].ToString()!= "") if (Convert.ToInt32(r["ApprovedPacks"]) != 0) { lineNo = lineNo + 1; int itemID = Convert.ToInt32(r["ItemID"]); int unitID = Convert.ToInt32(r["UnitID"]); ord.AddNew(); ord.OrderID = order.ID; ord.ItemID = itemID; if (r["ApprovedPacks"] != DBNull.Value) { ord.Pack = Convert.ToInt32(r["ApprovedPacks"]); } if (r["QtyPerPack"] != DBNull.Value) { ord.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]); } ord.Quantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]); ord.ApprovedQuantity = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]); ord.UnitID = unitID; ord.StoreID = Convert.ToInt32(lkAccountType.EditValue); ord.Save(); pkDetail.AddNew(); pkDetail.PickListID = picklist.ID; pkDetail.ItemID = itemID; pkDetail.PalletLocationID = Convert.ToInt32(r["LocationID"]); pkDetail.BatchNumber = r["BatchNo"].ToString(); if (r["ExpDate"] != DBNull.Value) pkDetail.ExpireDate = DateTime.Parse(r["ExpDate"].ToString()); pkDetail.StoreID = Convert.ToInt32(r["StoreID"]); pkDetail.UnitID = unitID; pkDetail.ReceiveDocID = Convert.ToInt32(r["ReceiveDocID"]); if (r["UnitPrice"] != DBNull.Value) { pkDetail.Cost = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]); pkDetail.UnitPrice = Convert.ToDouble(r["UnitPrice"]); } pkDetail.Packs = Convert.ToInt32(r["ApprovedPacks"]); pkDetail.QtyPerPack = Convert.ToInt32(r["QtyPerPack"]); pkDetail.QuantityInBU = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToInt32(r["QtyPerPack"]); pkDetail.StoreID = Convert.ToInt32(r["StoreID"]); pkDetail.ReceivePalletID = Convert.ToInt32(r["ReceivingLocationID"]); pkDetail.ManufacturerID = Convert.ToInt32(r["ManufacturerID"]); pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; pkDetail.Save(); //To Print The Picklist //Then reserve Items ReceivePallet receivepallet = new ReceivePallet(); receivepallet.LoadByPrimaryKey(Convert.ToInt32(r["ReceivingLocationID"])); receivepallet.ReservedStock = receivepallet.ReservedStock + Convert.ToInt32(r["ApprovedPacks"]); receivepallet.Save(); DataRow drvpl = dvPickList.NewRow(); drvpl["FullItemName"] = r["FullItemName"]; drvpl["StockCode"] = r["StockCode"]; drvpl["BatchNo"] = r["BatchNo"]; if (r["ExpDate"] != DBNull.Value) drvpl["ExpDate"] = Convert.ToDateTime(r["ExpDate"]).ToString("MMM/yyyy"); else drvpl["ExpDate"] = DBNull.Value; drvpl["LineNum"] = lineNo + 1; drvpl["ManufacturerName"] = r["Manufacturer"]; drvpl["Pack"] = r["ApprovedPacks"]; drvpl["UnitPrice"] = r["UnitPrice"]; drvpl["Unit"] = r["Unit"]; drvpl["PalletLocation"] = r["Location"]; drvpl["QtyInSKU"] = Convert.ToInt32(r["ApprovedPacks"]); if (r["UnitPrice"] != DBNull.Value) drvpl["CalculatedCost"] = Convert.ToInt32(r["ApprovedPacks"]) * Convert.ToDouble(r["UnitPrice"]); PalletLocation palletLocation = new PalletLocation(); palletLocation.LoadByPrimaryKey(pkDetail.PalletLocationID); drvpl["WarehouseName"] = palletLocation.WarehouseName; drvpl["PhysicalStoreName"] = palletLocation.PhysicalStoreName; var activity = new Activity(); activity.LoadByPrimaryKey(pkDetail.StoreID); drvpl["ActivityConcat"] = activity.FullActivityName; drvpl["AccountName"] = activity.AccountName; dvPickList.Rows.Add(drvpl); } } if (lineNo == 0) throw new System.ArgumentException("Please review your list,you haven't approved any Quantity"); var plr = HCMIS.Desktop.Reports.WorkflowReportFactory.CreatePicklistReport(order, lkForHub.Text, dvPickList.DefaultView); plr.PrintDialog(); if (!BLL.Settings.IsCenter) { if (TransferTypeID == 3) { XtraMessageBox.Show("Your Store To Store Transfer will be Printed now", "Store To Store Transfer"); Transfer.Move(picklist.ID); HCMIS.Desktop.Reports.StoreTransferPrintOut STM = new HCMIS.Desktop.Reports.StoreTransferPrintOut(); STM.LoadByPickListID(picklist.ID); STM.PrintDialog(); } else if (TransferTypeID == 2) { XtraMessageBox.Show(ReceiveDoc.ReceiveFromAccountTransfer(picklist.ID, Convert.ToInt32(lkForHub.EditValue), CurrentContext.LoggedInUserName, CurrentContext.UserId)); } } else { XtraMessageBox.Show("Picklist Prepared!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// This happes when there is plenty of transaction at the same time /// and will result a partial commit. /// This fake rows should be deleted from DB. /// </summary> /// <param name="orderID"></param> private void RemoveFakePartialCommitPickListDetails(int orderID) { var order = new Order(); order.LoadByPrimaryKey(orderID); if (order.OrderStatusID == OrderStatus.Constant.ORDER_APPROVED) { var pickList = new PickList(); pickList.LoadByOrderID(order.ID); if (pickList.RowCount == 0) //~ If there is no picklist, there is nothing to delete. ~// return; var picklistDetail = new PickListDetail(); picklistDetail.LoadByPickListID(pickList.ID); picklistDetail.Rewind(); while (!picklistDetail.EOF) { PickListDetailDeleted.AddNewLog(picklistDetail, CurrentContext.UserId); picklistDetail.MarkAsDeleted(); picklistDetail.MoveNext(); } picklistDetail.Save(); pickList.MarkAsDeleted(); pickList.Save(); } }
public static void DeleteIssueDoc(int issueID) { MyGeneration.dOOdads.TransactionMgr tranMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr(); try { tranMgr.BeginTransaction(); var pld = new PickListDetail(); var rdoc = new ReceiveDoc(); var rp = new ReceivePallet(); var idoc = new IssueDoc(); idoc.LoadByPrimaryKey(issueID); pld.LoadByPrimaryKey(idoc.PLDetailID); rdoc.LoadByPrimaryKey(idoc.RecievDocID); rp.LoadByPrimaryKey(pld.ReceivePalletID); var pl = new PalletLocation(); pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { pl.LoadByPrimaryKey(pld.PalletLocationID); if (pl.IsColumnNull("PalletID")) { pl.PalletID = rp.PalletID; pl.Save(); } } if (rp.RowCount == 0) { XtraMessageBox.Show("You cannot delete this item, please contact the administrator", "Error"); return; } if (rp.RowCount > 0) { // in error cases this could lead to a number greater than the received quantity // instead of being an error, it should just delete the respective issue and // adjust the remaining quantity to the received quantity. if (rdoc.QuantityLeft + idoc.Quantity > rdoc.Quantity) { rdoc.QuantityLeft = rp.Balance = rdoc.Quantity; } else { rdoc.QuantityLeft += idoc.Quantity; rp.Balance += idoc.Quantity; } //Delete from picklistDetail and add to pickListDetailDeleted PickListDetailDeleted.AddNewLog(pld, BLL.CurrentContext.UserId); pld.MarkAsDeleted(); // are we adding it the pick face? // if so add it to the balance of the pick face also pl.loadByPalletID(rp.PalletID); if (pl.RowCount == 0) { var plocation = new PutawayLocation(rdoc.ItemID); // we don't have a location for this yet, // select a new location //PutawayLocataion pl = new PutawayLocataion(); if (plocation.ShowDialog() == DialogResult.OK) { pl.LoadByPrimaryKey(plocation.PalletLocationID); if (pl.RowCount > 0) { pl.PalletID = rp.PalletID; pl.Save(); } } } if (pl.RowCount > 0) { var pf = new PickFace(); pf.LoadByPalletLocation(pl.ID); if (pf.RowCount > 0) { pf.Balance += Convert.ToInt32(idoc.Quantity); pf.Save(); } IssueDocDeleted.AddNewLog(idoc, CurrentContext.UserId); idoc.MarkAsDeleted(); rdoc.Save(); rp.Save(); idoc.Save(); pld.Save(); // now refresh the window XtraMessageBox.Show("Issue Deleted!", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information); tranMgr.CommitTransaction(); } } else { XtraMessageBox.Show( "This delete is not successfull because a free pick face location was not selected. please select a free location and try again.", "Error Deleteing issue transaction", MessageBoxButtons.OK, MessageBoxIcon.Error); tranMgr.RollbackTransaction(); } } catch { XtraMessageBox.Show("This delete is not successfull", "Warning ...", MessageBoxButtons.OK, MessageBoxIcon.Warning); tranMgr.RollbackTransaction(); } }
/// <summary> /// Handles the Click event of the btnPrint control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> private void btnPrint_Click(object sender, EventArgs e) { DataRow dr = gridViewTransaction.GetFocusedDataRow(); PickList pl = new PickList(); PickListDetail pld = new PickListDetail(); int orderId = Convert.ToInt32(dr["OrderID"]); DataView dv = pl.GetPickedOrderDetailForOrder(_stvLogIdChosen.Value, false); XtraReport xtraReport = RePrintSTV(dv, orderId, pl, _stvLogIdChosen, false, false); if (xtraReport != null) { xtraReport.PrintDialog(); } }
internal static PickListDetail GeneratePickListDetail(ReceivePallet receivePallet, int pickListId,decimal qtyInBU) { ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(receivePallet.ReceiveID); decimal pack = qtyInBU / Convert.ToDecimal(receiveDoc.QtyPerPack); PickListDetail pkDetail = new PickListDetail(); pkDetail.AddNew(); pkDetail.PickListID = pickListId; pkDetail.ItemID = receiveDoc.ItemID; PalletLocation palletLocation = new PalletLocation(); palletLocation.loadByPalletID(receivePallet.PalletID); int palletLocationId; try { palletLocationId = palletLocation.ID; } catch (Exception exp) { palletLocationId = receivePallet.PalletLocationID; palletLocation.LoadByPrimaryKey(palletLocationId); } pkDetail.PalletLocationID = palletLocationId; if (!receiveDoc.IsColumnNull("BatchNo")) pkDetail.BatchNumber = receiveDoc.BatchNo; if (!receiveDoc.IsColumnNull("ExpDate")) pkDetail.ExpireDate = receiveDoc.ExpDate; pkDetail.StoreID = receiveDoc.StoreID; pkDetail.UnitID = receiveDoc.UnitID; pkDetail.ReceiveDocID = receiveDoc.ID; if (!receiveDoc.IsColumnNull("Cost")) { pkDetail.Cost = Convert.ToDouble(pack) * Math.Round(receiveDoc.Cost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); pkDetail.UnitPrice = Math.Round(receiveDoc.Cost, BLL.Settings.NoOfDigitsAfterTheDecimalPoint); } pkDetail.Packs = pack; pkDetail.QtyPerPack = receiveDoc.QtyPerPack; pkDetail.QuantityInBU = qtyInBU; pkDetail.StoreID = receiveDoc.StoreID; pkDetail.ReceivePalletID = receivePallet.ID; pkDetail.ManufacturerID = receiveDoc.ManufacturerId; pkDetail.BoxLevel = 0; pkDetail.DeliveryNote = true; pkDetail.PhysicalStoreID = palletLocation.PhysicalStoreID; pkDetail.Save(); return pkDetail; }
/// <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> /// Fix For Delivery Note When Converting Do not use under any other situation /// </summary> /// <param name="issueDocID"></param> /// <param name="picklistID"></param> /// <returns></returns> public PickListDetail FixDeliveryNoteCostReceiveDoc(int issueDocID, int picklistID) { IssueDoc issueDoc = new IssueDoc(); issueDoc.LoadByPrimaryKey(issueDocID); PickListDetail pickList = new PickListDetail(); pickList.LoadByPrimaryKey(picklistID); //safety first if (issueDoc.RecievDocID != pickList.ReceiveDocID) { Item item = new Item(); item.LoadByPrimaryKey(picklistID); throw new Exception(String.Format("PicklistDetail vs IssueDoc Inconsistancy for Item {0}", item.FullItemName)); } // now we are sure we have one ReceiveDocID ReceiveDoc receiveDoc = new ReceiveDoc(); receiveDoc.LoadByPrimaryKey(pickList.ReceiveDocID); ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation(); receiveDocConfirmation.LoadByReceiveDocID(receiveDoc.ID); //Check if it has been Printed and that Selling Price and Cost is set if (receiveDocConfirmation.ReceiptConfirmationStatusID == ReceiptConfirmationStatus.Constants.GRV_PRINTED) { double unitPrice, unitCost, margin; if (Settings.IsCenter == true && !receiveDoc.IsColumnNull("Cost") && receiveDoc.Cost != 0) { unitPrice = Math.Round(receiveDoc.Cost, 2); unitCost = Math.Round(receiveDoc.Cost, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else if (!receiveDoc.IsColumnNull("SellingPrice") && receiveDoc.SellingPrice != 0) { unitPrice = Math.Round(receiveDoc.SellingPrice, 2); unitCost = Math.Round(receiveDoc.SellingPrice, 2); margin = !receiveDoc.IsColumnNull("Margin") ? receiveDoc.Margin : 0; } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("Price Not set For item: {0}", item.FullItemName)); } pickList.UnitPrice = unitPrice; pickList.Cost = Convert.ToDouble(pickList.Packs) * unitPrice; issueDoc.SellingPrice = Convert.ToDecimal(unitPrice); issueDoc.Cost = Convert.ToDouble(issueDoc.NoOfPack) * unitPrice; issueDoc.UnitCost = Convert.ToDecimal(unitCost); issueDoc.Margin = Convert.ToDecimal(margin); pickList.Save(); issueDoc.Save(); } else { var item = new Item(); item.LoadByPrimaryKey(pickList.ItemID); throw new Exception(String.Format("GRV/IGRV Not Printed For Item: {0}", item.FullItemName)); } return(pickList); }