Example #1
0
        private void OnDataPageLoaded(TDataPageLoadEventArgs e)
        {
//            TLogging.Log("OnDataPageLoaded");
            if (DataPageLoaded != null)
            {
                DataPageLoaded(this, e);
            }
        }
Example #2
0
        /// <summary>
        /// Loads a single data page into the paged table.
        ///
        /// </summary>
        /// <param name="ANeededPage">Page number of the data page to retrieve.
        /// </param>
        /// <returns>void</returns>
        private void LoadSingleDataPage(Int32 ANeededPage)
        {
            // Sanity check  just in case someone made the Grid so small that no Rows would be displayed...
            if (ANeededPage > 0)
            {
                // Fire OnDataPageLoading event.
                TDataPageLoadEventArgs CustomEventArgs = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = ANeededPage;
                this.OnDataPageLoading(CustomEventArgs);

//                TLogging.Log("Retrieving Page " + ANeededPage.ToString() + "...");

                Int32     CurrentTotalRecords; // These two values should be the same as FTotalRecords
                Int16     CurrentTotalPages;   // and FTotalPages, which were set when the first page was loaded.
                DataTable PagedTable = FGetDataPagedResult((short)ANeededPage, FPageSize, out CurrentTotalRecords, out CurrentTotalPages);

                if (PagedTable != null)
                {
                    FTransferredDataPages.Add(ANeededPage);
                    Int32 IdxBase = ANeededPage * FPageSize;

//                    TLogging.Log("Inserting Page " + ANeededPage.ToString() + " (PageSize: " + FPageSize.ToString() + "; Records returned: " +  PagedTable.Rows.Count.ToString() + ")...");
                    for (Int32 Counter = 0; Counter < PagedTable.Rows.Count; Counter++)
                    {
                        DataRow TargetRow;
                        bool    NewRow = false;

                        if (FPagedDataTable.Rows.Count <= IdxBase + Counter) // I need to create a new row?
                        {
                            TargetRow = FPagedDataTable.NewRow();
                            NewRow    = true;
                        }
                        else
                        {
                            TargetRow = FPagedDataTable.Rows[IdxBase + Counter]; // Otherwise overwrite the existing one
                        }

                        TargetRow.ItemArray = PagedTable.Rows[Counter].ItemArray;

                        if (NewRow)
                        {
                            FPagedDataTable.Rows.Add(TargetRow);
                        }
                    }
                }

                // Fire OnDataPageLoaded event.
                CustomEventArgs          = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = ANeededPage;
                this.OnDataPageLoaded(CustomEventArgs);
            }
        }
Example #3
0
        /// <summary>
        /// Needs to be called as soon as it is desired to display the first 'Page' of data.
        /// </summary>
        /// <remarks>All further pages are loaded by the control on demand!</remarks>
        /// <param name="ADelegateGetDataPagedResultFunction">Delegate function that gets called
        /// when a Page of data needs to be retrieved.
        /// </param>
        /// <param name="AAddEmptyRows">Whether empty Rows for the data that *hasn't* been loaded
        /// in the first 'Data Page' should be added, or not. Set this to false if you are planning to call
        /// .AutoSizeCells() on the Grid and there is a possibility that there could be more than a couple of hundred
        /// records in total. The reason is that calling .AutoSizeCells() can take a considerable amount of time if there
        /// are many Cells to autosize (ie. the combination of Columns and Rows is high). If set to false, a separate
        /// call to the Method <see cref="AddEmptyRows" /> needs to be made by the caller after .AutoSizeCells()
        /// has been called on the Grid to add the empty rows at that point in time! (This results in the AutoSize only
        /// taking the first Data Page's rows into consideration for the auto-sizing, but that is why it will not be slow!)</param>
        /// <returns>A DataTable holding the records that fitted into the first 'Data Page'.</returns>
        public DataTable LoadFirstDataPage(TDelegateGetDataPagedResult ADelegateGetDataPagedResultFunction, bool AAddEmptyRows = true)
        {
            DataTable ReturnValue;
            TDataPageLoadEventArgs CustomEventArgs;

//            TLogging.Log("Enter LoadFirstDataPage...");
//            TLogging.Log("LoadFirstDataPage:  HScrollBarVisible: " + HScrollBarVisible.ToString());

            DeterminePageSize();
            FGetDataPagedResult = ADelegateGetDataPagedResultFunction;
            FLastHeight         = this.Height;

            if (FGetDataPagedResult != null)
            {
                // Fire OnDataPageLoading event.
                CustomEventArgs          = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = 0;
                this.OnDataPageLoading(CustomEventArgs);

                // Fetch the first page of data
                if (FPageSize < FMinimumPageSize)
                {
                    FPageSize = FMinimumPageSize;
                }

                FPagedDataTable = FGetDataPagedResult(0, FPageSize, out FTotalRecords, out FTotalPages);
                ReturnValue     = FPagedDataTable;
                DataTransferDone(AAddEmptyRows);

                // Fire OnDataPageLoaded event.
                CustomEventArgs          = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = 0;
                this.OnDataPageLoaded(CustomEventArgs);
            }
            else
            {
                throw new EDataGridPagedDelegateFunctionNotSpecifiedException(
                          "The " + this.GetType().FullName + " control is not properly initialised yet. " +
                          "The ADelegateGetDataPagedResultFunction parameter of the InitialiseGrid method needs to be set to the delegate function that returns a page of data");
            }

            FGridInitialised = true;

//            TLogging.Log("LoadFirstDataPage is finished.");
            return(ReturnValue);
        }
