private void BindGridData(GridSortCommandEventArgs sortEventArgs) { if (SessionManager.CurrentUser == null) return; int pageSize = 15; int pageNumber = gridActions.CurrentPageIndex + 1; string sortExpress = string.Empty; string sortExpressInvert = string.Empty; foreach (GridSortExpression item in gridActions.MasterTableView.SortExpressions) { GridSortOrder newSortOrder = item.SortOrder; if (sortEventArgs != null && item.FieldName == sortEventArgs.SortExpression) { newSortOrder = sortEventArgs.NewSortOrder; } if (!string.IsNullOrEmpty(sortExpress) && newSortOrder != GridSortOrder.None) { sortExpress += ", "; sortExpressInvert += ", "; } if (newSortOrder == GridSortOrder.Ascending) { sortExpress += item.FieldName + " ASC"; sortExpressInvert += item.FieldName + " DESC"; } else if (newSortOrder == GridSortOrder.Descending) { sortExpress += item.FieldName + " DESC"; sortExpressInvert += item.FieldName + " ASC"; } } if (sortEventArgs != null && !sortExpress.Contains(sortEventArgs.SortExpression)) { if (!string.IsNullOrEmpty(sortExpress) && sortEventArgs.NewSortOrder != GridSortOrder.None) { sortExpress += ", "; sortExpressInvert += ", "; } if (sortEventArgs.NewSortOrder == GridSortOrder.Ascending) { sortExpress += sortEventArgs.SortExpression + " ASC"; sortExpressInvert += sortEventArgs.SortExpression + " DESC"; } else if (sortEventArgs.NewSortOrder == GridSortOrder.Descending) { sortExpress += sortEventArgs.SortExpression + " DESC"; sortExpressInvert += sortEventArgs.SortExpression + " ASC"; } } if (!string.IsNullOrEmpty(sortExpress)) { if (sortExpress.Contains("Hour")) { sortExpress = sortExpress.Replace("Hour", "Heure"); sortExpressInvert = sortExpressInvert.Replace("Hour", "Heure"); } if (sortExpress.Contains("CandidateFullName")) { sortExpress = sortExpress.Replace("CandidateFullName", "CanLastName"); sortExpressInvert = sortExpressInvert.Replace("CandidateFullName", "CanLastName"); } if (sortExpress.Contains("CompanyName")) { sortExpress = sortExpress.Replace("CompanyName", "SocNom"); sortExpressInvert = sortExpressInvert.Replace("CompanyName", "SocNom"); } } else { sortExpress = "ActionId DESC"; sortExpressInvert = "ActionId ASC"; } string type = "MyActiveThisWeek"; if (!string.IsNullOrEmpty(Request.QueryString["type"])) { type = Request.QueryString["type"]; } ActionSearchCriteria criteria = new ActionSearchCriteria(); switch (type) { case "MyActiveThisWeek": DateTime dateFrom = Common.GetBeginDayOfWeek(DateTime.Today); criteria.DateFrom = new DateTime(dateFrom.Year, dateFrom.Month, dateFrom.Day, 0, 0, 0); criteria.Active = "Yes"; criteria.Responsible = SessionManager.CurrentUser.UserID; break; case "MyActive": criteria.Active = "Yes"; criteria.Responsible = SessionManager.CurrentUser.UserID; break; case "MyInactive": criteria.Active = "No"; criteria.Responsible = SessionManager.CurrentUser.UserID; break; case "MyAllActions": criteria.Responsible = SessionManager.CurrentUser.UserID; break; case "AllActive": criteria.Active = "Yes"; break; case "AllInactive": criteria.Active = "No"; break; case "AllActions": break; case "search": if (!string.IsNullOrEmpty(Request.QueryString["active"])) criteria.Active = Request.QueryString["active"]; if (!string.IsNullOrEmpty(Request.QueryString["dateFrom"])) criteria.DateFrom = DateTime.ParseExact(Request.QueryString["dateFrom"], "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat); if (!string.IsNullOrEmpty(Request.QueryString["dateTo"])) criteria.DateTo = DateTime.ParseExact(Request.QueryString["dateTo"], "dd/MM/yyyy", System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat); if (!string.IsNullOrEmpty(Request.QueryString["candidate"])) criteria.CanName = Request.QueryString["candidate"]; if (!string.IsNullOrEmpty(Request.QueryString["company"])) criteria.ComName = Request.QueryString["company"]; if (!string.IsNullOrEmpty(Request.QueryString["typeAction"])) criteria.TypeActionID = int.Parse(Request.QueryString["typeAction"]); if (!string.IsNullOrEmpty(Request.QueryString["description"])) criteria.Description = Request.QueryString["description"]; if (!string.IsNullOrEmpty(Request.QueryString["responsible"])) criteria.Responsible = Request.QueryString["responsible"]; break; } ActionRepository repo = new ActionRepository(); gridActions.VirtualItemCount = repo.CountActions(criteria, pageSize, pageNumber, sortExpress, sortExpressInvert); IList<Neos.Data.Action> list = repo.SearchActions(criteria, pageSize, pageNumber, sortExpress, sortExpressInvert); gridActions.DataSource = list; }