예제 #1
0
        private void AddAllocations(Object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            if (cmbDetailTransactionTypeCode.GetSelectedString() == CommonAccountingTransactionTypesEnum.ALLOC.ToString())
            {
                TFrmAllocationJournalDialog AddAllocationJournal = new TFrmAllocationJournalDialog(this.FindForm());
                AddAllocationJournal.Journal = this.GetSelectedDetailRow();

                // open as a modal form
                if (AddAllocationJournal.ShowDialog() == DialogResult.OK)
                {
                    FMainDS.Merge(AddAllocationJournal.MainDS);

                    // manually enable save button (otherwise this doesn't happen)
                    FPetraUtilsObject.SetChangedFlag();
                }
            }
            else if (cmbDetailTransactionTypeCode.GetSelectedString() == CommonAccountingTransactionTypesEnum.REALLOC.ToString())
            {
                TFrmReallocationJournalDialog AddReallocationJournal = new TFrmReallocationJournalDialog(this.FindForm());
                AddReallocationJournal.Journal = this.GetSelectedDetailRow();

                // open as a modal form
                if (AddReallocationJournal.ShowDialog() == DialogResult.OK)
                {
                    FMainDS.Merge(AddReallocationJournal.MainDS);

                    // manually enable save button (otherwise this doesn't happen)
                    FPetraUtilsObject.SetChangedFlag();
                }
            }

            Cursor = Cursors.Default;
        }
        private void InitializeManualCode()
        {
            Type DataTableType;

            DataTable CacheRegionDT =
                TDataCache.GetCacheableDataTableFromCache("PostcodeRegionList", String.Empty, null, out DataTableType);
            DataTable CacheRegionRangeDT =
                TDataCache.GetCacheableDataTableFromCache("PostcodeRegionRangeList", String.Empty, null, out DataTableType);
            PPostcodeRangeTable RangeTable =
                (PPostcodeRangeTable)TDataCache.GetCacheableDataTableFromCache("PostcodeRangeList", String.Empty, null, out DataTableType);

            FMainDS.PPostcodeRegion.Merge(CacheRegionDT);
            FMainDS.PPostcodeRegionRange.Merge(CacheRegionRangeDT);

            foreach (PostcodeRegionsTDSPPostcodeRegionRangeRow Row in FMainDS.PPostcodeRegionRange.Rows)
            {
                PPostcodeRangeRow RangeRow = (PPostcodeRangeRow)RangeTable.Rows.Find(new object[] { Row.Range });
                Row.From = RangeRow.From;
                Row.To   = RangeRow.To;
            }

            FMainDS.AcceptChanges();

            FPetraUtilsObject.ApplySecurity(TSecurityChecks.SecurityPermissionsSetupScreensEditingAndSaving);
        }
예제 #3
0
        private void RefreshBankAccountAndCostCentreData()
        {
            //Populate CostCentreList variable
            DataTable costCentreList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList,
                                                                                     FLedgerNumber);

            ACostCentreTable tmpCostCentreTable = new ACostCentreTable();

            FMainDS.Tables.Add(tmpCostCentreTable);
            DataUtilities.ChangeDataTableToTypedDataTable(ref costCentreList, FMainDS.Tables[tmpCostCentreTable.TableName].GetType(), "");
            FMainDS.RemoveTable(tmpCostCentreTable.TableName);

            FCostCentreTable = (ACostCentreTable)costCentreList;

            //Populate AccountList variable
            DataTable accountList = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber);

            AAccountTable tmpAccountTable = new AAccountTable();

            FMainDS.Tables.Add(tmpAccountTable);
            DataUtilities.ChangeDataTableToTypedDataTable(ref accountList, FMainDS.Tables[tmpAccountTable.TableName].GetType(), "");
            FMainDS.RemoveTable(tmpAccountTable.TableName);

            FAccountTable = (AAccountTable)accountList;
        }
