public override void OnMouseUp(SourceGrid.CellContext sender, MouseEventArgs e)
            {
                base.OnMouseUp(sender, e);
                int iRow = sender.Position.Row - 1;

                if (iRow < 0)
                {
                    return;
                }

                TFrmSetupDailyExchangeRate frmExchangeRate = new TFrmSetupDailyExchangeRate(mainForm);

                decimal  selectedExchangeRate;
                DateTime selectedEffectiveDate;
                int      selectedEffectiveTime;

                if (frmExchangeRate.ShowDialog(
                        mainForm.FLedgerNumber,
                        dteStart,
                        dteEnd,
                        currencyExchangeList[iRow].Currency,
                        currencyExchangeList[iRow].mExchangeRate,
                        out selectedExchangeRate,
                        out selectedEffectiveDate,
                        out selectedEffectiveTime) != DialogResult.Cancel)
                {
                    currencyExchangeList[iRow].updateExchangeRate(selectedExchangeRate, selectedEffectiveDate);
                    sender.Grid.InvalidateRange(new SourceGrid.Range(sender.Position.Row, 1, sender.Position.Row, 4));
                }
            }
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate SetupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  SelectedExchangeRate;
            DateTime SelectedEffectiveDate;
            int      SelectedEffectiveTime;

            string CurrencyCode = txtDetailTransactionCurrency.Text;

            if (SetupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpEffectiveDate.Date.Value,
                    CurrencyCode,
                    DEFAULT_CURRENCY_EXCHANGE,
                    out SelectedExchangeRate,
                    out SelectedEffectiveDate,
                    out SelectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (SelectedExchangeRate > 0.0m)
            {
                FPreviouslySelectedDetailRow.ExchangeRateToBase = SelectedExchangeRate;
                txtDetailExchangeRateToBase.NumberValueDecimal  = SelectedExchangeRate;
                SetRateForSameCurrency(CurrencyCode, SelectedExchangeRate, FPreviouslySelectedDetailRow.JournalNumber);
            }
        }
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpEffectiveDate.Date.Value,
                    txtCurrencyCodeFrom.Text,
                    DEFAULT_CURRENCY_EXCHANGE,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (selectedExchangeRate > 0.0m)
            {
                FExchangeRateToBase = selectedExchangeRate;
                txtExchangeRateToBase.NumberValueDecimal = FExchangeRateToBase;
            }
        }
            public override void OnClick(SourceGrid.CellContext sender, EventArgs e)
            {
                base.OnClick(sender, e);

                ++ix;
                System.Diagnostics.Debug.WriteLine(sender.Position.Row.ToString());

                int iRow = sender.Position.Row - 1;

                TFrmSetupDailyExchangeRate frmExchangeRate =
                    new TFrmSetupDailyExchangeRate(mainForm);

                decimal  selectedExchangeRate;
                DateTime selectedEffectiveDate;
                int      selectedEffectiveTime;

                if (frmExchangeRate.ShowDialog(
                        mainForm.FLedgerNumber,
                        dteStart,
                        dteEnd,
                        currencyExchangeList[iRow].Currency,
                        currencyExchangeList[iRow].ExchangeRate,
                        out selectedExchangeRate,
                        out selectedEffectiveDate,
                        out selectedEffectiveTime) == DialogResult.Cancel)
                {
                    return;
                }

                currencyExchangeList[iRow].updateExchangeRate(selectedExchangeRate);
            }
        private void LookupExchangeRate(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FDocumentLedgerNumber,
                    DateTime.Now,
                    txtSupplierCurrency.Text,
                    1.0m,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (txtExchangeRateToBase.NumberValueDecimal != selectedExchangeRate)
            {
                //Enforce save needed condition
                FPetraUtilsObject.SetChangedFlag();
            }

            txtExchangeRateToBase.NumberValueDecimal = selectedExchangeRate;
        }
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpDetailGlEffectiveDate.Date.Value,
                    cmbDetailCurrencyCode.GetSelectedString(),
                    DEFAULT_CURRENCY_EXCHANGE,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (FPreviouslySelectedDetailRow.ExchangeRateToBase != selectedExchangeRate)
            {
                FPreviouslySelectedDetailRow.ExchangeRateToBase = selectedExchangeRate;
                RecalculateTransactionAmounts(selectedExchangeRate);

                //Enforce save needed condition
                FPetraUtilsObject.SetChangedFlag();
            }

            RefreshCurrencyAndExchangeRateControls();
        }
