public DataTable GetUserNamebyReceipt(int ReceiptID)
 {
     ReceiveDocConfirmation rdc = new ReceiveDocConfirmation();
     var query = HCMIS.Repository.Queries.ReceiveDocConfirmation.SelectGetUserNamebyReceipt(ReceiptID);
     rdc.LoadFromRawSql(query);
     return rdc.DataTable;
 }
        public DataTable GetUserNamebyReceipt(int ReceiptID)
        {
            ReceiveDocConfirmation rdc = new ReceiveDocConfirmation();
            var query = HCMIS.Repository.Queries.ReceiveDocConfirmation.SelectGetUserNamebyReceipt(ReceiptID);

            rdc.LoadFromRawSql(query);
            return(rdc.DataTable);
        }
        public void ChangeStatusByAccountReceiveDocs(string receiveDocs,int StatusID,int? PreviousStatusID = null)
        {
            if (receiveDocs!= "")
            {
                ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();

                var query = HCMIS.Repository.Queries.ReceiveDocConfirmation.UpdateChangeStatusByAccountReceiveDocs(receiveDocs, StatusID, PreviousStatusID);

                     receiveDocConfirmation.LoadFromRawSql(query);
                    }
        }
        public void ChangeStatusByAccountReceiveDocs(string receiveDocs, int StatusID, int?PreviousStatusID = null)
        {
            if (receiveDocs != "")
            {
                ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();

                var query = HCMIS.Repository.Queries.ReceiveDocConfirmation.UpdateChangeStatusByAccountReceiveDocs(receiveDocs, StatusID, PreviousStatusID);


                receiveDocConfirmation.LoadFromRawSql(query);
            }
        }
 private void btnChangeReceiptConfirmationStatus_Click(object sender, EventArgs e)
 {
     int newReceiptConfirmationStatus = int.Parse(lkReceiptConfirmationStatus.EditValue.ToString());
     BLL.ReceiveDoc rd = new ReceiveDoc();
     rd.LoadByReceiptID(int.Parse(txtReceiptID.Text));
     while (!rd.EOF)
     {
         ReceiveDocConfirmation rdc = new ReceiveDocConfirmation();
         rdc.LoadByReceiveDocID(rd.ID);
         rdc.ReceiptConfirmationStatusID = newReceiptConfirmationStatus;
         rdc.Save();
         rd.MoveNext();
     }
     XtraMessageBox.Show("Successful!");
 }
        internal void ChangeQuantity(decimal quantity)
        {
            ItemUnit itemUnit = new ItemUnit();
            itemUnit.LoadByPrimaryKey(UnitID);
            ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();
            receiveDocConfirmation.LoadByReceiveDocID(ID);

            if(receiveDocConfirmation.ReceiptConfirmationStatusID == ReceiptConfirmationStatus.Constants.GRV_PRINTED)
            {
                throw new Exception("Price has already been set for this Item, You cannot commit the Change you have Made");
            }

            if(QuantityLeft != Quantity)
            {
                 throw new Exception("Some Quantity has already been issued, You cannot commit the Change you have Made");
            }

            QuantityLeft= Quantity = quantity * itemUnit.QtyPerUnit;
            InvoicedNoOfPack = NoOfPack = quantity;
            Save();
            ReceivePallet receivePallet = new ReceivePallet();
            receivePallet.LoadByReceiveDocID(ID);

            receivePallet.ReceivedQuantity = receivePallet.Balance = Quantity;
            receivePallet.Save();
        }