예제 #4
0
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        public void LoadRecurringBatches(Int32 ALedgerNumber)
        {
            InitialiseLedgerControls();

            ((TFrmRecurringGiftBatch)ParentForm).ClearCurrentSelections();

            // TODO: more criteria: state of batch, period, etc
            FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadARecurringGiftBatch(ALedgerNumber));

            // Load Motivation detail in this central place; it will be used by UC_GiftTransactions
            AMotivationDetailTable motivationDetail = (AMotivationDetailTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                TCacheableFinanceTablesEnum.MotivationList,
                FLedgerNumber);

            motivationDetail.TableName = FMainDS.AMotivationDetail.TableName;
            FMainDS.Merge(motivationDetail);

            FMainDS.AMotivationDetail.AcceptChanges();

            FMainDS.ARecurringGiftBatch.DefaultView.Sort = String.Format("{0}, {1} DESC",
                                                                         ARecurringGiftBatchTable.GetLedgerNumberDBName(),
                                                                         ARecurringGiftBatchTable.GetBatchNumberDBName()
                                                                         );

            ((TFrmRecurringGiftBatch)this.ParentForm).EnableTransactions(grdDetails.Rows.Count > 1);
            ShowData();

            UpdateRecordNumberDisplay();
            SelectRowInGrid(1);

            FBatchLoaded = true;
        }
예제 #5
0
        private void InitialiseLedgerControls()
        {
            // Load Motivation detail in this central place; it will be used by UC_GiftTransactions
            AMotivationDetailTable motivationDetail = (AMotivationDetailTable)TDataCache.TMFinance.GetCacheableFinanceTable(
                TCacheableFinanceTablesEnum.MotivationList,
                FLedgerNumber);

            motivationDetail.TableName = FMainDS.AMotivationDetail.TableName;
            FMainDS.Merge(motivationDetail);

            FMainDS.AcceptChanges();

            FMainDS.ARecurringGiftBatch.DefaultView.Sort = String.Format("{0}, {1} DESC",
                                                                         ARecurringGiftBatchTable.GetLedgerNumberDBName(),
                                                                         ARecurringGiftBatchTable.GetBatchNumberDBName()
                                                                         );

            SetupExtraGridFunctionality();
            RefreshBankAccountAndCostCentreData();

            // if this form is readonly, then we need all codes, because old codes might have been used
            bool ActiveOnly = this.Enabled;

            SetupAccountAndCostCentreCombos(ActiveOnly);

            cmbDetailMethodOfPaymentCode.AddNotSetRow("", "");
            TFinanceControls.InitialiseMethodOfPaymentCodeList(ref cmbDetailMethodOfPaymentCode, ActiveOnly);
        }
예제 #6
0
        private void LoadDataGrid(bool AFirstTime)
        {
            FMainDS.PcConference.Clear();
            FMainDS.PPartner.Clear();

            FMainDS.Merge(TRemote.MConference.WebConnectors.GetConferences("", ""));

            if (FMainDS.PcConference.Rows.Count == FMainDS.PPartner.Rows.Count)
            {
                if (AFirstTime)
                {
                    FMainDS.PcConference.Columns.Add(PPartnerTable.GetPartnerShortNameDBName(), Type.GetType("System.String"));
                    FMainDS.PcConference.DefaultView.AllowNew = false;
                }

                for (int Counter = 0; Counter < FMainDS.PcConference.Rows.Count; ++Counter)
                {
                    FMainDS.PcConference.Rows[Counter][PPartnerTable.GetPartnerShortNameDBName()] =
                        FMainDS.PPartner.Rows[Counter][PPartnerTable.GetPartnerShortNameDBName()];
                }
            }

            // sort order for grid
            DataView MyDataView = FMainDS.PcConference.DefaultView;

            MyDataView.Sort           = "p_partner_short_name_c ASC";
            grdConferences.DataSource = new DevAge.ComponentModel.BoundDataView(MyDataView);

            UpdateRecordNumberDisplay();
        }
예제 #7
0
        /// <summary>
        /// Reload batches after an import
        /// </summary>
        public void ReloadBatches()
        {
            FPetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor;

            // Before we re-load make a note of the 'last' batch number so we can work out which batches have been imported.
            DataView dv = new DataView(FMainDS.ABatch, String.Empty, String.Format("{0} DESC",
                                                                                   ABatchTable.GetBatchNumberDBName()), DataViewRowState.CurrentRows);
            int lastBatchNumber = (dv.Count == 0) ? 0 : ((ABatchRow)dv[0].Row).BatchNumber;

            // Merge the new batches into our data set
            FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, FCurrentLedgerYear, 0));

            // Go round each imported batch loading its journals
            // Start with the highest batch number and continue until we reach the 'old' last batch
            for (int i = 0; i < dv.Count; i++)
            {
                int batchNumber = ((ABatchRow)dv[i].Row).BatchNumber;

                if (batchNumber <= lastBatchNumber)
                {
                    break;
                }

                FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournalAndContent(FLedgerNumber, batchNumber));
            }

            FPetraUtilsObject.GetForm().Cursor = Cursors.Default;
            EnsureNewBatchIsVisible();
        }
