Beispiel #1
0
        private System.Web.UI.WebControls.SortDirection GetSortDirection(string column)
        {
            // By default, set the sort direction to ascending.
            System.Web.UI.WebControls.SortDirection sortDirection = System.Web.UI.WebControls.SortDirection.Ascending;

            // Retrieve the last column that was sorted.
            string sortExpression = ViewState["SortExpression"] as string;

            if (sortExpression != null)
            {
                if (sortExpression == column)
                {
                    System.Web.UI.WebControls.SortDirection lastDirection = (System.Web.UI.WebControls.SortDirection)ViewState["SortDirection"];
                    if (lastDirection == System.Web.UI.WebControls.SortDirection.Ascending)
                    {
                        sortDirection = System.Web.UI.WebControls.SortDirection.Descending;
                    }
                }
            }
            // Save new values in ViewState.
            ViewState["SortDirection"]  = sortDirection;
            ViewState["SortExpression"] = column;

            return(sortDirection);
        }
Beispiel #2
0
        private void CarregarTela(string SortExpression)
        {
            if (IsPostBack)
            {
                ExtratoComponenteBLL CredReeBLL = new ExtratoComponenteBLL();
                int iRepresentante = 0;
                int.TryParse(ddlRepresentante.SelectedValue, out iRepresentante);

                //var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, " ", DateTime.Parse(txtDtIni.Text), DateTime.Parse(txtDtFim.Text));
                var dadosGrid = CredReeBLL.Listar(int.Parse(txtCodEmpresa.Text), int.Parse(txtCodMatricula.Text), iRepresentante, "00", short.Parse(ddlSemestre.SelectedValue), int.Parse(ddlNumAno.SelectedValue.ToString()));

                DataTable dt1        = dadosGrid;
                DataTable tblOrdered = new DataTable();
                DataView  view       = new DataView();

                var vsSort = ViewState["SortDirection"];

                if (String.IsNullOrEmpty(SortExpression))
                {
                    grdExtratoUtilizacao.DataSource = dt1;
                    grdExtratoUtilizacao.DataBind();
                    return;
                }

                if (dt1.Rows.Count > 0)
                {
                    if (vsSort == null)
                    {
                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }


                    System.Web.UI.WebControls.SortDirection lastDirection = (System.Web.UI.WebControls.SortDirection)ViewState["SortDirection"];

                    if (lastDirection != System.Web.UI.WebControls.SortDirection.Ascending)
                    {
                        EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable()
                                                                  orderby DateTime.Parse(row.Field <string>(SortExpression)) descending
                                                                  select row;

                        tblOrdered = query.AsDataView().ToTable();

                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Ascending;
                    }
                    else
                    {
                        EnumerableRowCollection <DataRow> query = from row in dt1.AsEnumerable()
                                                                  orderby DateTime.Parse(row.Field <string>(SortExpression)) ascending
                                                                  select row;

                        tblOrdered = query.AsDataView().ToTable();

                        ViewState["SortDirection"] = System.Web.UI.WebControls.SortDirection.Descending;
                    }

                    grdExtratoUtilizacao.DataSource = tblOrdered;
                    grdExtratoUtilizacao.DataBind();
                }
            }
        }
        protected void gvContact_Sorting(object sender, GridViewSortEventArgs e)
        {
            int clientID = Core.SessionHelper.getClientId();

            IQueryable <CRM.Data.Entities.Contact> contacts = null;

            contacts = ContactManager.GetAll(clientID);


            bool descending = false;

            if (ViewState[e.SortExpression] == null)
            {
                descending = false;
            }
            else
            {
                descending = !(bool)ViewState[e.SortExpression];
            }

            ViewState[e.SortExpression] = descending;

            //gvContact.DataSource = contacts.orderByExtension(e.SortExpression, descending);
            System.Web.UI.WebControls.SortDirection sortDirection = descending ? System.Web.UI.WebControls.SortDirection.Descending : System.Web.UI.WebControls.SortDirection.Ascending;

            gvContact.DataSource = contacts.orderByNested(e.SortExpression, sortDirection);

            gvContact.DataBind();
        }
    protected void GVMRFAgingForOpenPositionReport_Sorting(object sender, GridViewSortEventArgs e)
    {
        try
        {
            // GridViewRow gvrPager = GVResourcesOnboard.BottomPagerRow;
            // TextBox txtPages = (TextBox)gvrPager.Cells[0].FindControl("txtPages");
            // txtPages.Text = Session[SessionNames.CURRENT_PAGE_INDEX_EMP].ToString();

            //On sorting assign new sort expression
            sortExpression = e.SortExpression;

            if (Session[SessionNames.PREVIOUS_SORT_EXPRESSION_EMP] == null)
            {
                Session[SessionNames.PREVIOUS_SORT_EXPRESSION_EMP] = sortExpression;
            }

            if (Session[SessionNames.PREVIOUS_SORT_EXPRESSION_EMP].ToString() == sortExpression)
            {
                //Sort to opposite direction based upon previous sort direction
                if (Session[SessionNames.SORT_DIRECTION_EMP] == null || GridViewSortDirection == System.Web.UI.WebControls.SortDirection.Descending)
                {
                    GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Ascending;
                    SortGridView(sortExpression, ASCENDING);
                }
                else
                {
                    GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Descending;
                    SortGridView(sortExpression, DESCENDING);
                }
            }
            else
            {
                GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Ascending;
                SortGridView(sortExpression, ASCENDING);
            }

            if (Session[SessionNames.EMP_PROJECTID] != null || Session[SessionNames.EMP_DEPARTMENTID] != null || Session[SessionNames.EMP_ROLE] != null || Session[SessionNames.EMP_STATUSID] != null || Session[SessionNames.EMP_NAME] != null)
            {
                //Change here 26 March 2015
                //btnRemoveFilter.Visible = true;
            }

            //Set current sort expression as PreviousSortExpression
            Session[SessionNames.PREVIOUS_SORT_EXPRESSION_EMP] = sortExpression;
        }

        //catches RaveHRException exception
        catch (RaveHRException ex)
        {
            LogErrorMessage(ex);
        }
        catch (Exception ex)
        {
            RaveHRException objEx = new RaveHRException(ex.Message, ex, Sources.PresentationLayer, CLASS_NAME, "gvListOfMrf_RowCreated", EventIDConstants.RAVE_HR_MRF_PRESENTATION_LAYER);
            LogErrorMessage(objEx);
        }
    }