Beispiel #7
0
        /// <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);
        }
        /// <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;
        }
        /// <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 repIsConfirmed_CheckedChanged(object sender, EventArgs e)
 {
     DataRow Masterdr = gridMasterView.GetFocusedDataRow();
     Masterdr["IsConfirmed"] =(sender as CheckEdit).Checked;
     bool IsConfirmed = Convert.ToBoolean(Masterdr["IsConfirmed"]);
     if(XtraMessageBox.Show(String.Format("Are you sure you want to {0}",IsConfirmed?"Confirm":"UnConfirm"),"Are you sure...",MessageBoxButtons.YesNo,MessageBoxIcon.Question) == DialogResult.Yes)
     {
         ReceiveDocConfirmation  receiveDocConfirmation = new ReceiveDocConfirmation();
         string ReceiveDocs = Masterdr["ReceiveDocIds"].ToString();
         receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(ReceiveDocs,IsConfirmed?ReceiptConfirmationStatus.Constants.GRNF_PRINTED:ReceiptConfirmationStatus.Constants.RECEIVE_QUANTITY_CONFIRMED);
     }
 }
        private void btnApprove_Click(object sender, EventArgs e)
        {
            //dxCostingValidation.RemoveControlError(lkPeriod);
            if (!dxCostingValidation.Validate()) return;
             if (lkWarehouse.EditValue != null && lkAccount.EditValue != null && XtraMessageBox.Show(String.Format("Are you sure you want to Approve All Items, Once Approved the item will be available for release"), "Are you sure...", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
             try
             {

             ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();
             string receiveDocs = "";
             string rdPendingAverages = "";
             var ledgerService = new LedgerService();
             DataView dataView = (gridMain.DataSource as DataView);
             dataView.RowFilter = "PricePerPack <>0 and isConfirmed = 1";
             foreach (DataRowView drv in dataView)
             {
                 var costElement = new CostElement
                                       {
                                           ItemID = Convert.ToInt32(drv["ItemID"]),
                                           ItemUnitID = Convert.ToInt32(drv["UnitID"]),
                                           ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]),
                                           MovingAverageID = Convert.ToInt32(drv["MovingAverageID"])
                                       };

                 var ledgerObject = ledgerService.GetLedger(costElement.ItemID, costElement.ItemUnitID,
                                                            costElement.ManufacturerID, costElement.MovingAverageID);

                 costElement.UnitCost = Math.Round(Convert.ToDouble(ledgerObject.UnitCost),
                                                   BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                                   MidpointRounding.AwayFromZero);
                 costElement.AverageCost = Math.Round(Convert.ToDouble(drv["PricePerPack"]),
                                                      BLL.Settings.NoOfDigitsAfterTheDecimalPoint,
                                                      MidpointRounding.AwayFromZero);
                 costElement.Margin = Convert.ToDouble(drv["Margin"])/100;
                 costElement.SellingPrice = costElement.AverageCost*(1 + costElement.Margin);
                 var isSound = drv["Remark"].Equals("Sound");
                 if ((Math.Abs(costElement.UnitCost - costElement.AverageCost) == 0) || !isSound)
                 {

                     receiveDocs = receiveDocs != ""
                                       ? receiveDocs + ',' + drv["ReceiveDocIDs"].ToString()
                                       : receiveDocs + drv["ReceiveDocIDs"].ToString();
                 }
                 else if (ReceiveDoc.GetSoundStock(costElement) > 0)
                 {
                     rdPendingAverages = rdPendingAverages != ""
                                             ? rdPendingAverages + ',' + drv["ReceiveDocIDs"].ToString()
                                             : rdPendingAverages + drv["ReceiveDocIDs"].ToString();

                 }
                 else
                 {

                     IJournalService journal = new JournalService();
                     journal.StartRecordingSession();
                     costElement.SavePrice(CurrentContext.UserId, "", journal, ChangeMode.BeginningBalance);
                     journal.CommitRecordingSession();

                     journal.StartRecordingSession();
                     costElement.ConfirmPrice(CurrentContext.UserId, "", journal, ChangeMode.BeginningBalance);
                     journal.CommitRecordingSession();

                     receiveDocs = receiveDocs != ""
                                       ? receiveDocs + ',' + drv["ReceiveDocIDs"].ToString()
                                       : receiveDocs + drv["ReceiveDocIDs"].ToString();
                 }

             }

             receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(receiveDocs,
                                                                     ReceiptConfirmationStatus.Constants.GRV_PRINTED,
                                                                     ReceiptConfirmationStatus.Constants.GRNF_PRINTED);
             receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(rdPendingAverages,
                                                                     ReceiptConfirmationStatus.Constants.
                                                                         PRICE_CALCULATED,
                                                                     ReceiptConfirmationStatus.Constants.GRNF_PRINTED);
             XtraMessageBox.Show("Price has been successfully confirmed", "Success...", MessageBoxButtons.OK,
                                 MessageBoxIcon.Information);
             }
             catch (Exception exception)
             {
                 XtraMessageBox.Show(exception.Message, "Success...", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                 throw;
             }
                      lkWarehouse_EditValueChanged(null, null);
             }
        }
        private void btnMovingAverage_Click(object sender, EventArgs e)
        {
            MyGeneration.dOOdads.TransactionMgr transaction = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();

            var dialogResult =
                XtraMessageBox.Show(
                    String.Format("Are you Sure you want to Set the  Price for {0}", txtItemName.Text),
                    "Are you sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            if (dialogResult == DialogResult.Cancel)
            {
                return;
            }

            if (dialogResult == DialogResult.Yes)
            {
                try
                {
                    transaction.BeginTransaction();
                    // This is where we set the Price
                    JournalService journalService = new JournalService();
                    journalService.StartRecordingSession();
                    costElement.SavePrice(CurrentContext.UserId, "", journalService, ChangeMode.BeginningBalance);
                    journalService.CommitRecordingSession();
                    journalService.StartRecordingSession();
                    costElement.ConfirmPrice(CurrentContext.UserId, "", journalService, ChangeMode.BeginningBalance);
                    journalService.CommitRecordingSession();
                    ReceiveDoc receiveDoc = new ReceiveDoc();
                    receiveDoc.SavePrice(costElement, CurrentContext.UserId);

                    ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();
                    receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(receiveDocs, ReceiptConfirmationStatus.Constants.GRV_PRINTED, ReceiptConfirmationStatus.Constants.PRICE_CALCULATED);
                    transaction.CommitTransaction();
                    this.Close();
                }
                catch (Exception exception)
                {
                    transaction.RollbackTransaction();
                    XtraMessageBox.Show("Error : " + exception.Message, "Error...", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    throw exception;
                }
            }
        }
        private void btnConfirmAll_Click(object sender, EventArgs e)
        {
            if (lkWarehouse.EditValue != null && lkAccount.EditValue != null &&
                XtraMessageBox.Show(String.Format("Are you sure you want to  Confirm?"), "Are you sure...",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                int StoreID = Convert.ToInt32(lkAccount.EditValue);
                int WarehouseID = Convert.ToInt32(lkWarehouse.EditValue);
                ReceiveDocConfirmation receiveDocConfirmation = new ReceiveDocConfirmation();
                string ReceiveDocs = "";
                foreach (DataRowView drv in (gridMain.DataSource as DataView))
                {
                    ReceiveDocs = ReceiveDocs != ""
                                      ? ReceiveDocs + ',' + drv["ReceiveDocIDs"].ToString()
                                      : ReceiveDocs + drv["ReceiveDocIDs"].ToString();

                }
                receiveDocConfirmation.ChangeStatusByAccountReceiveDocs(ReceiveDocs,
                                                                        ReceiptConfirmationStatus.Constants.
                                                                            GRNF_PRINTED);
                XtraMessageBox.Show("Price has been successfully confirmed", "Success...", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                lkWarehouse_EditValueChanged(null, null);

            }
        }
 /// <summary>
 /// Sets the status as received.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void SetStatusAsReceived(int? userID)
 {
     this.Rewind();
     while (!this.EOF)
     {
         int receiveID = this.ID;
         BLL.ReceiveDocConfirmation rDocConfirmation = new ReceiveDocConfirmation();
         rDocConfirmation.SetStatusItemReceived(receiveID, userID);
         this.MoveNext();
     }
 }
        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>
        /// Confirms the quantity and location.
        /// </summary>
        /// <param name="userID">The user ID.</param>
        public void ConfirmQuantityAndLocation(int? userID)
        {
            while (!this.EOF)
            {
                int receiveID = this.ID;
                BLL.ReceiveDocConfirmation rDocConfirmation = new ReceiveDocConfirmation();
                rDocConfirmation.SetStatusConfirmQuantityAndLocation(receiveID, userID);

                this.Save();
                this.MoveNext();
            }
        }
 /// <summary>
 /// Confirms the price.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void ConfirmPrice(int? userID)
 {
     while (!this.EOF)
     {
         int receiveID = this.ID;
         BLL.ReceiveDocConfirmation rDocConfirmation = new ReceiveDocConfirmation();
         rDocConfirmation.SetStatusConfirmPrice(receiveID, userID);
         this.MoveNext();
     }
 }
 /// <summary>
 /// Confirms the GRV printed.
 /// </summary>
 /// <param name="userID">The user ID.</param>
 public void ConfirmGRVPrinted(int? userID)
 {
     while (!this.EOF)
     {
         this.Confirmed = true;
         if (userID.HasValue)
         {
             this.ConfirmedByUserID = userID.Value;
         }
         this.ConfirmedDateTime = DateTimeHelper.ServerDateTime;
         int receiveID = this.ID;
         BLL.ReceiveDocConfirmation rDocConfirmation = new ReceiveDocConfirmation();
         rDocConfirmation.SetStatusPrintGRV(receiveID, userID);
         this.MoveNext();
     }
     this.Save();
 }