예제 #8
0
        public void ModalValidation()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();
            FLedgerDS.CreateTestLedger();

            decimal  selectedRate;
            DateTime selectedDate;
            int      selectedTime;

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

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

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

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

            // Make sure we did save
            Assert.AreEqual(DialogResult.OK, dlgResult);
            Assert.IsFalse((new ToolStripButtonTester("tbbSave", mainScreen)).Properties.Enabled);
            FMainDS.LoadAll();
            Assert.AreEqual(2, FMainDS.ADailyExchangeRate.Rows.Count, "The data table should have 2 rows after a successful save operation");
        }
        private void LoadJournals()
        {
            FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadARecurringJournal(FLedgerNumber, FBatchNumber));

            DataView JournalDV = new DataView(FMainDS.ARecurringJournal);

            JournalDV.RowFilter = String.Format("{0}={1}",
                                                ARecurringJournalTable.GetBatchNumberDBName(),
                                                FBatchNumber);

            //Populate the dictionary with all journal currencies
            if (JournalDV.Count > 0)
            {
                string  currencyCode = string.Empty;
                decimal exchangeRate = 0;

                foreach (DataRowView drv in JournalDV)
                {
                    ARecurringJournalRow jr = (ARecurringJournalRow)drv.Row;

                    currencyCode = jr.TransactionCurrency;
                    exchangeRate = (currencyCode == FBaseCurrencyCode) ? 1 : 0;

                    if (!FExchangeRateDictionary.ContainsKey(currencyCode))
                    {
                        FExchangeRateDictionary.Add(currencyCode, exchangeRate);
                    }

                    jr.ExchangeRateToBase = exchangeRate;
                }
            }

            SelectRowInGrid(1);
        }
예제 #10
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();
        }
예제 #11
0
        public void Import()
        {
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TVerificationResultCollection results = new TVerificationResultCollection();
            string resultText;
            string firstResultCode;

            RunTestImport("corporate-csv/GoodImport.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(String.Empty, resultText, "Errors during import...");
            Assert.AreEqual(8, FMainDS.ACorporateExchangeRate.Rows.Count, "Wrong number of rows after successful import");

            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/BadCurrencyImport.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(CommonErrorCodes.ERR_INCONGRUOUSSTRINGS, firstResultCode);

            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/BadDateImport.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(CommonErrorCodes.ERR_INVALIDDATE, firstResultCode);

            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/BadRateImport.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(CommonErrorCodes.ERR_INVALIDNUMBER, firstResultCode);

            // Test for a missing column
            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/MissingColumn.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(1, results.Count);
            Assert.AreEqual(CommonErrorCodes.ERR_INFORMATIONMISSING, firstResultCode);

            // Run the test(s) that have duplicates
            FMainDS.DeleteAllRows();
            FMainDS.InsertStandardRows();
            RunTestImport("corporate-csv/GoodImport-WithDuplicates.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(String.Empty, resultText, "Errors during import...");
            Assert.AreEqual(12, FMainDS.ACorporateExchangeRate.Rows.Count, "Wrong number of rows after successful import");

            // And Headers
            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/GoodImport-WithHeader.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(String.Empty, resultText, "Errors during import...");
            Assert.AreEqual(8, FMainDS.ACorporateExchangeRate.Rows.Count, "Wrong number of rows after successful import");

            // Test a date/rate only file - this is tab separated
            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/USD_EUR.csv", "\t", results, out resultText, out firstResultCode);
            Assert.AreEqual(String.Empty, resultText, "Errors during import...");
            Assert.AreEqual(8, FMainDS.ACorporateExchangeRate.Rows.Count, "Wrong number of rows after successful import");

            // Test a file with its own inverses
            FMainDS.DeleteAllRows();
            RunTestImport("corporate-csv/GoodImport-WithInverses.csv", ",", results, out resultText, out firstResultCode);
            Assert.AreEqual(String.Empty, resultText, "Errors during import...");
            Assert.AreEqual(4, FMainDS.ACorporateExchangeRate.Rows.Count, "Wrong number of rows after successful import");
        }
예제 #12
0
        private void SetAccountCostCentreTableVariables()
        {
            //Populate CostCentreList variable
            DataTable CostCentreListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.CostCentreList,
                                                                                          FLedgerNumber);

            ACostCentreTable tmpCostCentreTable = new ACostCentreTable();

            FMainDS.Tables.Add(tmpCostCentreTable);
            DataUtilities.ChangeDataTableToTypedDataTable(ref CostCentreListTable, FMainDS.Tables[tmpCostCentreTable.TableName].GetType(), "");
            FMainDS.RemoveTable(tmpCostCentreTable.TableName);

            FCostCentreTable = (ACostCentreTable)CostCentreListTable;

            //Populate AccountList variable
            DataTable AccountListTable = TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.AccountList, FLedgerNumber);

            AAccountTable tmpAccountTable = new AAccountTable();

            FMainDS.Tables.Add(tmpAccountTable);
            DataUtilities.ChangeDataTableToTypedDataTable(ref AccountListTable, FMainDS.Tables[tmpAccountTable.TableName].GetType(), "");
            FMainDS.RemoveTable(tmpAccountTable.TableName);

            FAccountTable = (AAccountTable)AccountListTable;
        }
