Exemplo n.º 1
0
        /// <summary>
        /// 从Cookie中获取查询条件.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <returns></returns>
        public static SearchData GetSearchData(this Control container)
        {
            string str = CookieHelper.Get("SearchCondition");

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            SearchData data = str.DeJson <SearchData>();

            if (data == null)
            {
                return(null);
            }
            string str2 = container.Page.ToString();

            if (data.PageName != str2)
            {
                return(null);
            }
            return(data);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 从Cookie加载查询条件.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="controlPrefix">The control prefix.</param>
        /// <param name="pagername">The pagername.</param>
        /// <returns></returns>
        public static SearchData LoadSearchCondition(this Control container, string controlPrefix, string pagername)
        {
            string str = CookieHelper.Get("SearchCondition");

            if (string.IsNullOrEmpty(str))
            {
                return(null);
            }
            SearchData data = str.DeJson <SearchData>();

            if (data == null)
            {
                return(null);
            }
            string str2 = container.Page.ToString();

            if (data.PageName != str2)
            {
                return(null);
            }
            foreach (Control control in container.Controls)
            {
                if (((control.ID != null) && control.ID.StartsWith(controlPrefix)) && data.Conditions.ContainsKey(control.ID))
                {
                    SetControlProperty(control, data.Conditions[control.ID]);
                }
            }
            if (!string.IsNullOrEmpty(pagername))
            {
                Control control2 = container.Parent.FindControl(pagername);
                if (control2 != null)
                {
                    control2.GetType().GetProperty("RecordCount").SetValue(control2, data.RecordCount, null);
                    control2.GetType().GetProperty("CurrentPageIndex").SetValue(control2, data.PageIndex, null);
                }
            }
            return(data);
        }
Exemplo n.º 3
0
 /// <summary>
 /// 保存查询条件至Cookie.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="searchData">The search data.</param>
 public static void SetSearchData(this Control container, SearchData searchData)
 {
     CookieHelper.Add("SearchCondition", searchData.ToJson());
 }