/// <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(); }