Example #4
0
        private void OnDataPageLoaded(TDataPageLoadEventArgs e)
        {
//            TLogging.Log("OnDataPageLoaded");
            if (DataPageLoaded != null)
            {
                DataPageLoaded(this, e);
            }
        }
Example #5
0
        /// <summary>
        /// Loads a single data page into the paged table.
        ///
        /// </summary>
        /// <param name="ANeededPage">Page number of the data page to retrieve.
        /// </param>
        /// <returns>void</returns>
        private void LoadSingleDataPage(Int32 ANeededPage)
        {
            // Sanity check  just in case someone made the Grid so small that no Rows would be displayed...
            if (ANeededPage > 0)
            {
                // Fire OnDataPageLoading event.
                TDataPageLoadEventArgs CustomEventArgs = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = ANeededPage;
                this.OnDataPageLoading(CustomEventArgs);

//                TLogging.Log("Retrieving Page " + ANeededPage.ToString() + "...");

                Int32 CurrentTotalRecords;  // These two values should be the same as FTotalRecords
                Int16 CurrentTotalPages;    // and FTotalPages, which were set when the first page was loaded.
                DataTable PagedTable = FGetDataPagedResult((short)ANeededPage, FPageSize, out CurrentTotalRecords, out CurrentTotalPages);

                if (PagedTable != null)
                {
                    FTransferredDataPages.Add(ANeededPage);
                    Int32 IdxBase = ANeededPage * FPageSize;

//                    TLogging.Log("Inserting Page " + ANeededPage.ToString() + " (PageSize: " + FPageSize.ToString() + "; Records returned: " +  PagedTable.Rows.Count.ToString() + ")...");
                    for (Int32 Counter = 0; Counter < PagedTable.Rows.Count; Counter++)
                    {
                        DataRow TargetRow;
                        bool NewRow = false;

                        if (FPagedDataTable.Rows.Count <= IdxBase + Counter) // I need to create a new row?
                        {
                            TargetRow = FPagedDataTable.NewRow();
                            NewRow = true;
                        }
                        else
                        {
                            TargetRow = FPagedDataTable.Rows[IdxBase + Counter]; // Otherwise overwrite the existing one
                        }

                        TargetRow.ItemArray = PagedTable.Rows[Counter].ItemArray;

                        if (NewRow)
                        {
                            FPagedDataTable.Rows.Add(TargetRow);
                        }
                    }
                }

                // Fire OnDataPageLoaded event.
                CustomEventArgs = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = ANeededPage;
                this.OnDataPageLoaded(CustomEventArgs);
            }
        }