예제 #13
0
        private void RefreshCurrencyAndExchangeRateControls(bool AFromUserAction = false)
        {
            if (FPreviouslySelectedDetailRow == null)
            {
                return;
            }

            txtDetailHashTotal.CurrencyCode = FPreviouslySelectedDetailRow.CurrencyCode;

            txtDetailExchangeRateToBase.NumberValueDecimal = FPreviouslySelectedDetailRow.ExchangeRateToBase;
            txtDetailExchangeRateToBase.Enabled            =
                (FPreviouslySelectedDetailRow.ExchangeRateToBase != DEFAULT_CURRENCY_EXCHANGE);

            if ((FMainDS.ALedger == null) || (FMainDS.ALedger.Count == 0))
            {
                FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadALedgerTable(FLedgerNumber));
            }

            btnGetSetExchangeRate.Enabled = (FPreviouslySelectedDetailRow.CurrencyCode != FMainDS.ALedger[0].BaseCurrency);

            if (AFromUserAction && btnGetSetExchangeRate.Enabled)
            {
                btnGetSetExchangeRate.Focus();
            }
        }
예제 #14
0
        /// <summary>
        /// Reload batches after an import
        /// </summary>
        public void ReloadBatches(bool AIsFromMessage = false)
        {
            try
            {
                FPetraUtilsObject.GetForm().Cursor = Cursors.WaitCursor;

                if (!AIsFromMessage)
                {
                    // Before we re-load make a note of the 'last' batch number so we can work out which batches have been imported.
                    DataView dv = new DataView(FMainDS.ABatch, String.Empty, String.Format("{0} DESC",
                                                                                           ABatchTable.GetBatchNumberDBName()), DataViewRowState.CurrentRows);
                    int lastBatchNumber = (dv.Count == 0) ? 0 : ((ABatchRow)dv[0].Row).BatchNumber;

                    // Merge the new batches into our data set
                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, FCurrentLedgerYear, 0));

                    // Go round each imported batch loading its journals
                    // Start with the highest batch number and continue until we reach the 'old' last batch
                    for (int i = 0; i < dv.Count; i++)
                    {
                        ABatchRow batchRow    = (ABatchRow)dv[i].Row;
                        int       batchNumber = batchRow.BatchNumber;

                        if (batchNumber <= lastBatchNumber)
                        {
                            break;
                        }

                        batchRow.SetModified();

                        FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadAJournalAndRelatedTablesForBatch(FLedgerNumber, batchNumber));
                    }

                    EnsureNewBatchIsVisible();
                }
                else
                {
                    if (FPetraUtilsObject.HasChanges && !((TFrmGLBatch)ParentForm).SaveChanges())
                    {
                        string msg = String.Format(Catalog.GetString("A validation error has occured on the GL Batches" +
                                                                     " form while trying to refresh.{0}{0}" +
                                                                     "You will need to close and reopen the GL Batches form to see the new batch" +
                                                                     " after you have fixed the validation error."),
                                                   Environment.NewLine);

                        MessageBox.Show(msg, "Refresh GL Batches");
                        return;
                    }

                    FMainDS.Merge(TRemote.MFinance.GL.WebConnectors.LoadABatch(FLedgerNumber, FCurrentLedgerYear, 0));
                    grdDetails.SelectRowInGrid(1);
                }
            }
            finally
            {
                FPetraUtilsObject.GetForm().Cursor = Cursors.Default;
            }
        }
        private void InitializeManualCode()
        {
            if (!FMainDS.Tables.Contains(PartnerEditTDSPPartnerInterestTable.GetTableName()))
            {
                FMainDS.Tables.Add(new PartnerEditTDSPPartnerInterestTable());
            }

            FMainDS.InitVars();
        }
