Ejemplo n.º 1
0
        public void TestComboboxEmptyDescriptionBug()
        {
            TCmbAutoPopulated cmb = new TCmbAutoPopulated();

            DataTable detailTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.MotivationList, FLedgerNumber);

            Assert.AreNotEqual(0, detailTable.Rows.Count, "There should be a motivation detail in the cached table");

            cmb.Name = "TestCombobox";
            cmb.InitialiseUserControl(detailTable,
                                      AMotivationDetailTable.GetMotivationDetailCodeDBName(),
                                      AMotivationDetailTable.GetMotivationDetailDescDBName(),
                                      null);
            cmb.AppearanceSetup(new int[] { -1, 150 }, -1);

            Form TestForm = new Form();

            TestForm.Controls.Add(cmb);

            TestForm.Show();

            cmb.SelectedIndex = 1;
            Assert.AreEqual(cmb.GetSelectedString(), "KEYMIN");
            Assert.AreEqual(cmb.GetSelectedDescription(), "Key Ministry Gift");

            cmb.SelectedIndex = 0;
            Assert.AreEqual(cmb.GetSelectedString(), "FIELD");
            Assert.AreEqual(cmb.GetSelectedDescription(), "Field Gift");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns true if the specified cost centre code is active
        /// </summary>
        /// <param name="ACostCentreCode">The account code string to test.  If not supplied the code is taken from the current combo box item</param>
        /// <returns>Returns true if the specified cost centre code is active</returns>
        public bool CostCentreIsActive(string ACostCentreCode = "")
        {
            bool retVal = true;

            ACostCentreRow currentCostCentreRow = null;

            //If empty, read value from combo
            if (ACostCentreCode == string.Empty)
            {
                if ((FCostCentreTable != null) && (FCmbCostCentreCode.SelectedIndex != -1) && (FCmbCostCentreCode.Count > 0) &&
                    (FCmbCostCentreCode.GetSelectedString() != null))
                {
                    ACostCentreCode = FCmbCostCentreCode.GetSelectedString();
                }
            }

            if (FCostCentreTable != null)
            {
                currentCostCentreRow = (ACostCentreRow)FCostCentreTable.Rows.Find(new object[] { FLedgerNumber, ACostCentreCode });
            }

            if (currentCostCentreRow != null)
            {
                retVal = currentCostCentreRow.CostCentreActiveFlag;
            }

            return(retVal);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Handler for ModalEmptyTable test
        /// </summary>
        public void LoadModalEmptyTableHandler()
        {
            // Controls
            ButtonTester btnNewTester    = new ButtonTester("btnNew", FModalFormName);
            ButtonTester btnCloseTester  = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            Button             btnNew            = btnNewTester.Properties;
            Button             btnClose          = btnCloseTester.Properties;
            Button             btnDelete         = (new ButtonTester("btnDelete", FModalFormName)).Properties;
            TSgrdDataGrid      grdDetails        = (TSgrdDataGrid)((new TSgrdDataGridPagedTester("grdDetails", FModalFormName)).Properties);
            Panel              pnlDetails        = (new PanelTester("pnlDetails", FModalFormName)).Properties;
            TCmbAutoPopulated  cmbFromCurrency   = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", FModalFormName)).Properties;
            TCmbAutoPopulated  cmbToCurrency     = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", FModalFormName)).Properties;
            TtxtPetraDate      dtpDateEffective  = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;

            // These should be the states on an empty modal screen (as loaded)
            try
            {
                Assert.IsFalse(btnClose.Enabled);
                Assert.IsFalse(btnDelete.Enabled);
                Assert.IsFalse(dtpDateEffective.Date.HasValue);
                Assert.IsFalse(pnlDetails.Enabled);
                Assert.AreEqual(1, grdDetails.Rows.Count);

                // Now create a new row
                btnNewTester.Click();

                // These should be the states after adding a new row
                Assert.AreEqual("GBP", cmbFromCurrency.GetSelectedString());                    // GBP passed in as a ShowDialog parameter
                Assert.AreEqual(STANDARD_TEST_CURRENCY, cmbToCurrency.GetSelectedString());
                Assert.AreEqual(FStandardEffectiveDate, dtpDateEffective.Date);
                Assert.IsFalse(cmbFromCurrency.Enabled);
                Assert.IsFalse(cmbToCurrency.Enabled);
                Assert.IsTrue(btnClose.Enabled);
                Assert.IsTrue(btnDelete.Enabled);
                Assert.IsTrue(pnlDetails.Enabled);
                Assert.AreEqual(2, grdDetails.Rows.Count);

                // Rate should be 0.0m - we will need to set it to something else
                Assert.AreEqual(0.0m, txtRateOfExchange.NumberValueDecimal);
                txtRateOfExchange.NumberValueDecimal = STANDARD_RATE_OF_EXCHANGE;

                // Save this as our rate and quit
                btnCloseTester.Click();
            }
            catch (Exception ex)
            {
                // Handle the exception and abort without saving
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }
Ejemplo n.º 4
0
        private void GetDetailDataFromControlsManual(AMotivationDetailRow ARow)
        {
            StringCollection TickedFees = StringHelper.StrSplit(
                StringHelper.ConcatCSV(clbDetailFeesPayable.GetCheckedStringList(), clbDetailFeesReceivable.GetCheckedStringList()),
                ",");

            FMainDS.AMotivationDetailFee.DefaultView.RowFilter =
                String.Format("{0}={1} and {2}='{3}' and {4}='{5}'",
                              AMotivationDetailFeeTable.GetLedgerNumberDBName(),
                              ARow.LedgerNumber,
                              AMotivationDetailFeeTable.GetMotivationGroupCodeDBName(),
                              ARow.MotivationGroupCode,
                              AMotivationDetailFeeTable.GetMotivationDetailCodeDBName(),
                              ARow.MotivationDetailCode);

            StringCollection ExistingFees = new StringCollection();

            foreach (DataRowView rv in FMainDS.AMotivationDetailFee.DefaultView)
            {
                AMotivationDetailFeeRow detailFeeRow = (AMotivationDetailFeeRow)rv.Row;

                if (!TickedFees.Contains(detailFeeRow.FeeCode))
                {
                    // delete existing fees that have been unticked
                    detailFeeRow.Delete();
                }
                else
                {
                    ExistingFees.Add(detailFeeRow.FeeCode);
                }
            }

            // add new fees
            foreach (string fee in TickedFees)
            {
                if (!ExistingFees.Contains(fee))
                {
                    AMotivationDetailFeeRow NewRow = FMainDS.AMotivationDetailFee.NewRowTyped();
                    NewRow.LedgerNumber         = ARow.LedgerNumber;
                    NewRow.MotivationGroupCode  = ARow.MotivationGroupCode;
                    NewRow.MotivationDetailCode = ARow.MotivationDetailCode;
                    NewRow.FeeCode = fee;
                    FMainDS.AMotivationDetailFee.Rows.Add(NewRow);
                }
            }

            if (FTaxDeductiblePercentageEnabled)
            {
                ARow.TaxDeductibleAccount = cmbDeductibleAccountCode.GetSelectedString();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Checks if the Publication that is selected in a ComboBox is valid. If it isn't valid,
        /// a warning is shown to the user, asking the user as to whether the user still wants to use
        /// this Publication for the Subscription that the user is working with.
        /// </summary>
        /// <param name="APublicationComboBox">ComboBox containing Publications.</param>
        public static void CheckPublicationComboValidValue(TCmbAutoPopulated APublicationComboBox)
        {
            DataTable       DataCachePublicationListTable;
            PPublicationRow TmpRow;
            string          SelectedPublication;

            if (APublicationComboBox == null)
            {
                throw new ArgumentNullException("APublicationComboBox must not be null");
            }

            SelectedPublication = APublicationComboBox.GetSelectedString();

            if (!String.IsNullOrWhiteSpace(SelectedPublication))
            {
                DataCachePublicationListTable = TDataCache.TMPartner.GetCacheableSubscriptionsTable(TCacheableSubscriptionsTablesEnum.PublicationList);
                TmpRow = (PPublicationRow)DataCachePublicationListTable.Rows.Find(
                    new Object[] { SelectedPublication });

                if (TmpRow != null)
                {
                    if (!TmpRow.ValidPublication)
                    {
                        if (MessageBox.Show(
                                Catalog.GetString(String.Format("Please note that Publication\r\n\r\n    {0}\r\n\r\n" +
                                                                "is no longer available." + "\r\n\r\n" +
                                                                "Would you still like to use it for a Subscription?",
                                                                APublicationComboBox.GetSelectedString())),
                                Catalog.GetString("Publication Selection"),
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2) == DialogResult.No)
                        {
                            APublicationComboBox.cmbCombobox.SelectedIndex = -1;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handler for LoadModalTableWithData test
        /// </summary>
        public void LoadModalTableHandler()
        {
            // Controls
            ButtonTester btnCloseTester  = new ButtonTester("btnClose", FModalFormName);
            ButtonTester btnCancelTester = new ButtonTester("btnCancel", FModalFormName);

            Button             btnClose          = btnCloseTester.Properties;
            Button             btnDelete         = (new ButtonTester("btnDelete", FModalFormName)).Properties;
            TSgrdDataGrid      grdDetails        = (TSgrdDataGrid)((new TSgrdDataGridPagedTester("grdDetails", FModalFormName)).Properties);
            Panel              pnlDetails        = (new PanelTester("pnlDetails", FModalFormName)).Properties;
            TCmbAutoPopulated  cmbFromCurrency   = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", FModalFormName)).Properties;
            TCmbAutoPopulated  cmbToCurrency     = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", FModalFormName)).Properties;
            TtxtPetraDate      dtpDateEffective  = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", FModalFormName)).Properties;
            TTxtNumericTextBox txtRateOfExchange = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", FModalFormName)).Properties;

            // These should be the states given the standard modal data we loaded
            try
            {
                Assert.AreEqual("GBP", cmbFromCurrency.GetSelectedString());                    // GBP passed in as a ShowDialog parameter
                Assert.AreEqual(STANDARD_TEST_CURRENCY, cmbToCurrency.GetSelectedString());     // The ledger currency for the ledger passed in as parameter
                Assert.AreEqual(new DateTime(1900, 7, 1), dtpDateEffective.Date);
                Assert.AreEqual(0.51m, txtRateOfExchange.NumberValueDecimal);
                Assert.IsFalse(cmbFromCurrency.Enabled);
                Assert.IsFalse(cmbToCurrency.Enabled);
                Assert.IsTrue(btnClose.Enabled);
                Assert.IsTrue(btnClose.Visible);
                Assert.IsTrue(btnCancelTester.Properties.Visible);
                Assert.IsTrue(btnDelete.Enabled);
                Assert.IsTrue(pnlDetails.Enabled);
                Assert.AreEqual(3, grdDetails.Rows.Count);

                // select this item and close
                btnCloseTester.Click();
            }
            catch (Exception ex)
            {
                // Handle the exception and abort without saving
                HandleModalException(ex);
                btnCancelTester.Properties.DialogResult = DialogResult.Abort;
                btnCancelTester.Click();
            }
        }
Ejemplo n.º 7
0
        public void EditRow()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);

            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel              pnlDetails       = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester       btnNew           = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated  cmbFromCurrency  = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated  cmbToCurrency    = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate      dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate  = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            // Select the first row in the grid.  New rows should be based on data row 5
            SelectRowInGrid(1, 5);

            // Add three rows
            btnNew.Click();
            btnNew.Click();
            btnNew.Click();

            DateTime dt1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            //DateTime dt2 = dt1.AddMonths(1);
            DateTime dt3 = dt1.AddMonths(2);

            // Check the data first
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(dt3, dtpEffectiveDate.Date);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal.Value);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Focus on the from currency, then change it to 'BEF'
            cmbFromCurrency.Focus();
            cmbFromCurrency.SetSelectedString("BEF");
            cmbToCurrency.Focus();

            // Now check the date and rate.  Date should be back to this month and rate should be 0.00 because this currency has never been used
            Assert.AreEqual(dt1, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(1, mainScreen.GetSelectedRowIndex());

            // Reset the currency and confirm we go back to where we were
            cmbFromCurrency.Focus();
            cmbFromCurrency.SetSelectedString(EffectiveCurrency(FFromCurrencyId));
            cmbToCurrency.Focus();

            Assert.AreEqual(dt3, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Repeat for the To currency
            cmbToCurrency.Focus();
            cmbToCurrency.SetSelectedString("BEF");
            dtpEffectiveDate.Focus();

            // Now check the date and rate.  Date should be back to this month and rate should be 0.00 because this currency has never been used
            Assert.AreEqual(dt1, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(1, mainScreen.GetSelectedRowIndex());

            // Reset the currency and confirm we go back to where we were
            cmbToCurrency.Focus();
            cmbToCurrency.SetSelectedString(EffectiveCurrency(FToCurrencyId));
            dtpEffectiveDate.Focus();

            Assert.AreEqual(dt3, dtpEffectiveDate.Date.Value);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal);
            Assert.AreEqual(3, mainScreen.GetSelectedRowIndex());

            // Finally check what happens when editing the date
            SelectRowInGrid(5);
            txtExchangeRate.NumberValueDecimal = 8.0m;      // Today
            FixUnvalidatedChanges();
            SelectRowInGrid(4);
            txtExchangeRate.NumberValueDecimal = 9.0m;      // Today + 1m
            FixUnvalidatedChanges();
            SelectRowInGrid(3);
            txtExchangeRate.NumberValueDecimal = 10.0m;     // Today +2m
            FixUnvalidatedChanges();

            SelectRowInGrid(5);
            Assert.AreEqual(8.0m, txtExchangeRate.NumberValueDecimal);
            dtpEffectiveDate.Focus();
            dtpEffectiveDate.Date = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).AddMonths(6);
            grdDetails.Focus();
            Assert.AreEqual(10.0m, txtExchangeRate.NumberValueDecimal);

            mainScreen.SaveChanges();
            mainScreen.Close();
        }
Ejemplo n.º 8
0
        public void AddRowToTable()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);

            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel              pnlDetails       = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester       btnNew           = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated  cmbFromCurrency  = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated  cmbToCurrency    = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate      dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate  = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            // Select the bottom row - when we get a new row it should be based on StandardData[1]
            SelectRowInGrid(FAllRowCount, 1);

            // Check that the controls are disabled
            Assert.IsFalse(cmbFromCurrency.Enabled);
            Assert.IsFalse(cmbToCurrency.Enabled);
            Assert.IsTrue(dtpEffectiveDate.ReadOnly);

            // Check that the controls are enabled
            Assert.IsTrue(txtExchangeRate.Enabled);

            // Click the 'New' button
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");
            btnNew.Click();
            Assert.IsTrue(btnSave.Enabled, "The Save button should be enabled after adding a new row");
            Assert.IsTrue(cmbFromCurrency.Enabled);
            Assert.IsTrue(cmbToCurrency.Enabled);
            Assert.IsTrue(dtpEffectiveDate.Enabled);
            Assert.IsTrue(txtExchangeRate.Enabled);

            // The effective date should be 1st of current month
            DateTime expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(EffectiveRate(), txtExchangeRate.NumberValueDecimal.Value);

            // The row number of the new row should be at row 7
            Assert.AreEqual(FAllRowCount - 1, mainScreen.GetSelectedRowIndex());

            // Change the rate to a new value
            decimal newRate = 0.667m;

            txtExchangeRate.NumberValueDecimal = newRate;

            // click the 'New' button again - this time the date should be first of next month
            btnNew.Click();
            expectedDate = (new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1)).AddMonths(1);

            // The details should be the same as before except for the new date and the rate being what we just set
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId), cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId), cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(newRate, txtExchangeRate.NumberValueDecimal.Value);
            Assert.AreEqual(FAllRowCount - 1, mainScreen.GetSelectedRowIndex());

            // Save the changes and check the number of rows now
            mainScreen.SaveChanges();
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled after the new row has been saved");
            Assert.AreEqual(13, grdDetails.Rows.Count, "There should be 12 rows in the grid after saving 2 new rows");

            mainScreen.Close();
        }
Ejemplo n.º 9
0
        public void AddRowToEmptyTable()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);

            mainScreen.RunOnceOnActivation();
            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel              pnlDetails       = (new PanelTester("pnlDetails", mainScreen)).Properties;
            ButtonTester       btnNew           = new ButtonTester("btnNew", mainScreen);
            TCmbAutoPopulated  cmbFromCurrency  = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated  cmbToCurrency    = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate      dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            TTxtNumericTextBox txtExchangeRate  = (new TTxtNumericTextBoxTester("txtDetailRateOfExchange", mainScreen)).Properties;

            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");
            btnNew.Click();
            Assert.IsTrue(btnSave.Enabled, "The Save button should be enabled after adding a new row");

            // Work out our expectations
            string expectedToCurrency = "USD";
            string baseCurrency       = GetDefaultBaseCurrency();

            if (baseCurrency == "USD")
            {
                baseCurrency = "GBP";
            }

            DateTime expectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);

            // Check the details panel after adding the new row
            Assert.AreEqual(baseCurrency, cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(expectedToCurrency, cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(0.0m, txtExchangeRate.NumberValueDecimal);

            // Set a valid exchange rate and save
            txtExchangeRate.NumberValueDecimal = 2.0m;

            mainScreen.SaveChanges();
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled after the new row has been saved");

            // Check the row count in the grid
            Assert.AreEqual(3, grdDetails.Rows.Count, "There should be 2 rows in the grid after saving a new row");

            // Even though an inverse row has been added we should still be highlighting the newly added row
            Assert.AreEqual(baseCurrency, cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(expectedToCurrency, cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(2.0m, txtExchangeRate.NumberValueDecimal);

            // Now select the inverese row
            SelectRowInGrid(1);

            // Check the details are, in fact, the inverse
            Assert.AreEqual(expectedToCurrency, cmbFromCurrency.GetSelectedString());
            Assert.AreEqual(baseCurrency, cmbToCurrency.GetSelectedString());
            Assert.AreEqual(expectedDate, dtpEffectiveDate.Date);
            Assert.AreEqual(0.5m, txtExchangeRate.NumberValueDecimal);

            mainScreen.Close();
        }
Ejemplo n.º 10
0
        public void LoadTableContainingData()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);

            mainScreen.Show();

            // Toolstrip
            ToolStripButton btnSave = (new ToolStripButtonTester("tbbSave", mainScreen)).Properties;

            // Grid
            TSgrdDataGrid grdDetails = (TSgrdDataGrid)(new TSgrdDataGridPagedTester("grdDetails", mainScreen)).Properties;

            // Panel and controls
            Panel             pnlDetails       = (new PanelTester("pnlDetails", mainScreen)).Properties;
            TCmbAutoPopulated cmbFromCurrency  = (new TCmbAutoPopulatedTester("cmbDetailFromCurrencyCode", mainScreen)).Properties;
            TCmbAutoPopulated cmbToCurrency    = (new TCmbAutoPopulatedTester("cmbDetailToCurrencyCode", mainScreen)).Properties;
            TtxtPetraDate     dtpEffectiveDate = (new TTxtPetraDateTester("dtpDetailDateEffectiveFrom", mainScreen)).Properties;
            CheckBox          chkHideOthers    = (new CheckBoxTester("chkHideOthers", mainScreen)).Properties;

            // Start of testing...
            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");
            Assert.IsTrue(pnlDetails.Enabled, "The Details Panel should be enabled on initial load");

            // Check the number of rows in the grid
            Assert.AreEqual(FAllRowCount + 1, grdDetails.Rows.Count);

            FCurrentDataId = Row2DataId(1);

            // Check the content of the details panel matches the last item in standard data (because sorting will have put it first)
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId),
                            cmbFromCurrency.GetSelectedString(), "The From currency on row 1 should be {0}", EffectiveCurrency(FFromCurrencyId));
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId),
                            cmbToCurrency.GetSelectedString(), "The To currency on row 1 should be {0}", EffectiveCurrency(FToCurrencyId));
            Assert.AreEqual(EffectiveDate(), dtpEffectiveDate.Date, "The effective date on row 1 should be {0}", EffectiveDate().ToString());

            // Select the second row - which will be the last but one item of standard data
            SelectRowInGrid(2);

            // Check the details again for this row
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId),
                            cmbFromCurrency.GetSelectedString(), "The From currency on row 2 should be {0}", EffectiveCurrency(FFromCurrencyId));
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId),
                            cmbToCurrency.GetSelectedString(), "The To currency on row 2 should be {0}", EffectiveCurrency(FToCurrencyId));
            Assert.AreEqual(EffectiveDate(), dtpEffectiveDate.Date, "The effective date on row 2 should be {0}", EffectiveDate().ToString());

            // Now hide the other currencies
            chkHideOthers.Checked = true;

            // The number of rows in the grid should have changed
            Assert.AreEqual(FHiddenRowCount + 1,
                            grdDetails.Rows.Count,
                            "The grid should have {0} rows when the checkbox is checked",
                            FHiddenRowCount + 1);

            // But the details should still be the same
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId),
                            cmbFromCurrency.GetSelectedString(), "The From currency on row 2 should be {0}", EffectiveCurrency(FFromCurrencyId));
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId),
                            cmbToCurrency.GetSelectedString(), "The To currency on row 2 should be {0}", EffectiveCurrency(FToCurrencyId));
            Assert.AreEqual(EffectiveDate(), dtpEffectiveDate.Date, "The effective date on row 2 should be {0}", EffectiveDate().ToString());
            Assert.IsFalse(cmbToCurrency.Enabled, "The To Currency should be disabled when the checkbox is checked");

            // Uncheck the box and select the last row
            chkHideOthers.Checked = false;
            SelectRowInGrid(FAllRowCount);

            // Check the details - should be the first item of standard data
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId),
                            cmbFromCurrency.GetSelectedString(), "The From currency on row {0} should be {1}", FAllRowCount, EffectiveCurrency(FFromCurrencyId));
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId),
                            cmbToCurrency.GetSelectedString(), "The To currency on row {0} should be {1}", FAllRowCount, EffectiveCurrency(FToCurrencyId));
            Assert.AreEqual(EffectiveDate(), dtpEffectiveDate.Date, "The effective date on row {0} should be {1}", FAllRowCount,
                            EffectiveDate().ToString());

            // Hide other To currencies again - now the selected row will have jumped higher
            chkHideOthers.Checked = true;
            Assert.AreEqual(FHiddenRowCount,
                            mainScreen.GetSelectedRowIndex(), "When the checkbox is checked the selected row should be {0}", FHiddenRowCount);

            // But the details should again be the same as before the checkbox check
            Assert.AreEqual(EffectiveCurrency(FFromCurrencyId),
                            cmbFromCurrency.GetSelectedString(), "The From currency on row {0} should be {1}", FHiddenRowCount, EffectiveCurrency(FFromCurrencyId));
            Assert.AreEqual(EffectiveCurrency(FToCurrencyId),
                            cmbToCurrency.GetSelectedString(), "The To currency on row {0} should be {1}", FHiddenRowCount, EffectiveCurrency(FToCurrencyId));
            Assert.AreEqual(EffectiveDate(), dtpEffectiveDate.Date, "The effective date on row {0} should be {1}", FHiddenRowCount,
                            EffectiveDate().ToString());

            mainScreen.Close();
        }
        private void RefreshAnalysisAttributesGrid(TCmbAutoPopulated ACombo, GLBatchTDS ADS)
        {
            TSgrdDataGridPaged Grid = null;
            int TransactionNumber   = 0;

            if (ACombo.Name == cmbFromAccountCode.Name)
            {
                Grid = grdFromAnalAttributes;
                TransactionNumber = FJournal.LastTransactionNumber + 1;
            }
            else
            {
                Grid = grdToAnalAttributes;
                TransactionNumber = FCurrentTransactionNumber;
            }

            //Empty the grid
            ADS.ATransAnalAttrib.DefaultView.RowFilter = "1=2";
            FPSAttributesRow = null;

            if (!TRemote.MFinance.Setup.WebConnectors.AccountHasAnalysisAttributes(FLedgerNumber, ACombo.GetSelectedString(),
                                                                                   true))
            {
                if (Grid.Enabled)
                {
                    Grid.Enabled = false;
                }

                return;
            }
            else
            {
                if (!Grid.Enabled)
                {
                    Grid.Enabled = true;
                }
            }

            FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(ADS, TransactionNumber);

            Grid.DataSource = new DevAge.ComponentModel.BoundDataView(ADS.ATransAnalAttrib.DefaultView);

            if (Grid.Rows.Count > 1)
            {
                Grid.SelectRowWithoutFocus(1);
                AnalysisAttributesGrid_RowSelected(Grid, null);
            }
        }
        private void SetupAnalysisAttributeGrid(TSgrdDataGridPaged AGrid, ref SourceGrid.Cells.Editors.ComboBox AGridCombo)
        {
            AGrid.DataSource = null;
            GLBatchTDS        DS           = null;
            TCmbAutoPopulated AccountCombo = null;

            SourceGrid.Cells.Editors.ComboBox ATempCombo = null;

            if (AGrid.Name == grdFromAnalAttributes.Name)
            {
                FTempFromDS  = (GLBatchTDS)FMainDS.Clone();
                DS           = FTempFromDS;
                AccountCombo = cmbFromAccountCode;
            }
            else
            {
                DS           = FMainDS;
                AccountCombo = cmbDetailAccountCode;
            }

            if (AGrid.Columns.Count == 0)
            {
                ATempCombo              = new SourceGrid.Cells.Editors.ComboBox(typeof(string));
                ATempCombo.EnableEdit   = true;
                ATempCombo.EditableMode = EditableMode.Focus;
                AGrid.Columns.Clear();
                AGrid.AddTextColumn(Catalog.GetString("Type"), FMainDS.ATransAnalAttrib.ColumnAnalysisTypeCode, 99);
                AGrid.AddTextColumn(Catalog.GetString("Value"),
                                    DS.ATransAnalAttrib.Columns[ATransAnalAttribTable.GetAnalysisAttributeValueDBName()], 150,
                                    ATempCombo);
            }

            FAnalysisAttributesLogic.SetTransAnalAttributeDefaultView(DS);
            DS.ATransAnalAttrib.DefaultView.AllowNew = false;
            AGrid.DataSource = new DevAge.ComponentModel.BoundDataView(DS.ATransAnalAttrib.DefaultView);
            AGrid.SetHeaderTooltip(0, Catalog.GetString("Type"));
            AGrid.SetHeaderTooltip(1, Catalog.GetString("Value"));

            AGrid.Selection.SelectionChanged += AnalysisAttributesGrid_RowSelected;

            //Prepare Analysis attributes grid to highlight inactive analysis codes
            // Create a cell view for special conditions
            SourceGrid.Cells.Views.Cell strikeoutCell2 = new SourceGrid.Cells.Views.Cell();
            strikeoutCell2.Font = new System.Drawing.Font(AGrid.Font, FontStyle.Strikeout);

            // Create a condition, apply the view when true, and assign a delegate to handle it
            SourceGrid.Conditions.ConditionView conditionAnalysisCodeActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2);
            conditionAnalysisCodeActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2)
            {
                DataRowView row2         = (DataRowView)itemRow2;
                string      analysisCode = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString();
                return(!FAnalysisAttributesLogic.AnalysisCodeIsActive(AccountCombo.GetSelectedString(), FCacheDS.AAnalysisAttribute, analysisCode));
            };

            // Create a condition, apply the view when true, and assign a delegate to handle it
            SourceGrid.Conditions.ConditionView conditionAnalysisAttributeValueActive = new SourceGrid.Conditions.ConditionView(strikeoutCell2);
            conditionAnalysisAttributeValueActive.EvaluateFunction = delegate(SourceGrid.DataGridColumn column2, int gridRow2, object itemRow2)
            {
                if (itemRow2 != null)
                {
                    DataRowView row2                   = (DataRowView)itemRow2;
                    string      analysisCode           = row2[ATransAnalAttribTable.ColumnAnalysisTypeCodeId].ToString();
                    string      analysisAttributeValue = row2[ATransAnalAttribTable.ColumnAnalysisAttributeValueId].ToString();
                    return(!TAnalysisAttributes.AnalysisAttributeValueIsActive(ref ATempCombo,
                                                                               FCacheDS.AFreeformAnalysis,
                                                                               analysisCode,
                                                                               analysisAttributeValue));
                }
                else
                {
                    return(false);
                }
            };

            //Add conditions to columns
            int indexOfAnalysisCodeColumn           = 0;
            int indexOfAnalysisAttributeValueColumn = 1;

            AGrid.Columns[indexOfAnalysisCodeColumn].Conditions.Add(conditionAnalysisCodeActive);
            AGrid.Columns[indexOfAnalysisAttributeValueColumn].Conditions.Add(conditionAnalysisAttributeValueActive);

            AGridCombo = ATempCombo;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Gets the value of the current state of the controls.  If there are multiple controls the value will be a comma separated list.
        /// </summary>
        /// <returns>The value formatted as a string.  If there are no controls the result will be an empty string.
        /// If there was an error in the database specification of the controls, the result will be an empty string
        /// If a control value is null we set the string representation to ? which can be validated by the client.</returns>
        public string GetCurrentValue()
        {
            string ReturnValue = "";

            if (FCurrentHostPanel == null)
            {
                return(ReturnValue);
            }

            if (FCurrentHostPanel.Controls.Count == 0)
            {
                return(CONTROL_DEFINITION_ERROR);
            }

            for (int i = 0; i < FCurrentHostPanel.Controls.Count; i++)
            {
                Control control = FCurrentHostPanel.Controls[i];

                if (control is Label)
                {
                    continue;
                }

                if (control is TTxtNumericTextBox)
                {
                    // Numeric text box returns ? if the entry is null
                    TTxtNumericTextBox txt = (TTxtNumericTextBox)control;

                    switch (txt.ControlMode)
                    {
                    case TTxtNumericTextBox.TNumericTextBoxMode.Integer:
                        ReturnValue += ((txt.NumberValueInt.HasValue ? txt.NumberValueInt.ToString() : "?") + ",");
                        break;

                    default:
                        break;
                    }
                }
                else if (control is TextBox)
                {
                    ReturnValue += (((TextBox)control).Text + ",");
                }

                if (control is TCmbAutoPopulated)
                {
                    // Returns ? if the selected index is -1
                    TCmbAutoPopulated cmb = (TCmbAutoPopulated)control;
                    string            s   = cmb.GetSelectedString();
                    ReturnValue += ((s.Length == 0 ? "?" : s) + ",");
                }

                if (control is TCmbAutoComplete)
                {
                    TCmbAutoComplete cmb = (TCmbAutoComplete)control;

                    if (Convert.ToString(control.Tag) == "yes/no")
                    {
                        ReturnValue += (cmb.GetSelectedYesNo() + ",");
                    }
                    else
                    {
                        // Returns ? if the selected index is -1
                        string s = cmb.GetSelectedString();
                        ReturnValue += ((s.Length == 0 ? "?" : s) + ",");
                    }
                }

                if (control is TtxtPetraDate)
                {
                    // Returns ? where the date value is null
                    TtxtPetraDate txt = (TtxtPetraDate)control;
                    ReturnValue += ((txt.Date.HasValue ? txt.Date.Value.ToString("yyyy-MM-dd") : "?") + ",");
                }
            }

            // Remove the trailing comma we added
            return(ReturnValue.Trim(','));
        }