Esempio n. 1
0
    protected void SortHelper(string sortExpression, int pageIndex)
    {
        if (ListResults.Count >= 1)
        {
            List <OrganizationModel> sortedOrganization;
            //Sort if possible
            if (!string.IsNullOrEmpty(sortExpression))
            {
                //Sort the data. SWD-6936
                var prop = typeof(OrganizationModel).GetProperty(sortExpression);
                if (_sortDirection == "ASC")
                {
                    sortedOrganization = ListResults.OrderBy(lr => prop.GetValue(lr, null)).ToList();
                    sortImage.ImageUrl = descImagePath;
                    //set listResults to new sorted list
                    ListResults = sortedOrganization;
                }
                else
                {
                    sortedOrganization = ListResults.OrderByDescending(lr => prop.GetValue(lr, null)).ToList();
                    sortImage.ImageUrl = ascImagePath;
                    //set listResults to new sorted list
                    ListResults = sortedOrganization;
                }
            }
            else
            {
                //use the previous list
                sortedOrganization = ListResults;
            }
            OrganizationGridView.DataSource = sortedOrganization;
            OrganizationGridView.PageIndex  = pageIndex;
            OrganizationGridView.DataBind();
            SortDireaction = _sortDirection;
            int columnIndex = 0;
            foreach (DataControlFieldHeaderCell headerCell in OrganizationGridView.HeaderRow.Cells)
            {
                if (headerCell.ContainingField.SortExpression == sortExpression)
                {
                    columnIndex = OrganizationGridView.HeaderRow.Cells.GetCellIndex(headerCell);
                }
            }

            OrganizationGridView.HeaderRow.Cells[columnIndex].Controls.Add(sortImage);
        }
    }
Esempio n. 2
0
 protected void OrganizationGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     if (ListResults.Count() > 0)
     {
         if (string.IsNullOrEmpty(_sortDirection))
         {
             OrganizationGridView.DataSource = ListResults; // ds.Tables[0];
             OrganizationGridView.PageIndex  = e.NewPageIndex;
             OrganizationGridView.DataBind();
         }
         else
         {
             //Sort the data. SWD-6936
             if (string.IsNullOrEmpty(sortExpression) && SaltShakerSession.OrganizationSortExpression != null)
             {
                 sortExpression = SaltShakerSession.OrganizationSortExpression;
             }
             this.SortHelper(sortExpression, e.NewPageIndex);
         }
     }
 }
Esempio n. 3
0
 private void renderGridViewHelper(string id, string organizationName = "", string isContracted = "", string opeCode = "", string branchCode = "")
 {
     using (OrganizationBL Organization = new OrganizationBL())
     {
         Nullable <bool> bContracted = new bool();
         bContracted = null;
         if (!String.IsNullOrEmpty(isContracted))
         {
             //if user selected a value than update bool otherwise let it go as null
             if (isContracted.ToLower().IndexOf("please select") < 0)
             {
                 bContracted = (isContracted == "True") ? true : false;
             }
         }
         ListResults  = Organization.GetOrganizationsBySearchParms(id, bContracted, organizationName, opeCode, branchCode).ToList();
         iRecordCount = ListResults.Count();
         if (ListResults.Count() > 0)
         {
             if (iRecordCount == 1)
             {
                 OrganizationGridView.DataSource = ListResults;
                 OrganizationGridView.DataBind();
                 OrganizationGridView.SelectedIndex = 0; //select the only existing row
                 this.OrganizationRow_Click();
             }
             else
             {
                 _sortDirection = "ASC";
                 sortExpression = "OrganizationName";
                 this.SortHelper("OrganizationName", 0);
             }
         }
         else
         {
             ShowMessage(sMSG_NOORGANIZATIONFOUND);
         }
     }
 }