Exemple #1
0
        /// <summary>
        /// Will be called by TFormsList to inform any Form that is registered in TFormsList
        /// about any 'Forms Messages' that are broadcasted.
        /// </summary>
        /// <remarks>This screen 'listens' to such 'Forms Message' broadcasts by
        /// implementing this virtual Method. This Method will be called each time a
        /// 'Forms Message' broadcast occurs.
        /// </remarks>
        /// <param name="AFormsMessage">An instance of a 'Forms Message'. This can be
        /// inspected for parameters in the Method Body and the Form can use those to choose
        /// to react on the Message, or not.</param>
        /// <returns>Returns True if the Form reacted on the specific Forms Message,
        /// otherwise false.</returns>
        public bool ProcessFormsMessage(TFormsMessage AFormsMessage)
        {
            bool MessageProcessed = false;

            if (AFormsMessage.MessageClass == TFormsMessageClassEnum.mcAccountsChanged)
            {
                string CurrentlySelectedAccountCode = FPreviouslySelectedDetailRow.AccountCode;
                Type   DataTableType;

                // Load Data
                DataTable CacheDT = TDataCache.GetSpecificallyFilteredCacheableDataTableFromCache("AccountList", "Ledger", FFilter, out DataTableType);
                FMainDS.AAccount.Merge(CacheDT);

                GetData();

                // reapply filter
                FFilterAndFindObject.ApplyFilter();

                // reselect the last selected account code
                if (FPreviouslySelectedDetailRow != null)
                {
                    SelectAccountInGrid(CurrentlySelectedAccountCode);
                }

                UpdateRecordNumberDisplay();

                MessageProcessed = true;
            }

            return(MessageProcessed);
        }
        private void RunOnceOnActivationManual()
        {
            FPetraUtilsObject.DataSaved += new TDataSavedHandler(FPetraUtilsObject_DataSaved);

            // Load the data from the Fees Payable cached table
            Type      DataTableType;
            DataTable CacheDT = TDataCache.GetSpecificallyFilteredCacheableDataTableFromCache("FeesPayableList", "Ledger", FFilter, out DataTableType);

            FExtraDS.AFeesPayable.Merge(CacheDT);
            FExtraDS.AFeesPayable.DefaultView.Sort = String.Format("{0}, {1} ASC",
                                                                   AFeesPayableTable.GetLedgerNumberDBName(), AFeesPayableTable.GetFeeCodeDBName());

            ALedgerRow LedgerRow =
                ((ALedgerTable)TDataCache.TMFinance.GetCacheableFinanceTable(TCacheableFinanceTablesEnum.LedgerDetails, FLedgerNumber))[0];

            txtDetailChargeAmount.CurrencyCode = LedgerRow.BaseCurrency;

            SelectRowInGrid(1);
            UpdateRecordNumberDisplay();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="AParameters"></param>
        public void SetControls(TParameterList AParameters)
        {
            //
            // If LedgerNumber hasn't been set yet, do nothing:
            if (FLedgerNumber < 0)
            {
                return;
            }

            AFeesReceivableTable FeesReceivable = new AFeesReceivableTable();
            Type      DataTableType;
            DataTable CacheDT = TDataCache.GetSpecificallyFilteredCacheableDataTableFromCache("FeesReceivableList",
                                                                                              "Ledger",
                                                                                              FLedgerNumber,
                                                                                              out DataTableType);

            FeesReceivable.Merge(CacheDT);

            Array.Resize(ref FUnselectedFees, FeesReceivable.Rows.Count);

            for (Int32 Idx = 0; Idx < FeesReceivable.Rows.Count; Idx++)
            {
                AFeesReceivableRow Row = FeesReceivable[Idx];
                FUnselectedFees[Idx] = Row.FeeCode;
            }

            AFeesPayableTable FeesPayable = new AFeesPayableTable();

            CacheDT = TDataCache.GetSpecificallyFilteredCacheableDataTableFromCache("FeesPayableList", "Ledger", FLedgerNumber, out DataTableType);
            FeesPayable.Merge(CacheDT);

            Array.Resize(ref FUnselectedFees, FUnselectedFees.Length + FeesPayable.Rows.Count);

            for (Int32 Idx = 0; Idx < FeesPayable.Rows.Count; Idx++)
            {
                AFeesPayableRow Row = FeesPayable[Idx];
                FUnselectedFees[FeesReceivable.Rows.Count + Idx] = Row.FeeCode;
            }

            String FeeStr = AParameters.Get("param_fee_codes").ToString();

            //
            // If there's no fees selected, it's perhaps because the installation is new.
            // Add all the fees from the "Don't Print" box, up to the maximum number allowed.
            if (FeeStr == "")
            {
                Array.Resize(ref FSelectedFees, lstDontPrint.Items.Count);
                lstDontPrint.Items.CopyTo(FSelectedFees, 0);

                if (lstDontPrint.Items.Count > MAX_FEE_COUNT)
                {
                    Array.Resize(ref FSelectedFees, MAX_FEE_COUNT);
                }
            }
            else
            {
                FSelectedFees = FeeStr.Split(',');
            }

            // Now I want to remove the selected items from the FSelectedFees list:
            for (Int32 Idx = 0; Idx < FSelectedFees.Length; Idx++)
            {
                Int32 pos = ((IList)FUnselectedFees).IndexOf(FSelectedFees[Idx]);

                if (pos >= 0)
                {
                    Int32 NewLength = FUnselectedFees.Length - 1;

                    for (Int32 i = pos; i < NewLength; i++)
                    {
                        FUnselectedFees[i] = FUnselectedFees[i + 1];
                    }

                    Array.Resize(ref FUnselectedFees, NewLength);
                }
            }

            RefreshLists();
        }