Beispiel #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");
        }
        /// <summary>
        /// Helper method that we can call to initialise each of the filter/find comboBoxes
        /// </summary>
        private void InitFilterFindComboBox(TCmbAutoPopulated AClonedFromComboBox,
                                            TCmbAutoComplete AFFInstance)
        {
            AFFInstance.DisplayMember = AClonedFromComboBox.DisplayMember;
            AFFInstance.ValueMember   = AClonedFromComboBox.ValueMember;

            if (AClonedFromComboBox.Name.Contains("Account"))
            {
                // This is quicker than getting the cached table again
                AFFInstance.DataSource = FAccountTable.Copy().DefaultView;
                //AFFInstance.DataSource = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber).DefaultView;
            }
            else if (AClonedFromComboBox.Name.Contains("CostCentre"))
            {
                // This is quicker than getting the cached table again
                AFFInstance.DataSource = FCostCentreTable.Copy().DefaultView;
                //AFFInstance.DataSource = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, FLedgerNumber).DefaultView;
            }
            else
            {
                throw new Exception("Unexpected ComboBox name");
            }

            AFFInstance.DrawMode  = DrawMode.OwnerDrawFixed;
            AFFInstance.DrawItem += new DrawItemEventHandler(DrawComboBoxItem);
        }
Beispiel #3
0
        /// <summary>
        /// Helper method that we can call to initialise each of the filter/find comboBoxes
        /// </summary>
        private void InitFilterFindComboBox(TCmbAutoPopulated AClonedFromComboBox,
                                            TCmbAutoComplete AFFInstance)
        {
            AFFInstance.DisplayMember = AClonedFromComboBox.DisplayMember;
            AFFInstance.ValueMember   = AClonedFromComboBox.ValueMember;

            if (AClonedFromComboBox.Name.Contains("Account"))
            {
                // This is quicker than getting the cached table again
                DataView dv = new DataView(FAccountTable.Copy());
                dv.RowFilter           = TFinanceControls.PrepareAccountFilter(true, false, false, false, "");
                dv.Sort                = String.Format("{0}", AAccountTable.GetAccountCodeDBName());
                AFFInstance.DataSource = dv;
            }
            else if (AClonedFromComboBox.Name.Contains("CostCentre"))
            {
                // This is quicker than getting the cached table again
                DataView dv = new DataView(FCostCentreTable.Copy());
                dv.RowFilter           = TFinanceControls.PrepareCostCentreFilter(true, false, false, false);
                dv.Sort                = String.Format("{0}", ACostCentreTable.GetCostCentreCodeDBName());
                AFFInstance.DataSource = dv;
            }
            else
            {
                throw new Exception("Unexpected ComboBox name");
            }

            AFFInstance.DrawMode  = DrawMode.OwnerDrawFixed;
            AFFInstance.DrawItem += new DrawItemEventHandler(DrawComboBoxItem);
        }
Beispiel #4
0
        public void LoadEmptyTable()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            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;

            Assert.IsFalse(btnSave.Enabled, "The Save button should be disabled when the screen is loaded");
            Assert.IsFalse(pnlDetails.Enabled, "The Details Panel should be disabled on initial load");
            Assert.IsFalse(dtpEffectiveDate.Date.HasValue, "The date control should be empty on initial load");

            Assert.AreEqual(1, grdDetails.Rows.Count, "The grid should be empty");

            mainScreen.Close();
        }
Beispiel #5
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();
            }
        }
Beispiel #6
0
        /// <summary>
        /// Constructor
        /// </summary>
        public TUC_RecurringGiftBatches_AccountAndCostCentre(Int32 ALedgerNumber,
                                                             GiftBatchTDS AMainDS,
                                                             TCmbAutoPopulated ACmbBankAccountCode,
                                                             TCmbAutoPopulated ACmbCostCentreCode)
        {
            FLedgerNumber = ALedgerNumber;
            FMainDS       = AMainDS;

            FCmbBankAccountCode = ACmbBankAccountCode;
            FCmbCostCentreCode  = ACmbCostCentreCode;
        }