예제 #16
0
        /// <summary>
        /// Deletes the current row and optionally populates a completion message
        /// </summary>
        /// <param name="ARowToDelete">the currently selected row to delete</param>
        /// <param name="ACompletionMessage">if specified, is the deletion completion message</param>
        /// <returns>true if row deletion is successful</returns>
        private bool DeleteRowManual(ARecurringGiftBatchRow ARowToDelete, ref string ACompletionMessage)
        {
            bool deletionSuccessful = false;

            int batchNumber = ARowToDelete.BatchNumber;

            bool newBatch = (ARowToDelete.RowState == DataRowState.Added);

            // first save any changes
            if (!((TFrmRecurringGiftBatch)FPetraUtilsObject.GetForm()).SaveChangesManual(TExtraGiftBatchChecks.GiftBatchAction.DELETING))
            {
                return(false);
            }

            try
            {
                ACompletionMessage = String.Format(Catalog.GetString("Batch no.: {0} deleted successfully."),
                                                   batchNumber);

                //clear any transactions currently being editied in the Transaction Tab
                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().ClearCurrentSelection();

                if (!newBatch)
                {
                    //Load tables afresh
                    FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadRecurringGiftTransactionsForBatch(FLedgerNumber, batchNumber));
                    FMainDS.AcceptChanges();
                }

                ((TFrmRecurringGiftBatch)ParentForm).GetTransactionsControl().DeleteCurrentRecurringBatchGiftData(batchNumber);

                //Affect a change in the batch row, required by deletion process.
                ARowToDelete.DateModified = DateTime.Now;

                // Delete the recurring batch row.
                ARowToDelete.Delete();

                //FMainDS.AcceptChanges();
                FPreviouslySelectedDetailRow = null;

                deletionSuccessful = true;
            }
            catch (Exception ex)
            {
                ACompletionMessage = ex.Message;
                MessageBox.Show(ex.Message,
                                "Deletion Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            UpdateRecordNumberDisplay();

            return(deletionSuccessful);
        }
        private void InitializeManualCode()
        {
            FLogic = new TUCPartnerRelationshipsLogic();

            if (!FMainDS.Tables.Contains(PartnerEditTDSPPartnerRelationshipTable.GetTableName()))
            {
                FMainDS.Tables.Add(new PartnerEditTDSPPartnerRelationshipTable());
            }

            FMainDS.InitVars();
        }
        /// <summary>
        ///
        /// </summary>
        private void InitializeManualCode()
        {
            if (!FMainDS.Tables.Contains(PSubscriptionTable.GetTableName()))
            {
                FMainDS.Tables.Add(new PSubscriptionTable());
            }

            FMainDS.InitVars();

            ucoDetails.SpecialInitUserControl();
        }
예제 #19
0
        /// <summary>
        /// clean up, disconnect from OpenPetra server
        /// </summary>
        public override void TearDown()
        {
            if (!FConnectedToServer)
            {
                return;
            }

            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();

            TPetraConnector.Disconnect();
        }
예제 #20
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();
        }