Example #7
0
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate SetupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  SelectedExchangeRate;
            DateTime SelectedEffectiveDate;
            int      SelectedEffectiveTime;

            if (SetupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpDetailDateEffective.Date.HasValue ? dtpDetailDateEffective.Date.Value : DateTime.Today,
                    cmbDetailTransactionCurrency.GetSelectedString(),
                    (txtDetailExchangeRateToBase.NumberValueDecimal == null) ? 0.0m : txtDetailExchangeRateToBase.NumberValueDecimal.Value,
                    out SelectedExchangeRate,
                    out SelectedEffectiveDate,
                    out SelectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (FPreviouslySelectedDetailRow.ExchangeRateToBase != SelectedExchangeRate)
            {
                FPreviouslySelectedDetailRow.ExchangeRateToBase = SelectedExchangeRate;
                //Enforce save needed condition
                FPetraUtilsObject.SetChangedFlag();
            }

            txtDetailExchangeRateToBase.NumberValueDecimal = SelectedExchangeRate;
            FPreviouslySelectedDetailRow.ExchangeRateTime  = SelectedEffectiveTime;

            RefreshCurrencyAndExchangeRate();
        }
        private void LookupExchangeRate(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    DateTime.Now,
                    txtCurrency.Text,
                    1.0m,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            txtExchangeRate.NumberValueDecimal = selectedExchangeRate;

            // Put the rate in our client-side cache
            if (FLedgerRow != null)
            {
                TExchangeRateCache.SetDailyExchangeRate(txtCurrency.Text, FLedgerRow.BaseCurrency, selectedEffectiveDate, selectedExchangeRate);
            }
        }
Example #9
0
        private void SetExchangeRateValue(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    dtpDetailGlEffectiveDate.Date.Value,
                    cmbDetailCurrencyCode.GetSelectedString(),
                    (txtDetailExchangeRateToBase.NumberValueDecimal == null) ? 0.0m : txtDetailExchangeRateToBase.NumberValueDecimal.Value,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            if (FPreviouslySelectedDetailRow.ExchangeRateToBase != selectedExchangeRate)
            {
                FPreviouslySelectedDetailRow.ExchangeRateToBase = selectedExchangeRate;

                RefreshCurrencyAndExchangeRateControls();
                RecalculateTransactionAmounts(selectedExchangeRate);

                FPetraUtilsObject.VerificationResultCollection.Clear();
            }
        }
Example #10
0
        public void ModalValidation()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();
            FLedgerDS.CreateTestLedger();

            decimal  selectedRate;
            DateTime selectedDate;
            int      selectedTime;

            // Open the screen modally on our test ledger and a from currency of GBP
            // This test sets up a date range
            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);

            DialogBoxHandler = delegate(string name, IntPtr hWnd)
            {
                ModalValidationHandler();
            };

            DialogResult dlgResult = mainScreen.ShowDialog(STANDARD_TEST_LEDGER_NUMBER, FStandardEffectiveDate.AddDays(
                                                               -10), FStandardEffectiveDate, "GBP", 1.0m, out selectedRate, out selectedDate, out selectedTime);

            if (dlgResult == DialogResult.Abort)
            {
                Assert.Fail(FModalAssertResult);
            }

            // Make sure we did save
            Assert.AreEqual(DialogResult.OK, dlgResult);
            Assert.IsFalse((new ToolStripButtonTester("tbbSave", mainScreen)).Properties.Enabled);
            FMainDS.LoadAll();
            Assert.AreEqual(2, FMainDS.ADailyExchangeRate.Rows.Count, "The data table should have 2 rows after a successful save operation");
        }
