public string GetAdvanceFilter(Formas_de_PagoAdvanceSearchModel filter)
        {
            var where = "";
            if (!string.IsNullOrEmpty(filter.FromClave) || !string.IsNullOrEmpty(filter.ToClave))
            {
                if (!string.IsNullOrEmpty(filter.FromClave))
                {
                    where += " AND Formas_de_Pago.Clave >= " + filter.FromClave;
                }
                if (!string.IsNullOrEmpty(filter.ToClave))
                {
                    where += " AND Formas_de_Pago.Clave <= " + filter.ToClave;
                }
            }

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

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

                case Models.Filters.Exact:
                    where += " AND Formas_de_Pago.Nombre = '" + filter.Nombre + "'";
                    break;

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


            where = new Regex(Regex.Escape("AND ")).Replace(where, "", 1);
            return(where);
        }
        public ActionResult ShowAdvanceFilter(Formas_de_PagoAdvanceSearchModel 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));
        }
        public ActionResult ShowAdvanceFilter(string previousFilters = "")
        {
            if (!_tokenManager.GenerateToken())
            {
                return(Json(null, JsonRequestBehavior.AllowGet));
            }



            var previousFiltersObj = new Formas_de_PagoAdvanceSearchModel();

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

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