Beispiel #5
0
 protected void dgvDatos_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     Site1 oMaster = (Site1)this.Master;
     System.Web.UI.WebControls.SortDirection oDireccion = (System.Web.UI.WebControls.SortDirection)ViewState["direccionsorting"];
     var result = (IQueryable<MedDAL.DAL.tipos>)Session["resultadoquery"];
     DataTable dt = MedNeg.Utilidades.DataSetLinqOperators.CopyToDataTable(result);
     DataView dv = new DataView(dt);
     dgvDatos.DataSource = oMaster.Paging(e, ViewState["sortexpression"] == null ? "Nombre" : ViewState["sortexpression"].ToString(), dv, ref dgvDatos, ref oDireccion);
     ViewState["direccionsorting"] = oDireccion;
     dgvDatos.DataBind();
 }
Beispiel #6
0
        protected void grvInvFsArticulos_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            Site1 oMaster = (Site1)this.Master;

            System.Web.UI.WebControls.SortDirection oDireccion = (System.Web.UI.WebControls.SortDirection)ViewState["direccionsorting"];
            var       result = (IQueryable <MedNeg.Inventarios.Producto>)Session["resultadoquery2"];
            DataTable dt     = MedNeg.Utilidades.DataSetLinqOperators.CopyToDataTable(result);
            DataView  dv     = new DataView(dt);

            grvInvFsArticulos.DataSource  = oMaster.Paging(e, "codigo", dv, ref grvInvFsArticulos, ref oDireccion);
            ViewState["direccionsorting"] = oDireccion;
            grvInvFsArticulos.DataBind();
        }
        private void BindSearchResultsPanel()
        {
            Trace.Write(this.GetType().ToString(), "Begin Bind Search Results");
            if (_contentNodes.Count > 0)
            {
                //SORT THE CATEGORIES ACCORDINGLY
                string sortExpression = SortResults.SelectedValue;
                if (!string.IsNullOrEmpty(sortExpression))
                {
                    string[] sortTokens = sortExpression.Split(" ".ToCharArray());
                    System.Web.UI.WebControls.SortDirection dir = (sortTokens[1] == "ASC" ? System.Web.UI.WebControls.SortDirection.Ascending : System.Web.UI.WebControls.SortDirection.Descending);
                    switch (sortTokens[0])
                    {
                    case "Featured":
                        _contentNodes.Sort(new FeaturedComparer(dir));
                        break;

                    case "Price":
                        _contentNodes.Sort(new PriceComparer(dir));
                        break;

                    case "Name":
                        _contentNodes.Sort(new NameComparer(dir));
                        break;

                    case "Manufacturer":
                        _contentNodes.Sort(new ManufacturerComparer(dir));
                        break;
                    }
                }

                phCategoryContents.Visible = true;
                //INITIALIZE PAGING VARIABLES
                InitializePagingVars(false);
                //BIND THE RESULT PANE
                BindResultHeader();
                //BIND THE PAGING CONTROLS FOOTER
                BindPagingControls();
            }
            else
            {
                ResultIndexMessage.Text = string.Format(ResultIndexMessage.Text, 0, 0, 0);
                //HIDE THE CONTENTS
                phCategoryContents.Visible = false;
                phEmptyCategory.Visible    = (_category != null && _category.CatalogNodes.Count == 0);
                phNoSearchResults.Visible  = !phEmptyCategory.Visible;
            }
            //UPDATE AJAX PANEL
            SearchResultsAjaxPanel.Update();
            Trace.Write(this.GetType().ToString(), "End Bind Search Results");
        }
