예제 #1
0
        private void SetDataSource()
        {
            CreateLetterSearch();

            bool isUnauthorized = false;

            if (_searchFilter == Localization.GetString("All"))
            {
                _searchFilter = "";
            }
            else if (_searchFilter == Localization.GetString("Unauthorized"))
            {
                _searchFilter  = "";
                isUnauthorized = true;
            }

            //Get the list of vendors from the database
            var totalRecords     = 0;
            var vendorController = new VendorController();
            int portal           = Globals.IsHostTab(PortalSettings.ActiveTab.TabID) ? Null.NullInteger : PortalId;

            if (String.IsNullOrEmpty(_searchFilter))
            {
                grdVendors.DataSource       = vendorController.GetVendors(portal, isUnauthorized, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                grdVendors.VirtualItemCount = totalRecords;
            }
            else
            {
                if (_searchField == "email")
                {
                    grdVendors.DataSource       = vendorController.GetVendorsByEmail(_searchFilter, portal, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                    grdVendors.VirtualItemCount = totalRecords;
                }
                else
                {
                    grdVendors.DataSource       = vendorController.GetVendorsByName(_searchFilter, portal, grdVendors.CurrentPageIndex, grdVendors.PageSize, ref totalRecords);
                    grdVendors.VirtualItemCount = totalRecords;
                }
            }
        }
예제 #2
0
        private void BindData(string searchText, string searchField)
        {
            CreateLetterSearch();

            //Localize the Headers
            Localization.LocalizeDataGrid(ref grdVendors, LocalResourceFile);

            if (searchText == Localization.GetString("All"))
            {
                strFilter = "";
            }
            else if (searchText == Localization.GetString("Unauthorized"))
            {
                strFilter = "";
            }
            else
            {
                strFilter = searchText;
            }

            //Get the list of vendors from the database
            var PageSize     = Convert.ToInt32(ddlRecordsPerPage.SelectedItem.Value);
            var TotalRecords = 0;
            var objVendors   = new VendorController();
            int Portal       = Globals.IsHostTab(PortalSettings.ActiveTab.TabID) ? Null.NullInteger : PortalId;

            if (String.IsNullOrEmpty(strFilter))
            {
                if (searchText == Localization.GetString("Unauthorized"))
                {
                    grdVendors.DataSource = objVendors.GetVendors(Portal, true, CurrentPage - 1, PageSize, ref TotalRecords);
                }
                else
                {
                    grdVendors.DataSource = objVendors.GetVendors(Portal, false, CurrentPage - 1, PageSize, ref TotalRecords);
                }
            }
            else
            {
                if (searchField == "email")
                {
                    grdVendors.DataSource = objVendors.GetVendorsByEmail(strFilter, Portal, CurrentPage - 1, PageSize, ref TotalRecords);
                }
                else
                {
                    grdVendors.DataSource = objVendors.GetVendorsByName(strFilter, Portal, CurrentPage - 1, PageSize, ref TotalRecords);
                }
            }
            grdVendors.DataBind();

            ctlPagingControl.TotalRecords = TotalRecords;
            ctlPagingControl.PageSize     = PageSize;
            ctlPagingControl.CurrentPage  = CurrentPage;
            string strQuerystring = "";

            if (ddlRecordsPerPage.SelectedIndex != 0)
            {
                strQuerystring = "PageRecords=" + ddlRecordsPerPage.SelectedValue;
            }
            if (!String.IsNullOrEmpty(strFilter))
            {
                strQuerystring += "&filter=" + strFilter;
            }
            ctlPagingControl.QuerystringParams = strQuerystring;
            ctlPagingControl.TabID             = TabId;
        }