private void btnChangeTo_Click(object sender, EventArgs e)
        {
            // Do validation
            if (dxErrorCorrectionValidator.Validate() && IsItemDetailValid())
            {
                if (
                    XtraMessageBox.Show("Are you sure you want to commit this change? You will not be able to undo this.",
                                        "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }

                var      unitIdTo         = Convert.ToInt32(lkUnitTo.EditValue);
                var      manufacturerIdTo = Convert.ToInt32(lkManufacturerTo.EditValue);
                var      conversionFactor = Convert.ToDecimal(txtFactor.EditValue);
                var      changeExpiryDate = ckExpiryDate.Checked;
                var      changeBatchNo    = ckBatchNo.Checked;
                var      batchNo          = txtBatchNo.Text;
                var      expiryDate       = (DateTime?)dtExpiryDate.EditValue;
                DateTime dtCurrent;

                using (var dtDate = ConvertDate.GetCurrentEthiopianDateText())
                {
                    dtCurrent = ConvertDate.DateConverter(dtDate.Text);
                }
                TransactionMgr transactionMgr = TransactionMgr.ThreadTransactionMgr();

                int             userId          = CurrentContext.UserId;
                TransferService transferService = new TransferService();

                if (conversionFactor == 0 &&
                    XtraMessageBox.Show(
                        "This change is a factor of Zero make the Quantity Zero,Are you sure you want to commit this change? You will not be able to undo this.",
                        "Confirmation", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                try
                {
                    transactionMgr.BeginTransaction();
                    var dataView  = (DataView)gridItemDetailView.DataSource;
                    int IDPRinted = transferService.CreateTransactionForErrorCorrection(dataView, ItemIDTo, unitIdTo,
                                                                                        manufacturerIdTo,
                                                                                        conversionFactor,
                                                                                        "Error Correction",
                                                                                        dtCurrent, userId,
                                                                                        changeExpiryDate, expiryDate,
                                                                                        changeBatchNo, batchNo);

                    transactionMgr.CommitTransaction();

                    var xtraReport = ReturnErrorCorrectionReport(unitIdTo, manufacturerIdTo, dataView, conversionFactor,
                                                                 IDPRinted, changeExpiryDate, expiryDate, changeBatchNo,
                                                                 batchNo);
                    xtraReport.PrintDialog();

                    XtraMessageBox.Show("Your changes have been applied, thanks.", "Confirmation");
                    // refresh
                    btnDisplay_Click(null, null);
                    lkWarehouse_EditValueChanged(null, null);
                    layoutWarehouse.ContentVisible = false;
                    lkWarehouse.Visible            = false;
                }
                catch (Exception exp)
                {
                    XtraMessageBox.Show("There was an error applying your changes", "Error");
                    transactionMgr.RollbackTransaction();
                    XtraMessageBox.Show(exp.Message.ToString());
                }
                finally
                {
                    TransactionMgr.ThreadTransactionMgrReset();
                }
            }
            else
            {
                XtraMessageBox.Show("Please correct the errors marked in red", "Error");
            }
        }
        /// <summary>
        /// Handles the Click event of the btnConfirmIssue control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        /// <exception cref="System.Exception"></exception>
        private void btnConfirmIssue_Click(object sender, EventArgs e)
        {
            // This is where the Issue is actually recorded and the stv is printed.
            // Do all kinds of validations.
            XtraReport STVReport = null; XtraReport DeliveryNoteReport = null;

            btnConfirmIssue1.Enabled = false;
            if (!IssueValid())
            {
                XtraMessageBox.Show("Please Correct the Items Marked in Red before Proceeding with Issue", "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error);
                btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement);
                return;
            }

            if (XtraMessageBox.Show("Are You Sure, You want to save this Transaction?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                DateTimePickerEx dtDate = ConvertDate.GetCurrentEthiopianDateText();

                DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);
                // The User is now sure that the STV has to be printed and that
                // the order is also good to save.
                // This is the section that does the saving.

                BLL.Order order = new Order();
                order.LoadByPrimaryKey(_orderID);

                // what are the pick lists, do we have devliery notes too?
                DataView  dv         = _dvOutstandingPickList;
                DataTable dvUnpriced = new DataTable();
                DataTable dvPriced   = dv.ToTable();

                if (BLL.Settings.HandleGRV)
                {
                    if (BLL.Settings.IsCenter)
                    {
                        dv.RowFilter = "(Cost is null or Cost=0)";
                    }
                    else
                    {
                        dv.RowFilter = "DeliveryNote = true and (Cost is null or Cost=0)";
                    }
                    dvUnpriced = dv.ToTable();

                    dv.RowFilter = "Cost is not null and Cost <> 0";
                    dvPriced     = dv.ToTable();
                }
                else
                {
                    dvPriced = dv.ToTable();
                }

                string stvPrinterName      = "";
                string deliveryNotePrinter = "";

                if (!ConfirmPrinterSettings(dvPriced, dvUnpriced, out stvPrinterName, out deliveryNotePrinter))
                {
                    return;
                }
                bool saveSuccessful = false;

                MyGeneration.dOOdads.TransactionMgr mgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                try
                {
                    if (dvPriced.Rows.Count == 0 && dvUnpriced.Rows.Count == 0)
                    {
                        throw new Exception("The Items doesn’t meet the requirement: please check the price status for non-delivery notes!");
                    }

                    mgr.BeginTransaction();

                    if (dvPriced.Rows.Count > 0)
                    {
                        STVReport = SaveAndPrintSTV(dvPriced.DefaultView, false, stvPrinterName, dtDate, dtCurrent);
                    }


                    if (dvUnpriced.Rows.Count > 0)
                    {
                        DeliveryNoteReport = SaveAndPrintSTV(dvUnpriced.DefaultView, true, deliveryNotePrinter, dtDate,
                                                             dtCurrent);
                    }
                    var ordr = new Order();
                    ordr.LoadByPrimaryKey(_orderID);

                    if (!ordr.IsColumnNull("OrderTypeID") &&

                        (ordr.OrderTypeID == BLL.OrderType.CONSTANTS.ACCOUNT_TO_ACCOUNT_TRANSFER || ordr.OrderTypeID == BLL.OrderType.CONSTANTS.STORE_TO_STORE_TRANSFER))
                    {
                        var      transfer         = new Transfer();
                        DateTime convertedEthDate = ConvertDate.DateConverter(dtDate.Text);
                        transfer.CommitAccountToAccountTransfer(ordr.ID, CurrentContext.UserId, convertedEthDate);
                    }

                    mgr.CommitTransaction();

                    saveSuccessful = true;
                }
                catch (Exception exp)
                {
                    mgr.RollbackTransaction();
                    //Removed the reset logic
                    //MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgrReset();
                    XtraMessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    ErrorHandler.Handle(exp);
                    saveSuccessful = false;
                }

                if (saveSuccessful)
                {
                    if (STVReport != null)
                    {
                        if (InstitutionIType.IsVaccine(GeneralInfo.Current))
                        {
                            for (int i = 0; i < BLL.Settings.STVCopies; i++)
                            {
                                STVReport.Print(stvPrinterName);
                            }
                        }
                        else
                        {
                            STVReport.Print(stvPrinterName);
                        }
                    }

                    if (DeliveryNoteReport != null)
                    {
                        DeliveryNoteReport.Print(deliveryNotePrinter);
                    }

                    XtraMessageBox.Show("Transaction Successfully Saved!", "Success", MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                }

                btnConfirmIssue1.Enabled = (BLL.Settings.UseNewUserManagement && this.HasPermission("Print-Invoice")) ? true : (!BLL.Settings.UseNewUserManagement);
                BindOutstandingPicklists();
                gridOutstandingPicklistDetail.DataSource = null;
                PalletLocation.GarbageCollection();

                if (BLL.Settings.AllowOnlineOrders)
                {
                    Helpers.RRFServiceIntegration.SubmitOnlineIssue(_orderID);
                }
            }
        }