private void btnSetNewPrice_Click(object sender, EventArgs e)
        {
            bool       validated = false;
            ReceiveDoc rd        = new ReceiveDoc();

            validated = dxValidationProviderPrice.Validate();


            if (!validated)
            {
                XtraMessageBox.Show("Please fill in all required fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!isConfirmation)
            {
                if (XtraMessageBox.Show("Are u sure, you want to save the new price change?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    MyGeneration.dOOdads.TransactionMgr transactionMgr = MyGeneration.dOOdads.TransactionMgr.ThreadTransactionMgr();
                    transactionMgr.BeginTransaction();
                    try
                    {
                        rs.NewUnitCost     = Convert.ToDouble(txtAverageCost.EditValue);
                        rs.Margin          = Convert.ToDouble(txtMargin.EditValue);
                        rs.NewSellingPrice = Convert.ToDouble(txtSellingPrice.EditValue);
                        rs.NewPrice        = rs.NewSellingPrice;
                        //rs.Remark = txtRemark.EditValue.ToString();
                        // set the item as  weighted average item
                        Item itm = new Item();
                        itm.LoadByPrimaryKey(rs.ItemID);
                        itm.IsFree = false;

                        itm.Save();

                        rd.SavePrice(rs, CurrentContext.UserId);

                        transactionMgr.CommitTransaction();
                        XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    catch (Exception ex)
                    {
                        transactionMgr.RollbackTransaction();
                        XtraMessageBox.Show("Price setting failed", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        throw ex;
                    }
                }
            }
            else
            {
                if (XtraMessageBox.Show("Are you sure you want to approve the new price change.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    rd.ConfirmMovingAverage(rs, CurrentContext.UserId);
                    XtraMessageBox.Show("Price setting successful", "SUCCESS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            ResetForm();
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            ReceiveDoc rd = new ReceiveDoc();

            if (!confirmation)
            {
                rs.NewUnitCost     = Convert.ToDouble(txtAverageCost.EditValue);
                rs.Margin          = Convert.ToDouble(txtMargin.EditValue);
                rs.NewSellingPrice = Convert.ToDouble(txtSellingPrice.EditValue);
                rs.NewPrice        = rs.NewSellingPrice;

                // set the item as  weighted average item
                Item itm = new Item();
                itm.LoadByPrimaryKey(ItemID);
                itm.IsFree = false;

                itm.Save();

                rd.SavePrice(rs, CurrentContext.UserId);

                //if (!StoreType.IsFreeStore(StoreID))
                //{
                //    //Change the cost
                //    rs.NewCost = rs.NewUnitCost;
                //    rd.SaveNewCost(rs, NewMainWindow.UserId);
                //}

                //-----------
                XtraMessageBox.Show("New Price setting has been saved.", "Confirmation", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                rd.ConfirmMovingAverage(rs, CurrentContext.UserId);
            }
            this.Close();
        }