Beispiel #7
0
 /// <summary>
 /// This method must be called in order to correctly populate the ComboBoxes on the filter panel (by cloning from the main details panel)
 /// </summary>
 /// <param name="ACmbCostCentre"></param>
 /// <param name="ACmbAccountCode"></param>
 public void InitialiseDataSources(TCmbAutoPopulated ACmbCostCentre, TCmbAutoPopulated ACmbAccountCode)
 {
     // We have to do these because the filter/find panel is displayed when the screen is loaded, so they do not get populated
     InitFilterFindComboBox(ACmbCostCentre,
                            (TCmbAutoComplete)FFilterFindPanelObject.FilterPanelControls.FindControlByName(ACmbCostCentre.Name));
     InitFilterFindComboBox(ACmbAccountCode,
                            (TCmbAutoComplete)FFilterFindPanelObject.FilterPanelControls.FindControlByName(ACmbAccountCode.Name));
     InitFilterFindComboBox(ACmbCostCentre,
                            (TCmbAutoComplete)FFilterFindPanelObject.FindPanelControls.FindControlByName(ACmbCostCentre.Name));
     InitFilterFindComboBox(ACmbAccountCode,
                            (TCmbAutoComplete)FFilterFindPanelObject.FindPanelControls.FindControlByName(ACmbAccountCode.Name));
 }
Beispiel #8
0
        public void Validation()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TFrmSetupCorporateExchangeRate mainScreen = new TFrmSetupCorporateExchangeRate(null);

            mainScreen.Show();

            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;

            btnNew.Click();

            // Set up some bad entries
            dtpEffectiveDate.Text = "";
            txtExchangeRate.NumberValueDecimal = 0.0m;

            string dlgText      = String.Empty;
            bool   dlgDisplayed = false;

            // Click the New button and discover what validation errors we have
            // Note - we do not put assert's inside the delegate because we want the dialog to close.
            //   If the dialog is left hanging this might do bad stuff to automated testing
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                dlgText      = tester.Text;
                dlgDisplayed = true;
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            btnNew.Click();

            // Check that we did display the dialog and that we picked up the validation errors we predicted
            Assert.IsTrue(dlgDisplayed);
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_NOUNDEFINEDDATE));
            Assert.IsTrue(dlgText.Contains(CommonErrorCodes.ERR_INVALIDNUMBER));

            // Close without saving
            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.No);
            };

            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);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Populates the Cost Centre, Account Code and DR Account Code ComboBoxes.
        /// </summary>
        /// <param name="ACostCentreComboBox">Cost Centre ComboBox Control</param>
        /// <param name="AAccountCodeComboBox">Account Code ComboBox Control</param>
        /// <param name="ADrAccountCodeComboBox">DR Account Code ComboBox Control</param>
        /// <param name="ALedgerNumber">Ledger Number</param>
        /// <param name="ACalledByReceivableScreen">Set this to true if the 'Admin Grants Receivable' screen is calling this Method.</param>
        public static void PopulateComboBoxes(TCmbAutoPopulated ACostCentreComboBox,
                                              TCmbAutoPopulated AAccountCodeComboBox,
                                              TCmbAutoPopulated ADrAccountCodeComboBox,
                                              Int32 ALedgerNumber,
                                              bool ACalledByReceivableScreen)
        {
            string filter = String.Empty;

            DataTable CostCentreListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList, ALedgerNumber);

            CostCentreListTable.DefaultView.Sort = ACostCentreTable.GetCostCentreNameDBName() + " ASC";

            if (ACalledByReceivableScreen)
            {
                filter = ACostCentreTable.GetPostingCostCentreFlagDBName() + " = true AND " +
                         ACostCentreTable.GetCostCentreTypeDBName() + " = 'Local'";
            }
            else
            {
                filter = ACostCentreTable.GetPostingCostCentreFlagDBName() + " = true";
            }

            ACostCentreComboBox.InitialiseUserControl(CostCentreListTable,
                                                      ACostCentreTable.GetCostCentreCodeDBName(), ACostCentreTable.GetCostCentreNameDBName(), null);
            ACostCentreComboBox.AppearanceSetup(new int[] { -1, 300 }, 20);
            ACostCentreComboBox.Filter = filter;

            DataTable AccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber);

            AccountListTable.DefaultView.Sort = AAccountTable.GetAccountCodeDBName() + " ASC";
            filter = AAccountTable.GetPostingStatusDBName() + " = true AND " +
                     AAccountTable.GetAccountTypeDBName().ToUpper() + " = 'INCOME'";
            AAccountCodeComboBox.InitialiseUserControl(AccountListTable,
                                                       AAccountTable.GetAccountCodeDBName(), AAccountTable.GetAccountCodeShortDescDBName(), null);
            AAccountCodeComboBox.AppearanceSetup(new int[] { -1, 300 }, 20);
            AAccountCodeComboBox.Filter = filter;

            DataTable DrAccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, ALedgerNumber);

            DrAccountListTable.DefaultView.Sort = AAccountTable.GetAccountCodeDBName() + " ASC";
            filter = AAccountTable.GetPostingStatusDBName() + " = true AND " +
                     AAccountTable.GetAccountTypeDBName().ToUpper() + " = 'EXPENSE'";
            ADrAccountCodeComboBox.InitialiseUserControl(DrAccountListTable,
                                                         AAccountTable.GetAccountCodeDBName(), AAccountTable.GetAccountCodeShortDescDBName(), null);
            ADrAccountCodeComboBox.AppearanceSetup(new int[] { -1, 300 }, 20);
            ADrAccountCodeComboBox.Filter = filter;
        }