Example #11
0
        public void LoadModalEmptyTable()
        {
            // Initialise data - create an empty table and our test ledger
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();
            FLedgerDS.CreateTestLedger();

            // variables to hold the dialog result output
            decimal  selectedRate;
            DateTime selectedDate;
            int      selectedTime;

            // Open the screen modally on our test ledger using a 'from' currency of GBP
            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);

            DialogBoxHandler = delegate(string name, IntPtr hWnd)
            {
                LoadModalEmptyTableHandler();
            };

            DialogResult dlgResult = mainScreen.ShowDialog(STANDARD_TEST_LEDGER_NUMBER,
                                                           FStandardEffectiveDate,
                                                           "GBP",
                                                           1.0m,
                                                           out selectedRate,
                                                           out selectedDate,
                                                           out selectedTime);

            // Check the result for any assertions
            if (dlgResult == DialogResult.Abort)
            {
                Assert.Fail(FModalAssertResult);
            }

            // Check we returned the correct data to the caller
            Assert.AreEqual(DialogResult.OK, dlgResult);
            Assert.AreEqual(STANDARD_RATE_OF_EXCHANGE, selectedRate);
            Assert.AreEqual(FStandardEffectiveDate, selectedDate);
            Assert.AreEqual(7200, selectedTime);

            // Check we did also save the result
            FMainDS.LoadAll();
            ADailyExchangeRateRow row =
                (ADailyExchangeRateRow)FMainDS.ADailyExchangeRate.Rows.Find(new object[] { "GBP", STANDARD_TEST_CURRENCY, FStandardEffectiveDate,
                                                                                           7200 });

            Assert.IsNotNull(row, "The selected exchange rate was not saved");
            Assert.AreEqual(STANDARD_RATE_OF_EXCHANGE, row.RateOfExchange);
        }
Example #12
0
        public void ExchangeRateUsage()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardModalRows();
            FMainDS.SaveChanges();

            FGiftAndJournal.InitialiseData("load-data.sql");

            decimal  selectedRate;
            DateTime selectedDate;
            int      selectedTime;

            // Open the screen modally on our test ledger and a from currency of GBP
            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);

            mainScreen.ShowUsedRates();

            DialogBoxHandler = delegate(string name, IntPtr hWnd)
            {
                ExchangeRateUsageHandler();
            };

            DialogResult dlgResult = mainScreen.ShowDialog(STANDARD_TEST_LEDGER_NUMBER,
                                                           FStandardEffectiveDate,
                                                           "GBP",
                                                           1.0m,
                                                           out selectedRate,
                                                           out selectedDate,
                                                           out selectedTime);

            if (dlgResult == DialogResult.Abort)
            {
                Assert.Fail(FModalAssertResult);
            }

            Assert.AreEqual(DialogResult.OK, dlgResult);
        }
Example #13
0
        public void LoadModalTableWithData()
        {
            // Initialse data
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardModalRows();
            FMainDS.SaveChanges();
            FLedgerDS.CreateTestLedger();

            decimal  selectedRate;
            DateTime selectedDate;
            int      selectedTime;

            // Open the screen modally on our test ledger and a from currency of GBP
            TFrmSetupDailyExchangeRate mainScreen = new TFrmSetupDailyExchangeRate(null);

            DialogBoxHandler = delegate(string name, IntPtr hWnd)
            {
                LoadModalTableHandler();
            };

            DialogResult dlgResult = mainScreen.ShowDialog(STANDARD_TEST_LEDGER_NUMBER,
                                                           FStandardEffectiveDate,
                                                           "GBP",
                                                           1.0m,
                                                           out selectedRate,
                                                           out selectedDate,
                                                           out selectedTime);

            if (dlgResult == DialogResult.Abort)
            {
                Assert.Fail(FModalAssertResult);
            }

            Assert.AreEqual(DialogResult.OK, dlgResult);
            Assert.AreEqual(new DateTime(1900, 7, 1), selectedDate);
            Assert.AreEqual(0.51m, selectedRate);
        }
        private void LookupExchangeRate(Object sender, EventArgs e)
        {
            TFrmSetupDailyExchangeRate setupDailyExchangeRate =
                new TFrmSetupDailyExchangeRate(FPetraUtilsObject.GetForm());

            decimal  selectedExchangeRate;
            DateTime selectedEffectiveDate;
            int      selectedEffectiveTime;

            if (setupDailyExchangeRate.ShowDialog(
                    FLedgerNumber,
                    DateTime.Now,
                    txtCurrency.Text,
                    1.0m,
                    out selectedExchangeRate,
                    out selectedEffectiveDate,
                    out selectedEffectiveTime) == DialogResult.Cancel)
            {
                return;
            }

            txtExchangeRate.NumberValueDecimal = selectedExchangeRate;
        }