Пример #1
0
        public string GetAdvanceFilter(Forma_CaraAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromClave) || !string.IsNullOrEmpty(filter.ToClave))
            {
                if (!string.IsNullOrEmpty(filter.FromClave))
                {
                    where += " AND Forma_Cara.Clave >= " + filter.FromClave;
                }
                if (!string.IsNullOrEmpty(filter.ToClave))
                {
                    where += " AND Forma_Cara.Clave <= " + filter.ToClave;
                }
            }

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

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

                case Models.Filters.Exact:
                    where += " AND Forma_Cara.Descripcion = '" + filter.Descripcion + "'";
                    break;

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

            if (!string.IsNullOrEmpty(filter.FromLLAVE) || !string.IsNullOrEmpty(filter.ToLLAVE))
            {
                if (!string.IsNullOrEmpty(filter.FromLLAVE))
                {
                    where += " AND Forma_Cara.LLAVE >= " + filter.FromLLAVE;
                }
                if (!string.IsNullOrEmpty(filter.ToLLAVE))
                {
                    where += " AND Forma_Cara.LLAVE <= " + filter.ToLLAVE;
                }
            }


            where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1);
            return(where);
        }
Пример #2
0
        public ActionResult ShowAdvanceFilter(Forma_CaraAdvanceSearchModel model, int idFilter = -1)
        {
            if (ModelState.IsValid)
            {
                Session["AdvanceSearch"] = model;
                if (idFilter != -1)
                {
                    Session["AdvanceReportFilter"] = GetAdvanceFilter(model);
                    return(RedirectToAction("Index", "Report", new { id = idFilter }));
                }
                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));
        }
Пример #3
0
        public ActionResult ShowAdvanceFilter(string previousFilters = "")
        {
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            var previousFiltersObj = new Forma_CaraAdvanceSearchModel();

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

            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));
        }