Beispiel #8
0
        protected void gdvLista_Sorting(object sender, GridViewSortEventArgs e)
        {
            Site1 oMaster = (Site1)this.Master;

            System.Web.UI.WebControls.SortDirection oDireccion = (System.Web.UI.WebControls.SortDirection)ViewState["direccionsorting"];
            var       result = (IQueryable <MedDAL.Proveedores.ProveedoresView>)Session["resultadoquery"];
            DataTable dt     = MedNeg.Utilidades.DataSetLinqOperators.CopyToDataTable(result);
            DataView  dv     = new DataView(dt);

            gdvLista.DataSource           = oMaster.Sorting(e, ref oDireccion, dv);
            ViewState["direccionsorting"] = oDireccion;
            ViewState["sortexpression"]   = e.SortExpression;
            gdvLista.DataBind();
        }
    protected void grdSearchResults_Sorting(object sender, GridViewSortEventArgs e)
    {
        string sortExpression = e.SortExpression;

        if (GridViewSortDirection == System.Web.UI.WebControls.SortDirection.Ascending)
        {
            GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Descending;
            SortGridView(sortExpression, DESCENDING);
        }
        else
        {
            GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Ascending;
            SortGridView(sortExpression, ASCENDING);
        }
    }
Beispiel #10
0
    protected void gvSearchResult_Sorting(object sender, GridViewSortEventArgs e)
    {
        string sortExpression = e.SortExpression;

        ViewState["z_sortexpresion"] = e.SortExpression;
        if (GridViewSortDirection == System.Web.UI.WebControls.SortDirection.Ascending)
        {
            GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Descending;
            SortGridView(sortExpression, "DESC");
        }
        else
        {
            GridViewSortDirection = System.Web.UI.WebControls.SortDirection.Ascending;
            SortGridView(sortExpression, "ASC");
        }
    }
        private string ConvertSortDirectionToSql(System.Web.UI.WebControls.SortDirection sortDirection)
        {
            string newSortDirection = String.Empty;

            switch (sortDirection)
            {
            case System.Web.UI.WebControls.SortDirection.Ascending:
                newSortDirection = "ASC";
                break;

            case System.Web.UI.WebControls.SortDirection.Descending:
                newSortDirection = "DESC";
                break;
            }
            return(newSortDirection);
        }