Example #6
0
        /// <summary>
        /// Needs to be called as soon as it is desired to display the first 'Page' of data.
        /// </summary>
        /// <remarks>All further pages are loaded by the control on demand!</remarks>
        /// <param name="ADelegateGetDataPagedResultFunction">Delegate function that gets called
        /// when a Page of data needs to be retrieved.
        /// </param>
        /// <param name="AAddEmptyRows">Whether empty Rows for the data that *hasn't* been loaded
        /// in the first 'Data Page' should be added, or not. Set this to false if you are planning to call
        /// .AutoSizeCells() on the Grid and there is a possibility that there could be more than a couple of hundred
        /// records in total. The reason is that calling .AutoSizeCells() can take a considerable amount of time if there
        /// are many Cells to autosize (ie. the combination of Columns and Rows is high). If set to false, a separate
        /// call to the Method <see cref="AddEmptyRows" /> needs to be made by the caller after .AutoSizeCells()
        /// has been called on the Grid to add the empty rows at that point in time! (This results in the AutoSize only
        /// taking the first Data Page's rows into consideration for the auto-sizing, but that is why it will not be slow!)</param>
        /// <returns>A DataTable holding the records that fitted into the first 'Data Page'.</returns>
        public DataTable LoadFirstDataPage(TDelegateGetDataPagedResult ADelegateGetDataPagedResultFunction, bool AAddEmptyRows = true)
        {
            DataTable ReturnValue;
            TDataPageLoadEventArgs CustomEventArgs;

//            TLogging.Log("Enter LoadFirstDataPage...");
//            TLogging.Log("LoadFirstDataPage:  HScrollBarVisible: " + HScrollBarVisible.ToString());

            DeterminePageSize();
            FGetDataPagedResult = ADelegateGetDataPagedResultFunction;
            FLastHeight = this.Height;

            if (FGetDataPagedResult != null)
            {
                // Fire OnDataPageLoading event.
                CustomEventArgs = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = 0;
                this.OnDataPageLoading(CustomEventArgs);

                // Fetch the first page of data
                if (FPageSize < FMinimumPageSize)
                {
                    FPageSize = FMinimumPageSize;
                }

                FPagedDataTable = FGetDataPagedResult(0, FPageSize, out FTotalRecords, out FTotalPages);
                ReturnValue = FPagedDataTable;
                DataTransferDone(AAddEmptyRows);

                // Fire OnDataPageLoaded event.
                CustomEventArgs = new TDataPageLoadEventArgs();
                CustomEventArgs.DataPage = 0;
                this.OnDataPageLoaded(CustomEventArgs);
            }
            else
            {
                throw new EDataGridPagedDelegateFunctionNotSpecifiedException(
                    "The " + this.GetType().FullName + " control is not properly initialised yet. " +
                    "The ADelegateGetDataPagedResultFunction parameter of the InitialiseGrid method needs to be set to the delegate function that returns a page of data");
            }

            FGridInitialised = true;

//            TLogging.Log("LoadFirstDataPage is finished.");
            return ReturnValue;
        }
 private void grdResult_DataPageLoaded(object Sender, TDataPageLoadEventArgs e)
 {
     // This is where we end up after querying the database and loading the first data into the grid
     // We are back in our main thread here
     this.Cursor = Cursors.Default;
 }
        private void GrdResult_DataPageLoaded(System.Object Sender, TDataPageLoadEventArgs e)
        {
//            TLogging.Log("DataPageLoaded:  Page: " + e.DataPage.ToString());

            if (e.DataPage > 0)
            {
                this.Cursor = Cursors.Default;

                if (!FBankDetailsTab)
                {
                    FPetraUtilsObject.WriteToStatusBar(
                        MPartnerResourcestrings.StrResultGridHelpText + MPartnerResourcestrings.StrPartnerFindSearchTargetText);
                    FPetraUtilsObject.SetStatusBarText(grdResult,
                        MPartnerResourcestrings.StrResultGridHelpText + MPartnerResourcestrings.StrPartnerFindSearchTargetText);
                }
                else
                {
                    FPetraUtilsObject.WriteToStatusBar(
                        MPartnerResourcestrings.StrResultGridHelpText + MPartnerResourcestrings.StrPartnerFindByBankDetailsSearchTargetText);
                    FPetraUtilsObject.SetStatusBarText(grdResult,
                        MPartnerResourcestrings.StrResultGridHelpText + MPartnerResourcestrings.StrPartnerFindByBankDetailsSearchTargetText);
                }
            }
        }
        private void GrdResult_DataPageLoading(System.Object Sender, TDataPageLoadEventArgs e)
        {
//            TLogging.Log("DataPageLoading:  Page: " + e.DataPage.ToString());

            if (e.DataPage > 0)
            {
                this.Cursor = Cursors.WaitCursor;
                FPetraUtilsObject.WriteToStatusBar(MPartnerResourcestrings.StrTransferringDataForPageText + e.DataPage.ToString() + ')');
                FPetraUtilsObject.SetStatusBarText(grdResult, MPartnerResourcestrings.StrTransferringDataForPageText + e.DataPage.ToString() + ')');
            }
        }
        private void grdSuppliers_DataPageLoaded(object Sender, TDataPageLoadEventArgs e)
        {
            // This is where we end up after querying the database and loading the first data into the grid
            // We are back in our main thread here
            this.Cursor = Cursors.Default;

            if (e.DataPage == 0)
            {
                FMainForm.IsSupplierDataChanged = false;
            }
        }