Пример #1
0
        public ActionResult ShowAdvanceFilter(Spartan_Report_FormatAdvanceSearchModel model)
        {
            if (ModelState.IsValid)
            {
                Session["AdvanceSearch"] = model;
                return(RedirectToAction("Index"));
            }
            ViewBag.Filter = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = Resources.Resources.BeginWith, Value = "1"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.EndWith, Value = "2"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Contains, Value = "4"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Exact, Value = "3"
                },
            };
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            return(View(model));
        }
Пример #2
0
        public ActionResult ShowAdvanceFilter(string previousFilters = "")
        {
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            var previousFiltersObj = new Spartan_Report_FormatAdvanceSearchModel();

            if (previousFilters != "")
            {
                previousFiltersObj = (Spartan_Report_FormatAdvanceSearchModel)(Session["AdvanceSearch"] ?? new Spartan_Report_FormatAdvanceSearchModel());
            }

            ViewBag.Filter = new List <SelectListItem>
            {
                new SelectListItem()
                {
                    Text = Resources.Resources.BeginWith, Value = "1"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.EndWith, Value = "2"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Contains, Value = "4"
                },
                new SelectListItem()
                {
                    Text = Resources.Resources.Exact, Value = "3"
                },
            };

            return(View(previousFiltersObj));
        }
Пример #3
0
        public string GetAdvanceFilter(Spartan_Report_FormatAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromFormatId) || !string.IsNullOrEmpty(filter.ToFormatId))
            {
                if (!string.IsNullOrEmpty(filter.FromFormatId))
                {
                    where += " AND Spartan_Report_Format.FormatId >= " + filter.FromFormatId;
                }
                if (!string.IsNullOrEmpty(filter.ToFormatId))
                {
                    where += " AND Spartan_Report_Format.FormatId <= " + filter.ToFormatId;
                }
            }

            if (!string.IsNullOrEmpty(filter.Description))
            {
                switch (filter.DescriptionFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Report_Format.Description LIKE '" + filter.Description + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Report_Format.Description LIKE '%" + filter.Description + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Report_Format.Description = '" + filter.Description + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Report_Format.Description LIKE '%" + filter.Description + "%'";
                    break;
                }
            }

            if (!string.IsNullOrEmpty(filter.Format_Mask))
            {
                switch (filter.Format_MaskFilter)
                {
                case Models.Filters.BeginWith:
                    where += " AND Spartan_Report_Format.Format_Mask LIKE '" + filter.Format_Mask + "%'";
                    break;

                case Models.Filters.EndWith:
                    where += " AND Spartan_Report_Format.Format_Mask LIKE '%" + filter.Format_Mask + "'";
                    break;

                case Models.Filters.Exact:
                    where += " AND Spartan_Report_Format.Format_Mask = '" + filter.Format_Mask + "'";
                    break;

                case Models.Filters.Contains:
                    where += " AND Spartan_Report_Format.Format_Mask LIKE '%" + filter.Format_Mask + "%'";
                    break;
                }
            }


            where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1);
            return(where);
        }