Beispiel #12
0
    protected void SortRecords(object sender, GridViewSortEventArgs e)
    {
        var    sortExpression = e.SortExpression;
        string direction;

        if (SortDirection == SortDirection.Ascending)
        {
            SortDirection = SortDirection.Descending;
            direction     = "descending";
        }
        else
        {
            SortDirection = SortDirection.Ascending;
            direction     = "ascending";
        }
        var administrators = Administrator.FindAll().Sort(ref sortExpression, ref direction, "ManagerName").ToList();

        Administrators.DataSource = administrators;
        Administrators.DataBind();
    }
Beispiel #13
0
        public DataView Sorting(GridViewSortEventArgs e, ref System.Web.UI.WebControls.SortDirection oDireccion, DataView dv)
        {
            string sSortExpression = e.SortExpression;

            ViewState["sortexpression"] = e.SortExpression;

            if (oDireccion == System.Web.UI.WebControls.SortDirection.Ascending)
            {
                //e.SortDirection = System.Web.UI.WebControls.SortDirection.Descending;
                dv.Sort    = sSortExpression + DESCENDING;
                oDireccion = System.Web.UI.WebControls.SortDirection.Descending;
            }
            else
            {
                //e.SortDirection = System.Web.UI.WebControls.SortDirection.Ascending;
                dv.Sort    = sSortExpression + ASCENDING;
                oDireccion = System.Web.UI.WebControls.SortDirection.Ascending;
            }

            return(dv);
        }
 public FeaturedComparer(System.Web.UI.WebControls.SortDirection sortDirection)
 {
     _sortDirection = sortDirection;
 }
 public ManufacturerComparer(System.Web.UI.WebControls.SortDirection sortDirection)
 {
     _SortDirection = sortDirection;
 }
 public PriceComparer(System.Web.UI.WebControls.SortDirection sortDirection)
 {
     _SortDirection = sortDirection;
 }
Beispiel #17
0
 /// <summary>
 /// Gets resources on which user is having read permission.
 /// </summary>
 /// <param name="token">Authentication Token</param>
 /// <param name="fetchedRecords">Records fetched</param>
 /// <param name="pageSize">Page size</param>
 /// <param name="totalRecords">Total record count</param>
 /// <param name="sortExpression">Column to sort on</param>
 /// <param name="sortDirection">Direction to sort in</param>
 /// <returns>List of Entities</returns>
 private IList <Resource> GetEntityList(AuthenticatedToken token, int fetchedRecords, int pageSize,
                                        out int totalRecords, string sortExpression, System.Web.UI.WebControls.SortDirection sortDirection)
 {
     using (ResourceDataAccess dataAccess = new ResourceDataAccess(base.CreateContext()))
     {
         if (sortDirection == System.Web.UI.WebControls.SortDirection.Ascending)
         {
             return(dataAccess.SearchForResources(token, SearchCriteria, fetchedRecords,
                                                  pageSize, out totalRecords, sortExpression, Zentity.Platform.SortDirection.Ascending, IsSecurityAwareControl).ToList());
         }
         else
         {
             return(dataAccess.SearchForResources(token, SearchCriteria, fetchedRecords,
                                                  pageSize, out totalRecords, sortExpression, Zentity.Platform.SortDirection.Descending, IsSecurityAwareControl).ToList());
         }
     }
 }
Beispiel #18
0
        public DataView Paging(GridViewPageEventArgs e, string sExpresionSort, DataView dv, ref GridView gdvDatos, ref System.Web.UI.WebControls.SortDirection oDireccion)
        {
            int iPagina = e.NewPageIndex;

            gdvDatos.PageIndex = iPagina;

            if (oDireccion == System.Web.UI.WebControls.SortDirection.Ascending)
            {
                dv.Sort = sExpresionSort + ASCENDING;
            }
            else
            {
                dv.Sort = sExpresionSort + DESCENDING;
            }
            return(dv);
        }