Beispiel #11
0
        public void InvertRate()
        {
            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;
            ButtonTester       btnInvert        = new ButtonTester("btnInvertExchangeRate", mainScreen);

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

            // Check that Invert enabled and test that it works
            btnNew.Click();
            Assert.IsTrue(btnInvert.Properties.Enabled);
            txtExchangeRate.NumberValueDecimal = 5.0m;
            btnInvert.Click();
            Assert.AreEqual(0.2m, txtExchangeRate.NumberValueDecimal);
            btnInvert.Click();
            Assert.AreEqual(5.0m, txtExchangeRate.NumberValueDecimal);

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                MessageBoxTester tester = new MessageBoxTester(hWnd);
                tester.SendCommand(MessageBoxTester.Command.OK);
            };

            mainScreen.SaveChanges();
            mainScreen.Close();
        }
Beispiel #12
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();
            }
        }
Beispiel #13
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;
                        }
                    }
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Method to create and show the controls required for a particular code on the specified panel.
        /// Currently we support the following controls:
        ///    txt -> TextBox,
        ///    txt -> TTxtNumericTextBox with Format=Integer as the attribute,
        ///    cmb -> TCmbAutoComplete: content is defined in OptionalValues column: Format=yes/no turns the combo into a tri-state choice
        ///                where the OptionalValues do not have to be False and True because the result is yes or no based on SelectedIndex.
        ///    dtp -> TtxtPetraDate
        /// </summary>
        /// <param name="AControlCode">The code that is a primary key into the controls table</param>
        /// <param name="AHostPanel">The panel onto which the GUI controls will be placed</param>
        /// <param name="AInitialValue">The initial value for this 'setting'.  The value may be a comma separated list of values.</param>
        /// <param name="AReadOnly">Set to true to disable the control(s) or make them read-only as appropriate.</param>
        /// <param name="AValidationEventHandler">An event handler that will be called on validation</param>
        public void ShowControls(string AControlCode, Panel AHostPanel, string AInitialValue, bool AReadOnly, EventHandler AValidationEventHandler)
        {
            // Work out the PetraUtilsObject for the form that called us
            TFrmPetraUtils petraBase = ((IFrmPetra)AHostPanel.TopLevelControl).GetPetraUtilsObject();

            FPetraUtilsObject = (petraBase is TFrmPetraEditUtils) ? (TFrmPetraEditUtils)petraBase : null;

            // Set up a default view on the controls table that will tell us the controls we need for this code
            FDataTable.DefaultView.RowFilter = string.Format("{0}='{1}'", FCodeColumn, AControlCode);
            FDataTable.DefaultView.Sort      = string.Format("{0} ASC, {1} ASC", FCodeColumn, FControlIndexColumn);

            AHostPanel.AutoScroll = (FDataTable.DefaultView.Count > 1);
            AHostPanel.Controls.Clear();

            // Work out the value(s) that have been passed in as a comma separated list
            StringCollection values = StringHelper.GetCSVList(AInitialValue, ",", true);

            if (values.Count != FDataTable.DefaultView.Count)
            {
                return;
            }

            FCurrentHostPanel = AHostPanel;
            int id       = 0;
            int vPos     = 5;
            int tabIndex = 10;

            foreach (DataRowView drv in FDataTable.DefaultView)
            {
                // get the attributes as a dictionary
                Dictionary <string, string> attributes = new Dictionary <string, string>();
                object rowValue = drv.Row[FAttributesColumn];

                if ((rowValue != null) && rowValue.ToString().Contains("="))
                {
                    string[] attPairs = drv.Row[FAttributesColumn].ToString().Split(',');

                    foreach (string attPair in attPairs)
                    {
                        string[] att = attPair.Split('=');

                        if (att.Length == 2)
                        {
                            attributes.Add(att[0].Trim(), att[1].Trim());
                        }
                    }
                }

                // See if some of the popular attributes are defined and store their values in local variables
                string formatAttribute     = string.Empty;
                string allowBlankAttribute = string.Empty;
                string stretchAttribute    = string.Empty;
                int    widthAttribute      = -1;
                int    labelWidthAttribute = -1;

                if (attributes.ContainsKey("Format"))
                {
                    // Use lower case
                    formatAttribute = attributes["Format"].ToString().ToLower();
                }

                if (attributes.ContainsKey("Width"))
                {
                    widthAttribute = Convert.ToInt32(attributes["Width"]);
                }

                if (attributes.ContainsKey("LabelWidth"))
                {
                    labelWidthAttribute = Convert.ToInt32(attributes["LabelWidth"]);
                }

                if (attributes.ContainsKey("AllowBlankValue"))
                {
                    allowBlankAttribute = attributes["AllowBlankValue"].ToString().ToLower();
                }

                if (attributes.ContainsKey("Stretch"))
                {
                    stretchAttribute = attributes["Stretch"].ToString().ToLower();
                }

                // create the control label
                Label label = new Label();
                label.Name      = "cLabel_" + id.ToString();
                label.Text      = drv.Row[FLabelColumn].ToString() + ":";
                label.Location  = new Point(5, vPos);
                label.Size      = new Size((labelWidthAttribute > 0) ? labelWidthAttribute : (AHostPanel.Width / 2) - 10, 17);
                label.TextAlign = ContentAlignment.MiddleRight;
                label.Anchor    = AnchorStyles.Top | AnchorStyles.Left;

                AHostPanel.Controls.Add(label);

                // Create the control
                // We support text boxes, numeric (integer) text boxes, combo boxes and date boxes
                switch (drv.Row[FControlTypeColumn].ToString().Substring(0, 3))
                {
                case "txt":

                    if (formatAttribute == "integer")
                    {
                        TTxtNumericTextBox txt = new TTxtNumericTextBox();
                        txt.Context     = AHostPanel;
                        txt.ControlMode = TTxtNumericTextBox.TNumericTextBoxMode.Integer;
                        txt.Name        = "cValue_" + id.ToString();
                        txt.Location    = new Point(label.Right + 10, vPos);
                        txt.Size        = new Size((widthAttribute > 0) ? widthAttribute : 100, 22);
                        txt.TabStop     = true;
                        txt.TabIndex    = tabIndex;

                        int iValue;

                        if (int.TryParse(values[id], out iValue))
                        {
                            txt.NumberValueInt = iValue;
                        }

                        txt.ReadOnly = AReadOnly;

                        txt.Validated   += AValidationEventHandler;
                        txt.TextChanged += new EventHandler(MultiChangeEventHandler);

                        AHostPanel.Controls.Add(txt);
                    }
                    else
                    {
                        TextBox txt = new TextBox();
                        txt.Name     = "cValue_" + id.ToString();
                        txt.Location = new Point(label.Right + 10, vPos);
                        txt.Size     = new Size((widthAttribute > 0) ? widthAttribute : AHostPanel.Width - label.Width - 25, 22);
                        txt.TabStop  = true;
                        txt.TabIndex = tabIndex;
                        txt.Text     = values[id];
                        txt.ReadOnly = AReadOnly;

                        if (stretchAttribute == "horizontally")
                        {
                            txt.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        }

                        txt.Validated   += AValidationEventHandler;
                        txt.TextChanged += new EventHandler(MultiChangeEventHandler);

                        AHostPanel.Controls.Add(txt);
                    }

                    break;

                case "cmb":

                    if (attributes.ContainsKey("List"))
                    {
                        TCmbAutoPopulated cmb = new TCmbAutoPopulated();
                        cmb.Name      = "cValue_" + id.ToString();
                        cmb.Location  = new Point(label.Right + 10, vPos);
                        cmb.Size      = new Size((widthAttribute > 0) ? widthAttribute : AHostPanel.Width - label.Width - 25, 22);
                        cmb.TabStop   = true;
                        cmb.TabIndex  = tabIndex;
                        cmb.ListTable = (TCmbAutoPopulated.TListTableEnum)Enum.Parse(typeof(TCmbAutoPopulated.TListTableEnum),
                                                                                     attributes["List"].ToString(),
                                                                                     true);
                        cmb.InitialiseUserControl();
                        cmb.SetSelectedString(values[id], -1);

                        cmb.Enabled = !AReadOnly;

                        cmb.Validated            += AValidationEventHandler;
                        cmb.SelectedValueChanged += new EventHandler(MultiChangeEventHandler);

                        AHostPanel.Controls.Add(cmb);
                    }
                    else
                    {
                        TCmbAutoComplete cmb = new TCmbAutoComplete();
                        cmb.Name     = "cValue_" + id.ToString();
                        cmb.Location = new Point(label.Right + 10, vPos);
                        cmb.Size     = new Size((widthAttribute > 0) ? widthAttribute : AHostPanel.Width - label.Width - 25, 22);
                        cmb.TabStop  = true;
                        cmb.TabIndex = tabIndex;

                        if (drv.Row[FOptionalValuesColumn] != null)
                        {
                            string[] optValues = drv.Row[FOptionalValuesColumn].ToString().Split(',');

                            for (int i = 0; i < optValues.Length; i++)
                            {
                                cmb.Items.Add(optValues[i].ToString().Trim());
                            }
                        }

                        if (formatAttribute == "yes/no")
                        {
                            cmb.SetSelectedYesNo(values[id]);
                            cmb.Tag = "yes/no";
                        }
                        else
                        {
                            cmb.Text = values[id];
                        }

                        if (stretchAttribute == "horizontally")
                        {
                            cmb.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                        }

                        cmb.AllowBlankValue = (allowBlankAttribute == "true");
                        cmb.Enabled         = !AReadOnly;

                        cmb.Validated            += AValidationEventHandler;
                        cmb.SelectedIndexChanged += new EventHandler(MultiChangeEventHandler);
                        cmb.TextChanged          += new EventHandler(ComboBoxTextChangeEventHandler);

                        AHostPanel.Controls.Add(cmb);
                    }

                    break;

                case "dtp":
                    TtxtPetraDate dtp = new TtxtPetraDate();
                    dtp.Name     = "cValue_" + id.ToString();
                    dtp.Location = new Point(label.Right + 10, vPos);
                    dtp.Size     = new Size(94, 22);
                    dtp.TabStop  = true;
                    dtp.TabIndex = tabIndex;

                    DateTime dt;

                    if (DateTime.TryParse(values[id], out dt))
                    {
                        dtp.Date = Convert.ToDateTime(values[id]);
                    }
                    else
                    {
                        dtp.Date = null;
                    }

                    dtp.ReadOnly = AReadOnly;

                    dtp.Validated   += AValidationEventHandler;
                    dtp.DateChanged += new TPetraDateChangedEventHandler(MultiChangeEventHandler);

                    AHostPanel.Controls.Add(dtp);
                    break;

                default:
                    break;
                }

                id++;
                tabIndex += 10;
                vPos     += 30;
            }
        }
