Пример #1
0
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        public void LoadBatchesForCurrentYear()
        {
            FBatchesLoaded = false;

            // 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;

            // This call will get the first year's data and update the display.
            // Note: If the first year data has already been loaded once there will be no trip to the server to get any updates.
            //        if you know updates are available, you need to merge them afterwards or clear the data table first
            UpdateDisplay();

            if (((TFrmGLBatch)this.ParentForm).LoadForImport)
            {
                // We have been launched from the Import Batches main menu screen as opposed to the regular GL Batches menu
                // Call the logic object to import:  this will request a CSV file and merge the batches on the server.
                // Finally it will call back to ReloadBatches() in this class, which merges the server data into FMainDS and selects the first row
                FImportLogicObject.ImportBatches(TUC_GLBatches_Import.TImportDataSourceEnum.FromFile);

                // Reset the flag
                ((TFrmGLBatch)this.ParentForm).LoadForImport = false;
            }

            FBatchesLoaded = true;
        }
        /// <summary>
        /// load the batches into the grid
        /// </summary>
        public void LoadBatchesForCurrentYear()
        {
            FBatchesLoaded = false;

            TFrmGLBatch myParentForm = (TFrmGLBatch)this.ParentForm;

            myParentForm.InitialBatchFound = false;

            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;
            }

            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;
            }

            // This call will get the first year's data and update the display.
            // Note: If the first year data has already been loaded once there will be no trip to the server to get any updates.
            //        if you know updates are available, you need to merge them afterwards or clear the data table first
            UpdateDisplay();

            if (myParentForm.LoadForImport)
            {
                // We have been launched from the Import Batches main menu screen as opposed to the regular GL Batches menu
                // Call the logic object to import:  this will request a CSV file and merge the batches on the server.
                // Finally it will call back to ReloadBatches() in this class, which merges the server data into FMainDS and selects the first row
                FImportLogicObject.ImportBatches(TUC_GLBatches_Import.TImportDataSourceEnum.FromFile);

                // Reset the flag
                myParentForm.LoadForImport = false;
            }

            FBatchesLoaded = true;
        }