예제 #21
0
        /// <summary>
        /// Loads Extract Master Data from Petra Server into FMainDS.
        /// </summary>
        /// <param name="AExtractNameFilter"></param>
        /// <param name="AAllUsers"></param>
        /// <param name="ACreatedByUser"></param>
        /// <param name="AModifiedByUser"></param>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadData(String AExtractNameFilter, Boolean AAllUsers,
                                 String ACreatedByUser, String AModifiedByUser)
        {
            Boolean ReturnValue;

            // Load Extract Headers, if not already loaded
            try
            {
                // Make sure that Typed DataTables are already there at Client side
                if (FMainDS.MExtractMaster == null)
                {
                    FMainDS.Tables.Add(new MExtractMasterTable());
                    FMainDS.InitVars();
                }
                else
                {
                    // clear table so a load also works if records on the server have been removed
                    FMainDS.MExtractMaster.Clear();
                }

                // add filter data
                FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.GetAllExtractHeaders(AExtractNameFilter,
                                                                                          AAllUsers, ACreatedByUser, AModifiedByUser));

                // Make DataRows unchanged
                if (FMainDS.MExtractMaster.Rows.Count > 0)
                {
                    FMainDS.MExtractMaster.AcceptChanges();
                    FMainDS.AcceptChanges();
                }

                if (FMainDS.MExtractMaster.Rows.Count != 0)
                {
                    ReturnValue = true;
                }
                else
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }

            return(ReturnValue);
        }
예제 #22
0
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        public void LoadBatchesForCurrentYear()
        {
            TFrmGiftBatch MyParentForm        = (TFrmGiftBatch)this.ParentForm;
            bool          PerformStandardLoad = true;

            if (MyParentForm.InitialBatchYear >= 0)
            {
                FLoadAndFilterLogicObject.StatusAll = true;

                int yearIndex = FLoadAndFilterLogicObject.FindYearAsIndex(MyParentForm.InitialBatchYear);

                if (yearIndex >= 0)
                {
                    FLoadAndFilterLogicObject.YearIndex = yearIndex;

                    if (MyParentForm.InitialBatchPeriod >= 0)
                    {
                        FLoadAndFilterLogicObject.PeriodIndex = FLoadAndFilterLogicObject.FindPeriodAsIndex(MyParentForm.InitialBatchPeriod);
                    }
                    else
                    {
                        FLoadAndFilterLogicObject.PeriodIndex = (MyParentForm.InitialBatchYear == FMainDS.ALedger[0].CurrentFinancialYear) ? 1 : 0;
                    }

                    PerformStandardLoad = false;
                }

                // Reset the start-up value
                MyParentForm.InitialBatchYear = -1;
            }

            MyParentForm.ClearCurrentSelections();

            if (ViewMode)
            {
                FMainDS.Merge(ViewModeTDS);
                FLoadAndFilterLogicObject.DisableYearAndPeriod(true);
            }

            if (PerformStandardLoad)
            {
                // Set up for current year with current and forwarding periods (on initial load this will already be set so will not fire a change)
                FLoadAndFilterLogicObject.YearIndex   = 0;
                FLoadAndFilterLogicObject.PeriodIndex = 0;
            }

            // Get the data, populate the grid and re-select the current row (or first row if none currently selected) ...
            RefreshAllData();

            FBatchLoaded = true;
        }
        private bool CanCloseManual()
        {
            // if 'Cancel' button has been clicked then ask the user if they really want to close the screen.
            if (FMainDS.HasChanges() &&
                (this.DialogResult != DialogResult.OK) &&
                (MessageBox.Show(Catalog.GetString("Are you sure you want to cancel this Allocation?"),
                                 Catalog.GetString("Allocation Journal"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)
                 == DialogResult.No))
            {
                return(false);
            }

            return(true);
        }
예제 #24
0
        public void LoadModalEmptyTable()
        {
            // Initialise data - create an empty table and our test ledger
            FMainDS.LoadAll();
            FMainDS.DeleteAllRows();
            FMainDS.SaveChanges();
            FLedgerDS.CreateTestLedger();

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

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

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

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

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

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

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

            Assert.IsNotNull(row, "The selected exchange rate was not saved");
            Assert.AreEqual(STANDARD_RATE_OF_EXCHANGE, row.RateOfExchange);
        }
        private void Search(object sender, EventArgs e)
        {
            FMainDS.PContactLog.Clear();

            FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.FindContacts(
                              txtContactor.Text,
                              dtpContactDate.Date,
                              txtCommentContains.Text,
                              cmbContactCode.Text,
                              "",
                              cmbMailingCode.Text));

            FMainDS.PContactLog.DefaultView.AllowNew = false;
            grdDetails.DataSource = new DevAge.ComponentModel.BoundDataView(FMainDS.PContactLog.DefaultView);
        }