Beispiel #15
0
        private void SetupTaxDeductibilityControls()
        {
            // increase the width of the screen from the default width (760)
            if (ClientSize.Width == 760)
            {
                ClientSize = new System.Drawing.Size(920, ClientSize.Height);
            }

            // new label
            Label lblAccounts = new Label();

            lblAccounts.Name      = "lblAccounts";
            lblAccounts.Location  = lblDetailAccountCode.Location;
            lblAccounts.Anchor    = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
            lblAccounts.Size      = lblDetailAccountCode.Size;
            lblAccounts.Text      = "Accounts:";
            lblAccounts.TextAlign = System.Drawing.ContentAlignment.TopRight;
            pnlDetails.Controls.Add(lblAccounts);

            // changes to DetailAccountCode control
            lblDetailAccountCode.Location = new System.Drawing.Point(lblDetailAccountCode.Location.X + 90, lblDetailAccountCode.Location.Y);
            lblDetailAccountCode.Text     = "Non-Deductible:";
            lblDetailAccountCode.Size     = new System.Drawing.Size(102, 17);
            cmbDetailAccountCode.Location = new System.Drawing.Point(cmbDetailAccountCode.Location.X + 105, cmbDetailAccountCode.Location.Y);

            // create new label and combobox for the Tax-Deductible Account Code
            Label lblDeductibleAccountCode = new Label();

            lblDeductibleAccountCode.Name     = "lblDeductibleAccountCode";
            lblDeductibleAccountCode.Location = new System.Drawing.Point(cmbDetailAccountCode.Location.X + 310, lblDetailAccountCode.Location.Y);
            lblDeductibleAccountCode.Anchor   =
                ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
            lblDeductibleAccountCode.Size      = new System.Drawing.Size(102, 17);
            lblDeductibleAccountCode.Text      = "Tax-Deductible:";
            lblDeductibleAccountCode.TextAlign = System.Drawing.ContentAlignment.TopRight;
            pnlDetails.Controls.Add(lblDeductibleAccountCode);

            cmbDeductibleAccountCode            = new TCmbAutoPopulated();
            cmbDeductibleAccountCode.Name       = "cmbDeductibleAccountCode";
            cmbDeductibleAccountCode.Location   = new System.Drawing.Point(cmbDetailAccountCode.Location.X + 415, cmbDetailAccountCode.Location.Y);
            cmbDeductibleAccountCode.Size       = new System.Drawing.Size(300, 22);
            cmbDeductibleAccountCode.ListTable  = TCmbAutoPopulated.TListTableEnum.UserDefinedList;
            cmbDeductibleAccountCode.TabIndex   = cmbDetailAccountCode.TabIndex + 1;
            cmbDeductibleAccountCode.Validated += ControlValidatedHandler;
            pnlDetails.Controls.Add(cmbDeductibleAccountCode);

            TFinanceControls.InitialiseAccountList(ref cmbDeductibleAccountCode, FLedgerNumber, true, false, false, false);

            if (FMainDS.AMotivationDetail != null)
            {
                FPetraUtilsObject.ValidationControlsDict.Add(FMainDS.AMotivationDetail.Columns[(short)FMainDS.AMotivationDetail.GetType().GetField(
                                                                                                   "ColumnTaxDeductibleAccountId",
                                                                                                   BindingFlags.Public | BindingFlags.Static |
                                                                                                   BindingFlags.FlattenHierarchy).GetValue(FMainDS.
                                                                                                                                           AMotivationDetail.GetType())],
                                                             new TValidationControlsData(cmbDeductibleAccountCode, Catalog.GetString("Tax Deductible Account")));
            }

            // add new column to grid (TaxDeductibleAccount)
            grdDetails.Columns.Clear();
            grdDetails.AddTextColumn(Catalog.GetString("Group"), FMainDS.AMotivationDetail.ColumnMotivationGroupCode);
            grdDetails.AddTextColumn(Catalog.GetString("Motivation Detail"), FMainDS.AMotivationDetail.ColumnMotivationDetailCode);
            grdDetails.AddTextColumn(Catalog.GetString("Description"), FMainDS.AMotivationDetail.ColumnMotivationDetailDesc);
            grdDetails.AddTextColumn(Catalog.GetString("Non-Deductible Account"), FMainDS.AMotivationDetail.ColumnAccountCode);
            grdDetails.AddTextColumn(Catalog.GetString("Tax-Deductible Account"), FMainDS.AMotivationDetail.ColumnTaxDeductibleAccount);
            grdDetails.AddTextColumn(Catalog.GetString("Cost Centre Code"), FMainDS.AMotivationDetail.ColumnCostCentreCode);
            grdDetails.AddCheckBoxColumn(Catalog.GetString("Active"), FMainDS.AMotivationDetail.ColumnMotivationStatus);
            grdDetails.AddCheckBoxColumn(Catalog.GetString("Print Receipt"), FMainDS.AMotivationDetail.ColumnReceipt);

            SelectRowInGrid(1);
        }
Beispiel #16
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();
        }
Beispiel #17
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();
        }
Beispiel #18
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();
        }
Beispiel #19
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();
        }
Beispiel #20
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(','));
        }
Beispiel #21
0
        /// <summary>
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager
                resources = new System.ComponentModel.ComponentResourceManager(
                typeof(TFrmGLBatch));

            lblAccountText  = new Label();
            lblAccountValue = new Label();

            lblDateEnd      = new Label();
            lblDateEndValue = new Label();

            lblRevCur      = new Label();
            lblRevCurValue = new Label();

            lblCostCentre  = new Label();
            cmbCostCentres = new TCmbAutoPopulated();

            grdDetails = new SourceGrid.DataGrid();

            btnRevaluate = new Button();
            btnCancel    = new Button();
            SuspendLayout();

            int leftColStart  = 32;
            int leftColWidth  = 180;
            int colSpace      = 15;
            int rowY          = 5;
            int rowHeight     = 25;
            int rightColWidth = 280;

            // int buttonTop = 210;
            int buttonLeft = 120;

            //
            // lblAccountText
            //
            lblAccountText.Location  = new System.Drawing.Point(leftColStart, rowY);
            lblAccountText.Name      = "lblAccountText";
            lblAccountText.Size      = new System.Drawing.Size(leftColWidth, 21);
            lblAccountText.TextAlign = ContentAlignment.MiddleRight;

            //
            // lblAccountValue
            //
            lblAccountValue.Location  = new System.Drawing.Point(leftColStart + leftColWidth + colSpace, rowY);
            lblAccountValue.Name      = "lblAccountValue";
            lblAccountValue.Size      = new System.Drawing.Size(144, 21);
            lblAccountValue.TextAlign = ContentAlignment.MiddleLeft;

            rowY = rowY + rowHeight;

            //
            // lblDateEnd
            //
            lblDateEnd.Location  = new System.Drawing.Point(leftColStart, rowY);
            lblDateEnd.Name      = "lblDateEnd";
            lblDateEnd.Size      = new System.Drawing.Size(leftColWidth, 21);
            lblDateEnd.TextAlign = ContentAlignment.MiddleRight;

            //
            // lblDateEndValue
            //
            lblDateEndValue.Location  = new System.Drawing.Point(leftColStart + leftColWidth + colSpace, rowY);
            lblDateEndValue.Name      = "lblDateEndValue";
            lblDateEndValue.Size      = new System.Drawing.Size(rightColWidth, 21);
            lblDateEndValue.TextAlign = ContentAlignment.MiddleLeft;

            rowY = rowY + rowHeight;

            //
            // lblRevCur
            //
            lblRevCur.Location  = new System.Drawing.Point(leftColStart, rowY);
            lblRevCur.Name      = "lblRevCur";
            lblRevCur.Size      = new System.Drawing.Size(leftColWidth, 21);
            lblRevCur.TextAlign = ContentAlignment.MiddleRight;

            //
            // lblRevCurValue
            //
            lblRevCurValue.Location  = new System.Drawing.Point(leftColStart + leftColWidth + colSpace, rowY);
            lblRevCurValue.Name      = "lblRevCurValue";
            lblRevCurValue.Size      = new System.Drawing.Size(rightColWidth, 21);
            lblRevCurValue.TextAlign = ContentAlignment.MiddleLeft;

            rowY = rowY + rowHeight;

            //
            // Cost Centre
            //

            lblCostCentre.Location  = new System.Drawing.Point(leftColStart, rowY);
            lblCostCentre.Name      = "lblCostCentre";
            lblCostCentre.Size      = new System.Drawing.Size(leftColWidth, 21);
            lblCostCentre.TextAlign = ContentAlignment.MiddleRight;

            cmbCostCentres.Location  = new System.Drawing.Point(leftColStart + leftColWidth + colSpace, rowY);
            cmbCostCentres.Name      = "clbCostCentres";
            cmbCostCentres.Size      = new System.Drawing.Size(rightColWidth, 22);
            cmbCostCentres.ListTable = TCmbAutoPopulated.TListTableEnum.UserDefinedList;

            rowY = rowY + rowHeight + 20;

            grdDetails.Location    = new System.Drawing.Point(leftColStart, rowY);
            grdDetails.Size        = new System.Drawing.Size(430, 200);
            grdDetails.BorderStyle = BorderStyle.FixedSingle;
            grdDetails.Anchor      = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom;
            grdDetails.AutoStretchColumnsToFitWidth = true;

            rowY = rowY + 230;

            //
            // btnRevaluate
            //
            btnRevaluate.Location = new System.Drawing.Point(buttonLeft, rowY);
            btnRevaluate.Name     = "btnRevaluate";
            btnRevaluate.Size     = new System.Drawing.Size(95, 23);
            btnRevaluate.TabIndex = 2;
            btnRevaluate.Text     = "Revalue";
            btnRevaluate.UseVisualStyleBackColor = true;
            //
            // btnCancel
            //
            btnCancel.Location = new System.Drawing.Point(150 + buttonLeft, rowY);
            btnCancel.Name     = "btnCancel";
            btnCancel.Size     = new System.Drawing.Size(95, 23);
            btnCancel.TabIndex = 3;
            btnCancel.Text     = "Cancel";
            btnCancel.UseVisualStyleBackColor = true;
            //
            // GLRevaluation
            //
            AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            AutoScaleMode       = AutoScaleMode.Font;
            Font = new System.Drawing.Font("Verdana", 8.25f);


            ClientSize   = new System.Drawing.Size(500, rowY + 50);
            CancelButton = btnCancel;
            Controls.AddRange(new Control[] {
                btnCancel,
                btnRevaluate,
                lblAccountText,
                lblAccountValue,
                lblDateEnd,
                lblDateEndValue,
                lblRevCur,
                lblRevCurValue,
                lblCostCentre,
                cmbCostCentres,
                this.grdDetails
            });

            Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");

            Name = "GLRevaluation";
            Text = "Revaluation ...";
            ResumeLayout(false);
        }
        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;
        }