예제 #26
0
        private void InitializeManualCode()
        {
            if (!FMainDS.Tables.Contains(PContactLogTable.GetTableName()))
            {
                FMainDS.Merge(TRemote.MPartner.Partner.WebConnectors.GetPartnerContactLogData(FMainDS.PPartner[0].PartnerKey));
                FMainDS.PContactLog.DefaultView.AllowNew = false;
            }

            FMainDS.InitVars();

            OnHookupDataChange(new THookupPartnerEditDataChangeEventArgs(TPartnerEditTabPageEnum.petpContacts));
            //Hook up DataSavingStarted Event to be able to run code before SaveChanges is doing anything
            FPetraUtilsObject.DataSavingStarted += new TDataSavingStartHandler(this.DataSavingStarted);
            ucoDetails.SpecialInitUserControl();
        }
        /// <summary>
        /// Loads Job Assignment Data from Petra Server into FMainDS, if not already loaded.
        /// </summary>
        /// <returns>true if successful, otherwise false.</returns>
        private Boolean LoadDataOnDemand()
        {
            Boolean ReturnValue;

            try
            {
                // Make sure that Typed DataTables are already there at Client side
                if (FMainDS.PmJobAssignment == null)
                {
                    FMainDS.Tables.Add(new PmJobAssignmentTable());
                    FMainDS.InitVars();
                }

                if (TClientSettings.DelayedDataLoading &&
                    (FMainDS.PmJobAssignment.Rows.Count == 0))
                {
                    FMainDS.Merge(FPartnerEditUIConnector.GetDataPersonnelIndividualData(TIndividualDataItemEnum.idiJobAssignments));

                    // Make DataRows unchanged
                    if (FMainDS.PmJobAssignment.Rows.Count > 0)
                    {
                        if (FMainDS.PmJobAssignment.Rows[0].RowState != DataRowState.Added)
                        {
                            FMainDS.PmJobAssignment.AcceptChanges();
                        }
                    }
                }

                if (FMainDS.PmJobAssignment.Rows.Count != 0)
                {
                    ReturnValue = true;
                }
                else
                {
                    ReturnValue = false;
                }
            }
            catch (System.NullReferenceException)
            {
                return(false);
            }
            catch (Exception)
            {
                throw;
            }

            return(ReturnValue);
        }
예제 #28
0
        private void RunOnceOnParentActivationManual()
        {
            ParentForm.Cursor                  = Cursors.WaitCursor;
            grdDetails.DoubleClickCell        += new TDoubleClickCellEventHandler(this.ShowTransactionTab);
            grdDetails.DataSource.ListChanged += new System.ComponentModel.ListChangedEventHandler(DataSource_ListChanged);

            // Load the ledger table so we know the base currency
            FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadALedgerTable(FLedgerNumber));
            FLedgerBaseCurrency = FMainDS.ALedger[0].BaseCurrency;

            FLoadAndFilterLogicObject.ActivateFilter();
            LoadBatchesForCurrentYear();
            ParentForm.Cursor = Cursors.Default;

            SetInitialFocus();
        }
예제 #29
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();
        }
예제 #30
0
        /// <summary>
        /// Ensure the data is loaded for the specified batch
        /// </summary>
        /// <param name="ALedgerNumber"></param>
        /// <param name="ABatchNumber"></param>
        /// <returns>If transactions exist</returns>
        public Boolean EnsureGiftDataPresent(Int32 ALedgerNumber, Int32 ABatchNumber)
        {
            DataView TransDV = new DataView(FMainDS.ARecurringGiftDetail);

            TransDV.RowFilter = String.Format("{0}={1} And {2}={3}",
                                              ARecurringGiftDetailTable.GetLedgerNumberDBName(),
                                              ALedgerNumber,
                                              ARecurringGiftDetailTable.GetBatchNumberDBName(),
                                              ABatchNumber);

            if (TransDV.Count == 0)
            {
                FMainDS.Merge(TRemote.MFinance.Gift.WebConnectors.LoadARecurringGiftBatchAndRelatedData(ALedgerNumber, ABatchNumber, true));
            }

            return(TransDV.Count > 0);
        }